Rename bt_ctf_X -> bt_X, maintain backward compat. for pre-2.0 CTF writer
[deliverable/babeltrace.git] / bindings / python / bt2 / bt2 / native_bt.i
index 59595a3117965a5bb432d39b2819d7236a8ef614..62964f256380539d8b9463013512d554fdc00cb8 100644 (file)
@@ -63,14 +63,14 @@ typedef int bt_bool;
 }
 
 /* Output argument typemap for field type output (always appends) */
-%typemap(in, numinputs=0) struct bt_ctf_field_type **BTOUTFT (struct bt_ctf_field_type *temp_ft = NULL) {
+%typemap(in, numinputs=0) struct bt_field_type **BTOUTFT (struct bt_field_type *temp_ft = NULL) {
        $1 = &temp_ft;
 }
 
-%typemap(argout) struct bt_ctf_field_type **BTOUTFT {
+%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_ctf_field_type, 0));
+               $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);
@@ -192,6 +192,43 @@ 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;
+
+       assert(!PyErr_Occurred());
+
+       if (py_notif_types == Py_None) {
+               goto end;
+       }
+
+       assert(PyList_Check(py_notif_types));
+       notification_types = g_new0(enum bt_notification_type,
+               PyList_Size(py_notif_types) + 1);
+       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;
+
+               assert(item);
+               assert(PyLong_Check(item));
+               value = PyLong_AsLongAndOverflow(item, &overflow);
+               assert(overflow == 0);
+               notification_types[i] = value;
+       }
+
+end:
+       return notification_types;
+}
+%}
+
 /* Per-module interface files */
 %include "native_btccpriomap.i"
 %include "native_btclockclass.i"
This page took 0.024258 seconds and 5 git commands to generate.