1 #ifndef SCRIPTHELPER_H 2 #define SCRIPTHELPER_H 3 4 #include <sstream> 5 #include <string> 6 7 #ifndef ANGELSCRIPT_H 8 // Avoid having to inform include path if header is already include before 9 #include "angelscript.h" 10 #endif 11 12 13 BEGIN_AS_NAMESPACE 14 15 // Compare relation between two objects of the same type 16 int CompareRelation(asIScriptEngine *engine, void *lobj, void *robj, int typeId, int &result); 17 18 // Compare equality between two objects of the same type 19 int CompareEquality(asIScriptEngine *engine, void *lobj, void *robj, int typeId, bool &result); 20 21 // Compile and execute simple statements 22 // The module is optional. If given the statements can access the entities compiled in the module. 23 // The caller can optionally provide its own context, for example if a context should be reused. 24 int ExecuteString(asIScriptEngine *engine, const char *code, asIScriptModule *mod = 0, asIScriptContext *ctx = 0); 25 26 // Compile and execute simple statements with option of return value 27 // The module is optional. If given the statements can access the entitites compiled in the module. 28 // The caller can optionally provide its own context, for example if a context should be reused. 29 int ExecuteString(asIScriptEngine *engine, const char *code, void *ret, int retTypeId, asIScriptModule *mod = 0, asIScriptContext *ctx = 0); 30 31 // Write the registered application interface to a file for an offline compiler. 32 // The format is compatible with the offline compiler in /sdk/samples/asbuild/. 33 int WriteConfigToFile(asIScriptEngine *engine, const char *filename); 34 35 // Write the registered application interface to a text stream. 36 int WriteConfigToStream(asIScriptEngine *engine, std::ostream &strm); 37 38 // Loads an interface from a text stream and configures the engine with it. This will not 39 // set the correct function pointers, so it is not possible to use this engine to execute 40 // scripts, but it can be used to compile scripts and save the byte code. 41 int ConfigEngineFromStream(asIScriptEngine *engine, std::istream &strm, const char *nameOfStream = "config"); 42 43 // Format the details of the script exception into a human readable text 44 std::string GetExceptionInfo(asIScriptContext *ctx, bool showStack = false); 45 46 END_AS_NAMESPACE 47 48 #endif 49