1 #ifndef SpiderMonkeyEngine_h 2 #define SpiderMonkeyEngine_h 3 4 #include <set> 5 #include <vector> 6 #include "IScriptEngine.h" 7 8 struct JSClass; 9 struct JSContext; 10 struct JSErrorReport; 11 struct JSFunctionSpec; 12 struct JSObject; 13 struct JSRuntime; 14 15 class SpiderMonkeyEngine : public IScriptEngine 16 { 17 private: 18 typedef struct 19 { 20 const char *name; 21 const char *text; 22 JSFunctionSpec *jsFunctions; 23 } JsHook; 24 25 static JSClass _globalClass; 26 27 JSContext *_jsContext; 28 JSObject *_jsObject; 29 JSRuntime *_jsRuntime; 30 IEditor *_editor; 31 32 std::set<eventHandlerFunc*> _eventHandlerSet; 33 34 static void printError(JSContext *cx, const char *message, JSErrorReport *report); 35 void registerFunctions(JSContext *cx, JSObject *obj); 36 void registerDialogFunctions(JSContext *cx, JSObject *obj); 37 void registerFunctionGroup(const char *name, const char *text, JSFunctionSpec *s, JSContext *cx, JSObject *obj); 38 39 public: 40 std::vector<JsHook> jsHooks; 41 42 ~SpiderMonkeyEngine(); 43 void callEventHandlers(EventType eventType, const char *fileName, int lineNo, const char *message); 44 Capabilities capabilities(); 45 IScriptWriter* createScriptWriter(); 46 std::string defaultFileExtension(); 47 IEditor* editor(); 48 void initialise(IEditor *videoBody); 49 int maturityRanking(); 50 std::string name(); 51 void openDebuggerShell(); 52 std::string referenceUrl(); 53 void registerEventHandler(eventHandlerFunc *func); 54 bool runScript(std::string script, RunMode mode); 55 bool runScriptFile(std::string name, RunMode mode); 56 void unregisterEventHandler(eventHandlerFunc *func); 57 }; 58 59 #endif 60