From 1f94fd234223de1cd10f4fa96548a9a138ade015 Mon Sep 17 00:00:00 2001 From: Alexey Odinokov Date: Sun, 9 Jun 2024 22:22:05 -0500 Subject: [PATCH 1/6] alternative approach, though still need a type to have copy of results --- examples/c_print_args/main.c | 191 ++++++++++++++++------------------- 1 file changed, 87 insertions(+), 104 deletions(-) diff --git a/examples/c_print_args/main.c b/examples/c_print_args/main.c index 7ed1640..139d138 100644 --- a/examples/c_print_args/main.c +++ b/examples/c_print_args/main.c @@ -5,13 +5,51 @@ #include "metac/reflect.h" -void vprint_args(metac_tag_map_t * p_tag_map, metac_entry_t *p_entry, va_list args) { +static metac_flag_t handle_sz(va_list *p_args, metac_size_t sz, char * p_buf /*16*/) { + if (p_buf == NULL) { + return 0; + } +#define _handle_sz_(_sz_) \ + do { \ + if (sz == _sz_) { \ + char *x = va_arg(*p_args, char[_sz_]); \ + memcpy(p_buf, x, sz); \ + return 1;\ + } \ + } while(0) + _handle_sz_(1); + _handle_sz_(2); + _handle_sz_(3); + _handle_sz_(4); + _handle_sz_(5); + _handle_sz_(6); + _handle_sz_(7); + _handle_sz_(8); + _handle_sz_(9); + _handle_sz_(10); + _handle_sz_(11); + _handle_sz_(12); + _handle_sz_(13); + _handle_sz_(14); + _handle_sz_(15); + _handle_sz_(16); +#undef _handle_sz_ + return 0; +} + +void vprint_args(metac_tag_map_t * p_tag_map, metac_flag_t has_res, metac_entry_t *p_entry, va_list args) { if (p_entry == NULL || metac_entry_has_paremeter(p_entry) == 0) { return; } + if (has_res == 0) { + printf("calling "); + } + printf("%s(", metac_entry_name(p_entry)); + char buf[16]; + for (int i = 0; i < metac_entry_paremeter_count(p_entry); ++i) { if (i > 0) { printf(", "); @@ -41,55 +79,12 @@ void vprint_args(metac_tag_map_t * p_tag_map, metac_entry_t *p_entry, va_list ar break; } - char buf[32]; - int handled = 0; -#define _handle_sz_(_sz_) \ - do { \ - if (param_byte_sz == _sz_) { \ - char *x = va_arg(args, char[_sz_]); \ - memcpy(buf, x, _sz_); \ - handled = 1; \ - } \ - } while(0) - _handle_sz_(1); - _handle_sz_(2); - _handle_sz_(3); - _handle_sz_(4); - _handle_sz_(5); - _handle_sz_(6); - _handle_sz_(7); - _handle_sz_(8); - _handle_sz_(9); - _handle_sz_(10); - _handle_sz_(11); - _handle_sz_(12); - _handle_sz_(13); - _handle_sz_(14); - _handle_sz_(15); - _handle_sz_(16); - _handle_sz_(17); - _handle_sz_(18); - _handle_sz_(19); - _handle_sz_(20); - _handle_sz_(21); - _handle_sz_(22); - _handle_sz_(23); - _handle_sz_(24); - _handle_sz_(25); - _handle_sz_(26); - _handle_sz_(27); - _handle_sz_(28); - _handle_sz_(29); - _handle_sz_(30); - _handle_sz_(31); - _handle_sz_(32); -#undef _handle_sz_ - + int handled = handle_sz(&args, param_byte_sz, &buf[0]); if (handled == 0) { break; } - metac_value_t * p_val = metac_new_value(p_param_type_entry, &buf); + metac_value_t * p_val = metac_new_value(p_param_type_entry, &buf[0]); if (p_val == NULL) { break; } @@ -110,82 +105,70 @@ void vprint_args(metac_tag_map_t * p_tag_map, metac_entry_t *p_entry, va_list ar free(arg_decl); free(v); + metac_value_delete(p_val); } printf(")"); -} -void print_args(metac_tag_map_t * p_tag_map, metac_entry_t *p_entry, ...) { - va_list args; - va_start(args, p_entry); - vprint_args(p_tag_map, p_entry, args); - va_end(args); - return; -} + do { + if (has_res != 0 && metac_entry_has_result(p_entry)){ + metac_entry_t * p_result_type_entry = metac_entry_result_type(p_entry); + if (p_result_type_entry == NULL) { + break; + } + + metac_size_t result_byte_sz = 0; + if (metac_entry_byte_size(p_result_type_entry, &result_byte_sz) != 0) { + break; + } + + int handled = handle_sz(&args, result_byte_sz, &buf[0]); + if (handled == 0) { + break; + } + + metac_value_t * p_val = metac_new_value(p_result_type_entry, &buf[0]); + if (p_val == NULL) { + break; + } + char * v = metac_value_string_ex(p_val, METAC_WMODE_deep, p_tag_map); + if (v == NULL) { + metac_value_delete(p_val); + break; + } + printf(" returned %s", v); -void print_res(metac_tag_map_t * p_tag_map, metac_entry_t * p_entry, metac_value_t * p_val) { - if (p_entry == NULL || metac_entry_has_result(p_entry) == 0 || p_val == NULL) { - return; - } - metac_entry_t * p_res_type = metac_entry_result_type(p_entry); - if (metac_entry_final_entry(p_res_type, NULL) != metac_entry_final_entry(metac_value_entry(p_val), NULL)) { - printf("provided type doesn't match with type info\n"); - return; - } - char * v = metac_value_string_ex(p_val, METAC_WMODE_deep, p_tag_map); - if (v == NULL) { - return; - } + free(v); - printf("%s() returned %s\n", metac_entry_name(p_entry), v); - free(v); + metac_value_delete(p_val); + } + }while(0); - metac_value_delete(p_val); + printf("\n"); } -void print_args_and_res(metac_tag_map_t * p_tag_map, metac_entry_t * p_entry, metac_value_t * p_val, ...) { - if (p_entry == NULL || metac_entry_has_result(p_entry) == 0 || p_val == NULL) { - return; - } - metac_entry_t * p_res_type = metac_entry_result_type(p_entry); - if (metac_entry_final_entry(p_res_type, NULL) != metac_entry_final_entry(metac_value_entry(p_val), NULL)) { - printf("provided type doesn't match with type info\n"); - return; - } - char * v = metac_value_string_ex(p_val, METAC_WMODE_deep, p_tag_map); - if (v == NULL) { - return; - } - +void print_args(metac_tag_map_t * p_tag_map, metac_flag_t has_res, metac_entry_t *p_entry, ...) { va_list args; - va_start(args, p_val); - vprint_args(p_tag_map, p_entry, args); + va_start(args, p_entry); + vprint_args(p_tag_map, has_res, p_entry, args); va_end(args); - printf(" returned %s\n", v); - free(v); - - metac_value_delete(p_val); + return; } #define METAC_WRAP_FN(_fn_, _args_...) ({ \ - printf("calling "); \ - print_args(NULL, METAC_GSYM_LINK_ENTRY(_fn_), _args_); \ - printf("\n"); \ + print_args(NULL, 0, METAC_GSYM_LINK_ENTRY(_fn_), _args_); \ _fn_(_args_); \ }) #define METAC_WRAP_FN_RES(_type_, _fn_, _args_...) ({ \ - printf("calling "); \ - print_args(NULL, METAC_GSYM_LINK_ENTRY(_fn_), _args_); \ - printf("\n"); \ - WITH_METAC_DECLLOC(loc, _type_ res = _fn_(_args_)); \ - print_args_and_res(NULL, METAC_GSYM_LINK_ENTRY(_fn_), METAC_VALUE_FROM_DECLLOC(loc, res), _args_); \ + print_args(NULL, 0, METAC_GSYM_LINK_ENTRY(_fn_), _args_); \ + _type_ res = _fn_(_args_); \ + print_args(NULL, 1, METAC_GSYM_LINK_ENTRY(_fn_), _args_, res); \ res; \ }) - int test_function1_with_args(int a, short b){ return a + b + 6; } @@ -220,15 +203,15 @@ METAC_GSYM_LINK(test_function4_with_args); int main() { printf("fn returned: %i\n", METAC_WRAP_FN(test_function1_with_args, 10, 22)); - int x = 689; /* could use (int[]){{689, }}, but used this to simplify reading */ - printf("fn returned: %i\n", METAC_WRAP_FN(test_function2_with_args, &x, 22)); + // int x = 689; /* could use (int[]){{689, }}, but used this to simplify reading */ + // printf("fn returned: %i\n", METAC_WRAP_FN(test_function2_with_args, &x, 22)); list_t * p_list = (list_t[]){{.x = 42.42, .p_next = (list_t[]){{ .x = 45.4, .p_next = NULL}}}}; - printf("fn returned: %f\n", METAC_WRAP_FN(test_function3_with_args, p_list)); + // printf("fn returned: %f\n", METAC_WRAP_FN(test_function3_with_args, p_list)); - METAC_WRAP_FN_RES(int, test_function2_with_args, &x, 22); + // METAC_WRAP_FN_RES(int, test_function2_with_args, &x, 22); - METAC_WRAP_FN_RES(double, test_function4_with_args, p_list); + printf("fn returned: %f\n", METAC_WRAP_FN_RES(double, test_function4_with_args, p_list)); return 0; } \ No newline at end of file From 99fb3e46ea7339af28e803619d9e144bdc5eac8b Mon Sep 17 00:00:00 2001 From: Alexey Odinokov Date: Sun, 9 Jun 2024 22:23:13 -0500 Subject: [PATCH 2/6] enables all examples back --- examples/c_print_args/main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/c_print_args/main.c b/examples/c_print_args/main.c index 139d138..dfc02e8 100644 --- a/examples/c_print_args/main.c +++ b/examples/c_print_args/main.c @@ -203,13 +203,13 @@ METAC_GSYM_LINK(test_function4_with_args); int main() { printf("fn returned: %i\n", METAC_WRAP_FN(test_function1_with_args, 10, 22)); - // int x = 689; /* could use (int[]){{689, }}, but used this to simplify reading */ - // printf("fn returned: %i\n", METAC_WRAP_FN(test_function2_with_args, &x, 22)); + int x = 689; /* could use (int[]){{689, }}, but used this to simplify reading */ + printf("fn returned: %i\n", METAC_WRAP_FN(test_function2_with_args, &x, 22)); list_t * p_list = (list_t[]){{.x = 42.42, .p_next = (list_t[]){{ .x = 45.4, .p_next = NULL}}}}; - // printf("fn returned: %f\n", METAC_WRAP_FN(test_function3_with_args, p_list)); + printf("fn returned: %f\n", METAC_WRAP_FN(test_function3_with_args, p_list)); - // METAC_WRAP_FN_RES(int, test_function2_with_args, &x, 22); + METAC_WRAP_FN_RES(int, test_function2_with_args, &x, 22); printf("fn returned: %f\n", METAC_WRAP_FN_RES(double, test_function4_with_args, p_list)); From 489a23b271c00a6f49298e978f8c1d067383cb53 Mon Sep 17 00:00:00 2001 From: Alexey Odinokov Date: Sun, 9 Jun 2024 22:31:51 -0500 Subject: [PATCH 3/6] name of was is updated --- examples/c_print_args/main.c | 61 +++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/examples/c_print_args/main.c b/examples/c_print_args/main.c index dfc02e8..4d3d0a8 100644 --- a/examples/c_print_args/main.c +++ b/examples/c_print_args/main.c @@ -37,12 +37,12 @@ static metac_flag_t handle_sz(va_list *p_args, metac_size_t sz, char * p_buf /*1 return 0; } -void vprint_args(metac_tag_map_t * p_tag_map, metac_flag_t has_res, metac_entry_t *p_entry, va_list args) { +void vprint_args(metac_tag_map_t * p_tag_map, metac_flag_t want_res, metac_entry_t *p_entry, va_list args) { if (p_entry == NULL || metac_entry_has_paremeter(p_entry) == 0) { return; } - if (has_res == 0) { + if (want_res == 0) { printf("calling "); } @@ -112,36 +112,39 @@ void vprint_args(metac_tag_map_t * p_tag_map, metac_flag_t has_res, metac_entry_ printf(")"); do { - if (has_res != 0 && metac_entry_has_result(p_entry)){ - metac_entry_t * p_result_type_entry = metac_entry_result_type(p_entry); - if (p_result_type_entry == NULL) { - break; - } - - metac_size_t result_byte_sz = 0; - if (metac_entry_byte_size(p_result_type_entry, &result_byte_sz) != 0) { - break; - } - - int handled = handle_sz(&args, result_byte_sz, &buf[0]); - if (handled == 0) { - break; - } + if (want_res != 0) { + printf(" returned"); + if (metac_entry_has_result(p_entry)!=0) { + metac_entry_t * p_result_type_entry = metac_entry_result_type(p_entry); + if (p_result_type_entry == NULL) { + break; + } + + metac_size_t result_byte_sz = 0; + if (metac_entry_byte_size(p_result_type_entry, &result_byte_sz) != 0) { + break; + } + + int handled = handle_sz(&args, result_byte_sz, &buf[0]); + if (handled == 0) { + break; + } + + metac_value_t * p_val = metac_new_value(p_result_type_entry, &buf[0]); + if (p_val == NULL) { + break; + } + char * v = metac_value_string_ex(p_val, METAC_WMODE_deep, p_tag_map); + if (v == NULL) { + metac_value_delete(p_val); + break; + } + printf(" %s", v); + + free(v); - metac_value_t * p_val = metac_new_value(p_result_type_entry, &buf[0]); - if (p_val == NULL) { - break; - } - char * v = metac_value_string_ex(p_val, METAC_WMODE_deep, p_tag_map); - if (v == NULL) { metac_value_delete(p_val); - break; } - printf(" returned %s", v); - - free(v); - - metac_value_delete(p_val); } }while(0); From 4ded31e2afaa763a05cc0831a7075268d8dc03ca Mon Sep 17 00:00:00 2001 From: Alexey Odinokov Date: Sun, 9 Jun 2024 22:51:37 -0500 Subject: [PATCH 4/6] updated example with param updates --- examples/c_print_args/main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/c_print_args/main.c b/examples/c_print_args/main.c index 4d3d0a8..3c90228 100644 --- a/examples/c_print_args/main.c +++ b/examples/c_print_args/main.c @@ -191,6 +191,8 @@ double test_function3_with_args(list_t *p_list) { double sum = 0.0; while(p_list != NULL) { sum += p_list->x; + p_list->x += 1; + p_list = p_list->p_next; } return sum; From 98c046cbd816921c9e10568d4053fe99e32557be Mon Sep 17 00:00:00 2001 From: Alexey Odinokov Date: Mon, 10 Jun 2024 10:14:40 -0500 Subject: [PATCH 5/6] the option with enabled or disabled debug --- examples/c_print_args/main.c | 48 +++++++++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 11 deletions(-) diff --git a/examples/c_print_args/main.c b/examples/c_print_args/main.c index 3c90228..9e12e67 100644 --- a/examples/c_print_args/main.c +++ b/examples/c_print_args/main.c @@ -159,11 +159,11 @@ void print_args(metac_tag_map_t * p_tag_map, metac_flag_t has_res, metac_entry_t return; } -#define METAC_WRAP_FN(_fn_, _args_...) ({ \ +#define METAC_WRAP_FN_NORES(_fn_, _args_...) { \ print_args(NULL, 0, METAC_GSYM_LINK_ENTRY(_fn_), _args_); \ _fn_(_args_); \ - }) - + print_args(NULL, 1, METAC_GSYM_LINK_ENTRY(_fn_), _args_); \ + } #define METAC_WRAP_FN_RES(_type_, _fn_, _args_...) ({ \ print_args(NULL, 0, METAC_GSYM_LINK_ENTRY(_fn_), _args_); \ _type_ res = _fn_(_args_); \ @@ -171,16 +171,23 @@ void print_args(metac_tag_map_t * p_tag_map, metac_flag_t has_res, metac_entry_t res; \ }) +#define DEBUG int test_function1_with_args(int a, short b){ return a + b + 6; } METAC_GSYM_LINK(test_function1_with_args); +#ifdef DEBUG +#define test_function1_with_args(args...) METAC_WRAP_FN_RES(int, test_function1_with_args, args) +#endif int test_function2_with_args(int *a, short b){ return *a + b + 999; } METAC_GSYM_LINK(test_function2_with_args); +#ifdef DEBUG +#define test_function2_with_args(args...) METAC_WRAP_FN_RES(int, test_function2_with_args, args) +#endif typedef struct list_s{ double x; @@ -196,27 +203,46 @@ double test_function3_with_args(list_t *p_list) { p_list = p_list->p_next; } return sum; - } - METAC_GSYM_LINK(test_function3_with_args); +} +METAC_GSYM_LINK(test_function3_with_args); +#ifdef DEBUG +#define test_function3_with_args(args...) METAC_WRAP_FN_RES(double, test_function3_with_args, args) +#endif double test_function4_with_args(list_t *p_list) { - return METAC_WRAP_FN_RES(double, test_function3_with_args, p_list) - 1000; + return test_function3_with_args(p_list) - 1000; } METAC_GSYM_LINK(test_function4_with_args); +#ifdef DEBUG +#define test_function4_with_args(args...) METAC_WRAP_FN_RES(double, test_function4_with_args, args) +#endif +void test_function5_no_res(list_t *p_list) { + while(p_list != NULL) { + p_list->x -= 1; + + p_list = p_list->p_next; + } +} +METAC_GSYM_LINK(test_function5_no_res); +#ifdef DEBUG +#define test_function5_no_res(args...) METAC_WRAP_FN_NORES(test_function5_no_res, args); +#endif int main() { - printf("fn returned: %i\n", METAC_WRAP_FN(test_function1_with_args, 10, 22)); + printf("fn returned: %i\n", test_function1_with_args(10, 22)); int x = 689; /* could use (int[]){{689, }}, but used this to simplify reading */ - printf("fn returned: %i\n", METAC_WRAP_FN(test_function2_with_args, &x, 22)); + printf("fn returned: %i\n", test_function2_with_args(&x, 22)); list_t * p_list = (list_t[]){{.x = 42.42, .p_next = (list_t[]){{ .x = 45.4, .p_next = NULL}}}}; - printf("fn returned: %f\n", METAC_WRAP_FN(test_function3_with_args, p_list)); + printf("fn returned: %f\n", test_function3_with_args(p_list)); - METAC_WRAP_FN_RES(int, test_function2_with_args, &x, 22); + test_function2_with_args(&x, 22); - printf("fn returned: %f\n", METAC_WRAP_FN_RES(double, test_function4_with_args, p_list)); + printf("fn returned: %f\n", test_function4_with_args(p_list)); + test_function5_no_res(p_list); + return 0; } \ No newline at end of file From be4366c7997111735313f1e6bd7ff2038bf08955 Mon Sep 17 00:00:00 2001 From: Alexey Odinokov Date: Mon, 17 Jun 2024 20:47:18 -0500 Subject: [PATCH 6/6] reverted result to the declloc approach --- examples/c_print_args/main.c | 74 ++++++++++++----------------------- include/metac/reflect/entry.h | 6 +-- src/entry.c | 6 +-- 3 files changed, 32 insertions(+), 54 deletions(-) diff --git a/examples/c_print_args/main.c b/examples/c_print_args/main.c index 9e12e67..9007149 100644 --- a/examples/c_print_args/main.c +++ b/examples/c_print_args/main.c @@ -5,7 +5,7 @@ #include "metac/reflect.h" -static metac_flag_t handle_sz(va_list *p_args, metac_size_t sz, char * p_buf /*16*/) { +static metac_flag_t handle_sz(va_list *p_args, metac_size_t sz, char * p_buf /*max 16b */) { if (p_buf == NULL) { return 0; } @@ -14,7 +14,7 @@ static metac_flag_t handle_sz(va_list *p_args, metac_size_t sz, char * p_buf /*1 if (sz == _sz_) { \ char *x = va_arg(*p_args, char[_sz_]); \ memcpy(p_buf, x, sz); \ - return 1;\ + return 1; \ } \ } while(0) _handle_sz_(1); @@ -37,12 +37,12 @@ static metac_flag_t handle_sz(va_list *p_args, metac_size_t sz, char * p_buf /*1 return 0; } -void vprint_args(metac_tag_map_t * p_tag_map, metac_flag_t want_res, metac_entry_t *p_entry, va_list args) { - if (p_entry == NULL || metac_entry_has_paremeter(p_entry) == 0) { +void vprint_args(metac_tag_map_t * p_tag_map, metac_flag_t calling, metac_entry_t *p_entry, metac_value_t * p_res, va_list args) { + if (p_entry == NULL || metac_entry_has_paremeters(p_entry) == 0) { return; } - if (want_res == 0) { + if (calling == 1) { printf("calling "); } @@ -50,7 +50,7 @@ void vprint_args(metac_tag_map_t * p_tag_map, metac_flag_t want_res, metac_entry char buf[16]; - for (int i = 0; i < metac_entry_paremeter_count(p_entry); ++i) { + for (int i = 0; i < metac_entry_paremeters_count(p_entry); ++i) { if (i > 0) { printf(", "); } @@ -111,63 +111,41 @@ void vprint_args(metac_tag_map_t * p_tag_map, metac_flag_t want_res, metac_entry } printf(")"); - do { - if (want_res != 0) { - printf(" returned"); - if (metac_entry_has_result(p_entry)!=0) { - metac_entry_t * p_result_type_entry = metac_entry_result_type(p_entry); - if (p_result_type_entry == NULL) { - break; - } - - metac_size_t result_byte_sz = 0; - if (metac_entry_byte_size(p_result_type_entry, &result_byte_sz) != 0) { - break; - } - - int handled = handle_sz(&args, result_byte_sz, &buf[0]); - if (handled == 0) { - break; - } - - metac_value_t * p_val = metac_new_value(p_result_type_entry, &buf[0]); - if (p_val == NULL) { - break; - } - char * v = metac_value_string_ex(p_val, METAC_WMODE_deep, p_tag_map); - if (v == NULL) { - metac_value_delete(p_val); - break; - } - printf(" %s", v); - - free(v); - - metac_value_delete(p_val); + if (calling == 0) { + printf(" returned"); + if (p_res != NULL) { + char * v = metac_value_string_ex(p_res, METAC_WMODE_deep, p_tag_map); + if (v == NULL) { + return; } + printf(" %s", v); + + free(v); + + metac_value_delete(p_res); } - }while(0); + } printf("\n"); } -void print_args(metac_tag_map_t * p_tag_map, metac_flag_t has_res, metac_entry_t *p_entry, ...) { +void print_args(metac_tag_map_t * p_tag_map, metac_flag_t calling, metac_entry_t *p_entry, metac_value_t * p_res, ...) { va_list args; - va_start(args, p_entry); - vprint_args(p_tag_map, has_res, p_entry, args); + va_start(args, p_res); + vprint_args(p_tag_map, calling, p_entry, p_res, args); va_end(args); return; } #define METAC_WRAP_FN_NORES(_fn_, _args_...) { \ - print_args(NULL, 0, METAC_GSYM_LINK_ENTRY(_fn_), _args_); \ + print_args(NULL, 1, METAC_GSYM_LINK_ENTRY(_fn_), NULL, _args_); \ _fn_(_args_); \ - print_args(NULL, 1, METAC_GSYM_LINK_ENTRY(_fn_), _args_); \ + print_args(NULL, 0, METAC_GSYM_LINK_ENTRY(_fn_), NULL, _args_); \ } #define METAC_WRAP_FN_RES(_type_, _fn_, _args_...) ({ \ - print_args(NULL, 0, METAC_GSYM_LINK_ENTRY(_fn_), _args_); \ - _type_ res = _fn_(_args_); \ - print_args(NULL, 1, METAC_GSYM_LINK_ENTRY(_fn_), _args_, res); \ + print_args(NULL, 1, METAC_GSYM_LINK_ENTRY(_fn_), NULL, _args_); \ + WITH_METAC_DECLLOC(loc, _type_ res = _fn_(_args_)); \ + print_args(NULL, 0, METAC_GSYM_LINK_ENTRY(_fn_), METAC_VALUE_FROM_DECLLOC(loc, res), _args_); \ res; \ }) diff --git a/include/metac/reflect/entry.h b/include/metac/reflect/entry.h index 09a5123..92d281b 100644 --- a/include/metac/reflect/entry.h +++ b/include/metac/reflect/entry.h @@ -226,13 +226,13 @@ metac_entry_t * metac_entry_by_member_ids(metac_entry_t * p_entry, metac_flag_t /** * @brief check if final entry is function (METAC_KND_subroutine) */ -metac_flag_t metac_entry_has_paremeter(metac_entry_t * p_entry); +metac_flag_t metac_entry_has_paremeters(metac_entry_t * p_entry); /** * @brief return number of parameters. Negative value is errno */ -metac_num_t metac_entry_paremeter_count(metac_entry_t *p_entry); +metac_num_t metac_entry_paremeters_count(metac_entry_t *p_entry); /** - * @brief returns pointer to the parameter entry (kind==METAC_KND_member) by param_id which is in range [0; metac_entry_paremeter_count -1] + * @brief returns pointer to the parameter entry (kind==METAC_KND_member) by param_id which is in range [0; metac_entry_paremeters_count -1] */ metac_entry_t * metac_entry_by_paremeter_id(metac_entry_t *p_entry, metac_num_t param_id); /** diff --git a/src/entry.c b/src/entry.c index f47b98b..768013c 100644 --- a/src/entry.c +++ b/src/entry.c @@ -476,11 +476,11 @@ static metac_entry_t * _entry_with_paremeter_info(metac_entry_t *p_entry) { return p_final_entry; } -metac_flag_t metac_entry_has_paremeter(metac_entry_t * p_entry) { +metac_flag_t metac_entry_has_paremeters(metac_entry_t * p_entry) { return _entry_with_paremeter_info(p_entry) != NULL; } -metac_num_t metac_entry_paremeter_count(metac_entry_t *p_entry) { +metac_num_t metac_entry_paremeters_count(metac_entry_t *p_entry) { metac_entry_t * p_final_entry = _entry_with_paremeter_info(p_entry); _check_(p_final_entry == NULL, -(EINVAL)); return p_final_entry->subprogram_info.parameters_count; @@ -489,7 +489,7 @@ metac_num_t metac_entry_paremeter_count(metac_entry_t *p_entry) { metac_num_t metac_entry_paremeter_name_to_id(metac_entry_t *p_entry, metac_name_t name) { metac_entry_t * p_final_entry = _entry_with_paremeter_info(p_entry); _check_(p_final_entry == NULL, -(EINVAL)); - metac_num_t par_count = metac_entry_paremeter_count(p_entry); + metac_num_t par_count = metac_entry_paremeters_count(p_entry); _check_(par_count < 0, -(EFAULT)); for (metac_num_t i = 0; i < par_count; ++i) { if (p_final_entry->subprogram_info.parameters[i].name != NULL &&