Hi guys,
I've figured out it's a bug, and fixed in latest revision. I think test coverage for new features are increasing, thank you.
I also added many new features recently, but not documented yet, such as generic LIST, DICT collections, garbage collection management for a new referenced usertype, and evaluating sub from C.
A simple LIST, DICT usage eg:
l = list(1, 2, 3)
d = dict("hah", l)
c = clone(d)
print get(get(c, "hah"), 0);
i = iterator(get(c, "hah"))
while move_next(i)
print get(i);
wend
The memory is managed by Reference Counter and GC, so don't worry about leak or reference cycles.
Another example for referenced usertype. Assuming a FOO defined:
static void _str_dtor(struct mb_interpreter_t* s, void* ptr) {
char* str = (char*)ptr;
mb_assert(s);
}
static void* _str_clone(struct mb_interpreter_t* s, void* ptr) {
char* str = (char*)ptr;
mb_assert(s);
return ptr;
}
static void _str_fmt(struct mb_interpreter_t* s, void* ptr, mb_print_func_t f) {
char* str = (char*)ptr;
mb_assert(s);
f(str);
}
static int foo(struct mb_interpreter_t* s, void** l) {
int result = MB_FUNC_OK;
char* str = 0;
mb_value_t ret;
mb_assert(s && l);
mb_check(mb_attempt_open_bracket(s, l));
mb_check(mb_attempt_close_bracket(s, l));
mb_check(mb_make_ref_value(s, str, &ret, _str_dtor, _str_clone, 0, 0, _str_fmt));
mb_check(mb_push_value(s, l, ret));
return result;
}
We could use it as:
l = list()
push(l, foo())
a = clone(l)
l = nil
print pop(a);
A referenced usertype is also benefited by RC and GC.