31 #include "hpl1/engine/resources/ResourceBase.h" 34 #define SCRIPT_DEFINE_FUNC(return, funcname) \ 35 SCRIPT_FUNC_BEGIN(funcname, return, "") \ 36 SCRIPT_RETURN_CALL_##return funcname(); \ 37 SCRIPT_FUNC_END(funcname, return ) 38 #define SCRIPT_DEFINE_FUNC_1(return, funcname, arg0) \ 39 SCRIPT_FUNC_BEGIN(funcname, return, #arg0) \ 40 SCRIPT_ARG_##arg0(0); \ 41 SCRIPT_RETURN_CALL_##return funcname(_arg0); \ 42 SCRIPT_FUNC_END(funcname, return ) 43 #define SCRIPT_DEFINE_FUNC_2(return, funcname, arg0, arg1) \ 44 SCRIPT_FUNC_BEGIN(funcname, return, #arg0 "," #arg1) \ 45 SCRIPT_ARG_##arg0(0); \ 46 SCRIPT_ARG_##arg1(1); \ 47 SCRIPT_RETURN_CALL_##return funcname(_arg0, _arg1); \ 48 SCRIPT_FUNC_END(funcname, return ) 49 #define SCRIPT_DEFINE_FUNC_3(return, funcname, arg0, arg1, arg2) \ 50 SCRIPT_FUNC_BEGIN(funcname, return, #arg0 "," #arg1 "," #arg2) \ 51 SCRIPT_ARG_##arg0(0); \ 52 SCRIPT_ARG_##arg1(1); \ 53 SCRIPT_ARG_##arg2(2); \ 54 SCRIPT_RETURN_CALL_##return funcname(_arg0, _arg1, _arg2); \ 55 SCRIPT_FUNC_END(funcname, return ) 56 #define SCRIPT_DEFINE_FUNC_4(return, funcname, arg0, arg1, arg2, arg3) \ 57 SCRIPT_FUNC_BEGIN(funcname, return, #arg0 "," #arg1 "," #arg2 "," #arg3) \ 58 SCRIPT_ARG_##arg0(0); \ 59 SCRIPT_ARG_##arg1(1); \ 60 SCRIPT_ARG_##arg2(2); \ 61 SCRIPT_ARG_##arg3(3); \ 62 SCRIPT_RETURN_CALL_##return funcname(_arg0, _arg1, _arg2, _arg3); \ 63 SCRIPT_FUNC_END(funcname, return ) 64 #define SCRIPT_DEFINE_FUNC_5(return, funcname, arg0, arg1, arg2, arg3, arg4) \ 65 SCRIPT_FUNC_BEGIN(funcname, return, #arg0 "," #arg1 "," #arg2 "," #arg3 "," #arg4) \ 66 SCRIPT_ARG_##arg0(0); \ 67 SCRIPT_ARG_##arg1(1); \ 68 SCRIPT_ARG_##arg2(2); \ 69 SCRIPT_ARG_##arg3(3); \ 70 SCRIPT_ARG_##arg4(4); \ 71 SCRIPT_RETURN_CALL_##return funcname(_arg0, _arg1, _arg2, _arg3, _arg4); \ 72 SCRIPT_FUNC_END(funcname, return ) 73 #define SCRIPT_DEFINE_FUNC_6(return, funcname, arg0, arg1, arg2, arg3, arg4, arg5) \ 74 SCRIPT_FUNC_BEGIN(funcname, return, #arg0 "," #arg1 "," #arg2 "," #arg3 "," #arg4 "," #arg5) \ 75 SCRIPT_ARG_##arg0(0); \ 76 SCRIPT_ARG_##arg1(1); \ 77 SCRIPT_ARG_##arg2(2); \ 78 SCRIPT_ARG_##arg3(3); \ 79 SCRIPT_ARG_##arg4(4); \ 80 SCRIPT_ARG_##arg5(5); \ 81 SCRIPT_RETURN_CALL_##return funcname(_arg0, _arg1, _arg2, _arg3, _arg4, _arg5); \ 82 SCRIPT_FUNC_END(funcname, return ) 83 #define SCRIPT_DEFINE_FUNC_7(return, funcname, arg0, arg1, arg2, arg3, arg4, arg5, arg6) \ 84 SCRIPT_FUNC_BEGIN(funcname, return, #arg0 "," #arg1 "," #arg2 "," #arg3 "," #arg4 "," #arg5 "," #arg6) \ 85 SCRIPT_ARG_##arg0(0); \ 86 SCRIPT_ARG_##arg1(1); \ 87 SCRIPT_ARG_##arg2(2); \ 88 SCRIPT_ARG_##arg3(3); \ 89 SCRIPT_ARG_##arg4(4); \ 90 SCRIPT_ARG_##arg5(5); \ 91 SCRIPT_ARG_##arg6(6); \ 92 SCRIPT_RETURN_CALL_##return funcname(_arg0, _arg1, _arg2, _arg3, _arg4, _arg5, _arg6); \ 93 SCRIPT_FUNC_END(funcname, return ) 94 #define SCRIPT_DEFINE_FUNC_8(return, funcname, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) \ 95 SCRIPT_FUNC_BEGIN(funcname, return, #arg0 "," #arg1 "," #arg2 "," #arg3 "," #arg4 "," #arg5 "," #arg6 "," #arg7) \ 96 SCRIPT_ARG_##arg0(0); \ 97 SCRIPT_ARG_##arg1(1); \ 98 SCRIPT_ARG_##arg2(2); \ 99 SCRIPT_ARG_##arg3(3); \ 100 SCRIPT_ARG_##arg4(4); \ 101 SCRIPT_ARG_##arg5(5); \ 102 SCRIPT_ARG_##arg6(6); \ 103 SCRIPT_ARG_##arg7(7); \ 104 SCRIPT_RETURN_CALL_##return funcname(_arg0, _arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7); \ 105 SCRIPT_FUNC_END(funcname, return ) 106 #define SCRIPT_DEFINE_FUNC_9(return, funcname, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) \ 107 SCRIPT_FUNC_BEGIN(funcname, return, #arg0 "," #arg1 "," #arg2 "," #arg3 "," #arg4 "," #arg5 "," #arg6 "," #arg7 "," #arg8) \ 108 SCRIPT_ARG_##arg0(0); \ 109 SCRIPT_ARG_##arg1(1); \ 110 SCRIPT_ARG_##arg2(2); \ 111 SCRIPT_ARG_##arg3(3); \ 112 SCRIPT_ARG_##arg4(4); \ 113 SCRIPT_ARG_##arg5(5); \ 114 SCRIPT_ARG_##arg6(6); \ 115 SCRIPT_ARG_##arg7(7); \ 116 SCRIPT_ARG_##arg8(8); \ 117 SCRIPT_RETURN_CALL_##return funcname(_arg0, _arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7, _arg8); \ 118 SCRIPT_FUNC_END(funcname, return ) 120 #define SCRIPT_DEFINE_FUNC_10(return, funcname, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) \ 121 SCRIPT_FUNC_BEGIN(funcname, return, #arg0 "," #arg1 "," #arg2 "," #arg3 "," #arg4 "," #arg5 "," #arg6 "," #arg7 "," #arg8 "," #arg9) \ 122 SCRIPT_ARG_##arg0(0); \ 123 SCRIPT_ARG_##arg1(1); \ 124 SCRIPT_ARG_##arg2(2); \ 125 SCRIPT_ARG_##arg3(3); \ 126 SCRIPT_ARG_##arg4(4); \ 127 SCRIPT_ARG_##arg5(5); \ 128 SCRIPT_ARG_##arg6(6); \ 129 SCRIPT_ARG_##arg7(7); \ 130 SCRIPT_ARG_##arg8(8); \ 131 SCRIPT_ARG_##arg9(9); \ 132 SCRIPT_RETURN_CALL_##return funcname(_arg0, _arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7, _arg8, _arg9); \ 133 SCRIPT_FUNC_END(funcname, return ) 135 #define SCRIPT_DEFINE_FUNC_12(return, funcname, arg0, arg1, arg2, arg3, arg4, arg5, arg6, \ 136 arg7, arg8, arg9, arg10, arg11) \ 137 SCRIPT_FUNC_BEGIN(funcname, return, #arg0 "," #arg1 "," #arg2 "," #arg3 "," #arg4 "," #arg5 "," #arg6 "," #arg7 "," #arg8 "," #arg9 "," #arg10 "," #arg11) \ 138 SCRIPT_ARG_##arg0(0); \ 139 SCRIPT_ARG_##arg1(1); \ 140 SCRIPT_ARG_##arg2(2); \ 141 SCRIPT_ARG_##arg3(3); \ 142 SCRIPT_ARG_##arg4(4); \ 143 SCRIPT_ARG_##arg5(5); \ 144 SCRIPT_ARG_##arg6(6); \ 145 SCRIPT_ARG_##arg7(7); \ 146 SCRIPT_ARG_##arg8(8); \ 147 SCRIPT_ARG_##arg9(9); \ 148 SCRIPT_ARG_##arg10(10); \ 149 SCRIPT_ARG_##arg11(11); \ 150 SCRIPT_RETURN_CALL_##return funcname(_arg0, _arg1, _arg2, _arg3, _arg4, _arg5, _arg6, \ 151 _arg7, _arg8, _arg9, _arg10, _arg11); \ 152 SCRIPT_FUNC_END(funcname, return ) 153 #define SCRIPT_DEFINE_FUNC_17(return, funcname, arg0, arg1, arg2, arg3, arg4, arg5, arg6, \ 154 arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16) \ 155 SCRIPT_FUNC_BEGIN(funcname, return, #arg0 "," #arg1 "," #arg2 "," #arg3 "," #arg4 "," #arg5 "," #arg6 "," #arg7 "," #arg8 "," #arg9 "," #arg10 "," #arg11 "," #arg12 "," #arg13 "," #arg14 "," #arg15 "," #arg16) \ 156 SCRIPT_ARG_##arg0(0); \ 157 SCRIPT_ARG_##arg1(1); \ 158 SCRIPT_ARG_##arg2(2); \ 159 SCRIPT_ARG_##arg3(3); \ 160 SCRIPT_ARG_##arg4(4); \ 161 SCRIPT_ARG_##arg5(5); \ 162 SCRIPT_ARG_##arg6(6); \ 163 SCRIPT_ARG_##arg7(7); \ 164 SCRIPT_ARG_##arg8(8); \ 165 SCRIPT_ARG_##arg9(9); \ 166 SCRIPT_ARG_##arg10(10); \ 167 SCRIPT_ARG_##arg11(11); \ 168 SCRIPT_ARG_##arg12(12); \ 169 SCRIPT_ARG_##arg13(13); \ 170 SCRIPT_ARG_##arg14(14); \ 171 SCRIPT_ARG_##arg15(15); \ 172 SCRIPT_ARG_##arg16(16); \ 173 SCRIPT_RETURN_CALL_##return funcname(_arg0, _arg1, _arg2, _arg3, _arg4, _arg5, _arg6, \ 174 _arg7, _arg8, _arg9, _arg10, _arg11, _arg12, _arg13, _arg14, _arg15, _arg16); \ 175 SCRIPT_FUNC_END(funcname, return ) 177 #define SCRIPT_FUNC_BEGIN(funcname, return, args) \ 178 namespace GenericScript { \ 179 static const char *funcname##_return = #return; \ 180 static const char *funcname##_arg = args; \ 181 void funcname##_Generic(asIScriptGeneric * gen) { \ 182 SCRIPT_RETURN_##return; 184 #define SCRIPT_FUNC_END(funcname, return ) \ 185 SCRIPT_SET_RETURN_##return; \ 191 #define SCRIPT_ARG_string(n) tString _arg##n = (*(Common::String *)gen->GetArgObject(n)) 192 #define SCRIPT_ARG_float(n) float _arg##n = gen->GetArgFloat(n) 193 #define SCRIPT_ARG_int(n) int _arg##n = gen->GetArgDWord(n) 194 #define SCRIPT_ARG_bool(n) bool _arg##n = gen->GetArgByte(n) 196 #define SCRIPT_RETURN_string tString _ret 197 #define SCRIPT_RETURN_CALL_string _ret = 198 #define SCRIPT_SET_RETURN_string gen->SetReturnObject(&_ret) 199 #define SCRIPT_RETURN_bool bool _ret 200 #define SCRIPT_RETURN_CALL_bool _ret = 201 #define SCRIPT_SET_RETURN_bool gen->SetReturnByte(_ret ? -1 : 0) 202 #define SCRIPT_RETURN_int int _ret 203 #define SCRIPT_RETURN_CALL_int _ret = 204 #define SCRIPT_SET_RETURN_int gen->SetReturnDWord(_ret) 205 #define SCRIPT_RETURN_float float _ret 206 #define SCRIPT_RETURN_CALL_float _ret = 207 #define SCRIPT_SET_RETURN_float gen->SetReturnFloat(_ret) 208 #define SCRIPT_RETURN_void 209 #define SCRIPT_RETURN_CALL_void 210 #define SCRIPT_SET_RETURN_void 212 #define AS_MAX_PORTABILITY 213 #if defined(AS_MAX_PORTABILITY) 214 #define SCRIPT_REGISTER_FUNC(funcname) \ 215 Common::String(GenericScript::funcname##_return) + " " + Common::String(#funcname) + " (" + Common::String(GenericScript::funcname##_arg) + ")", GenericScript::funcname##_Generic, asCALL_GENERIC 217 #define SCRIPT_REGISTER_FUNC(funcname) \ 218 GenericScript::funcname##_return + " " #funcname " (" + GenericScript::funcname##_arg + ")", (void *)funcname, asCALL_STDCALL 232 virtual bool CreateFromFile(
const tString &asFile) = 0;
234 virtual int GetFuncHandle(
const tString &asFunc) = 0;
236 virtual void AddArg(
const tString &asArg) = 0;
243 virtual bool Run(
const tString &asFuncLine) = 0;
245 virtual bool Run(
int alHandle) = 0;
250 #endif // HPL_SCRIPT_H
Definition: ResourceBase.h:36
void unload()
Definition: Script.h:229
void destroy()
Definition: Script.h:230
bool reload()
Definition: Script.h:228
virtual bool Run(const tString &asFuncLine)=0