Make the array has/get/setindex functions part of the public API.

This commit is contained in:
Tor Andersson
2014-01-28 17:11:19 +01:00
parent 3b3bf534ae
commit 01cab639cb
2 changed files with 11 additions and 6 deletions

7
js.h
View File

@@ -90,11 +90,16 @@ void js_getglobal(js_State *J, const char *name);
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);

View File

@@ -17,28 +17,28 @@ static void js_setlength(js_State *J, int idx, unsigned int len)
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);
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);
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);
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 @@ static int Ap_concat(js_State *J, int argc)
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;