00001 /* 00002 * $Id: $ 00003 * 00004 * Description : JSEnvironment defines API for scripts. 00005 * Author : Jakub Zelenka <jakub.zelenka@gmail.com> 00006 * 00007 * Purpose : 00008 * JSEnvironment defines API for scripts. 00009 */ 00010 00011 00012 #ifndef __JSENVIRONMENT_H_ 00013 #define __JSENVIRONMENT_H_ 00014 00015 #include <string> 00016 #include <vector> 00017 #include <jsapi.h> 00018 00019 #include "scriptexception.h" 00020 #include "../../core/src/module.h" 00021 00022 namespace VRUT 00023 { 00024 class JSHandler; 00026 class JSEnvironment 00027 { 00028 private: 00030 JSRuntime *rt; 00032 JSContext *cx; 00034 JSObject *globalObj; 00036 JSObject *sceneObj; 00037 00039 JSHandler *handler; 00040 00042 #pragma warning( disable : 4290 ) 00043 void initJSClasses() throw(ScriptException); 00044 00045 public: 00047 static const unsigned long MAX_SLEEP = 100; 00048 00050 JSEnvironment(JSHandler * _handler); 00051 00053 virtual ~JSEnvironment(); 00054 00056 bool RunScript(Kernel *_kernel, const char *fileName, SCENE_ID sceneID); 00057 00058 00059 }; 00060 } 00061 00062 #endif /* __JSENVIRONMENT_H_ */ 00063