Exemple #1
0
class ReturnOneHelper:
    c_data_set = MultiSet()

    @staticmethod
    def toPy(obj):
        if obj == ffi.NULL:
            return None
        return ReturnOneCppProxy(obj)
Exemple #2
0
class SortItemsHelper:
    c_data_set = MultiSet()

    @staticmethod
    def toPy(obj):
        if obj == ffi.NULL:
            return None
        return SortItemsCppProxy(obj)
Exemple #3
0
class MyCppInterfaceHelper:
    c_data_set = MultiSet()

    @staticmethod
    def toPy(obj):
        if obj == ffi.NULL:
            return None
        return MyCppInterfaceCppProxy(obj)
Exemple #4
0
class ListenerCallerHelper:
    c_data_set = MultiSet()

    @staticmethod
    def toPy(obj):
        if obj == ffi.NULL:
            return None
        return ListenerCallerCppProxy(obj)
class UsesSingleLanguageListenersHelper:
    c_data_set = MultiSet()

    @staticmethod
    def toPy(obj):
        if obj == ffi.NULL:
            return None
        return UsesSingleLanguageListenersCppProxy(obj)
class MapEnumColorEnumColorHelper:
    c_data_set = MultiSet()

    @staticmethod
    def check_c_data_set_empty():
        assert len(MapEnumColorEnumColorHelper.c_data_set) == 0
        Color.check_c_data_set_empty()
        Color.check_c_data_set_empty()

    @ffi.callback("int(struct DjinniObjectHandle *, int)")
    def __get_value(cself, key):
        pyKey = CPyEnum.toPy(Color, key)
        assert pyKey is not None
        try:
            _ret = CPyEnum.fromPy(CPyObjectProxy.toPyObj(None, cself)[pyKey])
            assert _ret != -1
            return _ret
        except Exception as _djinni_py_e:
            CPyException.setExceptionFromPy(_djinni_py_e)
            return ffi.NULL

    @ffi.callback("size_t(struct DjinniObjectHandle *)")
    def __get_size(cself):
        return len(CPyObjectProxy.toPyObj(None, cself))

    @ffi.callback("struct DjinniObjectHandle *()")
    def __python_create():
        c_ptr = ffi.new_handle(MapEnumColorEnumColorProxy(dict()))
        MapEnumColorEnumColorHelper.c_data_set.add(c_ptr)
        return ffi.cast("struct DjinniObjectHandle *", c_ptr)

    @ffi.callback("void(struct DjinniObjectHandle *, int, int)")
    def __python_add(cself, key, value):
        CPyObjectProxy.toPyObj(None, cself)[CPyEnum.toPy(Color, key)] = CPyEnum.toPy(Color, value)

    @ffi.callback("void(struct DjinniObjectHandle * )")
    def __delete(c_ptr):
        assert c_ptr in MapEnumColorEnumColorHelper.c_data_set
        MapEnumColorEnumColorHelper.c_data_set.remove(c_ptr)

    @ffi.callback("int(struct DjinniObjectHandle *)")
    def __python_next(cself):
        try:
            _ret = CPyEnum.fromPy(next(CPyObjectProxy.toPyIter(cself)))
            assert _ret != -1
            return _ret
        except Exception as _djinni_py_e:
            CPyException.setExceptionFromPy(_djinni_py_e)
            return ffi.NULL

    @staticmethod
    def _add_callbacks():
        lib.map_enum_color_enum_color_add_callback__get_value(MapEnumColorEnumColorHelper.__get_value)
        lib.map_enum_color_enum_color_add_callback___delete(MapEnumColorEnumColorHelper.__delete)
        lib.map_enum_color_enum_color_add_callback__get_size(MapEnumColorEnumColorHelper.__get_size)
        lib.map_enum_color_enum_color_add_callback__python_create(MapEnumColorEnumColorHelper.__python_create)
        lib.map_enum_color_enum_color_add_callback__python_add(MapEnumColorEnumColorHelper.__python_add)
        lib.map_enum_color_enum_color_add_callback__python_next(MapEnumColorEnumColorHelper.__python_next)
