[mw-devel] MW3 r918 - branches/jscript/src

arthur at sucs.org arthur at sucs.org
Mon Mar 19 22:04:59 GMT 2007


Author: arthur
Date: 2007-03-19 22:04:59 +0000 (Mon, 19 Mar 2007)
New Revision: 918

Modified:
   branches/jscript/src/js.c
   branches/jscript/src/script.c
Log:
catch the return value from event scripts and turn output, 
for some reason changing script_output=0 doesnt have any effect
refs #13


Modified: branches/jscript/src/js.c
===================================================================
--- branches/jscript/src/js.c	2007-03-19 18:12:45 UTC (rev 917)
+++ branches/jscript/src/js.c	2007-03-19 22:04:59 UTC (rev 918)
@@ -355,6 +355,28 @@
 	return (jschar *)utf16;
 }
 
+void show_type(char *name, jsval j)
+{
+	printf("%s is:",name);
+	if (JSVAL_IS_BOOLEAN(j)) {
+		printf(" BOOLEAN");
+		printf("=%d",JSVAL_TO_BOOLEAN(j));
+	}
+	if (JSVAL_IS_DOUBLE(j)) printf(" DOUBLE");
+	if (JSVAL_IS_GCTHING(j)) printf(" GCTHING");
+	if (JSVAL_IS_INT(j)) {
+		printf(" INT");
+		printf("=%d", JSVAL_TO_INT(j));
+	}
+	if (JSVAL_IS_NULL(j)) printf(" NULL");
+	if (JSVAL_IS_NUMBER(j)) printf(" NUMBER");
+	if (JSVAL_IS_OBJECT(j)) printf(" OBJECT");
+	if (JSVAL_IS_PRIMITIVE(j)) printf(" PRIMITIVE");
+	if (JSVAL_IS_STRING(j)) printf(" STRING");
+	if (JSVAL_IS_VOID(j)) printf(" VOID");
+	printf(" End.\n");
+}
+
 /* Execute some javascript commands */
 int
 js_exec(char * name, int argc, char **argvc) {
@@ -390,6 +412,11 @@
 	if (!ret) {
 		printf("JS function '%s' (args: %d) not found.\n", name, argc);
 	}
+	show_type("js_exec(rval)", rval);
+	if (JSVAL_IS_BOOLEAN(rval) && JSVAL_TO_BOOLEAN(rval)==0) {
+		printf("Disable script output\n");
+		script_output=0;
+	}
 	JS_free(jscx, js_string);
 	free(argv);
 	return ret ? 1 : 0;

Modified: branches/jscript/src/script.c
===================================================================
--- branches/jscript/src/script.c	2007-03-19 18:12:45 UTC (rev 917)
+++ branches/jscript/src/script.c	2007-03-19 22:04:59 UTC (rev 918)
@@ -843,7 +843,10 @@
 		argv[1]=who;
 		argv[2]=text;
 		argv[3]=text+pre;
-		return js_exec(script, 4, argv);
+		busy++;
+		retval=js_exec(script, 4, argv);
+		busy--;
+		return retval;
 	}
 	runaway=0;
 	if (!script_running) { flood=0;}





More information about the mw-devel mailing list