mirror of
https://github.com/ccxvii/mujs.git
synced 2026-02-06 01:41:37 +08:00
Make the array has/get/setindex functions part of the public API.
This commit is contained in:
7
js.h
7
js.h
@@ -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);
|
||||
|
||||
10
jsarray.c
10
jsarray.c
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user