class MapInt8TBoolHelper:
    c_data_set = MultiSet()

    @staticmethod
    def check_c_data_set_empty():
        assert len(MapInt8TBoolHelper.c_data_set) == 0

    @ffi.callback("bool(struct DjinniObjectHandle *, int8_t)")
    def __get_value(cself, key):
        pyKey = CPyPrimitive.toPy(key)
        assert pyKey is not None
        try:
            _ret = CPyPrimitive.fromPy(
                CPyObjectProxy.toPyObj(None, cself)[pyKey])
            return _ret
        except Exception as _djinni_py_e:
            CPyException.setExceptionFromPy(_djinni_py_e)
            return ffi.NULL

    @ffi.callback("size_t(struct DjinniObjectHandle *)")
    def __get_size(cself):
        return len(CPyObjectProxy.toPyObj(None, cself))

    @ffi.callback("struct DjinniObjectHandle *()")
    def __create():
        c_ptr = ffi.new_handle(MapInt8TBoolProxy(dict()))
        MapInt8TBoolHelper.c_data_set.add(c_ptr)
        return ffi.cast("struct DjinniObjectHandle *", c_ptr)

    @ffi.callback("void(struct DjinniObjectHandle *, int8_t, bool)")
    def __add(cself, key, value):
        CPyObjectProxy.toPyObj(
            None, cself)[CPyPrimitive.toPy(key)] = CPyPrimitive.toPy(value)

    @ffi.callback("void(struct DjinniObjectHandle * )")
    def __delete(c_ptr):
        assert c_ptr in MapInt8TBoolHelper.c_data_set
        MapInt8TBoolHelper.c_data_set.remove(c_ptr)

    @ffi.callback("int8_t(struct DjinniObjectHandle *)")
    def __next(cself):
        try:
            _ret = CPyPrimitive.fromPy(next(CPyObjectProxy.toPyIter(cself)))
            return _ret
        except Exception as _djinni_py_e:
            CPyException.setExceptionFromPy(_djinni_py_e)
            return ffi.NULL

    @staticmethod
    def _add_callbacks():
        lib.map_int8_t_bool_add_callback__get_value(
            MapInt8TBoolHelper.__get_value)
        lib.map_int8_t_bool_add_callback___delete(MapInt8TBoolHelper.__delete)
        lib.map_int8_t_bool_add_callback__get_size(
            MapInt8TBoolHelper.__get_size)
        lib.map_int8_t_bool_add_callback__create(MapInt8TBoolHelper.__create)
        lib.map_int8_t_bool_add_callback__add(MapInt8TBoolHelper.__add)
        lib.map_int8_t_bool_add_callback__next(MapInt8TBoolHelper.__next)
class CustomDatatype:
    c_data_set = MultiSet()

    @staticmethod
    def check_c_data_set_empty():
        assert len(CustomDatatype.c_data_set) == 0

    def __init__(self, recordData):
        self.recordData = recordData
Exemple #9
0
class JsonRecord:
    c_data_set = MultiSet()

    @staticmethod
    def check_c_data_set_empty():
        assert len(JsonRecord.c_data_set) == 0

    def __init__(self, optional_rc):
        self.optional_rc = optional_rc
