| 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 | /* |
| 26 | * Typemap for the user data attached to (and owned by) a self component port. |
| 27 | * The pointer saved as the port's user data is directly the PyObject *. |
| 28 | * |
| 29 | * As per the CPython calling convention, we need to return a new reference to |
| 30 | * the returned object, which will be transferred to the caller. The following |
| 31 | * typedef allows us to apply the typemap. |
| 32 | */ |
| 33 | %{ |
| 34 | typedef void *PY_SELF_PORT_USER_DATA; |
| 35 | %} |
| 36 | |
| 37 | %typemap(out) PY_SELF_PORT_USER_DATA { |
| 38 | Py_INCREF($1); |
| 39 | $result = $1; |
| 40 | } |
| 41 | |
| 42 | /* From port-const.h */ |
| 43 | |
| 44 | typedef enum bt_port_type { |
| 45 | BT_PORT_TYPE_INPUT = 0, |
| 46 | BT_PORT_TYPE_OUTPUT = 1, |
| 47 | } bt_port_type; |
| 48 | |
| 49 | extern const char *bt_port_get_name(const bt_port *port); |
| 50 | |
| 51 | extern bt_port_type bt_port_get_type(const bt_port *port); |
| 52 | |
| 53 | extern const bt_connection *bt_port_borrow_connection_const( |
| 54 | const bt_port *port); |
| 55 | |
| 56 | extern const bt_component *bt_port_borrow_component_const( |
| 57 | const bt_port *port); |
| 58 | |
| 59 | extern bt_bool bt_port_is_connected(const bt_port *port); |
| 60 | |
| 61 | bt_bool bt_port_is_input(const bt_port *port); |
| 62 | |
| 63 | bt_bool bt_port_is_output(const bt_port *port); |
| 64 | |
| 65 | extern void bt_port_get_ref(const bt_port *port); |
| 66 | |
| 67 | extern void bt_port_put_ref(const bt_port *port); |
| 68 | |
| 69 | /* From port-output-const.h */ |
| 70 | |
| 71 | const bt_port *bt_port_output_as_port_const(const bt_port_output *port_output); |
| 72 | |
| 73 | extern void bt_port_output_get_ref(const bt_port_output *port_output); |
| 74 | |
| 75 | extern void bt_port_output_put_ref(const bt_port_output *port_output); |
| 76 | |
| 77 | /* From port-input-const.h */ |
| 78 | |
| 79 | const bt_port *bt_port_input_as_port_const(const bt_port_input *port_input); |
| 80 | |
| 81 | extern void bt_port_input_get_ref(const bt_port_input *port_input); |
| 82 | |
| 83 | extern void bt_port_input_put_ref(const bt_port_input *port_input); |
| 84 | |
| 85 | /* From self-component-port.h */ |
| 86 | |
| 87 | typedef enum bt_self_component_port_status { |
| 88 | BT_SELF_PORT_STATUS_OK = 0, |
| 89 | } bt_self_component_port_status; |
| 90 | |
| 91 | const bt_port *bt_self_component_port_as_port( |
| 92 | bt_self_component_port *self_port); |
| 93 | |
| 94 | extern bt_self_component *bt_self_component_port_borrow_component( |
| 95 | bt_self_component_port *self_port); |
| 96 | |
| 97 | extern PY_SELF_PORT_USER_DATA bt_self_component_port_get_data( |
| 98 | const bt_self_component_port *self_port); |
| 99 | |
| 100 | /* From self-component-port-output.h */ |
| 101 | |
| 102 | bt_self_component_port * |
| 103 | bt_self_component_port_output_as_self_component_port( |
| 104 | bt_self_component_port_output *self_component_port); |
| 105 | |
| 106 | const bt_port_output *bt_self_component_port_output_as_port_output( |
| 107 | bt_self_component_port_output *self_component_port); |
| 108 | |
| 109 | /* From self-component-port-input.h */ |
| 110 | |
| 111 | bt_self_component_port * |
| 112 | bt_self_component_port_input_as_self_component_port( |
| 113 | bt_self_component_port_input *self_component_port); |
| 114 | |
| 115 | const bt_port_input *bt_self_component_port_input_as_port_input( |
| 116 | const bt_self_component_port_input *self_component_port); |