예제 #1
0
    def test_function_type(self):
        def stringObj(c_ptr):
            char_ptr = ctypes.c_char_p(c_ptr)
            python_string = char_ptr.value
            return python_string.decode('ascii')

        Prototype.registerType("string_obj", stringObj)

        dateStamp  = TestUtilPrototype("string_obj util_alloc_date_stamp_utc()")
        date_stamp = dateStamp()
        self.assertIsInstance(date_stamp, string_types)
예제 #2
0
    def test_function_type(self):
        def stringObj(c_ptr):
            char_ptr = ctypes.c_char_p(c_ptr)
            python_string = char_ptr.value
            TestUtilPrototype.lib.free(c_ptr)
            return python_string

        Prototype.registerType("string_obj", stringObj)

        dateStamp = TestUtilPrototype("string_obj util_alloc_date_stamp_utc()")
        date_stamp = dateStamp()
        self.assertIsInstance(date_stamp, str)
예제 #3
0
 def test_already_registered(self):
     with self.assertRaises(PrototypeError):
         Prototype.registerType("test_stringlist", None)
예제 #4
0
from ctypes import Structure, c_int
from cwrap import Prototype


class NodeId(Structure):
    """
    NodeId is specified in enkf_types.h
    """
    _fields_ = [("report_step", c_int), ("iens", c_int)]

    def __init__(self, report_step, realization_number):
        """
        @type report_step: int
        @type realization_number: int
        """
        super(NodeId, self).__init__(report_step, realization_number)

    def __repr__(self):
        rs = self.report_step
        ie = self.iens
        return 'NodeId(report_step = %d, iens = %d)' % (rs, ie)


Prototype.registerType("node_id", NodeId)
예제 #5
0
 def test_already_registered(self):
     with self.assertRaises(PrototypeError):
         Prototype.registerType("test_stringlist", None)
예제 #6
0
from ctypes import Structure, c_int
from cwrap import Prototype

class NodeId(Structure):
    """
    NodeId is specified in enkf_types.h
    """
    _fields_ = [("report_step", c_int),
                ("iens", c_int)]

    def __init__(self, report_step, realization_number):
        """
        @type report_step: int
        @type realization_number: int
        """
        super(NodeId, self).__init__(report_step, realization_number)

Prototype.registerType( "node_id" , NodeId )