Exemple #10
0
class Constants:
    """
     Record containing constants
    Constants
        BOOL_CONSTANT: bool_constant has documentation.
        I8_CONSTANT
        I16_CONSTANT
        I32_CONSTANT
        I64_CONSTANT
        F32_CONSTANT
        F64_CONSTANT: f64_constant has long documentation.
             (Second line of multi-line documentation.
               Indented third line of multi-line documentation.)
        OPT_BOOL_CONSTANT
        OPT_I8_CONSTANT
        OPT_I16_CONSTANT: opt_i16_constant has documentation.
        OPT_I32_CONSTANT
        OPT_I64_CONSTANT
        OPT_F32_CONSTANT: opt_f32_constant has long documentation.
             (Second line of multi-line documentation.
               Indented third line of multi-line documentation.)
        OPT_F64_CONSTANT
        STRING_CONSTANT
        OPT_STRING_CONSTANT
        OBJECT_CONSTANT
        DUMMY: No support for null optional constants
             No support for optional constant records
             No support for constant binary, list, set, map
    """

    c_data_set = MultiSet()

    @staticmethod
    def check_c_data_set_empty():
        assert len(Constants.c_data_set) == 0

    BOOL_CONSTANT = True
    I8_CONSTANT = 1
    I16_CONSTANT = 2
    I32_CONSTANT = 3
    I64_CONSTANT = 4
    F32_CONSTANT = 5.0
    F64_CONSTANT = 5.0
    OPT_BOOL_CONSTANT = True
    OPT_I8_CONSTANT = 1
    OPT_I16_CONSTANT = 2
    OPT_I32_CONSTANT = 3
    OPT_I64_CONSTANT = 4
    OPT_F32_CONSTANT = 5.0
    OPT_F64_CONSTANT = 5.0
    STRING_CONSTANT = "string-constant"
    OPT_STRING_CONSTANT = "string-constant"
    DUMMY = False

    def __init__(self):
        pass
Exemple #11
0
class MapStringInt64THelper:
    c_data_set = MultiSet()

    @staticmethod
    def check_c_data_set_empty():
        assert len(MapStringInt64THelper.c_data_set) == 0

    @ffi.callback("int64_t(struct DjinniObjectHandle *, struct DjinniString *)")
    def __get_value(cself, key):
        pyKey = CPyString.toPyWithoutTakingOwnership(key)
        assert pyKey is not None
        try:
            _ret = CPyPrimitive.fromPy(CPyObjectProxy.toPyObj(None, cself)[pyKey])
            return _ret
        except Exception as _djinni_py_e:
            CPyException.setExceptionFromPy(_djinni_py_e)
            return ffi.NULL

    @ffi.callback("size_t(struct DjinniObjectHandle *)")
    def __get_size(cself):
        return len(CPyObjectProxy.toPyObj(None, cself))

    @ffi.callback("struct DjinniObjectHandle *()")
    def __python_create():
        c_ptr = ffi.new_handle(MapStringInt64TProxy(dict()))
        MapStringInt64THelper.c_data_set.add(c_ptr)
        return ffi.cast("struct DjinniObjectHandle *", c_ptr)

    @ffi.callback("void(struct DjinniObjectHandle *, struct DjinniString *, int64_t)")
    def __python_add(cself, key, value):
        CPyObjectProxy.toPyObj(None, cself)[CPyString.toPy(key)] = CPyPrimitive.toPy(value)

    @ffi.callback("void(struct DjinniObjectHandle * )")
    def __delete(c_ptr):
        assert c_ptr in MapStringInt64THelper.c_data_set
        MapStringInt64THelper.c_data_set.remove(c_ptr)

    @ffi.callback("struct DjinniString *(struct DjinniObjectHandle *)")
    def __python_next(cself):
        try:
            with CPyString.fromPy(next(CPyObjectProxy.toPyIter(cself))) as py_obj:
                _ret = py_obj.release_djinni_string()
                assert _ret != ffi.NULL
                return _ret
        except Exception as _djinni_py_e:
            CPyException.setExceptionFromPy(_djinni_py_e)
            return ffi.NULL

    @staticmethod
    def _add_callbacks():
        lib.map_string_int64_t_add_callback__get_value(MapStringInt64THelper.__get_value)
        lib.map_string_int64_t_add_callback___delete(MapStringInt64THelper.__delete)
        lib.map_string_int64_t_add_callback__get_size(MapStringInt64THelper.__get_size)
        lib.map_string_int64_t_add_callback__python_create(MapStringInt64THelper.__python_create)
        lib.map_string_int64_t_add_callback__python_add(MapStringInt64THelper.__python_add)
        lib.map_string_int64_t_add_callback__python_next(MapStringInt64THelper.__python_next)
class RecordUsingExtendedRecord:
    c_data_set = MultiSet()

    @staticmethod
    def check_c_data_set_empty():
        assert len(RecordUsingExtendedRecord.c_data_set) == 0
        ExtendedRecord.check_c_data_set_empty()

    def __init__(self, er):
        self.er = er
class FooExtensibleRecordBase:
    c_data_set = MultiSet()

    @staticmethod
    def check_c_data_set_empty():
        assert len(FooExtensibleRecord.c_data_set) == 0

    def __init__(self, number1, string1):
        self.number1 = number1
        self.string1 = string1
Exemple #14
0
class ItemList:
    c_data_set = MultiSet()

    @staticmethod
    def check_c_data_set_empty():
        assert len(ItemList.c_data_set) == 0
        ListStringHelper.check_c_data_set_empty()

    def __init__(self, items):
        self.items = items
Exemple #15
0
class Rc:
    c_data_set = MultiSet()

    @staticmethod
    def check_c_data_set_empty():
        assert len(Rc.c_data_set) == 0


    def __init__(self, a):
        self.a = a
Exemple #16
0
class ExtendedRecord:
    """ Extended record """

    c_data_set = MultiSet()

    @staticmethod
    def check_c_data_set_empty():
        assert len(ExtendedRecord.c_data_set) == 0

    def __init__(self, foo):
        self.foo = foo
Exemple #17
0
class OtherRecord:
    c_data_set = MultiSet()

    @staticmethod
    def check_c_data_set_empty():
        assert len(OtherRecord.c_data_set) == 0
        CustomDatatype.check_c_data_set_empty()


    def __init__(self, customDatatypeData):
        self.customDatatypeData = customDatatypeData
class ListMapStringInt64THelper:
    c_data_set = MultiSet()

    @staticmethod
    def check_c_data_set_empty():
        assert len(ListMapStringInt64THelper.c_data_set) == 0
        MapStringInt64THelper.check_c_data_set_empty()

    @ffi.callback(
        "struct DjinniObjectHandle *(struct DjinniObjectHandle *, size_t)")
    def __get_elem(cself, index):
        try:
            _ret = CPyObjectProxy.fromPy(
                MapStringInt64THelper.c_data_set,
                MapStringInt64TProxy(CPyObject.toPy(None, cself)[index]))
            assert _ret != ffi.NULL
            return _ret
        except Exception as _djinni_py_e:
            CPyException.setExceptionFromPy(_djinni_py_e)
            return ffi.NULL

    @ffi.callback("size_t(struct DjinniObjectHandle *)")
    def __get_size(cself):
        return len(CPyObject.toPy(None, cself))

    @ffi.callback("struct DjinniObjectHandle *()")
    def __python_create():
        c_ptr = ffi.new_handle(list())
        ListMapStringInt64THelper.c_data_set.add(c_ptr)
        return ffi.cast("struct DjinniObjectHandle *", c_ptr)

    @ffi.callback(
        "void(struct DjinniObjectHandle *, struct DjinniObjectHandle *)")
    def __python_add(cself, el):
        CPyObject.toPy(None, cself).append(
            CPyObjectProxy.toPyObj(MapStringInt64THelper.c_data_set, el))

    @ffi.callback("void(struct DjinniObjectHandle * )")
    def __delete(c_ptr):
        assert c_ptr in ListMapStringInt64THelper.c_data_set
        ListMapStringInt64THelper.c_data_set.remove(c_ptr)

    @staticmethod
    def _add_callbacks():
        lib.list_map_string_int64_t_add_callback__get_elem(
            ListMapStringInt64THelper.__get_elem)
        lib.list_map_string_int64_t_add_callback___delete(
            ListMapStringInt64THelper.__delete)
        lib.list_map_string_int64_t_add_callback__get_size(
            ListMapStringInt64THelper.__get_size)
        lib.list_map_string_int64_t_add_callback__python_create(
            ListMapStringInt64THelper.__python_create)
        lib.list_map_string_int64_t_add_callback__python_add(
            ListMapStringInt64THelper.__python_add)
