X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Fbindings%2Fpython%2Fbt2%2Fbt2%2Fgraph.py;h=ef40014ba9262e58e678193e2b9355c59a92de27;hb=3e03e5e334d6a995f4fc63f52b6d6745688f640f;hp=14c3b65b84f56fc2351455230e3e4edc2eddd08d;hpb=9012866ad93646be8a0108d5673202361755c5b3;p=babeltrace.git diff --git a/src/bindings/python/bt2/bt2/graph.py b/src/bindings/python/bt2/bt2/graph.py index 14c3b65b..ef40014b 100644 --- a/src/bindings/python/bt2/bt2/graph.py +++ b/src/bindings/python/bt2/bt2/graph.py @@ -33,10 +33,10 @@ import bt2 def _graph_port_added_listener_from_native( user_listener, component_ptr, component_type, port_ptr, port_type ): - component = bt2_component._create_component_from_ptr_and_get_ref( + component = bt2_component._create_component_from_const_ptr_and_get_ref( component_ptr, component_type ) - port = bt2_port._create_from_ptr_and_get_ref(port_ptr, port_type) + port = bt2_port._create_from_const_ptr_and_get_ref(port_ptr, port_type) user_listener(component, port) @@ -49,16 +49,16 @@ def _graph_ports_connected_listener_from_native( downstream_component_type, downstream_port_ptr, ): - upstream_component = bt2_component._create_component_from_ptr_and_get_ref( + upstream_component = bt2_component._create_component_from_const_ptr_and_get_ref( upstream_component_ptr, upstream_component_type ) - upstream_port = bt2_port._create_from_ptr_and_get_ref( + upstream_port = bt2_port._create_from_const_ptr_and_get_ref( upstream_port_ptr, native_bt.PORT_TYPE_OUTPUT ) - downstream_component = bt2_component._create_component_from_ptr_and_get_ref( + downstream_component = bt2_component._create_component_from_const_ptr_and_get_ref( downstream_component_ptr, downstream_component_type ) - downstream_port = bt2_port._create_from_ptr_and_get_ref( + downstream_port = bt2_port._create_from_const_ptr_and_get_ref( downstream_port_ptr, native_bt.PORT_TYPE_INPUT ) user_listener( @@ -91,15 +91,15 @@ class Graph(object._SharedObject): obj=None, logging_level=bt2_logging.LoggingLevel.NONE, ): - if isinstance(component_class, bt2_component._SourceComponentClass): + if isinstance(component_class, bt2_component._SourceComponentClassConst): cc_ptr = component_class._ptr add_fn = native_bt.bt2_graph_add_source_component cc_type = native_bt.COMPONENT_CLASS_TYPE_SOURCE - elif isinstance(component_class, bt2_component._FilterComponentClass): + elif isinstance(component_class, bt2_component._FilterComponentClassConst): cc_ptr = component_class._ptr add_fn = native_bt.bt2_graph_add_filter_component cc_type = native_bt.COMPONENT_CLASS_TYPE_FILTER - elif isinstance(component_class, bt2_component._SinkComponentClass): + elif isinstance(component_class, bt2_component._SinkComponentClassConst): cc_ptr = component_class._ptr add_fn = native_bt.bt2_graph_add_sink_component cc_type = native_bt.COMPONENT_CLASS_TYPE_SINK @@ -129,7 +129,11 @@ class Graph(object._SharedObject): if obj is not None and not native_bt.bt2_is_python_component_class(base_cc_ptr): raise ValueError('cannot pass a Python object to a non-Python component') + if params is not None and not isinstance(params, (dict, bt2.MapValue)): + raise TypeError("'params' parameter is not a 'dict' or a 'bt2.MapValue'.") + params = bt2.create_value(params) + params_ptr = params._ptr if params is not None else None status, comp_ptr = add_fn( @@ -137,11 +141,11 @@ class Graph(object._SharedObject): ) utils._handle_func_status(status, 'cannot add component to graph') assert comp_ptr - return bt2_component._create_component_from_ptr(comp_ptr, cc_type) + return bt2_component._create_component_from_const_ptr(comp_ptr, cc_type) def connect_ports(self, upstream_port, downstream_port): - utils._check_type(upstream_port, bt2_port._OutputPort) - utils._check_type(downstream_port, bt2_port._InputPort) + utils._check_type(upstream_port, bt2_port._OutputPortConst) + utils._check_type(downstream_port, bt2_port._InputPortConst) status, conn_ptr = native_bt.graph_connect_ports( self._ptr, upstream_port._ptr, downstream_port._ptr )