4 * Babeltrace Python module complements, required for Python bindings
6 * Copyright 2012 EfficiOS Inc.
8 * Author: Danny Serres <danny.serres@efficios.com>
10 * Permission is hereby granted, free of charge, to any person obtaining a copy
11 * of this software and associated documentation files (the "Software"), to deal
12 * in the Software without restriction, including without limitation the rights
13 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 * copies of the Software, and to permit persons to whom the Software is
15 * furnished to do so, subject to the following conditions:
17 * The above copyright notice and this permission notice shall be included in
18 * all copies or substantial portions of the Software.
21 #include "python-complements.h"
24 ----------------------------------------------------
27 FILE *_bt_file_open(char *file_path
, char *mode
)
30 if (file_path
!= NULL
)
31 fp
= fopen(file_path
, mode
);
35 void _bt_file_close(FILE *fp
)
42 /* List-related functions
43 ----------------------------------------------------
47 struct bt_definition
**_bt_python_field_listcaller(
48 const struct bt_ctf_event
*ctf_event
,
49 const struct bt_definition
*scope
)
51 struct bt_definition
**list
;
55 ret
= bt_ctf_get_field_list(ctf_event
, scope
,
56 (const struct bt_definition
* const **)&list
, &count
);
58 if (ret
< 0) /* For python to know an error occured */
60 else /* For python to know the end is reached */
66 struct bt_definition
*_bt_python_field_one_from_list(
67 struct bt_definition
**list
, int index
)
73 struct bt_ctf_event_decl
**_bt_python_event_decl_listcaller(
74 int handle_id
, struct bt_context
*ctx
)
76 struct bt_ctf_event_decl
**list
;
80 ret
= bt_ctf_get_event_decl_list(handle_id
, ctx
,
81 (struct bt_ctf_event_decl
* const **)&list
, &count
);
83 if (ret
< 0) /* For python to know an error occured */
85 else /* For python to know the end is reached */
91 struct bt_ctf_event_decl
*_bt_python_decl_one_from_list(
92 struct bt_ctf_event_decl
**list
, int index
)
98 struct bt_ctf_field_decl
**_by_python_field_decl_listcaller(
99 struct bt_ctf_event_decl
*event_decl
,
100 enum bt_ctf_scope scope
)
102 struct bt_ctf_field_decl
**list
;
106 ret
= bt_ctf_get_decl_fields(event_decl
, scope
,
107 (const struct bt_ctf_field_decl
* const **)&list
, &count
);
109 if (ret
< 0) /* For python to know an error occured */
111 else /* For python to know the end is reached */
117 struct bt_ctf_field_decl
*_bt_python_field_decl_one_from_list(
118 struct bt_ctf_field_decl
**list
, int index
)
123 struct definition_array
*_bt_python_get_array_from_def(
124 struct bt_definition
*field
)
126 const struct bt_declaration
*array_decl
;
127 struct definition_array
*array
= NULL
;
133 array_decl
= bt_ctf_get_decl_from_def(field
);
134 if (bt_ctf_field_type(array_decl
) == CTF_TYPE_ARRAY
) {
135 array
= container_of(field
, struct definition_array
, p
);
141 struct definition_sequence
*_bt_python_get_sequence_from_def(
142 struct bt_definition
*field
)
144 if (field
&& bt_ctf_field_type(
145 bt_ctf_get_decl_from_def(field
)) == CTF_TYPE_SEQUENCE
) {
146 return container_of(field
, struct definition_sequence
, p
);
This page took 0.043151 seconds and 6 git commands to generate.