diff spidermonkey-playground.cpp @ 3:7237a81919b2

Renamed some variables.
author Atul Varma <varmaa@toolness.com>
date Thu, 18 Jun 2009 22:40:17 -0700
parents 1f3e9c8df4f0
children 71de19be1054
line wrap: on
line diff
--- a/spidermonkey-playground.cpp	Thu Jun 18 22:11:08 2009 -0700
+++ b/spidermonkey-playground.cpp	Thu Jun 18 22:40:17 2009 -0700
@@ -54,7 +54,7 @@
   return JS_TRUE;
 }
 
-static JSFunctionSpec global_functions[] = {
+static JSFunctionSpec tcb_global_functions[] = {
   JS_FS("print",   print,   1, 0, 0),
   JS_FS("wrap",    wrap,    2, 0, 0),
   JS_FS_END
@@ -64,8 +64,8 @@
 {
   /* JS variables. */
   JSRuntime *rt;
-  JSContext *cx;
-  JSObject  *global;
+  JSContext *tcb_cx;
+  JSObject  *tcb_global;
 
   /* Create a JS runtime. */
   rt = JS_NewRuntime(8L * 1024L * 1024L);
@@ -73,24 +73,24 @@
     return 1;
 
   /* Create a context. */
-  cx = JS_NewContext(rt, 8192);
-  if (cx == NULL)
+  tcb_cx = JS_NewContext(rt, 8192);
+  if (tcb_cx == NULL)
     return 1;
-  JS_SetOptions(cx, JSOPTION_VAROBJFIX);
-  JS_SetVersion(cx, JSVERSION_LATEST);
-  JS_SetErrorReporter(cx, reportError);
+  JS_SetOptions(tcb_cx, JSOPTION_VAROBJFIX);
+  JS_SetVersion(tcb_cx, JSVERSION_LATEST);
+  JS_SetErrorReporter(tcb_cx, reportError);
 
-  /* Create the global object. */
-  global = JS_NewObject(cx, &global_class, NULL, NULL);
-  if (global == NULL)
+  /* Create the TCB's global object. */
+  tcb_global = JS_NewObject(tcb_cx, &global_class, NULL, NULL);
+  if (tcb_global == NULL)
     return 1;
 
-  /* Populate the global object with the standard globals,
+  /* Populate the tcb_global object with the standard globals,
      like Object and Array. */
-  if (!JS_InitStandardClasses(cx, global))
+  if (!JS_InitStandardClasses(tcb_cx, tcb_global))
     return 1;
 
-  if (!JS_DefineFunctions(cx, global, global_functions))
+  if (!JS_DefineFunctions(tcb_cx, tcb_global, tcb_global_functions))
     return 1;
 
   /* Your application code here. This may include JSAPI calls
@@ -104,7 +104,7 @@
   fclose(f);
 
   jsval rval;
-  if (!JS_EvaluateScript(cx, global, source,
+  if (!JS_EvaluateScript(tcb_cx, tcb_global, source,
                          strlen(source), TCB_FILENAME, 1,
                          &rval)) {
     printf("An error occurred.\n");
@@ -112,7 +112,7 @@
   }
 
   /* Cleanup. */
-  JS_DestroyContext(cx);
+  JS_DestroyContext(tcb_cx);
   JS_DestroyRuntime(rt);
   JS_ShutDown();