diff --git a/src/dom/jsengine.h b/src/dom/jsengine.h
index 8b775c98bffd5ef61dbb71caa8349456f34d0b12..abcbb23e91457bd29d36b3db6d00d1ac672b9731 100644 (file)
--- a/src/dom/jsengine.h
+++ b/src/dom/jsengine.h
*/
+#include "dom.h"
#include "js/jsapi.h"
* Constructor
*/
JavascriptEngine()
- { init(); }
+ { startup(); }
+
/**
- * Copy constructor
+ * Destructor
*/
- JavascriptEngine(const JavascriptEngine &other)
- { assign(other); }
+ virtual ~JavascriptEngine()
+ { shutdown(); }
/**
- * Assignment operator
+ * Evaluate a script
*/
- JavascriptEngine &operator=(const JavascriptEngine &other)
- { assign(other); return *this; }
+ bool evaluate(const DOMString &script);
/**
- * Destructor
+ * Evaluate a script from a file
*/
- virtual ~JavascriptEngine()
- {}
+ bool evaluateFile(const DOMString &script);
+
+
+ /**
+ * Return the runtime of the wrapped JS engine
+ */
+ JSRuntime *getRuntime()
+ { return rt; }
+
+ /**
+ * Return the current context of the wrapped JS engine
+ */
+ JSContext *getContext()
+ { return cx; }
+
+ /**
+ * Return the current global object of the wrapped JS engine
+ */
+ JSObject *getGlobalObject()
+ { return globalObj; }
+
+
+private:
/**
* Startup the javascript engine
*/
bool shutdown();
-
-
-private:
-
void init()
{
rt = NULL;
globalObj = NULL;
}
+ /**
+ * Assignment operator. Let's keep this private for now,
+ * as we want one Spidermonkey runtime per c++ shell
+ */
+ JavascriptEngine &operator=(const JavascriptEngine &other)
+ { assign(other); return *this; }
+
void assign(const JavascriptEngine &other)
{
rt = other.rt;
JSObject *globalObj;
+ static void errorReporter(JSContext *cx,
+ const char *message, JSErrorReport *report)
+ {
+ JavascriptEngine *engine =
+ (JavascriptEngine *) JS_GetContextPrivate(cx);
+ engine->error((char *)message);
+ }
+
+
+
+
};