sgs_LoadArgsExt(VA) [function]
SGSBOOL sgs_LoadArgsExt( sgs_Context* C, int from, const char* cmd, ... )
SGSBOOL sgs_LoadArgsExtVA( sgs_Context* C, int from, const char* cmd, va_list* args )
Parse the stack items and retrieve their data according to cmd, starting from item from.
- For anything function requires, pass the value; for anything it returns - the pointer to the value.
cmd is a string consisting of one-character commands.
- The commands are grouped into two kinds: control commands and parsing commands.
- Function returns whether all required arguments have been parsed successfully;
- thus, if function returns < 1, state of outputs is somewhat unknown unless filled with defaults;
- it is guaranteed that all arguments will be parsed from first (specified) forward, not in any other way;
null values in optional arguments are skipped (this may not apply to custom checking functions).
control commands
? -- only check, do not write the result and do not require a pointer to write the data to
! -- enable strict parsing for the next item (requires exactly the type specified
-,+ -- enable (-) or disable (+) treating integers as signed (default = true)
| -- mark the point where required arguments end and optional arguments begin
# -- do range checking on integer arguments (min/max of the required types)
^ -- clamp the argument to the range of the required type
~ -- ignore ranges and chop out-of-range integers (default)
< -- move argument pointer 1 item back (cannot move it before 0)
> -- move argument pointer 1 item forward
@ -- specify that this is a method (argument 0 = 'this'; shifts argument indices on error printing by -1)
. -- specify the end of argument list (how many arguments are expected)
parsing commands
n -- check for null (returns SGSBOOL = 1, always strict)
b -- check for bool (returns sgs_Bool)
c -- check for int (returns int8_t or uint8_t, depending on sign settings, may check ranges)
w -- check for int (returns int16_t or uint16_t, depending on sign settings, may check ranges)
l -- check for int (returns int32_t or uint32_t, depending on sign settings, may check ranges)
q -- check for int (returns int64_t or uint64_t, depending on sign settings, may check ranges)
i -- check for int (returns sgs_Int, may check ranges)
I -- check for int (returns int or unsigned int, depending on sign settings, may check ranges)
f -- check for real (returns float)
d -- check for real (returns double)
r -- check for real (returns sgs_Real)
s -- check for string (returns char*)
m -- check for string (returns char* string and sgs_SizeVal size)
p -- check for func/cfunc/object with CALL (callables) (returns SGSBOOL = 1)
y -- check for thread (returns sgs_Context*)
a -- check for array (returns sgs_SizeVal size, use -1 as starting value to check optional arguments)
t -- check for dict (returns sgs_SizeVal size, use -1 as starting value to check optional arguments)
h -- check for map (returns sgs_SizeVal size, use -1 as starting value to check optional arguments)
o -- check for specific object (requires sgs_ObjInterface* interface, returns <type>* data - the data pointer)
* -- check for any object (returns sgs_ObjInterface* interface)
& -- check for pointer (returns void* data - the pointer)
v -- check for any (non-null if strict, returns sgs_Variable data)
x -- call a custom checking function (requires sgs_ArgCheckFunc, everything else depends on function)