class SomeConstRecord:
    c_data_set = MultiSet()

    @staticmethod
    def check_c_data_set_empty():
        assert len(SomeConstRecord.c_data_set) == 0


    def __init__(self, number1, number2):
        self.number1 = number1
        self.number2 = number2
class ListRecordFooSomeOtherRecordHelper:
    c_data_set = MultiSet()

    @staticmethod
    def check_c_data_set_empty():
        assert len(ListRecordFooSomeOtherRecordHelper.c_data_set) == 0
        FooSomeOtherRecord.check_c_data_set_empty()

    @ffi.callback(
        "struct DjinniRecordHandle *(struct DjinniObjectHandle *, size_t)")
    def __get_elem(cself, index):
        try:
            _ret = CPyRecord.fromPy(FooSomeOtherRecord.c_data_set,
                                    CPyObject.toPy(None, cself)[index])
            assert _ret != ffi.NULL
            return _ret
        except Exception as _djinni_py_e:
            CPyException.setExceptionFromPy(_djinni_py_e)
            return ffi.NULL

    @ffi.callback("size_t(struct DjinniObjectHandle *)")
    def __get_size(cself):
        return len(CPyObject.toPy(None, cself))

    @ffi.callback("struct DjinniObjectHandle *()")
    def __python_create():
        c_ptr = ffi.new_handle(list())
        ListRecordFooSomeOtherRecordHelper.c_data_set.add(c_ptr)
        return ffi.cast("struct DjinniObjectHandle *", c_ptr)

    @ffi.callback(
        "void(struct DjinniObjectHandle *, struct DjinniRecordHandle *)")
    def __python_add(cself, el):
        CPyObject.toPy(None, cself).append(
            CPyRecord.toPy(FooSomeOtherRecord.c_data_set, el))

    @ffi.callback("void(struct DjinniObjectHandle * )")
    def __delete(c_ptr):
        assert c_ptr in ListRecordFooSomeOtherRecordHelper.c_data_set
        ListRecordFooSomeOtherRecordHelper.c_data_set.remove(c_ptr)

    @staticmethod
    def _add_callbacks():
        lib.list_record_foo_some_other_record_add_callback__get_elem(
            ListRecordFooSomeOtherRecordHelper.__get_elem)
        lib.list_record_foo_some_other_record_add_callback___delete(
            ListRecordFooSomeOtherRecordHelper.__delete)
        lib.list_record_foo_some_other_record_add_callback__get_size(
            ListRecordFooSomeOtherRecordHelper.__get_size)
        lib.list_record_foo_some_other_record_add_callback__python_create(
            ListRecordFooSomeOtherRecordHelper.__python_create)
        lib.list_record_foo_some_other_record_add_callback__python_add(
            ListRecordFooSomeOtherRecordHelper.__python_add)
Exemple #21
0
class ConstantRecord:
    """ Record for use in constants """

    c_data_set = MultiSet()

    @staticmethod
    def check_c_data_set_empty():
        assert len(ConstantRecord.c_data_set) == 0

    def __init__(self, some_integer, some_string):
        self.some_integer = some_integer
        self.some_string = some_string
Exemple #22
0
class SetRecord:
    c_data_set = MultiSet()

    @staticmethod
    def check_c_data_set_empty():
        assert len(SetRecord.c_data_set) == 0
        SetStringHelper.check_c_data_set_empty()
        SetInt32THelper.check_c_data_set_empty()

    def __init__(self, set, iset):
        self.set = set
        self.iset = iset
