diff --git a/jsarray.c b/jsarray.c index 3535f8e..dcd4858 100644 --- a/jsarray.c +++ b/jsarray.c @@ -687,16 +687,16 @@ void jsB_initarray(js_State *J) js_pushobject(J, J->Array_prototype); { jsB_propf(J, "toString", Ap_toString, 0); - jsB_propf(J, "concat", Ap_concat, 1); + jsB_propf(J, "concat", Ap_concat, 0); /* 1 */ jsB_propf(J, "join", Ap_join, 1); jsB_propf(J, "pop", Ap_pop, 0); - jsB_propf(J, "push", Ap_push, 1); + jsB_propf(J, "push", Ap_push, 0); /* 1 */ jsB_propf(J, "reverse", Ap_reverse, 0); jsB_propf(J, "shift", Ap_shift, 0); jsB_propf(J, "slice", Ap_slice, 2); jsB_propf(J, "sort", Ap_sort, 1); - jsB_propf(J, "splice", Ap_splice, 2); - jsB_propf(J, "unshift", Ap_unshift, 1); + jsB_propf(J, "splice", Ap_splice, 0); /* 2 */ + jsB_propf(J, "unshift", Ap_unshift, 0); /* 1 */ /* ES5 */ jsB_propf(J, "indexOf", Ap_indexOf, 1); @@ -709,7 +709,7 @@ void jsB_initarray(js_State *J) jsB_propf(J, "reduce", Ap_reduce, 1); jsB_propf(J, "reduceRight", Ap_reduceRight, 1); } - js_newcconstructor(J, jsB_new_Array, jsB_new_Array, "Array", 1); + js_newcconstructor(J, jsB_new_Array, jsB_new_Array, "Array", 0); /* 1 */ { /* ES5 */ jsB_propf(J, "isArray", A_isArray, 1); diff --git a/jsdate.c b/jsdate.c index e644c03..94bd15e 100644 --- a/jsdate.c +++ b/jsdate.c @@ -10,7 +10,7 @@ #include #endif -#define js_optnumber(J,I,V) (js_gettop(J) > I ? js_tonumber(J,I) : V) +#define js_optnumber(J,I,V) (js_isdefined(J,I) ? js_tonumber(J,I) : V) static double Now(void) { @@ -792,7 +792,7 @@ void jsB_initdate(js_State *J) jsB_propf(J, "toISOString", Dp_toISOString, 0); jsB_propf(J, "toJSON", Dp_toJSON, 1); } - js_newcconstructor(J, jsB_Date, jsB_new_Date, "Date", 1); + js_newcconstructor(J, jsB_Date, jsB_new_Date, "Date", 0); /* 1 */ { jsB_propf(J, "parse", D_parse, 1); jsB_propf(J, "UTC", D_UTC, 7); diff --git a/jsmath.c b/jsmath.c index 7ee07a2..cf300fa 100644 --- a/jsmath.c +++ b/jsmath.c @@ -153,8 +153,8 @@ void jsB_initmath(js_State *J) jsB_propf(J, "exp", Math_exp, 1); jsB_propf(J, "floor", Math_floor, 1); jsB_propf(J, "log", Math_log, 1); - jsB_propf(J, "max", Math_max, 0); - jsB_propf(J, "min", Math_min, 0); + jsB_propf(J, "max", Math_max, 0); /* 2 */ + jsB_propf(J, "min", Math_min, 0); /* 2 */ jsB_propf(J, "pow", Math_pow, 2); jsB_propf(J, "random", Math_random, 0); jsB_propf(J, "round", Math_round, 1); diff --git a/jsnumber.c b/jsnumber.c index 8f29f21..8394c0b 100644 --- a/jsnumber.c +++ b/jsnumber.c @@ -89,7 +89,7 @@ void jsB_initnumber(js_State *J) jsB_propf(J, "toExponential", Np_toExponential, 1); jsB_propf(J, "toPrecision", Np_toPrecision, 1); } - js_newcconstructor(J, jsB_Number, jsB_new_Number, "Number", 1); + js_newcconstructor(J, jsB_Number, jsB_new_Number, "Number", 0); /* 1 */ { jsB_propn(J, "MAX_VALUE", 1.7976931348623157e+308); jsB_propn(J, "MIN_VALUE", 5e-324); diff --git a/jsobject.c b/jsobject.c index 51ed86e..83cb2e1 100644 --- a/jsobject.c +++ b/jsobject.c @@ -4,7 +4,7 @@ static void jsB_new_Object(js_State *J) { - if (js_gettop(J) == 1 || js_isundefined(J, 1) || js_isnull(J, 1)) + if (js_isundefined(J, 1) || js_isnull(J, 1)) js_newobject(J); else js_pushobject(J, js_toobject(J, 1)); @@ -12,7 +12,7 @@ static void jsB_new_Object(js_State *J) static void jsB_Object(js_State *J) { - if (js_gettop(J) == 1 || js_isundefined(J, 1) || js_isnull(J, 1)) + if (js_isundefined(J, 1) || js_isnull(J, 1)) js_newobject(J); else js_pushobject(J, js_toobject(J, 1)); diff --git a/jsregexp.c b/jsregexp.c index ecf001d..2617216 100644 --- a/jsregexp.c +++ b/jsregexp.c @@ -146,7 +146,7 @@ static void jsB_new_RegExp(js_State *J) static void jsB_RegExp(js_State *J) { - if (js_gettop(J) == 2 && js_isregexp(J, 1)) + if (js_isregexp(J, 1)) return; jsB_new_RegExp(J); } diff --git a/jsstring.c b/jsstring.c index fd60c27..40e4cd5 100644 --- a/jsstring.c +++ b/jsstring.c @@ -661,7 +661,7 @@ void jsB_initstring(js_State *J) jsB_propf(J, "valueOf", Sp_valueOf, 0); jsB_propf(J, "charAt", Sp_charAt, 1); jsB_propf(J, "charCodeAt", Sp_charCodeAt, 1); - jsB_propf(J, "concat", Sp_concat, 1); + jsB_propf(J, "concat", Sp_concat, 0); /* 1 */ jsB_propf(J, "indexOf", Sp_indexOf, 1); jsB_propf(J, "lastIndexOf", Sp_lastIndexOf, 1); jsB_propf(J, "localeCompare", Sp_localeCompare, 1); @@ -679,9 +679,9 @@ void jsB_initstring(js_State *J) /* ES5 */ jsB_propf(J, "trim", Sp_trim, 0); } - js_newcconstructor(J, jsB_String, jsB_new_String, "String", 1); + js_newcconstructor(J, jsB_String, jsB_new_String, "String", 0); /* 1 */ { - jsB_propf(J, "fromCharCode", S_fromCharCode, 1); + jsB_propf(J, "fromCharCode", S_fromCharCode, 0); /* 1 */ } js_defglobal(J, "String", JS_DONTENUM); } diff --git a/main.c b/main.c index 6d021b4..6212a84 100644 --- a/main.c +++ b/main.c @@ -153,7 +153,7 @@ main(int argc, char **argv) js_newcfunction(J, jsB_load, "load", 1); js_setglobal(J, "load"); - js_newcfunction(J, jsB_print, "print", 1); + js_newcfunction(J, jsB_print, "print", 0); js_setglobal(J, "print"); js_newcfunction(J, jsB_write, "write", 0);