X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Fbindings%2Fpython%2Fbt2%2Fbt2%2Fnative_bt.i;h=21a869e606376d4bc9101f92a31d44aae8fc47de;hb=900eef7317d3e8b350a93fb8782639845c62c2bd;hp=e538b268b448268c07fdd76c4af3544541495c1c;hpb=350ad6c1c5f45a4e90c33e3c1354125c209bbf02;p=babeltrace.git diff --git a/src/bindings/python/bt2/bt2/native_bt.i b/src/bindings/python/bt2/bt2/native_bt.i index e538b268..21a869e6 100644 --- a/src/bindings/python/bt2/bt2/native_bt.i +++ b/src/bindings/python/bt2/bt2/native_bt.i @@ -1,25 +1,7 @@ /* - * The MIT License (MIT) + * SPDX-License-Identifier: MIT * * Copyright (c) 2016 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. */ #ifndef SWIGPYTHON @@ -32,14 +14,30 @@ #define BT_LOG_TAG "BT2-PY" #include "logging.h" +/* + * Include before `` because + * `` removes the `__BT_IN_BABELTRACE_H` + * definition. + */ #include -#include + +/* + * This is not part of the API, but because those bindings reside within + * the project, we take the liberty to use them. + */ +#define __BT_IN_BABELTRACE_H +#include + #include "common/assert.h" +#include "py-common/py-common.h" -typedef const uint8_t *bt_uuid; +/* Used by some interface files */ +#include "native_bt_bt2_objects.h" +#include "native_bt_log_and_append_error.h" %} typedef int bt_bool; +typedef uint64_t bt_listener_id; /* For uint*_t/int*_t */ %include "stdint.i" @@ -61,11 +59,11 @@ typedef int bt_bool; * functions on which we apply this typemap don't guarantee that the value of * `temp_value` will be unchanged or valid. */ -%typemap(in, numinputs=0) (const char **OUT) (char *temp_value = (void *) 1) { +%typemap(in, numinputs=0) (const char **) (char *temp_value = (void *) 1) { $1 = &temp_value; } -%typemap(argout) (const char **OUT) { +%typemap(argout) (const char **) { if (*$1) { /* SWIG_Python_AppendOutput() steals the created object */ $result = SWIG_Python_AppendOutput($result, SWIG_Python_str_FromChar(*$1)); @@ -77,11 +75,11 @@ typedef int bt_bool; } /* Output argument typemap for value output (always appends) */ -%typemap(in, numinputs=0) (bt_value **OUT) (struct bt_value *temp_value = NULL) { +%typemap(in, numinputs=0) (bt_value **) (struct bt_value *temp_value = NULL) { $1 = &temp_value; } -%typemap(argout) (bt_value **OUT) { +%typemap(argout) (bt_value **) { if (*$1) { /* SWIG_Python_AppendOutput() steals the created object */ $result = SWIG_Python_AppendOutput($result, @@ -95,40 +93,42 @@ typedef int bt_bool; } /* Output argument typemap for initialized uint64_t output parameter (always appends) */ -%typemap(in, numinputs=0) (uint64_t *OUT) (uint64_t temp) { +%typemap(in, numinputs=0) (uint64_t *) (uint64_t temp) { $1 = &temp; } -%typemap(argout) uint64_t *OUT { +%typemap(argout) uint64_t * { $result = SWIG_Python_AppendOutput(resultobj, SWIG_From_unsigned_SS_long_SS_long((*$1))); } /* Output argument typemap for initialized int64_t output parameter (always appends) */ -%typemap(in, numinputs=0) (int64_t *OUT) (int64_t temp) { +%typemap(in, numinputs=0) (int64_t *) (int64_t temp) { $1 = &temp; } -%typemap(argout) (int64_t *OUT) { +%typemap(argout) (int64_t *) { $result = SWIG_Python_AppendOutput(resultobj, SWIG_From_long_SS_long((*$1))); } /* Output argument typemap for initialized unsigned int output parameter (always appends) */ -%typemap(in, numinputs=0) (unsigned int *OUT) (unsigned int temp) { +%typemap(in, numinputs=0) (unsigned int *) (unsigned int temp) { $1 = &temp; } -%typemap(argout) (unsigned int *OUT) { +%typemap(argout) (unsigned int *) { $result = SWIG_Python_AppendOutput(resultobj, SWIG_From_unsigned_SS_long_SS_long((uint64_t) (*$1))); } -/* Output argument typemap for initialized double output parameter (always appends) */ -%typemap(in, numinputs=0) (double *OUT) (double temp) { + +/* Output argument typemap for initialized bt_boot output parameter (always appends) */ +%typemap(in, numinputs=0) (bt_bool *) (bt_bool temp) { $1 = &temp; } -%typemap(argout) (double *OUT) { - $result = SWIG_Python_AppendOutput(resultobj, SWIG_From_int((*$1))); +%typemap(argout) bt_bool * { + $result = SWIG_Python_AppendOutput(resultobj, + SWIG_From_bool(*$1)); } /* Input argument typemap for UUID bytes */ @@ -159,7 +159,6 @@ typedef int bt_bool; $result = Py_False; } Py_INCREF($result); - return $result; } /* @@ -179,28 +178,58 @@ typedef int bt_bool; $result = $1; } -/* From property.h */ +/* Native part initialization and finalization */ +void bt_bt2_init_from_bt2(void); +void bt_bt2_exit_handler(void); + +/* + * These functions cause some -Wformat-nonliteral warnings, but we don't need + * them. Ignore them, so that we can keep the warning turned on. + */ +%ignore bt_current_thread_error_append_cause_from_component; +%ignore bt_current_thread_error_append_cause_from_component_class; +%ignore bt_current_thread_error_append_cause_from_message_iterator; +%ignore bt_current_thread_error_append_cause_from_unknown; + +/* + * Define `__BT_IN_BABELTRACE_H` to allow specific headers to be + * included. This remains defined as long as we don't include the main + * header, ``. + */ +#define __BT_IN_BABELTRACE_H + +/* + * Define `__BT_ATTR_FORMAT_PRINTF` to nothing, otherwise SWIG fails to parse + * the included header files that use it. + */ +#define __BT_ATTR_FORMAT_PRINTF(_string_index, _first_to_check) + +/* Common types */ +%include -typedef enum bt_property_availability { - BT_PROPERTY_AVAILABILITY_AVAILABLE, - BT_PROPERTY_AVAILABILITY_NOT_AVAILABLE, -} bt_property_availability; +/* Common function status codes */ +%include /* Per-module interface files */ +%include "native_bt_autodisc.i" %include "native_bt_clock_class.i" %include "native_bt_clock_snapshot.i" %include "native_bt_component.i" %include "native_bt_component_class.i" %include "native_bt_connection.i" +%include "native_bt_error.i" %include "native_bt_event.i" %include "native_bt_event_class.i" %include "native_bt_field.i" %include "native_bt_field_class.i" %include "native_bt_field_path.i" %include "native_bt_graph.i" +%include "native_bt_integer_range_set.i" +%include "native_bt_interrupter.i" %include "native_bt_logging.i" %include "native_bt_message.i" -%include "native_bt_notifier.i" +%include "native_bt_message_iterator.i" +%include "native_bt_mip.i" %include "native_bt_packet.i" %include "native_bt_plugin.i" %include "native_bt_port.i" @@ -211,3 +240,13 @@ typedef enum bt_property_availability { %include "native_bt_trace_class.i" %include "native_bt_value.i" %include "native_bt_version.i" + +%{ + +/* + * This function is defined by SWIG. Declare here to avoid a + * -Wmissing-prototypes warning. + */ +PyObject *SWIG_init(void); + +%}