Exemple #23
0
class FooListenerHelper:
    c_data_set = MultiSet()
    @staticmethod
    def toPy(obj):
        if obj == ffi.NULL:
            return None
        # Python Objects can be returned without being wrapped in proxies
        py_handle = lib.get_handle_from_proxy_object_cw__foo_listener(obj)
        if py_handle:
            assert py_handle in FooListenerHelper.c_data_set
            aux = ffi.from_handle(ffi.cast("void * ", py_handle))
            lib.foo_listener___wrapper_dec_ref(obj)
            return aux
        return FooListenerCppProxy(obj)

    @staticmethod
    def selfToPy(obj):
        assert obj in FooListenerHelper.c_data_set
        return ffi.from_handle(ffi.cast("void * ",obj))

    @staticmethod
    def fromPy(py_obj):
        if py_obj is None:
            return ffi.NULL
        py_proxy = (py_obj)
        if not hasattr(py_obj, "on_string_change"):
            raise TypeError
        if not hasattr(py_obj, "get_private_int"):
            raise TypeError
        if not hasattr(py_obj, "on_changes_string_returned"):
            raise TypeError
        if not hasattr(py_obj, "on_changes_binary_returned"):
            raise TypeError
        if not hasattr(py_obj, "on_changes_date_returned"):
            raise TypeError
        if not hasattr(py_obj, "on_changes_int_returned"):
            raise TypeError
        if not hasattr(py_obj, "on_changes_record_returned"):
            raise TypeError
        if not hasattr(py_obj, "on_changes_string_optional_returned"):
            raise TypeError
        if not hasattr(py_obj, "on_changes_int_optional_returned"):
            raise TypeError
        if not hasattr(py_obj, "cause_py_exception"):
            raise TypeError
        if not hasattr(py_obj, "cause_zero_division_error"):
            raise TypeError

        bare_c_ptr = ffi.new_handle(py_proxy)
        FooListenerHelper.c_data_set.add(bare_c_ptr)
        wrapped_c_ptr = lib.make_proxy_object_from_handle_cw__foo_listener(bare_c_ptr)
        return wrapped_c_ptr
Exemple #24
0
class FooListenerBfHelper:
    c_data_set = MultiSet()
    @staticmethod
    def toPy(obj):
        if obj == ffi.NULL:
            return None
        # Python Objects can be returned without being wrapped in proxies
        py_handle = lib.get_handle_from_proxy_object_cw__foo_listener_bf(obj)
        if py_handle:
            assert py_handle in FooListenerBfHelper.c_data_set
            aux = ffi.from_handle(ffi.cast("void * ", py_handle))
            lib.foo_listener_bf___wrapper_dec_ref(obj)
            return aux
        return FooListenerBfCppProxy(obj)

    @staticmethod
    def selfToPy(obj):
        assert obj in FooListenerBfHelper.c_data_set
        return ffi.from_handle(ffi.cast("void * ",obj))

    @staticmethod
    def fromPy(py_obj):
        if py_obj is None:
            return ffi.NULL
        if isinstance(py_obj, FooListenerBfCppProxy):
            lib.foo_listener_bf___wrapper_add_ref(py_obj._cpp_impl)
            return py_obj._cpp_impl

        py_proxy = (py_obj)
        if not hasattr(py_obj, "on_string_change"):
            raise TypeError
        if not hasattr(py_obj, "get_string"):
            raise TypeError
        if not hasattr(py_obj, "set_listener_bf"):
            raise TypeError
        if not hasattr(py_obj, "get_listener_bf"):
            raise TypeError
        if not hasattr(py_obj, "set_binary"):
            raise TypeError
        if not hasattr(py_obj, "get_binary"):
            raise TypeError
        if not hasattr(py_obj, "send_return"):
            raise TypeError
        if not hasattr(py_obj, "delete_fl_in_fl"):
            raise TypeError

        bare_c_ptr = ffi.new_handle(py_proxy)
        FooListenerBfHelper.c_data_set.add(bare_c_ptr)
        wrapped_c_ptr = lib.make_proxy_object_from_handle_cw__foo_listener_bf(bare_c_ptr)
        return wrapped_c_ptr
