Menu

[r1967]: / trunk / src / sdk / scriptingmanager.h  Maximize  Restore  History

Download this file

54 lines (45 with data), 1.8 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#ifndef SCRIPTING_H
#define SCRIPTING_H
#include "settings.h"
#include "manager.h"
#include <wx/intl.h>
class asIScriptEngine;
class DLLIMPORT ScriptingManager : public Mgr<ScriptingManager>
{
friend class Mgr<ScriptingManager>;
public:
~ScriptingManager();
asIScriptEngine* GetEngine(){ return m_pEngine; }
/** Loads script and runs the function "int main()".
* @param filename The script's filename. If it doesn't exist,
* it is also looked up in <data_path>/scripts/
* @return If the script has errors, -1 s returned, else the
* script's return value is returned.
*/
int LoadScript(const wxString& filename, const wxString& module = _T(""), bool autorunMain = true);
int FindFunctionByDeclaration(const wxString& decl, const wxString& module = _T(""));
int FindFunctionByName(const wxString& name, const wxString& module = _T(""));
static wxString GetErrorDescription(int error);
protected:
asIScriptEngine* m_pEngine;
private:
ScriptingManager();
bool DoLoadScript(const wxString& filename, wxString& script);
};
#define asCHECK_ERROR_RET(r,what,ret) \
{ \
if (r < 0) \
{ \
LOGSTREAM << what << _T(": ") << ScriptingManager::GetErrorDescription(r) << _T(" (") _U(__FILE__) << _T(":") << wxString::Format(_T("%d"), __LINE__) << _T(")\n"); \
return ret; \
} \
}
#define asCHECK_ERROR(r,what) \
{ \
if (r < 0) \
{ \
LOGSTREAM << what << _T(": ") << ScriptingManager::GetErrorDescription(r) << _T(" (") _U(__FILE__) << _T(":") << wxString::Format(_T("%d"), __LINE__) << _T(")\n"); \
return; \
} \
}
#endif // SCRIPTING_H