| 1 | /* |
| 2 | * The MIT License (MIT) |
| 3 | * |
| 4 | * Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com> |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | * of this software and associated documentation files (the "Software"), to deal |
| 8 | * in the Software without restriction, including without limitation the rights |
| 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 10 | * copies of the Software, and to permit persons to whom the Software is |
| 11 | * furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included in |
| 14 | * all copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 22 | * THE SOFTWARE. |
| 23 | */ |
| 24 | |
| 25 | /* Output argument typemap for connection output (always appends) */ |
| 26 | %typemap(in, numinputs=0) |
| 27 | (const bt_connection **) |
| 28 | (bt_connection *temp_conn = NULL) { |
| 29 | $1 = &temp_conn; |
| 30 | } |
| 31 | |
| 32 | %typemap(argout) |
| 33 | (const bt_connection **) { |
| 34 | if (*$1) { |
| 35 | /* SWIG_Python_AppendOutput() steals the created object */ |
| 36 | $result = SWIG_Python_AppendOutput($result, |
| 37 | SWIG_NewPointerObj(SWIG_as_voidptr(*$1), |
| 38 | SWIGTYPE_p_bt_connection, 0)); |
| 39 | } else { |
| 40 | /* SWIG_Python_AppendOutput() steals Py_None */ |
| 41 | Py_INCREF(Py_None); |
| 42 | $result = SWIG_Python_AppendOutput($result, Py_None); |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | /* Output argument typemap for component output (always appends) */ |
| 47 | %typemap(in, numinputs=0) |
| 48 | (const bt_component_source **) |
| 49 | (bt_component_source *temp_comp = NULL) { |
| 50 | $1 = &temp_comp; |
| 51 | } |
| 52 | |
| 53 | %typemap(in, numinputs=0) |
| 54 | (const bt_component_filter **) |
| 55 | (bt_component_filter *temp_comp = NULL) { |
| 56 | $1 = &temp_comp; |
| 57 | } |
| 58 | |
| 59 | %typemap(in, numinputs=0) |
| 60 | (const bt_component_sink **) |
| 61 | (bt_component_sink *temp_comp = NULL) { |
| 62 | $1 = &temp_comp; |
| 63 | } |
| 64 | |
| 65 | %typemap(argout) (const bt_component_source **) { |
| 66 | if (*$1) { |
| 67 | /* SWIG_Python_AppendOutput() steals the created object */ |
| 68 | $result = SWIG_Python_AppendOutput($result, |
| 69 | SWIG_NewPointerObj(SWIG_as_voidptr(*$1), |
| 70 | SWIGTYPE_p_bt_component_source, 0)); |
| 71 | } else { |
| 72 | /* SWIG_Python_AppendOutput() steals Py_None */ |
| 73 | Py_INCREF(Py_None); |
| 74 | $result = SWIG_Python_AppendOutput($result, Py_None); |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | %typemap(argout) (const bt_component_filter **) { |
| 79 | if (*$1) { |
| 80 | /* SWIG_Python_AppendOutput() steals the created object */ |
| 81 | $result = SWIG_Python_AppendOutput($result, |
| 82 | SWIG_NewPointerObj(SWIG_as_voidptr(*$1), |
| 83 | SWIGTYPE_p_bt_component_filter, 0)); |
| 84 | } else { |
| 85 | /* SWIG_Python_AppendOutput() steals Py_None */ |
| 86 | Py_INCREF(Py_None); |
| 87 | $result = SWIG_Python_AppendOutput($result, Py_None); |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | %typemap(argout) (const bt_component_sink **) { |
| 92 | if (*$1) { |
| 93 | /* SWIG_Python_AppendOutput() steals the created object */ |
| 94 | $result = SWIG_Python_AppendOutput($result, |
| 95 | SWIG_NewPointerObj(SWIG_as_voidptr(*$1), |
| 96 | SWIGTYPE_p_bt_component_sink, 0)); |
| 97 | } else { |
| 98 | /* SWIG_Python_AppendOutput() steals Py_None */ |
| 99 | Py_INCREF(Py_None); |
| 100 | $result = SWIG_Python_AppendOutput($result, Py_None); |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | %include <babeltrace2/graph/graph-const.h> |
| 105 | %include <babeltrace2/graph/graph.h> |
| 106 | |
| 107 | /* Helper functions for Python */ |
| 108 | |
| 109 | %{ |
| 110 | #include "native_bt_graph.i.h" |
| 111 | %} |
| 112 | |
| 113 | PyObject *bt_bt2_graph_add_port_added_listener(struct bt_graph *graph, |
| 114 | PyObject *py_callable); |
| 115 | |
| 116 | PyObject *bt_bt2_graph_add_ports_connected_listener(struct bt_graph *graph, |
| 117 | PyObject *py_callable); |
| 118 | |
| 119 | bt_graph_add_component_status |
| 120 | bt_bt2_graph_add_source_component( |
| 121 | bt_graph *graph, |
| 122 | const bt_component_class_source *component_class, |
| 123 | const char *name, const bt_value *params, |
| 124 | PyObject *obj, bt_logging_level log_level, |
| 125 | const bt_component_source **component); |
| 126 | |
| 127 | bt_graph_add_component_status |
| 128 | bt_bt2_graph_add_filter_component( |
| 129 | bt_graph *graph, |
| 130 | const bt_component_class_filter *component_class, |
| 131 | const char *name, const bt_value *params, |
| 132 | PyObject *obj, bt_logging_level log_level, |
| 133 | const bt_component_filter **component); |
| 134 | |
| 135 | bt_graph_add_component_status |
| 136 | bt_bt2_graph_add_sink_component( |
| 137 | bt_graph *graph, |
| 138 | const bt_component_class_sink *component_class, |
| 139 | const char *name, const bt_value *params, |
| 140 | PyObject *obj, bt_logging_level log_level, |
| 141 | const bt_component_sink **component); |