svn commit: samba r8638 - in branches/SAMBA_4_0:
source/scripting/ejs source/scripting/libjs swat/scripting
testprogs/ejs
tridge at samba.org
tridge at samba.org
Wed Jul 20 07:04:08 GMT 2005
Author: tridge
Date: 2005-07-20 07:04:07 +0000 (Wed, 20 Jul 2005)
New Revision: 8638
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=8638
Log:
continue the trend of maknig our C functions true ejs objects by making the string functions
into an object. To keep existing code working I have added:
string_init(global);
into base.js. That brings the functions into the global scope for our
existing scripts
Modified:
branches/SAMBA_4_0/source/scripting/ejs/smbcalls_string.c
branches/SAMBA_4_0/source/scripting/libjs/base.js
branches/SAMBA_4_0/swat/scripting/common.js
branches/SAMBA_4_0/testprogs/ejs/sprintf.js
Changeset:
Modified: branches/SAMBA_4_0/source/scripting/ejs/smbcalls_string.c
===================================================================
--- branches/SAMBA_4_0/source/scripting/ejs/smbcalls_string.c 2005-07-20 07:01:09 UTC (rev 8637)
+++ branches/SAMBA_4_0/source/scripting/ejs/smbcalls_string.c 2005-07-20 07:04:07 UTC (rev 8638)
@@ -321,15 +321,27 @@
}
/*
+ initialise string ejs subsystem
+*/
+static int ejs_string_init(MprVarHandle eid, int argc, struct MprVar **argv)
+{
+ struct MprVar *obj = mprInitObject(eid, "string", argc, argv);
+
+ mprSetStringCFunction(obj, "strlen", ejs_strlen);
+ mprSetStringCFunction(obj, "strlower", ejs_strlower);
+ mprSetStringCFunction(obj, "strupper", ejs_strupper);
+ mprSetStringCFunction(obj, "split", ejs_split);
+ mprSetCFunction(obj, "join", ejs_join);
+ mprSetCFunction(obj, "sprintf", ejs_sprintf);
+ mprSetCFunction(obj, "vsprintf", ejs_vsprintf);
+
+ return 0;
+}
+
+/*
setup C functions that be called from ejs
*/
void smb_setup_ejs_string(void)
{
- ejsDefineStringCFunction(-1, "strlen", ejs_strlen, NULL, MPR_VAR_SCRIPT_HANDLE);
- ejsDefineStringCFunction(-1, "strlower", ejs_strlower, NULL, MPR_VAR_SCRIPT_HANDLE);
- ejsDefineStringCFunction(-1, "strupper", ejs_strupper, NULL, MPR_VAR_SCRIPT_HANDLE);
- ejsDefineStringCFunction(-1, "split", ejs_split, NULL, MPR_VAR_SCRIPT_HANDLE);
- ejsDefineCFunction(-1, "join", ejs_join, NULL, MPR_VAR_SCRIPT_HANDLE);
- ejsDefineCFunction(-1, "sprintf", ejs_sprintf, NULL, MPR_VAR_SCRIPT_HANDLE);
- ejsDefineCFunction(-1, "vsprintf", ejs_vsprintf, NULL, MPR_VAR_SCRIPT_HANDLE);
+ ejsDefineCFunction(-1, "string_init", ejs_string_init, NULL, MPR_VAR_SCRIPT_HANDLE);
}
Modified: branches/SAMBA_4_0/source/scripting/libjs/base.js
===================================================================
--- branches/SAMBA_4_0/source/scripting/libjs/base.js 2005-07-20 07:01:09 UTC (rev 8637)
+++ branches/SAMBA_4_0/source/scripting/libjs/base.js 2005-07-20 07:04:07 UTC (rev 8638)
@@ -9,6 +9,9 @@
}
HAVE_BASE_JS=1
+/* bring the string functions into the global frame */
+string_init(global);
+
/*
an essential function!
*/
Modified: branches/SAMBA_4_0/swat/scripting/common.js
===================================================================
--- branches/SAMBA_4_0/swat/scripting/common.js 2005-07-20 07:01:09 UTC (rev 8637)
+++ branches/SAMBA_4_0/swat/scripting/common.js 2005-07-20 07:04:07 UTC (rev 8638)
@@ -8,6 +8,8 @@
/* fill in some defaults */
global.page.title = "Samba Web Administration Tool";
+libinclude("base.js");
+
/* to cope with browsers that don't support cookies we append the sessionid
to the URI */
global.SESSIONURI = "";
Modified: branches/SAMBA_4_0/testprogs/ejs/sprintf.js
===================================================================
--- branches/SAMBA_4_0/testprogs/ejs/sprintf.js 2005-07-20 07:01:09 UTC (rev 8637)
+++ branches/SAMBA_4_0/testprogs/ejs/sprintf.js 2005-07-20 07:04:07 UTC (rev 8638)
@@ -3,6 +3,8 @@
test sprintf function
*/
+string_init(local);
+
function check_result(s, v)
{
if (s != v) {
More information about the samba-cvs
mailing list