X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=src%2Fbindings%2Fpython%2Fbt2%2Fbt2%2Fnative_bt_component.i;h=e0fc247d7e705a7be3bf894dcecf4594372f0762;hp=e663c7220c8e76c7404c6687b6450e9876cd486c;hb=0235b0db7de5bcacdb3650c92461f2ce5eb2143d;hpb=c594ab036e1797da45594dce8dfc07d90f2bb81f diff --git a/src/bindings/python/bt2/bt2/native_bt_component.i b/src/bindings/python/bt2/bt2/native_bt_component.i index e663c722..e0fc247d 100644 --- a/src/bindings/python/bt2/bt2/native_bt_component.i +++ b/src/bindings/python/bt2/bt2/native_bt_component.i @@ -1,35 +1,17 @@ /* - * The MIT License (MIT) + * SPDX-License-Identifier: MIT * * Copyright (c) 2017 Philippe Proulx - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. */ /* Output argument typemap for self port output (always appends) */ %typemap(in, numinputs=0) - (bt_self_component_port_input **OUT) + (bt_self_component_port_input **) (bt_self_component_port_input *temp_self_port = NULL) { $1 = &temp_self_port; } -%typemap(argout) bt_self_component_port_input **OUT { +%typemap(argout) bt_self_component_port_input ** { if (*$1) { /* SWIG_Python_AppendOutput() steals the created object */ $result = SWIG_Python_AppendOutput($result, @@ -44,12 +26,12 @@ /* Output argument typemap for self port output (always appends) */ %typemap(in, numinputs=0) - (bt_self_component_port_output **OUT) + (bt_self_component_port_output **) (bt_self_component_port_output *temp_self_port = NULL) { $1 = &temp_self_port; } -%typemap(argout) (bt_self_component_port_output **OUT) { +%typemap(argout) (bt_self_component_port_output **) { if (*$1) { /* SWIG_Python_AppendOutput() steals the created object */ $result = SWIG_Python_AppendOutput($result, @@ -68,7 +50,7 @@ * The user data Python object is kept as the user data of the port, we pass * the PyObject pointer directly to the port creation function. */ -%typemap(in) void *PY_SELF_PORT_USER_DATA { +%typemap(in) void *user_data { $1 = $input; } @@ -76,232 +58,17 @@ * The port, if created successfully, now owns a reference to the Python object, * we reflect that here. */ -%typemap(argout) void *PY_SELF_PORT_USER_DATA { - if (PyLong_AsLong($result) == BT_SELF_COMPONENT_STATUS_OK) { +%typemap(argout) void *user_data { + if (PyLong_AsLong($result) == __BT_FUNC_STATUS_OK) { Py_INCREF($1); } } -/* From component-const.h */ - -extern const char *bt_component_get_name(const bt_component *component); - -extern bt_logging_level bt_component_get_logging_level( - const bt_component *component); - -extern const bt_component_class *bt_component_borrow_class_const( - const bt_component *component); - -extern bt_component_class_type bt_component_get_class_type( - const bt_component *component); - -bt_bool bt_component_is_source(const bt_component *component); - -bt_bool bt_component_is_filter(const bt_component *component); - -bt_bool bt_component_is_sink(const bt_component *component); - -extern bt_bool bt_component_graph_is_canceled( - const bt_component *component); - -extern void bt_component_get_ref(const bt_component *component); - -extern void bt_component_put_ref(const bt_component *component); - -/* From component-source-const.h */ - -const bt_component *bt_component_source_as_component_const( - const bt_component_source *component); - -extern const bt_component_class_source * -bt_component_source_borrow_class_const( - const bt_component_source *component); - -extern uint64_t bt_component_source_get_output_port_count( - const bt_component_source *component); - -extern const bt_port_output * -bt_component_source_borrow_output_port_by_name_const( - const bt_component_source *component, const char *name); - -extern const bt_port_output * -bt_component_source_borrow_output_port_by_index_const( - const bt_component_source *component, uint64_t index); - -extern void bt_component_source_get_ref( - const bt_component_source *component_source); - -extern void bt_component_source_put_ref( - const bt_component_source *component_source); - -/* From component-filter-const.h */ - -const bt_component *bt_component_filter_as_component_const( - const bt_component_filter *component); - -extern const bt_component_class_filter * -bt_component_filter_borrow_class_const( - const bt_component_filter *component); - -extern uint64_t bt_component_filter_get_input_port_count( - const bt_component_filter *component); - -extern const bt_port_input * -bt_component_filter_borrow_input_port_by_name_const( - const bt_component_filter *component, const char *name); - -extern const bt_port_input * -bt_component_filter_borrow_input_port_by_index_const( - const bt_component_filter *component, uint64_t index); - -extern uint64_t bt_component_filter_get_output_port_count( - const bt_component_filter *component); - -extern const bt_port_output * -bt_component_filter_borrow_output_port_by_name_const( - const bt_component_filter *component, const char *name); - -extern const bt_port_output * -bt_component_filter_borrow_output_port_by_index_const( - const bt_component_filter *component, uint64_t index); - -extern void bt_component_filter_get_ref( - const bt_component_filter *component_filter); - -extern void bt_component_filter_put_ref( - const bt_component_filter *component_filter); - -/* From component-sink-const.h */ - -const bt_component *bt_component_sink_as_component_const( - const bt_component_sink *component); +%include +%include -extern const bt_component_class_sink * -bt_component_sink_borrow_class_const( - const bt_component_sink *component); - -extern uint64_t bt_component_sink_get_input_port_count( - const bt_component_sink *component); - -extern const bt_port_input * -bt_component_sink_borrow_input_port_by_name_const( - const bt_component_sink *component, const char *name); - -extern const bt_port_input * -bt_component_sink_borrow_input_port_by_index_const( - const bt_component_sink *component, uint64_t index); - -extern void bt_component_sink_get_ref( - const bt_component_sink *component_sink); - -extern void bt_component_sink_put_ref( - const bt_component_sink *component_sink); - -/* From self-component.h */ - -typedef enum bt_self_component_status { - BT_SELF_COMPONENT_STATUS_OK = 0, - BT_SELF_COMPONENT_STATUS_END = 1, - BT_SELF_COMPONENT_STATUS_AGAIN = 11, - BT_SELF_COMPONENT_STATUS_ERROR = -1, - BT_SELF_COMPONENT_STATUS_NOMEM = -12, -} bt_self_component_status; - -const bt_component *bt_self_component_as_component( - bt_self_component *self_component); - -extern void *bt_self_component_get_data( - const bt_self_component *self_component); - -extern void bt_self_component_set_data( - bt_self_component *self_component, void *data); - -/* From self-component-source.h */ - -bt_self_component *bt_self_component_source_as_self_component( - bt_self_component_source *self_comp_source); - -const bt_component_source * -bt_self_component_source_as_component_source( - bt_self_component_source *self_comp_source); - -extern bt_self_component_port_output * -bt_self_component_source_borrow_output_port_by_name( - bt_self_component_source *self_component, - const char *name); - -extern bt_self_component_port_output * -bt_self_component_source_borrow_output_port_by_index( - bt_self_component_source *self_component, - uint64_t index); - -extern bt_self_component_status -bt_self_component_source_add_output_port( - bt_self_component_source *self_component, - const char *name, void *PY_SELF_PORT_USER_DATA, - bt_self_component_port_output **OUT); - -/* From self-component-filter.h */ - -bt_self_component *bt_self_component_filter_as_self_component( - bt_self_component_filter *self_comp_filter); - -const bt_component_filter * -bt_self_component_filter_as_component_filter( - bt_self_component_filter *self_comp_filter); - -extern bt_self_component_port_output * -bt_self_component_filter_borrow_output_port_by_name( - bt_self_component_filter *self_component, - const char *name); - -extern bt_self_component_port_output * -bt_self_component_filter_borrow_output_port_by_index( - bt_self_component_filter *self_component, - uint64_t index); - -extern bt_self_component_status -bt_self_component_filter_add_output_port( - bt_self_component_filter *self_component, - const char *name, void *PY_SELF_PORT_USER_DATA, - bt_self_component_port_output **OUT); - -extern bt_self_component_port_input * -bt_self_component_filter_borrow_input_port_by_name( - bt_self_component_filter *self_component, - const char *name); - -extern bt_self_component_port_input * -bt_self_component_filter_borrow_input_port_by_index( - bt_self_component_filter *self_component, - uint64_t index); - -extern bt_self_component_status -bt_self_component_filter_add_input_port( - bt_self_component_filter *self_component, - const char *name, void *PY_SELF_PORT_USER_DATA, - bt_self_component_port_input **OUT); - -/* From self-component-sink.h */ - -bt_self_component *bt_self_component_sink_as_self_component( - bt_self_component_sink *self_comp_sink); - -const bt_component_sink * -bt_self_component_sink_as_component_sink( - bt_self_component_sink *self_comp_sink); - -extern bt_self_component_port_input * -bt_self_component_sink_borrow_input_port_by_name( - bt_self_component_sink *self_component, - const char *name); - -extern bt_self_component_port_input * -bt_self_component_sink_borrow_input_port_by_index( - bt_self_component_sink *self_component, uint64_t index); - -extern bt_self_component_status -bt_self_component_sink_add_input_port( - bt_self_component_sink *self_component, - const char *name, void *PY_SELF_PORT_USER_DATA, - bt_self_component_port_input **OUT); +/* + * This type map relies on the rather common "user_data" name, so don't pollute + * the typemap namespace. + */ +%clear void *user_data;