mirror of
https://github.com/ccxvii/mujs.git
synced 2026-09-24 01:03:35 +08:00
The typeof operator should return 'function' for callable objects.
This commit is contained in:
@@ -147,13 +147,17 @@ int js_isuserdata(js_State *J, const char *tag, int idx)
|
||||
|
||||
static const char *js_typeof(js_State *J, int idx)
|
||||
{
|
||||
switch (stackidx(J, idx)->type) {
|
||||
const js_Value *v = stackidx(J, idx);
|
||||
switch (v->type) {
|
||||
case JS_TUNDEFINED: return "undefined";
|
||||
case JS_TNULL: return "object";
|
||||
case JS_TBOOLEAN: return "boolean";
|
||||
case JS_TNUMBER: return "number";
|
||||
case JS_TSTRING: return "string";
|
||||
case JS_TOBJECT: return "object";
|
||||
case JS_TOBJECT:
|
||||
if (v->u.object->type == JS_CFUNCTION || v->u.object->type == JS_CCFUNCTION)
|
||||
return "function";
|
||||
return "object";
|
||||
}
|
||||
return "object";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user