lib: Make bt_value_null a const pointer
[babeltrace.git] / bindings / python / bt2 / bt2 / native_bttrace.i
CommitLineData
81447b5b
PP
1/*
2 * The MIT License (MIT)
3 *
4 * Copyright (c) 2016 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
81447b5b 25/* Type */
839d52a5 26struct bt_trace;
81447b5b
PP
27
28/* Functions */
839d52a5
PP
29struct bt_trace *bt_trace_create(void);
30const char *bt_trace_get_name(struct bt_trace *trace_class);
31int bt_trace_set_name(struct bt_trace *trace_class,
81447b5b 32 const char *name);
839d52a5
PP
33enum bt_byte_order bt_trace_get_native_byte_order(
34 struct bt_trace *trace_class);
35int bt_trace_set_native_byte_order(struct bt_trace *trace_class,
36 enum bt_byte_order native_byte_order);
37BTUUID bt_trace_get_uuid(
38 struct bt_trace *trace_class);
39int bt_trace_set_uuid(struct bt_trace *trace_class,
f6a5e476 40 BTUUID uuid);
839d52a5
PP
41int64_t bt_trace_get_environment_field_count(
42 struct bt_trace *trace_class);
81447b5b 43const char *
839d52a5
PP
44bt_trace_get_environment_field_name_by_index(
45 struct bt_trace *trace_class, uint64_t index);
81447b5b 46struct bt_value *
839d52a5 47bt_trace_get_environment_field_value_by_index(struct bt_trace *trace_class,
f6a5e476 48 uint64_t index);
81447b5b 49struct bt_value *
839d52a5
PP
50bt_trace_get_environment_field_value_by_name(
51 struct bt_trace *trace_class, const char *name);
52int bt_trace_set_environment_field(
53 struct bt_trace *trace_class, const char *name,
81447b5b 54 struct bt_value *value);
839d52a5
PP
55struct bt_field_type *bt_trace_get_packet_header_type(
56 struct bt_trace *trace_class);
57int bt_trace_set_packet_header_type(struct bt_trace *trace_class,
58 struct bt_field_type *packet_header_type);
59int64_t bt_trace_get_clock_class_count(
60 struct bt_trace *trace_class);
61struct bt_clock_class *bt_trace_get_clock_class_by_index(
62 struct bt_trace *trace_class, uint64_t index);
63struct bt_clock_class *bt_trace_get_clock_class_by_name(
64 struct bt_trace *trace_class, const char *name);
65int bt_trace_add_clock_class(struct bt_trace *trace_class,
66 struct bt_clock_class *clock_class);
67int64_t bt_trace_get_stream_class_count(
68 struct bt_trace *trace_class);
69struct bt_stream_class *bt_trace_get_stream_class_by_index(
70 struct bt_trace *trace_class, uint64_t index);
71struct bt_stream_class *bt_trace_get_stream_class_by_id(
72 struct bt_trace *trace_class, uint64_t id);
73int bt_trace_add_stream_class(struct bt_trace *trace_class,
74 struct bt_stream_class *stream_class);
75int64_t bt_trace_get_stream_count(struct bt_trace *trace_class);
76struct bt_stream *bt_trace_get_stream_by_index(
77 struct bt_trace *trace_class, uint64_t index);
78int bt_trace_is_static(struct bt_trace *trace_class);
79int bt_trace_set_is_static(struct bt_trace *trace_class);
f6a5e476
PP
80
81/* Helper functions for Python */
82%{
839d52a5 83void trace_is_static_listener(struct bt_trace *trace, void *py_callable)
f6a5e476
PP
84{
85 PyObject *py_trace_ptr = NULL;
86 PyObject *py_res = NULL;
87
88 py_trace_ptr = SWIG_NewPointerObj(SWIG_as_voidptr(trace),
839d52a5 89 SWIGTYPE_p_bt_trace, 0);
f6a5e476
PP
90 if (!py_trace_ptr) {
91 BT_LOGF_STR("Failed to create a SWIG pointer object.");
92 abort();
93 }
94
95 py_res = PyObject_CallFunction(py_callable, "(O)", py_trace_ptr);
8b45963b 96 BT_ASSERT(py_res == Py_None);
f6a5e476
PP
97 Py_DECREF(py_trace_ptr);
98 Py_DECREF(py_res);
99}
100
839d52a5 101void trace_listener_removed(struct bt_trace *trace, void *py_callable)
f6a5e476 102{
8b45963b 103 BT_ASSERT(py_callable);
f6a5e476
PP
104 Py_DECREF(py_callable);
105}
106
450e6770 107static int bt_py3_trace_add_is_static_listener(unsigned long long trace_addr,
f6a5e476
PP
108 PyObject *py_callable)
109{
839d52a5 110 struct bt_trace *trace = (void *) trace_addr;
f6a5e476
PP
111 int ret = 0;
112
8b45963b
PP
113 BT_ASSERT(trace);
114 BT_ASSERT(py_callable);
839d52a5 115 ret = bt_trace_add_is_static_listener(trace,
f6a5e476
PP
116 trace_is_static_listener, trace_listener_removed, py_callable);
117 if (ret >= 0) {
118 Py_INCREF(py_callable);
119 }
120
121 return ret;
122}
123%}
124
450e6770 125int bt_py3_trace_add_is_static_listener(unsigned long long trace_addr,
f6a5e476 126 PyObject *py_callable);
This page took 0.037426 seconds and 4 git commands to generate.