Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, libarchive.org for more info) to build successfully.

Commit 356d5935 authored by rswindell's avatar rswindell

Each method alias has to be created as a descriptor (for JS_InitClass),

so I'm using a new method type: JSTYPE_ALIAS to denote method aliases
(not documented).
parent 96faae84
......@@ -132,7 +132,7 @@ enum {
};
#ifdef _DEBUG
static char* bbs_prop_desc[BBS_PROPERTIES] = {
static char* bbs_prop_desc[BBS_PROPERTIES+1] = {
"system status"
,"startup options"
,"answer time"
......@@ -2477,8 +2477,8 @@ static jsMethodSpec js_bbs_functions[] = {
},
{"nodesync", js_nodesync, 0, JSTYPE_VOID, ""
,JSDOCSTR("synchronize node with system")
,"node_sync"
},
{"node_sync", js_nodesync, 0, JSTYPE_ALIAS },
{"auto_msg", js_automsg, 0, JSTYPE_VOID, ""
,JSDOCSTR("edit/create auto-message")
},
......
......@@ -1016,12 +1016,12 @@ static jsMethodSpec js_console_functions[] = {
},
{"ansi_save", js_ansi_save, 0, JSTYPE_VOID, ""
,JSDOCSTR("Save current cursor position")
,"ansi_pushxy"
},
{"ansi_pushxy", js_ansi_save, 0, JSTYPE_ALIAS },
{"ansi_restore", js_ansi_restore, 0, JSTYPE_VOID, ""
,JSDOCSTR("Restore saved cursor position")
,"ansi_popxy"
},
{"ansi_popxy", js_ansi_restore, 0, JSTYPE_ALIAS },
{"ansi_gotoxy", js_ansi_gotoxy, 2, JSTYPE_VOID, JSDOCSTR("number x,y")
,JSDOCSTR("Move cursor to a specific screen coordinate (ANSI)")
},
......
......@@ -879,12 +879,12 @@ static jsMethodSpec js_file_functions[] = {
},
{"delete", js_delete, 0, JSTYPE_BOOLEAN, ""
,"Remove the file from the disk"
,"remove"
},
},
{"remove", js_delete, 0, JSTYPE_ALIAS },
{"clear_error", js_clear_error, 0, JSTYPE_BOOLEAN, ""
,"Clears the current error value"
,"clearError"
},
{"clearError", js_clear_error, 0, JSTYPE_ALIAS },
{"flush", js_flush, 0, JSTYPE_BOOLEAN, ""
,"flush buffers"
},
......
......@@ -719,8 +719,8 @@ static jsMethodSpec js_global_functions[] = {
},
{"mswait", js_mswait, 0, JSTYPE_VOID, "[number milliseconds]"
,"millisecond wait/sleep routine"
,"sleep"
},
},
{"sleep", js_mswait, 0, JSTYPE_ALIAS },
{"random", js_random, 1, JSTYPE_NUMBER, "number max"
,"return random int between 0 and n"
},
......
......@@ -996,8 +996,8 @@ static jsMethodSpec js_socket_functions[] = {
},
{"send", js_send, 1, JSTYPE_BOOLEAN, JSDOCSTR("string data")
,JSDOCSTR("send a string")
,"write"
},
{"write", js_send, 1, JSTYPE_ALIAS },
{"sendto", js_sendto, 3, JSTYPE_BOOLEAN, JSDOCSTR("string data, address, port")
,JSDOCSTR("send a string to a specific address and port (typically used for UDP sockets)")
},
......@@ -1006,15 +1006,16 @@ static jsMethodSpec js_socket_functions[] = {
},
{"recv", js_recv, 0, JSTYPE_STRING, JSDOCSTR("[maxlen]")
,JSDOCSTR("receive a string, default maxlen is 512 characters")
,"read"
},
{"read", js_recv, 1, JSTYPE_ALIAS },
{"peek", js_peek, 0, JSTYPE_STRING, JSDOCSTR("[maxlen]")
,JSDOCSTR("receive a string, default maxlen is 512 characters, leave string in receive buffer")
},
{"recvline", js_recvline, 0, JSTYPE_STRING, JSDOCSTR("[maxlen] [,timeout]")
,JSDOCSTR("receive a line-feed terminated string, default maxlen is 512 characters, default timeout is 30 seconds")
,"readline"
},
{"readline", js_recvline, 0, JSTYPE_ALIAS },
{"readln", js_recvline, 0, JSTYPE_ALIAS },
{"recvfrom", js_recvfrom, 0, JSTYPE_OBJECT, JSDOCSTR("[maxlen]")
,JSDOCSTR("receive a string from (typically UDP) socket, return address and port of sender")
},
......
......@@ -328,6 +328,9 @@ DLLCALL js_DefineMethods(JSContext* cx, JSObject* obj, jsMethodSpec *funcs)
JS_DefineFunction(cx, obj, funcs[i].name, funcs[i].call, funcs[i].nargs, 0);
if(funcs[i].type==JSTYPE_ALIAS)
continue;
method = JS_NewObject(cx, &js_method_class, NULL, method_array);
if(method==NULL)
......@@ -355,12 +358,6 @@ DLLCALL js_DefineMethods(JSContext* cx, JSObject* obj, jsMethodSpec *funcs)
JS_SetProperty(cx, method, "desc", &val);
}
if(funcs[i].alias != NULL) {
JS_DefineFunction(cx, obj, funcs[i].alias, funcs[i].call, funcs[i].nargs, 0);
val = STRING_TO_JSVAL(JS_NewStringCopyZ(cx,funcs[i].alias));
JS_SetProperty(cx, method, "alias", &val);
}
val=OBJECT_TO_JSVAL(method);
if(!JS_SetElement(cx, method_array, len+i, &val))
return(JS_FALSE);
......@@ -380,11 +377,8 @@ DLLCALL js_DefineMethods(JSContext* cx, JSObject* obj, jsMethodSpec *funcs)
{
int i;
for(i=0;funcs[i].name;i++) {
for(i=0;funcs[i].name;i++)
JS_DefineFunction(cx, obj, funcs[i].name, funcs[i].call, funcs[i].nargs, 0);
if(funcs[i].alias != NULL)
JS_DefineFunction(cx, obj, funcs[i].alias, funcs[i].call, funcs[i].nargs, 0);
}
return(JS_TRUE);
}
......
......@@ -832,13 +832,13 @@ extern "C" {
const char* name;
JSNative call;
uint8 nargs;
JSType type; /* return type */
int type; /* return type */
const char* args; /* arguments */
const char* desc; /* description */
const char* alias; /* a.k.a. */
} jsMethodSpec;
#define JSTYPE_ARRAY JSTYPE_LIMIT
#define JSTYPE_ALIAS JSTYPE_LIMIT+1
#ifdef _DEBUG /* String compiled into debug build only, for JS documentation generation */
#define JSDOCSTR(s) s
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment