mirror of
https://github.com/ccxvii/mujs.git
synced 2026-02-06 01:41:37 +08:00
Update docs.
This commit is contained in:
@@ -41,7 +41,7 @@ int main(int argc, char **argv)
|
||||
{
|
||||
js_State *J = js_newstate(NULL, NULL, JS_STRICT);
|
||||
|
||||
js_newcfunction(J, hello, 1);
|
||||
js_newcfunction(J, hello, "hello", 1);
|
||||
js_setglobal(J, "hello");
|
||||
|
||||
js_dostring(J, "hello('world');");
|
||||
@@ -155,16 +155,16 @@ void initfile(js_State *J)
|
||||
js_getproperty(J, -1, "prototype"); // File.prototype.[[Prototype]] = Object.prototype
|
||||
js_newuserdata(J, TAG, stdin); // File.prototype.[[Userdata]] = stdin
|
||||
{
|
||||
js_newcfunction(J, File_prototype_readByte, 0);
|
||||
js_newcfunction(J, File_prototype_readByte, "File.prototype.readByte", 0);
|
||||
js_defproperty(J, -2, "readByte", JS_DONTENUM);
|
||||
|
||||
js_newcfunction(J, File_prototype_readLine, 0);
|
||||
js_newcfunction(J, File_prototype_readLine, "File.prototype.readLine", 0);
|
||||
js_defproperty(J, -2, "readLine", JS_DONTENUM);
|
||||
|
||||
js_newcfunction(J, File_prototype_close, 0);
|
||||
js_newcfunction(J, File_prototype_close, "File.prototype.close", 0);
|
||||
js_defproperty(J, -2, "close", JS_DONTENUM);
|
||||
}
|
||||
js_newcconstructor(J, new_File, new_File, 1);
|
||||
js_newcconstructor(J, new_File, new_File, "File", 1);
|
||||
js_defglobal(J, "File", JS_DONTENUM);
|
||||
}
|
||||
</pre>
|
||||
|
||||
@@ -146,7 +146,7 @@ Destroy the state and free all dynamic memory used by the state.
|
||||
The interpreter uses a host provided function for all memory allocation needs:
|
||||
|
||||
<pre>
|
||||
typedef void *(*js_Alloc)(void *memctx, void *ptr, unsigned int size);
|
||||
typedef void *(*js_Alloc)(void *memctx, void *ptr, int size);
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
@@ -504,18 +504,18 @@ Delete the named property from the object.
|
||||
<h3>Array properties</h3>
|
||||
|
||||
<pre>
|
||||
unsigned int js_getlength(js_State *J, int idx);
|
||||
void js_setlength(js_State *J, int idx, unsigned int len);
|
||||
int js_getlength(js_State *J, int idx);
|
||||
void js_setlength(js_State *J, int idx, int len);
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
Wrappers to get and set the "length" property of an object.
|
||||
|
||||
<pre>
|
||||
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);
|
||||
int js_hasindex(js_State *J, int idx, int i);
|
||||
void js_getindex(js_State *J, int idx, int i);
|
||||
void js_setindex(js_State *J, int idx, int i);
|
||||
void js_delindex(js_State *J, int idx, int i);
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
@@ -543,7 +543,7 @@ Wrappers around js_pushglobal and js_get/set/defproperty to read and write the v
|
||||
<h3>C Functions</h3>
|
||||
|
||||
<pre>
|
||||
void js_newcfunction(js_State *J, js_CFunction fun, unsigned int length);
|
||||
void js_newcfunction(js_State *J, js_CFunction fun, const char *name, int length);
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
@@ -555,7 +555,8 @@ If the function is called with fewer arguments, the argument list will be padded
|
||||
|
||||
<pre>
|
||||
void js_newcconstructor(js_State *J,
|
||||
js_CFunction fun, js_CFunction con, unsigned int length);
|
||||
js_CFunction fun, js_CFunction con,
|
||||
const char *name, int length);
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
|
||||
Reference in New Issue
Block a user