Example #1
0
    def _query_from_native(cls, query_exec_ptr, obj, params_ptr):
        # this can raise, in which case the native call to
        # bt_component_class_query() returns NULL
        if params_ptr is not None:
            native_bt.get(params_ptr)
            params = bt2.values._create_from_ptr(params_ptr)
        else:
            params = None

        native_bt.get(query_exec_ptr)
        query_exec = bt2.QueryExecutor._create_from_ptr(query_exec_ptr)

        # this can raise, but the native side checks the exception
        results = cls._query(query_exec, obj, params)

        if results is NotImplemented:
            return results

        # this can raise, but the native side checks the exception
        results = bt2.create_value(results)

        if results is None:
            results_addr = int(native_bt.value_null)
        else:
            # return new reference
            results._get()
            results_addr = int(results._ptr)

        return results_addr
Example #2
0
    def _query_from_native(cls, query_exec_ptr, obj, params_ptr):
        # this can raise, in which case the native call to
        # bt_component_class_query() returns NULL
        if params_ptr is not None:
            native_bt.get(params_ptr)
            params = bt2.values._create_from_ptr(params_ptr)
        else:
            params = None

        native_bt.get(query_exec_ptr)
        query_exec = bt2.QueryExecutor._create_from_ptr(query_exec_ptr)

        # this can raise, but the native side checks the exception
        results = cls._query(query_exec, obj, params)

        if results is NotImplemented:
            return results

        # this can raise, but the native side checks the exception
        results = bt2.create_value(results)

        if results is None:
            results_addr = int(native_bt.value_null)
        else:
            # return new reference
            results._get()
            results_addr = int(results._ptr)

        return results_addr
Example #3
0
    def _port_disconnected_from_native(self, port_ptr):
        native_bt.get(port_ptr)
        port = bt2.port._create_private_from_ptr(port_ptr)

        try:
            self._port_disconnected(port)
        except:
            if not _NO_PRINT_TRACEBACK:
                traceback.print_exc()
Example #4
0
    def _port_disconnected_from_native(self, port_ptr):
        native_bt.get(port_ptr)
        port = bt2.port._create_private_from_ptr(port_ptr)

        try:
            self._port_disconnected(port)
        except:
            if not _NO_PRINT_TRACEBACK:
                traceback.print_exc()
Example #5
0
    def _accept_port_connection_from_native(self, port_ptr, other_port_ptr):
        native_bt.get(port_ptr)
        native_bt.get(other_port_ptr)
        port = bt2.port._create_private_from_ptr(port_ptr)
        other_port = bt2.port._create_from_ptr(other_port_ptr)
        res = self._accept_port_connection(port, other_port_ptr)

        if type(res) is not bool:
            raise TypeError("'{}' is not a 'bool' object")

        return res
Example #6
0
    def _accept_port_connection_from_native(self, port_ptr, other_port_ptr):
        native_bt.get(port_ptr)
        native_bt.get(other_port_ptr)
        port = bt2.port._create_private_from_ptr(port_ptr)
        other_port = bt2.port._create_from_ptr(other_port_ptr)
        res = self._accept_port_connection(port, other_port_ptr)

        if type(res) is not bool:
            raise TypeError("'{}' is not a 'bool' object")

        return res
Example #7
0
    def _init_from_native(cls, comp_ptr, params_ptr):
        # create instance, not user-initialized yet
        self = cls.__new__(cls)

        # pointer to native private component object (weak/borrowed)
        self._ptr = comp_ptr

        # call user's __init__() method
        if params_ptr is not None:
            native_bt.get(params_ptr)
            params = bt2.values._create_from_ptr(params_ptr)
        else:
            params = None

        self.__init__(params)
        return self
Example #8
0
    def _init_from_native(cls, comp_ptr, params_ptr):
        # create instance, not user-initialized yet
        self = cls.__new__(cls)

        # pointer to native private component object (weak/borrowed)
        self._ptr = comp_ptr

        # call user's __init__() method
        if params_ptr is not None:
            native_bt.get(params_ptr)
            params = bt2.values._create_from_ptr(params_ptr)
        else:
            params = None

        self.__init__(params)
        return self
Example #9
0
 def _get(self):
     native_bt.get(self._ptr)
Example #10
0
 def _get(self):
     native_bt.get(self._ptr)