ref: 4b68d5235174444a8bea0237b0276f88dd62fa61
parent: 5aed7d6e94028464e7fefffef407c28e42082d8b
author: Tor Andersson <tor.andersson@artifex.com>
date: Thu Apr 28 08:48:09 EDT 2016
Add js_iscoercible function.
--- a/jsrun.c
+++ b/jsrun.c
@@ -192,6 +192,7 @@
int js_isstring(js_State *J, int idx) { enum js_Type t = stackidx(J, idx)->type; return t == JS_TSHRSTR || t == JS_TLITSTR || t == JS_TMEMSTR; }
int js_isprimitive(js_State *J, int idx) { return stackidx(J, idx)->type != JS_TOBJECT; }
int js_isobject(js_State *J, int idx) { return stackidx(J, idx)->type == JS_TOBJECT; }
+int js_iscoercible(js_State *J, int idx) { js_Value *v = stackidx(J, idx); return v->type != JS_TUNDEFINED && v->type != JS_TNULL; }
int js_iscallable(js_State *J, int idx)
{
--- a/mujs.h
+++ b/mujs.h
@@ -160,6 +160,7 @@
int js_isobject(js_State *J, int idx);
int js_isarray(js_State *J, int idx);
int js_isregexp(js_State *J, int idx);
+int js_iscoercible(js_State *J, int idx);
int js_iscallable(js_State *J, int idx);
int js_isuserdata(js_State *J, int idx, const char *tag);