ref: 01cab639cb79d1835b2531604aaa8bf8290ff55d
parent: 3b3bf534ae049f72d15b8b1371f14203d0766979
author: Tor Andersson <[email protected]>
date: Tue Jan 28 12:11:19 EST 2014
Make the array has/get/setindex functions part of the public API.
--- a/js.h
+++ b/js.h
@@ -90,11 +90,16 @@
void js_setglobal(js_State *J, const char *name);
void js_defglobal(js_State *J, const char *name, int atts);
+int js_hasproperty(js_State *J, int idx, const char *name);
void js_getproperty(js_State *J, int idx, const char *name);
void js_setproperty(js_State *J, int idx, const char *name);
void js_defproperty(js_State *J, int idx, const char *name, int atts);
void js_delproperty(js_State *J, int idx, const char *name);
-int js_hasproperty(js_State *J, int idx, const char *name);
+
+int js_hasindex(js_State *J, int idx, unsigned int i);
+void js_getindex(js_State *J, int idx, unsigned int i);
+void js_setindex(js_State *J, int idx, unsigned int i);
+void js_delindex(js_State *J, int idx, unsigned int i);
void js_pushglobal(js_State *J);
void js_pushundefined(js_State *J);
--- a/jsarray.c
+++ b/jsarray.c
@@ -17,7 +17,7 @@
js_setproperty(J, idx, "length");
}
-static int js_hasindex(js_State *J, int idx, unsigned int i)
+int js_hasindex(js_State *J, int idx, unsigned int i)
{
char buf[32];
sprintf(buf, "%u", i);
@@ -24,7 +24,7 @@
return js_hasproperty(J, idx, buf);
}
-static void js_getindex(js_State *J, int idx, unsigned int i)
+void js_getindex(js_State *J, int idx, unsigned int i)
{
char buf[32];
sprintf(buf, "%u", i);
@@ -31,7 +31,7 @@
js_getproperty(J, idx, buf);
}
-static void js_setindex(js_State *J, int idx, unsigned int i)
+void js_setindex(js_State *J, int idx, unsigned int i)
{
char buf[32];
sprintf(buf, "%u", i);
@@ -38,7 +38,7 @@
js_setproperty(J, idx, buf);
}
-static void js_delindex(js_State *J, int idx, unsigned int i)
+void js_delindex(js_State *J, int idx, unsigned int i)
{
char buf[32];
sprintf(buf, "%u", i);
@@ -76,7 +76,7 @@
js_newarray(J);
n = 0;
- for (i = 0; i <= argc; i++) {
+ for (i = 0; i <= argc; ++i) {
js_copy(J, i);
if (js_isarray(J, -1)) {
unsigned int k = 0;