X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=bindings%2Fpython%2Fpython-complements.c;h=5c65fb0f0e37f2044a0518faf95d798fff364ffa;hb=24d5c942785816bc3c6ad926dc1272510c38948d;hp=a4ee37e23262f4c014527061a4016d0ea2d059f0;hpb=92c6a024cd3e81293bd39fd2b322e12ce57ea502;p=babeltrace.git diff --git a/bindings/python/python-complements.c b/bindings/python/python-complements.c index a4ee37e2..5c65fb0f 100644 --- a/bindings/python/python-complements.c +++ b/bindings/python/python-complements.c @@ -44,46 +44,43 @@ void _bt_file_close(FILE *fp) */ /* ctf-field-list */ -struct definition **_bt_python_field_listcaller( +struct bt_definition **_bt_python_field_listcaller( const struct bt_ctf_event *ctf_event, - const struct definition *scope) + const struct bt_definition *scope, + unsigned int *len) { - struct definition **list; - unsigned int count; + struct bt_definition **list; int ret; ret = bt_ctf_get_field_list(ctf_event, scope, - (const struct definition * const **)&list, &count); + (const struct bt_definition * const **)&list, len); if (ret < 0) /* For python to know an error occured */ list = NULL; - else /* For python to know the end is reached */ - list[count] = NULL; return list; } -struct definition *_bt_python_field_one_from_list( - struct definition **list, int index) +struct bt_definition *_bt_python_field_one_from_list( + struct bt_definition **list, int index) { return list[index]; } /* event_decl_list */ struct bt_ctf_event_decl **_bt_python_event_decl_listcaller( - int handle_id, struct bt_context *ctx) + int handle_id, + struct bt_context *ctx, + unsigned int *len) { struct bt_ctf_event_decl **list; - unsigned int count; int ret; ret = bt_ctf_get_event_decl_list(handle_id, ctx, - (struct bt_ctf_event_decl * const **)&list, &count); + (struct bt_ctf_event_decl * const **)&list, len); if (ret < 0) /* For python to know an error occured */ list = NULL; - else /* For python to know the end is reached */ - list[count] = NULL; return list; } @@ -97,19 +94,17 @@ struct bt_ctf_event_decl *_bt_python_decl_one_from_list( /* decl_fields */ struct bt_ctf_field_decl **_by_python_field_decl_listcaller( struct bt_ctf_event_decl *event_decl, - enum bt_ctf_scope scope) + enum bt_ctf_scope scope, + unsigned int *len) { struct bt_ctf_field_decl **list; - unsigned int count; int ret; ret = bt_ctf_get_decl_fields(event_decl, scope, - (const struct bt_ctf_field_decl * const **)&list, &count); + (const struct bt_ctf_field_decl * const **)&list, len); if (ret < 0) /* For python to know an error occured */ list = NULL; - else /* For python to know the end is reached */ - list[count] = NULL; return list; } @@ -119,3 +114,32 @@ struct bt_ctf_field_decl *_bt_python_field_decl_one_from_list( { return list[index]; } + +struct definition_array *_bt_python_get_array_from_def( + struct bt_definition *field) +{ + const struct bt_declaration *array_decl; + struct definition_array *array = NULL; + + if (!field) { + goto end; + } + + array_decl = bt_ctf_get_decl_from_def(field); + if (bt_ctf_field_type(array_decl) == CTF_TYPE_ARRAY) { + array = container_of(field, struct definition_array, p); + } +end: + return array; +} + +struct definition_sequence *_bt_python_get_sequence_from_def( + struct bt_definition *field) +{ + if (field && bt_ctf_field_type( + bt_ctf_get_decl_from_def(field)) == CTF_TYPE_SEQUENCE) { + return container_of(field, struct definition_sequence, p); + } + + return NULL; +}