X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=bindings%2Fpython%2Fbt2%2Fnative_btcomponentclass.i;h=6acfdb6e3d0f4d9cf04c919f014000f9420ddd2d;hb=911dec0860545c08f347bf8dc291f94494cd4da5;hp=53652b9acb7510b46e888635589f9eec56899f21;hpb=9a0a47aeda7c5de37b7090c074bd9031109bb47d;p=babeltrace.git diff --git a/bindings/python/bt2/native_btcomponentclass.i b/bindings/python/bt2/native_btcomponentclass.i index 53652b9a..6acfdb6e 100644 --- a/bindings/python/bt2/native_btcomponentclass.i +++ b/bindings/python/bt2/native_btcomponentclass.i @@ -51,6 +51,9 @@ const char *bt_component_class_get_description( struct bt_component_class *component_class); const char *bt_component_class_get_help( struct bt_component_class *component_class); +struct bt_value *bt_component_class_query_info( + struct bt_component_class *component_class, + const char *action, struct bt_value *params); enum bt_component_class_type bt_component_class_get_type( struct bt_component_class *component_class); @@ -560,6 +563,70 @@ static void bt_py3_cc_destroy(struct bt_component *component) } } +static struct bt_value *bt_py3_cc_query_info( + struct bt_component_class *component_class, + const char *action, struct bt_value *params) +{ + PyObject *py_cls = NULL; + PyObject *py_params = NULL; + PyObject *py_query_info_func = NULL; + PyObject *py_action = NULL; + PyObject *py_results_addr = NULL; + struct bt_value *results = NULL; + + py_cls = lookup_cc_ptr_to_py_cls(component_class); + if (!py_cls) { + goto error; + } + + py_params = bt_py3_bt_value_from_ptr(params); + if (!py_params) { + goto error; + } + + py_action = SWIG_FromCharPtr(action); + if (!py_action) { + goto error; + } + + py_results_addr = PyObject_CallMethod(py_cls, + "_query_info_from_bt", "(OO)", py_action, py_params); + if (!py_results_addr) { + goto error; + } + + /* + * The returned object, on success, is an integer object + * (PyLong) containing the address of a BT value object + * (which is now ours). + */ + results = (struct bt_value *) PyLong_AsUnsignedLongLong( + py_results_addr); + + /* Clear potential overflow error; should never happen */ + if (PyErr_Occurred()) { + results = NULL; + goto error; + } + + if (!results) { + goto error; + } + + goto end; + +error: + BT_PUT(results); + PyErr_Clear(); + +end: + Py_XDECREF(py_params); + Py_XDECREF(py_query_info_func); + Py_XDECREF(py_action); + Py_XDECREF(py_results_addr); + return results; +} + static enum bt_notification_iterator_status bt_py3_exc_to_notif_iter_status(void) { enum bt_notification_iterator_status status = @@ -728,13 +795,14 @@ static struct bt_notification *bt_py3_cc_notification_iterator_get( /* * The returned object, on success, is an integer object * (PyLong) containing the address of a BT notification - * object (which is not ours). + * object (which is now ours). */ notif = (struct bt_notification *) PyLong_AsUnsignedLongLong( py_get_method_result); /* Clear potential overflow error; should never happen */ if (PyErr_Occurred()) { + notif = NULL; goto error; } @@ -914,6 +982,12 @@ static int bt_py3_cc_set_optional_attrs_methods(struct bt_component_class *cc, goto end; } + ret = bt_component_class_set_query_info_method(cc, + bt_py3_cc_query_info); + if (ret) { + goto end; + } + end: return ret; }