class SetEnumMyEnumHelper:
    c_data_set = MultiSet()

    @staticmethod
    def check_c_data_set_empty():
        assert len(SetEnumMyEnumHelper.c_data_set) == 0
        MyEnum.check_c_data_set_empty()

    @ffi.callback("size_t(struct DjinniObjectHandle *)")
    def __get_size(cself):
        return len(CPyObjectProxy.toPyObj(None, cself))

    @ffi.callback("struct DjinniObjectHandle *()")
    def __python_create():
        c_ptr = ffi.new_handle(SetEnumMyEnumProxy(set()))
        SetEnumMyEnumHelper.c_data_set.add(c_ptr)
        return ffi.cast("struct DjinniObjectHandle *", c_ptr)

    @ffi.callback("void(struct DjinniObjectHandle *, int)")
    def __python_add(cself, el):
        CPyObjectProxy.toPyObj(None, cself).add(CPyEnum.toPy(MyEnum, el))

    @ffi.callback("void(struct DjinniObjectHandle * )")
    def __delete(c_ptr):
        assert c_ptr in SetEnumMyEnumHelper.c_data_set
        SetEnumMyEnumHelper.c_data_set.remove(c_ptr)

    @ffi.callback("int(struct DjinniObjectHandle *)")
    def __python_next(cself):
        try:
            _ret = CPyEnum.fromPy(next(CPyObjectProxy.toPyIter(cself)))
            assert _ret != -1
            return _ret
        except Exception as _djinni_py_e:
            CPyException.setExceptionFromPy(_djinni_py_e)
            return ffi.NULL

    @staticmethod
    def _add_callbacks():
        lib.set_enum_my_enum_add_callback___delete(
            SetEnumMyEnumHelper.__delete)
        lib.set_enum_my_enum_add_callback__get_size(
            SetEnumMyEnumHelper.__get_size)
        lib.set_enum_my_enum_add_callback__python_create(
            SetEnumMyEnumHelper.__python_create)
        lib.set_enum_my_enum_add_callback__python_add(
            SetEnumMyEnumHelper.__python_add)
        lib.set_enum_my_enum_add_callback__python_next(
            SetEnumMyEnumHelper.__python_next)
Exemple #26
0
class Rc:
    c_data_set = MultiSet()

    @staticmethod
    def check_c_data_set_empty():
        assert len(Rc.c_data_set) == 0
        MyEnum.check_c_data_set_empty()


    def __init__(self, a, b, c, d, e):
        self.a = a
        self.b = b
        self.c = c
        self.d = d
        self.e = e
Exemple #27
0
class FooRecord:
    """
     this file is using mixed-case as in past this was causing
     duplicate files creation error
    """

    c_data_set = MultiSet()

    @staticmethod
    def check_c_data_set_empty():
        assert len(FooRecord.c_data_set) == 0


    def __init__(self, a):
        self.a = a
Exemple #28
0
class VarnameRecord:
    """
     Underscore is used as a separator in Djinni names, so we don't really
     anticipate it to be used as a prefix/suffix.  Some name styles behave
     badly when it is.  However this test case ensures we at least don't crash.
    """

    c_data_set = MultiSet()

    @staticmethod
    def check_c_data_set_empty():
        assert len(VarnameRecord.c_data_set) == 0

    def __init__(self, _field_):
        self._field_ = _field_
