Commit | Line | Data |
---|---|---|
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 */ |
50842bdc | 26 | struct bt_trace; |
81447b5b PP |
27 | |
28 | /* Functions */ | |
50842bdc PP |
29 | struct bt_trace *bt_trace_create(void); |
30 | const char *bt_trace_get_name(struct bt_trace *trace_class); | |
31 | int bt_trace_set_name(struct bt_trace *trace_class, | |
81447b5b | 32 | const char *name); |
50842bdc PP |
33 | enum bt_byte_order bt_trace_get_native_byte_order( |
34 | struct bt_trace *trace_class); | |
35 | int bt_trace_set_native_byte_order(struct bt_trace *trace_class, | |
36 | enum bt_byte_order native_byte_order); | |
37 | BTUUID bt_trace_get_uuid( | |
38 | struct bt_trace *trace_class); | |
39 | int bt_trace_set_uuid(struct bt_trace *trace_class, | |
811644b8 | 40 | BTUUID uuid); |
50842bdc PP |
41 | int64_t bt_trace_get_environment_field_count( |
42 | struct bt_trace *trace_class); | |
81447b5b | 43 | const char * |
50842bdc PP |
44 | bt_trace_get_environment_field_name_by_index( |
45 | struct bt_trace *trace_class, uint64_t index); | |
81447b5b | 46 | struct bt_value * |
50842bdc | 47 | bt_trace_get_environment_field_value_by_index(struct bt_trace *trace_class, |
811644b8 | 48 | uint64_t index); |
81447b5b | 49 | struct bt_value * |
50842bdc PP |
50 | bt_trace_get_environment_field_value_by_name( |
51 | struct bt_trace *trace_class, const char *name); | |
52 | int bt_trace_set_environment_field( | |
53 | struct bt_trace *trace_class, const char *name, | |
81447b5b | 54 | struct bt_value *value); |
50842bdc PP |
55 | struct bt_field_type *bt_trace_get_packet_header_type( |
56 | struct bt_trace *trace_class); | |
57 | int bt_trace_set_packet_header_type(struct bt_trace *trace_class, | |
58 | struct bt_field_type *packet_header_type); | |
59 | int64_t bt_trace_get_clock_class_count( | |
60 | struct bt_trace *trace_class); | |
61 | struct bt_clock_class *bt_trace_get_clock_class_by_index( | |
62 | struct bt_trace *trace_class, uint64_t index); | |
63 | struct bt_clock_class *bt_trace_get_clock_class_by_name( | |
64 | struct bt_trace *trace_class, const char *name); | |
65 | int bt_trace_add_clock_class(struct bt_trace *trace_class, | |
66 | struct bt_clock_class *clock_class); | |
67 | int64_t bt_trace_get_stream_class_count( | |
68 | struct bt_trace *trace_class); | |
69 | struct bt_stream_class *bt_trace_get_stream_class_by_index( | |
70 | struct bt_trace *trace_class, uint64_t index); | |
71 | struct bt_stream_class *bt_trace_get_stream_class_by_id( | |
72 | struct bt_trace *trace_class, uint64_t id); | |
73 | int bt_trace_add_stream_class(struct bt_trace *trace_class, | |
74 | struct bt_stream_class *stream_class); | |
75 | int64_t bt_trace_get_stream_count(struct bt_trace *trace_class); | |
76 | struct bt_stream *bt_trace_get_stream_by_index( | |
77 | struct bt_trace *trace_class, uint64_t index); | |
78 | int bt_trace_is_static(struct bt_trace *trace_class); | |
79 | int bt_trace_set_is_static(struct bt_trace *trace_class); | |
811644b8 PP |
80 | |
81 | /* Helper functions for Python */ | |
82 | %{ | |
50842bdc | 83 | void trace_is_static_listener(struct bt_trace *trace, void *py_callable) |
811644b8 PP |
84 | { |
85 | PyObject *py_trace_ptr = NULL; | |
86 | PyObject *py_res = NULL; | |
87 | ||
88 | py_trace_ptr = SWIG_NewPointerObj(SWIG_as_voidptr(trace), | |
50842bdc | 89 | SWIGTYPE_p_bt_trace, 0); |
811644b8 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); | |
96 | assert(py_res == Py_None); | |
97 | Py_DECREF(py_trace_ptr); | |
98 | Py_DECREF(py_res); | |
99 | } | |
100 | ||
50842bdc | 101 | void trace_listener_removed(struct bt_trace *trace, void *py_callable) |
811644b8 PP |
102 | { |
103 | assert(py_callable); | |
104 | Py_DECREF(py_callable); | |
105 | } | |
106 | ||
107 | static int bt_py3_trace_add_is_staitc_listener(unsigned long long trace_addr, | |
108 | PyObject *py_callable) | |
109 | { | |
50842bdc | 110 | struct bt_trace *trace = (void *) trace_addr; |
811644b8 PP |
111 | int ret = 0; |
112 | ||
113 | assert(trace); | |
114 | assert(py_callable); | |
50842bdc | 115 | ret = bt_trace_add_is_static_listener(trace, |
811644b8 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 | ||
125 | int bt_py3_trace_add_is_staitc_listener(unsigned long long trace_addr, | |
126 | PyObject *py_callable); |