Exemple #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
Exemple #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
Exemple #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()
Exemple #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()
Exemple #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
Exemple #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
Exemple #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
Exemple #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
Exemple #9
0
 def _get(self):
     native_bt.get(self._ptr)
Exemple #10
0
 def _get(self):
     native_bt.get(self._ptr)