[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdelibs/kjs
From:       Peter Kelly <pmk () post ! com>
Date:       2003-02-18 3:01:00
[Download RAW message or body]

CVS commit by pmk: 

Merged in changes from JavaScriptCore to make compatible with mozilla
tests


  M +23 -4     testkjs.cpp   1.24


--- kdelibs/kjs/testkjs.cpp  #1.23:1.24
@@ -22,4 +22,5 @@
 
 #include <stdio.h>
+#include <string.h>
 
 #include "value.h"
@@ -43,4 +44,18 @@ Value TestFunctionImp::call(ExecState *e
 }
 
+class VersionFunctionImp : public ObjectImp {
+public:
+  VersionFunctionImp() : ObjectImp() {}
+  virtual bool implementsCall() const { return true; }
+  virtual Value call(ExecState *exec, Object &thisObj, const List &args);
+};
+
+Value VersionFunctionImp::call(ExecState *exec, Object &/*thisObj*/, const List &args)
+{
+  // We need this function for compatibility with the Mozilla JS tests but for now
+  // we don't actually do any version-specific handling
+  return Undefined();
+}
+
 class GlobalImp : public ObjectImp {
 public:
@@ -63,7 +78,9 @@ int main(int argc, char **argv)
     Interpreter interp(global);
     // add debug() function
-    global.put(interp.globalExec(),"debug", Object(new TestFunctionImp()));
+    global.put(interp.globalExec(), UString("debug"), Object(new TestFunctionImp()));
     // add "print" for compatibility with the mozilla js shell
-    global.put(interp.globalExec(),"print", Object(new TestFunctionImp()));
+    global.put(interp.globalExec(), UString("print"), Object(new TestFunctionImp()));
+    // add "version" for compatibility with the mozilla js shell 
+    global.put(interp.globalExec(), UString("version"), Object(new VersionFunctionImp()));
 
     const int BufferSize = 200000;
@@ -72,4 +89,6 @@ int main(int argc, char **argv)
     for (int i = 1; i < argc; i++) {
       const char *file = argv[i];
+      if (strcmp(file, "-f") == 0)
+        continue;
       FILE *f = fopen(file, "r");
       if (!f) {
@@ -93,5 +112,5 @@ int main(int argc, char **argv)
         int lineno = -1;
         if (exVal.type() == ObjectType) {
-          Value lineVal = Object::dynamicCast(exVal).get(exec,"line");
+          Value lineVal = Object::dynamicCast(exVal).get(exec,UString("line"));
           if (lineVal.type() == NumberType)
             lineno = int(lineVal.toNumber(exec));
@@ -117,4 +136,4 @@ int main(int argc, char **argv)
   Interpreter::finalCheck();
 #endif
-  return ret ? 0 : 1;
+  return ret ? 0 : 3;
 }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic