X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=bindings%2Fpython%2Fpython-complements.c;h=6b47ff9bf9aaaaac16213b00e9cb854c9752b89f;hp=b6f1d5a88891a98e0081409b3f6d1bfaec956fbf;hb=a9049b491173a73f8544a16a95ab4e5375f28466;hpb=024e61817685a20caceb4e3ef3bdc019a7af6b6e diff --git a/bindings/python/python-complements.c b/bindings/python/python-complements.c index b6f1d5a8..6b47ff9b 100644 --- a/bindings/python/python-complements.c +++ b/bindings/python/python-complements.c @@ -21,6 +21,10 @@ #include "python-complements.h" #include #include +#include +#include +#include +#include /* FILE functions ---------------------------------------------------- @@ -135,6 +139,68 @@ end: return array; } +struct bt_declaration *_bt_python_get_array_element_declaration( + struct bt_declaration *field) +{ + struct declaration_array *array_decl; + struct bt_declaration *ret = NULL; + + if (!field) { + goto end; + } + + array_decl = container_of(field, struct declaration_array, p); + ret = array_decl->elem; +end: + return ret; +} + +struct bt_declaration *_bt_python_get_sequence_element_declaration( + struct bt_declaration *field) +{ + struct declaration_sequence *sequence_decl; + struct bt_declaration *ret = NULL; + + if (!field) { + goto end; + } + + sequence_decl = container_of(field, struct declaration_sequence, p); + ret = sequence_decl->elem; +end: + return ret; +} + +const char *_bt_python_get_array_string(struct bt_definition *field) +{ + struct definition_array *array; + const char *ret = NULL; + + if (!field) { + goto end; + } + + array = container_of(field, struct definition_array, p); + ret = array->string->str; +end: + return ret; +} + +const char *_bt_python_get_sequence_string(struct bt_definition *field) +{ + struct definition_sequence *sequence; + const char *ret = NULL; + + if (!field) { + goto end; + } + + sequence = container_of(field, struct definition_sequence, p); + ret = sequence->string->str; +end: + return ret; +} + struct definition_sequence *_bt_python_get_sequence_from_def( struct bt_definition *field) { @@ -174,3 +240,33 @@ enum ctf_type_id _bt_python_get_field_type(const struct bt_ctf_field *field) end: return type_id; } + +/* + * Python 3.5 changes the StopIteration exception clearing behaviour which + * erroneously marks swig clean-up function as having failed. This explicit + * allocation function is intended as a work-around so SWIG doesn't manage + * the lifetime of a "temporary" object by itself. + */ +struct bt_iter_pos *_bt_python_create_iter_pos(void) +{ + return g_new0(struct bt_iter_pos, 1); +} + +struct bt_ctf_iter *_bt_python_ctf_iter_create_intersect( + struct bt_context *ctx, + struct bt_iter_pos *inter_begin_pos, + struct bt_iter_pos *inter_end_pos) +{ + return bt_ctf_iter_create_intersect(ctx, &inter_begin_pos, + &inter_end_pos); +} + +int _bt_python_has_intersection(struct bt_context *ctx) +{ + int ret; + uint64_t begin = 0, end = ULLONG_MAX; + + ret = ctf_find_packets_intersection(ctx, &begin, &end); + + return ret == 0 ? 1 : 0; +}