shithub: libmujs

Download patch

ref: 702fb1eb4a1a2d26e8bed54c9498d771e9e53fa7
parent: ffc82eabd78042d4020776af64baf6a32de3a8d2
author: Tor Andersson <[email protected]>
date: Fri Jan 17 20:15:10 EST 2014

Rename functions that push new objects on the stack.

--- a/jsbuiltin.c
+++ b/jsbuiltin.c
@@ -64,7 +64,7 @@
 static void jsB_initobject(js_State *J)
 {
 	J->Object_prototype = jsR_newobject(J, JS_COBJECT, NULL);
-	js_pushcconstructor(J, jsB_Object, jsB_new_Object);
+	js_newcconstructor(J, jsB_Object, jsB_new_Object);
 	js_pushobject(J, J->Object_prototype);
 	js_setproperty(J, -2, "prototype");
 	js_setglobal(J, "Object");
@@ -73,7 +73,7 @@
 static void jsB_initarray(js_State *J)
 {
 	J->Array_prototype = jsR_newobject(J, JS_COBJECT, NULL);
-	js_pushcfunction(J, jsB_Array);
+	js_newcfunction(J, jsB_Array);
 	js_pushobject(J, J->Array_prototype);
 	js_setproperty(J, -2, "prototype");
 	js_setglobal(J, "Array");
@@ -82,7 +82,7 @@
 static void jsB_initfunction(js_State *J)
 {
 	J->Function_prototype = jsR_newobject(J, JS_COBJECT, NULL);
-	js_pushcfunction(J, jsB_Function);
+	js_newcfunction(J, jsB_Function);
 	js_pushobject(J, J->Function_prototype);
 	js_setproperty(J, -2, "prototype");
 	js_setglobal(J, "Function");
@@ -91,7 +91,7 @@
 static void jsB_initboolean(js_State *J)
 {
 	J->Boolean_prototype = jsR_newobject(J, JS_COBJECT, NULL);
-	js_pushcfunction(J, jsB_Boolean);
+	js_newcfunction(J, jsB_Boolean);
 	js_pushobject(J, J->Boolean_prototype);
 	js_setproperty(J, -2, "prototype");
 	js_setglobal(J, "Boolean");
@@ -100,7 +100,7 @@
 static void jsB_initnumber(js_State *J)
 {
 	J->Number_prototype = jsR_newobject(J, JS_COBJECT, NULL);
-	js_pushcfunction(J, jsB_Number);
+	js_newcfunction(J, jsB_Number);
 	js_pushobject(J, J->Number_prototype);
 	js_setproperty(J, -2, "prototype");
 	js_setglobal(J, "Number");
@@ -109,7 +109,7 @@
 static void jsB_initstring(js_State *J)
 {
 	J->String_prototype = jsR_newobject(J, JS_COBJECT, NULL);
-	js_pushcfunction(J, jsB_String);
+	js_newcfunction(J, jsB_String);
 	js_pushobject(J, J->String_prototype);
 	js_setproperty(J, -2, "prototype");
 	js_setglobal(J, "String");
@@ -146,7 +146,7 @@
 
 static void jsB_register(js_State *J, const char *name, js_CFunction cfun)
 {
-	js_pushcfunction(J, cfun);
+	js_newcfunction(J, cfun);
 	js_setglobal(J, name);
 }
 
--- a/jsrun.c
+++ b/jsrun.c
@@ -121,7 +121,7 @@
 	js_setproperty(J, -2, "prototype");
 }
 
-void js_pushcfunction(js_State *J, js_CFunction fun)
+void js_newcfunction(js_State *J, js_CFunction fun)
 {
 	js_pushobject(J, jsR_newcfunction(J, fun));
 	// TODO: length property?
@@ -131,9 +131,10 @@
 	js_setproperty(J, -2, "prototype");
 }
 
-void js_pushcconstructor(js_State *J, js_CFunction fun, js_CFunction con)
+void js_newcconstructor(js_State *J, js_CFunction fun, js_CFunction con)
 {
 	js_pushobject(J, jsR_newcconstructor(J, fun, con));
+	// TODO: length property?
 	js_newobject(J);
 	js_copy(J, -2);
 	js_setproperty(J, -2, "constructor");
--- a/jsrun.h
+++ b/jsrun.h
@@ -35,10 +35,11 @@
 void js_pushboolean(js_State *J, int v);
 void js_pushnumber(js_State *J, double v);
 void js_pushstring(js_State *J, const char *v);
+
 void js_newobject(js_State *J);
 void js_newarray(js_State *J);
-void js_pushcfunction(js_State *J, js_CFunction fun);
-void js_pushcconstructor(js_State *J, js_CFunction fun, js_CFunction con);
+void js_newcfunction(js_State *J, js_CFunction fun);
+void js_newcconstructor(js_State *J, js_CFunction fun, js_CFunction con);
 
 int js_isundefined(js_State *J, int idx);
 int js_isnull(js_State *J, int idx);