bt2: pass custom Python object to Python component's __init__()
[babeltrace.git] / src / bindings / python / bt2 / bt2 / component.py
index a057019aa379c37cb7af3f471b2fe46cb070a146..8052e8a4b0c5ac35af07dbd32387d75f9ec870fe 100644 (file)
@@ -508,7 +508,7 @@ class _UserComponentType(type):
 
         cls._bt_cc_ptr = cc_ptr
 
-    def _bt_init_from_native(cls, comp_ptr, params_ptr):
+    def _bt_init_from_native(cls, comp_ptr, params_ptr, obj):
         # create instance, not user-initialized yet
         self = cls.__new__(cls)
 
@@ -521,7 +521,7 @@ class _UserComponentType(type):
         else:
             params = None
 
-        self.__init__(params)
+        self.__init__(params, obj)
         return self
 
     def __call__(cls, *args, **kwargs):
@@ -617,6 +617,7 @@ class _UserComponentType(type):
         if hasattr(cls, '_bt_cc_ptr'):
             cc_ptr = cls._bt_as_component_class_ptr(cls._bt_cc_ptr)
             native_bt.component_class_put_ref(cc_ptr)
+            native_bt.bt2_unregister_cc_ptr_to_py_cls(cc_ptr)
 
 
 # Subclasses must provide these methods or property:
@@ -658,7 +659,7 @@ class _UserComponent(metaclass=_UserComponentType):
     def addr(self):
         return int(self._bt_ptr)
 
-    def __init__(self, params=None):
+    def __init__(self, params=None, obj=None):
         pass
 
     def _user_finalize(self):
This page took 0.024782 seconds and 4 git commands to generate.