Add a helper for getting array length: tf_util_get_length.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3925 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
@ -205,3 +205,12 @@ void tf_util_register(JSContext* context)
|
||||
JS_SetPropertyStr(context, global, "setTimeout", JS_NewCFunction(context, _util_setTimeout, "setTimeout", 2));
|
||||
JS_FreeValue(context, global);
|
||||
}
|
||||
|
||||
int tf_util_get_length(JSContext* context, JSValue value)
|
||||
{
|
||||
JSValue length = JS_GetPropertyStr(context, value, "length");
|
||||
int result = 0;
|
||||
JS_ToInt32(context, &result, length);
|
||||
JS_FreeValue(context, length);
|
||||
return result;
|
||||
}
|
||||
|
Reference in New Issue
Block a user