Add js_isbooleanobject and js_isdateobject functions.

This commit is contained in:
Tor Andersson
2022-05-25 16:33:53 +02:00
parent f5b3c703e1
commit 88f6d86b6c
2 changed files with 12 additions and 0 deletions

10
json.c
View File

@@ -15,6 +15,16 @@ int js_isstringobject(js_State *J, int idx)
return js_isobject(J, idx) && js_toobject(J, idx)->type == JS_CSTRING; return js_isobject(J, idx) && js_toobject(J, idx)->type == JS_CSTRING;
} }
int js_isbooleanobject(js_State *J, int idx)
{
return js_isobject(J, idx) && js_toobject(J, idx)->type == JS_CBOOLEAN;
}
int js_isdateobject(js_State *J, int idx)
{
return js_isobject(J, idx) && js_toobject(J, idx)->type == JS_CDATE;
}
static void jsonnext(js_State *J) static void jsonnext(js_State *J)
{ {
J->lookahead = jsY_lexjson(J); J->lookahead = jsY_lexjson(J);

2
mujs.h
View File

@@ -198,6 +198,8 @@ int js_isuserdata(js_State *J, int idx, const char *tag);
int js_iserror(js_State *J, int idx); int js_iserror(js_State *J, int idx);
int js_isnumberobject(js_State *J, int idx); int js_isnumberobject(js_State *J, int idx);
int js_isstringobject(js_State *J, int idx); int js_isstringobject(js_State *J, int idx);
int js_isbooleanobject(js_State *J, int idx);
int js_isdateobject(js_State *J, int idx);
int js_toboolean(js_State *J, int idx); int js_toboolean(js_State *J, int idx);
double js_tonumber(js_State *J, int idx); double js_tonumber(js_State *J, int idx);