-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.c
31 lines (28 loc) · 1.06 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "metac/reflect.h"
#include <stdlib.h> /*free*/
#define METAC_WRAP_FN_RES(_tag_map_, _fn_, _args_...) ({ \
metac_parameter_storage_t * p_param_storage = metac_new_parameter_storage(); \
if (p_param_storage != NULL) { \
p_val = metac_value_parameter_wrap(metac_new_value(METAC_GSYM_LINK_ENTRY(_fn_), p_param_storage), _tag_map_, _args_); \
} \
_fn_(_args_);\
})
int test_function1_with_args(int a, short b){
return a + b + 6;
}
METAC_GSYM_LINK(test_function1_with_args);
int main() {
metac_value_t * p_val = NULL;
printf("fn returned: %i\n", METAC_WRAP_FN_RES(NULL, test_function1_with_args, 10, 22));
if (p_val != NULL) {
char * s = metac_value_string_ex(p_val, METAC_WMODE_deep, NULL);
if (s != NULL) {
printf("captured %s\n", s);
free(s);
}
metac_parameter_storage_t * p_param_storage = (metac_parameter_storage_t *)metac_value_addr(p_val);
metac_parameter_storage_delete(p_param_storage);
metac_value_delete(p_val);
}
return 0;
}