bindings/python/bt2: Make the bt2 Python bindings build
[babeltrace.git] / bindings / python / bt2 / bt2 / native_bt.i
index 7ac34206b351d6c4204b04997c81a960b3f5c692..b1e2d27df70382341801768cd98dc0ab918401d8 100644 (file)
 #include "logging.h"
 
 #include <babeltrace/babeltrace.h>
+#include <babeltrace/property.h>
 #include <babeltrace/assert-internal.h>
 
-typedef const unsigned char *BTUUID;
+typedef const uint8_t *bt_uuid;
 %}
 
 typedef int bt_bool;
@@ -43,16 +44,20 @@ typedef int bt_bool;
 /* For uint*_t/int*_t */
 %include "stdint.i"
 
-/* Remove `bt_` and `BT_` prefixes from function names and enumeration items */
+/*
+ * Remove `bt_` and `BT_` prefixes from function names, global variables and
+ * enumeration items
+ */
 %rename("%(strip:[bt_])s", %$isfunction) "";
+%rename("%(strip:[bt_])s", %$isvariable) "";
 %rename("%(strip:[BT_])s", %$isenumitem) "";
 
 /* Output argument typemap for string output (always appends) */
-%typemap(in, numinputs=0) const char **BTOUTSTR (char *temp_value = NULL) {
+%typemap(in, numinputs=0) (const char **OUT) (char *temp_value) {
        $1 = &temp_value;
 }
 
-%typemap(argout) const char **BTOUTSTR {
+%typemap(argout) (const char **OUT) {
        if (*$1) {
                /* SWIG_Python_AppendOutput() steals the created object */
                $result = SWIG_Python_AppendOutput($result, SWIG_Python_str_FromChar(*$1));
@@ -63,31 +68,17 @@ typedef int bt_bool;
        }
 }
 
-/* Output argument typemap for field type output (always appends) */
-%typemap(in, numinputs=0) struct bt_field_type **BTOUTFT (struct bt_field_type *temp_ft = NULL) {
-       $1 = &temp_ft;
-}
-
-%typemap(argout) struct bt_field_type **BTOUTFT {
-       if (*$1) {
-               /* SWIG_Python_AppendOutput() steals the created object */
-               $result = SWIG_Python_AppendOutput($result, SWIG_NewPointerObj(SWIG_as_voidptr(*$1), SWIGTYPE_p_bt_field_type, 0));
-       } else {
-               /* SWIG_Python_AppendOutput() steals Py_None */
-               Py_INCREF(Py_None);
-               $result = SWIG_Python_AppendOutput($result, Py_None);
-       }
-}
-
-/* Output argument typemap for component output (always appends) */
-%typemap(in, numinputs=0) struct bt_component **BTOUTCOMP (struct bt_component *temp_comp = NULL) {
-       $1 = &temp_comp;
+/* Output argument typemap for value output (always appends) */
+%typemap(in, numinputs=0) (bt_value **OUT) (struct bt_value *temp_value = NULL) {
+       $1 = &temp_value;
 }
 
-%typemap(argout) struct bt_component **BTOUTCOMP {
+%typemap(argout) (bt_value **OUT) {
        if (*$1) {
                /* SWIG_Python_AppendOutput() steals the created object */
-               $result = SWIG_Python_AppendOutput($result, SWIG_NewPointerObj(SWIG_as_voidptr(*$1), SWIGTYPE_p_bt_component, 0));
+               $result = SWIG_Python_AppendOutput($result,
+                               SWIG_NewPointerObj(SWIG_as_voidptr(*$1),
+                                       SWIGTYPE_p_bt_value, 0));
        } else {
                /* SWIG_Python_AppendOutput() steals Py_None */
                Py_INCREF(Py_None);
@@ -95,79 +86,50 @@ typedef int bt_bool;
        }
 }
 
-/* Output argument typemap for connection output (always appends) */
-%typemap(in, numinputs=0) struct bt_connection **BTOUTCONN (struct bt_connection *temp_conn = NULL) {
-       $1 = &temp_conn;
-}
-
-%typemap(argout) struct bt_connection **BTOUTCONN {
-       if (*$1) {
-               /* SWIG_Python_AppendOutput() steals the created object */
-               $result = SWIG_Python_AppendOutput($result, SWIG_NewPointerObj(SWIG_as_voidptr(*$1), SWIGTYPE_p_bt_connection, 0));
-       } else {
-               /* SWIG_Python_AppendOutput() steals Py_None */
-               Py_INCREF(Py_None);
-               $result = SWIG_Python_AppendOutput($result, Py_None);
-       }
+/* Output argument typemap for initialized uint64_t output parameter (always appends) */
+%typemap(in, numinputs=0) (uint64_t *OUT) (uint64_t temp) {
+       $1 = &temp;
 }
 
-/* Output argument typemap for private port output (always appends) */
-%typemap(in, numinputs=0) struct bt_private_port **BTOUTPRIVPORT (struct bt_private_port *temp_priv_port = NULL) {
-       $1 = &temp_priv_port;
+%typemap(argout) uint64_t *OUT {
+       $result = SWIG_Python_AppendOutput(resultobj,
+                       SWIG_From_unsigned_SS_long_SS_long((*$1)));
 }
 
-%typemap(argout) struct bt_private_port **BTOUTPRIVPORT {
-       if (*$1) {
-               /* SWIG_Python_AppendOutput() steals the created object */
-               $result = SWIG_Python_AppendOutput($result, SWIG_NewPointerObj(SWIG_as_voidptr(*$1), SWIGTYPE_p_bt_private_port, 0));
-       } else {
-               /* SWIG_Python_AppendOutput() steals Py_None */
-               Py_INCREF(Py_None);
-               $result = SWIG_Python_AppendOutput($result, Py_None);
-       }
-}
-
-/* Output argument typemap for value output (always appends) */
-%typemap(in, numinputs=0) struct bt_value **BTOUTVALUE (struct bt_value *temp_value = NULL) {
-       $1 = &temp_value;
+/* Output argument typemap for initialized int64_t output parameter (always appends) */
+%typemap(in, numinputs=0) (int64_t *OUT) (int64_t temp) {
+       $1 = &temp;
 }
 
-%typemap(argout) struct bt_value **BTOUTVALUE {
-       if (*$1) {
-               /* SWIG_Python_AppendOutput() steals the created object */
-               $result = SWIG_Python_AppendOutput($result, SWIG_NewPointerObj(SWIG_as_voidptr(*$1), SWIGTYPE_p_bt_value, 0));
-       } else {
-               /* SWIG_Python_AppendOutput() steals Py_None */
-               Py_INCREF(Py_None);
-               $result = SWIG_Python_AppendOutput($result, Py_None);
-       }
+%typemap(argout) (int64_t *OUT) {
+       $result = SWIG_Python_AppendOutput(resultobj, SWIG_From_long_SS_long((*$1)));
 }
 
-/* Output argument typemap for initialized uint64_t output parameter (always appends) */
-%typemap(in, numinputs=0) uint64_t *OUTPUTINIT (uint64_t temp = -1ULL) {
+/* Output argument typemap for initialized unsigned int output parameter (always appends) */
+%typemap(in, numinputs=0) (unsigned int *OUT) (unsigned int temp) {
        $1 = &temp;
 }
 
-%typemap(argout) uint64_t *OUTPUTINIT {
-       $result = SWIG_Python_AppendOutput(resultobj, SWIG_From_unsigned_SS_long_SS_long((*$1)));
+%typemap(argout) (unsigned int *OUT) {
+       $result = SWIG_Python_AppendOutput(resultobj,
+                       SWIG_From_unsigned_SS_long_SS_long((uint64_t) (*$1)));
 }
-
-/* Output argument typemap for initialized unsigned int output parameter (always appends) */
-%typemap(in, numinputs=0) unsigned int *OUTPUTINIT (unsigned int temp = -1) {
+/* Output argument typemap for initialized double output parameter (always appends) */
+%typemap(in, numinputs=0) (double *OUT) (double temp) {
        $1 = &temp;
 }
 
-%typemap(argout) unsigned int *OUTPUTINIT {
-       $result = SWIG_Python_AppendOutput(resultobj, SWIG_From_unsigned_SS_long_SS_long((uint64_t) (*$1)));
+%typemap(argout) (double *OUT) {
+       $result = SWIG_Python_AppendOutput(resultobj, SWIG_From_int((*$1)));
 }
 
 /* Input argument typemap for UUID bytes */
-%typemap(in) BTUUID {
+%typemap(in) bt_uuid {
        $1 = (unsigned char *) PyBytes_AsString($input);
 }
 
 /* Output argument typemap for UUID bytes */
-%typemap(out) BTUUID {
+%typemap(out) bt_uuid {
        if (!$1) {
                Py_INCREF(Py_None);
                $result = Py_None;
@@ -176,6 +138,22 @@ typedef int bt_bool;
        }
 }
 
+/* Input argument typemap for bt_bool */
+%typemap(in) bt_bool {
+       $1 = PyObject_IsTrue($input);
+}
+
+/* Output argument typemap for bt_bool */
+%typemap(out) bt_bool {
+       if ($1 > 0) {
+               $result = Py_True;
+       } else {
+               $result = Py_False;
+       }
+       Py_INCREF($result);
+       return $result;
+}
+
 /*
  * Input and output argument typemaps for raw Python objects (direct).
  *
@@ -193,65 +171,35 @@ typedef int bt_bool;
        $result = $1;
 }
 
-%{
-static enum bt_notification_type *bt_py3_notif_types_from_py_list(
-               PyObject *py_notif_types)
-{
-       enum bt_notification_type *notification_types = NULL;
-       size_t i;
-
-       BT_ASSERT(!PyErr_Occurred());
+/* From property.h */
 
-       if (py_notif_types == Py_None) {
-               goto end;
-       }
-
-       BT_ASSERT(PyList_Check(py_notif_types));
-       notification_types = g_new0(enum bt_notification_type,
-               PyList_Size(py_notif_types) + 1);
-       BT_ASSERT(notification_types);
-       notification_types[PyList_Size(py_notif_types)] =
-               BT_NOTIFICATION_TYPE_SENTINEL;
-
-       for (i = 0; i < PyList_Size(py_notif_types); i++) {
-               PyObject *item = PyList_GetItem(py_notif_types, i);
-               long value;
-               int overflow;
-
-               BT_ASSERT(item);
-               BT_ASSERT(PyLong_Check(item));
-               value = PyLong_AsLongAndOverflow(item, &overflow);
-               BT_ASSERT(overflow == 0);
-               notification_types[i] = value;
-       }
-
-end:
-       return notification_types;
-}
-%}
+typedef enum bt_property_availability {
+       BT_PROPERTY_AVAILABILITY_AVAILABLE,
+       BT_PROPERTY_AVAILABILITY_NOT_AVAILABLE,
+} bt_property_availability;
 
 /* Per-module interface files */
-%include "native_btccpriomap.i"
-%include "native_btclockclass.i"
-%include "native_btcomponent.i"
-%include "native_btcomponentclass.i"
-%include "native_btconnection.i"
-%include "native_btctfwriter.i"
-%include "native_btevent.i"
-%include "native_bteventclass.i"
-%include "native_btfields.i"
-%include "native_btft.i"
-%include "native_btgraph.i"
-%include "native_btlogging.i"
-%include "native_btnotification.i"
-%include "native_btnotifiter.i"
-%include "native_btpacket.i"
-%include "native_btplugin.i"
-%include "native_btport.i"
-%include "native_btqueryexec.i"
-%include "native_btref.i"
-%include "native_btstream.i"
-%include "native_btstreamclass.i"
-%include "native_bttrace.i"
-%include "native_btvalues.i"
-%include "native_btversion.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_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_logging.i"
+%include "native_bt_message.i"
+%include "native_bt_notifier.i"
+%include "native_bt_packet.i"
+%include "native_bt_plugin.i"
+%include "native_bt_port.i"
+%include "native_bt_query_exec.i"
+%include "native_bt_stream.i"
+%include "native_bt_stream_class.i"
+%include "native_bt_trace.i"
+%include "native_bt_trace_class.i"
+%include "native_bt_value.i"
+%include "native_bt_version.i"
This page took 0.027142 seconds and 4 git commands to generate.