Exemple #29
0
class ListOptionalBinaryHelper:
    c_data_set = MultiSet()

    @staticmethod
    def check_c_data_set_empty():
        assert len(ListOptionalBinaryHelper.c_data_set) == 0

    @ffi.callback("struct DjinniBinary *(struct DjinniObjectHandle *, size_t)")
    def __get_elem(cself, index):
        try:
            with CPyBinary.fromPyOpt(CPyObject.toPy(None,
                                                    cself)[index]) as py_obj:
                return py_obj.release_djinni_binary()
        except Exception as _djinni_py_e:
            CPyException.setExceptionFromPy(_djinni_py_e)
            return ffi.NULL

    @ffi.callback("size_t(struct DjinniObjectHandle *)")
    def __get_size(cself):
        return len(CPyObject.toPy(None, cself))

    @ffi.callback("struct DjinniObjectHandle *()")
    def __python_create():
        c_ptr = ffi.new_handle(list())
        ListOptionalBinaryHelper.c_data_set.add(c_ptr)
        return ffi.cast("struct DjinniObjectHandle *", c_ptr)

    @ffi.callback("void(struct DjinniObjectHandle *, struct DjinniBinary *)")
    def __python_add(cself, el):
        CPyObject.toPy(None, cself).append(CPyBinary.toPyOpt(el))

    @ffi.callback("void(struct DjinniObjectHandle * )")
    def __delete(c_ptr):
        assert c_ptr in ListOptionalBinaryHelper.c_data_set
        ListOptionalBinaryHelper.c_data_set.remove(c_ptr)

    @staticmethod
    def _add_callbacks():
        lib.list_optional_binary_add_callback__get_elem(
            ListOptionalBinaryHelper.__get_elem)
        lib.list_optional_binary_add_callback___delete(
            ListOptionalBinaryHelper.__delete)
        lib.list_optional_binary_add_callback__get_size(
            ListOptionalBinaryHelper.__get_size)
        lib.list_optional_binary_add_callback__python_create(
            ListOptionalBinaryHelper.__python_create)
        lib.list_optional_binary_add_callback__python_add(
            ListOptionalBinaryHelper.__python_add)
class SetOptionalStringHelper:
    c_data_set = MultiSet()

    @staticmethod
    def check_c_data_set_empty():
        assert len(SetOptionalStringHelper.c_data_set) == 0

    @ffi.callback("size_t(struct DjinniObjectHandle *)")
    def __get_size(cself):
        return len(CPyObjectProxy.toPyObj(None, cself))

    @ffi.callback("struct DjinniObjectHandle *()")
    def __python_create():
        c_ptr = ffi.new_handle(SetOptionalStringProxy(set()))
        SetOptionalStringHelper.c_data_set.add(c_ptr)
        return ffi.cast("struct DjinniObjectHandle *", c_ptr)

    @ffi.callback("void(struct DjinniObjectHandle *, struct DjinniString *)")
    def __python_add(cself, el):
        CPyObjectProxy.toPyObj(None, cself).add(CPyString.toPyOpt(el))

    @ffi.callback("void(struct DjinniObjectHandle * )")
    def __delete(c_ptr):
        assert c_ptr in SetOptionalStringHelper.c_data_set
        SetOptionalStringHelper.c_data_set.remove(c_ptr)

    @ffi.callback("struct DjinniString *(struct DjinniObjectHandle *)")
    def __python_next(cself):
        try:
            with CPyString.fromPyOpt(next(
                    CPyObjectProxy.toPyIter(cself))) as py_obj:
                return py_obj.release_djinni_string()
        except Exception as _djinni_py_e:
            CPyException.setExceptionFromPy(_djinni_py_e)
            return ffi.NULL

    @staticmethod
    def _add_callbacks():
        lib.set_optional_string_add_callback___delete(
            SetOptionalStringHelper.__delete)
        lib.set_optional_string_add_callback__get_size(
            SetOptionalStringHelper.__get_size)
        lib.set_optional_string_add_callback__python_create(
            SetOptionalStringHelper.__python_create)
        lib.set_optional_string_add_callback__python_add(
            SetOptionalStringHelper.__python_add)
        lib.set_optional_string_add_callback__python_next(
            SetOptionalStringHelper.__python_next)