Commit 8060478b authored by take_cheeze's avatar take_cheeze

add 'd' format specifier to get data pointer directly from mrb_get_args

parent d345134f
......@@ -14,6 +14,7 @@
#include "mruby/string.h"
#include "mruby/variable.h"
#include "mruby/error.h"
#include "mruby/data.h"
KHASH_DEFINE(mt, mrb_sym, struct RProc*, 1, kh_int_hash_func, kh_int_hash_equal)
......@@ -406,6 +407,7 @@ to_hash(mrb_state *mrb, mrb_value val)
i: Integer [mrb_int]
b: Boolean [mrb_bool]
n: Symbol [mrb_sym]
d: Data [void*,mrb_data_type const] 2nd argument will be used to check data type so it won't be modified
&: Block [mrb_value]
*: rest argument [mrb_value*,int] Receive the rest of the arguments as an array.
|: optional Next argument of '|' and later are optional.
......@@ -658,6 +660,19 @@ mrb_get_args(mrb_state *mrb, const char *format, ...)
}
}
break;
case 'd':
{
void** datap;
struct mrb_data_type const* type;
datap = va_arg(ap, void**);
type = va_arg(ap, struct mrb_data_type const*);
if (i < argc) {
*datap = mrb_data_get_ptr(mrb, *sp++, type);
++i;
}
}
break;
case '&':
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment