29 #ifndef AGS_ENGINE_SCRIPT_SCRIPT_API_H 30 #define AGS_ENGINE_SCRIPT_SCRIPT_API_H 33 #include "ags/shared/core/types.h" 34 #include "ags/engine/ac/runtime_defines.h" 35 #include "ags/shared/debugging/out.h" 39 struct RuntimeScriptValue;
42 typedef RuntimeScriptValue ScriptAPIFunction(
const RuntimeScriptValue *params, int32_t param_count);
43 typedef RuntimeScriptValue ScriptAPIObjectFunction(
void *
self,
const RuntimeScriptValue *params, int32_t param_count);
48 const char *ScriptSprintf(
char *buffer,
size_t buf_length,
const char *format,
49 const RuntimeScriptValue *sc_args, int32_t sc_argc, va_list *varg_ptr);
51 inline const char *ScriptSprintf(
char *buffer,
size_t buf_length,
const char *format,
const RuntimeScriptValue *args, int32_t argc) {
52 return ScriptSprintf(buffer, buf_length, format, args, argc,
nullptr);
56 inline const char *ScriptVSprintf(
char *buffer,
size_t buf_length,
const char *format, va_list &arg_ptr) {
57 return ScriptSprintf(buffer, buf_length, format,
nullptr, 0, &arg_ptr);
63 #define API_FN_PAIR(FN_NAME) Sc_##FN_NAME, (void *)FN_NAME 67 #define ASSERT_SELF(METHOD) \ 68 (void)params; (void)param_count; \ 69 assert((self != NULL) && "Object pointer is null in call to API function") 70 #define ASSERT_PARAM_COUNT(FUNCTION, X) \ 71 (void)params; (void)param_count; \ 72 assert((params != NULL && param_count >= X) && "Not enough parameters in call to API function") 73 #define ASSERT_VARIABLE_VALUE(VARIABLE) \ 74 (void)params; (void)param_count; \ 75 assert((params != NULL && param_count >= 1) && "Not enough parameters to set API property") 76 #define ASSERT_OBJ_PARAM_COUNT(METHOD, X) \ 77 ASSERT_SELF(METHOD); \ 78 ASSERT_PARAM_COUNT(METHOD, X) 83 #define API_SCALL_SCRIPT_SPRINTF(FUNCTION, PARAM_COUNT) \ 84 ASSERT_PARAM_COUNT(FUNCTION, PARAM_COUNT); \ 85 char ScSfBuffer[STD_BUFFER_SIZE]; \ 86 const char *scsf_buffer = ScriptSprintf(ScSfBuffer, STD_BUFFER_SIZE, get_translation(params[PARAM_COUNT - 1].CStr), params + PARAM_COUNT, param_count - PARAM_COUNT) 88 #define API_OBJCALL_SCRIPT_SPRINTF(METHOD, PARAM_COUNT) \ 89 ASSERT_OBJ_PARAM_COUNT(METHOD, PARAM_COUNT); \ 90 char ScSfBuffer[STD_BUFFER_SIZE]; \ 91 const char *scsf_buffer = ScriptSprintf(ScSfBuffer, STD_BUFFER_SIZE, get_translation(params[PARAM_COUNT - 1].CStr), params + PARAM_COUNT, param_count - PARAM_COUNT) 96 #define API_SCALL_SCRIPT_SPRINTF_PURE(FUNCTION, PARAM_COUNT) \ 97 ASSERT_PARAM_COUNT(FUNCTION, PARAM_COUNT); \ 98 char ScSfBuffer[STD_BUFFER_SIZE]; \ 99 const char *scsf_buffer = ScriptSprintf(ScSfBuffer, STD_BUFFER_SIZE, params[PARAM_COUNT - 1].CStr, params + PARAM_COUNT, param_count - PARAM_COUNT) 105 #define API_PLUGIN_SCRIPT_SPRINTF(FORMAT_STR) \ 107 va_start(args, FORMAT_STR); \ 108 char ScSfBuffer[STD_BUFFER_SIZE]; \ 109 const char *scsf_buffer = ScriptVSprintf(ScSfBuffer, STD_BUFFER_SIZE, get_translation(FORMAT_STR), args); \ 112 #define API_PLUGIN_SCRIPT_SPRINTF_PURE(FORMAT_STR) \ 114 va_start(args, FORMAT_STR); \ 115 char ScSfBuffer[STD_BUFFER_SIZE]; \ 116 const char *scsf_buffer = ScriptVSprintf(ScSfBuffer, STD_BUFFER_SIZE, FORMAT_STR, args); \ 129 #define API_SCALL_VOID(FUNCTION) \ 130 (void)params; (void)param_count; \ 132 return RuntimeScriptValue((int32_t)0) 134 #define API_SCALL_VOID_PBOOL(FUNCTION) \ 135 ASSERT_PARAM_COUNT(FUNCTION, 1); \ 136 FUNCTION(params[0].GetAsBool()); \ 137 return RuntimeScriptValue((int32_t)0) 139 #define API_SCALL_VOID_PINT(FUNCTION) \ 140 ASSERT_PARAM_COUNT(FUNCTION, 1); \ 141 FUNCTION(params[0].IValue); \ 142 return RuntimeScriptValue((int32_t)0) 144 #define API_SCALL_VOID_PINT2(FUNCTION) \ 145 ASSERT_PARAM_COUNT(FUNCTION, 2); \ 146 FUNCTION(params[0].IValue, params[1].IValue); \ 147 return RuntimeScriptValue((int32_t)0) 149 #define API_SCALL_VOID_PINT3(FUNCTION) \ 150 ASSERT_PARAM_COUNT(FUNCTION, 3); \ 151 FUNCTION(params[0].IValue, params[1].IValue, params[2].IValue); \ 152 return RuntimeScriptValue((int32_t)0) 154 #define API_SCALL_VOID_PINT4(FUNCTION) \ 155 ASSERT_PARAM_COUNT(FUNCTION, 4); \ 156 FUNCTION(params[0].IValue, params[1].IValue, params[2].IValue, params[3].IValue); \ 157 return RuntimeScriptValue((int32_t)0) 159 #define API_SCALL_VOID_PINT5(FUNCTION) \ 160 ASSERT_PARAM_COUNT(FUNCTION, 5); \ 161 FUNCTION(params[0].IValue, params[1].IValue, params[2].IValue, params[3].IValue, params[4].IValue); \ 162 return RuntimeScriptValue((int32_t)0) 164 #define API_SCALL_VOID_PINT6(FUNCTION) \ 165 ASSERT_PARAM_COUNT(FUNCTION, 6); \ 166 FUNCTION(params[0].IValue, params[1].IValue, params[2].IValue, params[3].IValue, params[4].IValue, params[5].IValue); \ 167 return RuntimeScriptValue((int32_t)0) 169 #define API_SCALL_VOID_PINT_POBJ(FUNCTION, P1CLASS) \ 170 ASSERT_PARAM_COUNT(FUNCTION, 2); \ 171 FUNCTION(params[0].IValue, (P1CLASS*)params[1].Ptr); \ 172 return RuntimeScriptValue((int32_t)0) 174 #define API_SCALL_VOID_PINT_POBJ2(FUNCTION, P1CLASS, P2CLASS) \ 175 ASSERT_PARAM_COUNT(FUNCTION, 3); \ 176 FUNCTION(params[0].IValue, (P1CLASS*)params[1].Ptr, (P2CLASS*)params[2].Ptr); \ 177 return RuntimeScriptValue((int32_t)0) 179 #define API_SCALL_VOID_PINT2_POBJ(FUNCTION, P1CLASS) \ 180 ASSERT_PARAM_COUNT(FUNCTION, 3); \ 181 FUNCTION(params[0].IValue, params[1].IValue, (P1CLASS*)params[2].Ptr); \ 182 return RuntimeScriptValue((int32_t)0) 184 #define API_SCALL_VOID_PINT3_POBJ_PINT(FUNCTION, P1CLASS) \ 185 ASSERT_PARAM_COUNT(FUNCTION, 5); \ 186 FUNCTION(params[0].IValue, params[1].IValue, params[2].IValue, (P1CLASS*)params[3].Ptr, params[4].IValue); \ 187 return RuntimeScriptValue((int32_t)0) 189 #define API_SCALL_VOID_PINT4_POBJ(FUNCTION, P1CLASS) \ 190 ASSERT_PARAM_COUNT(FUNCTION, 5); \ 191 FUNCTION(params[0].IValue, params[1].IValue, params[2].IValue, params[3].IValue, (P1CLASS*)params[4].Ptr); \ 192 return RuntimeScriptValue((int32_t)0) 194 #define API_SCALL_VOID_PFLOAT2(FUNCTION) \ 195 ASSERT_PARAM_COUNT(FUNCTION, 2); \ 196 FUNCTION(params[0].FValue, params[1].FValue); \ 197 return RuntimeScriptValue((int32_t)0) 199 #define API_SCALL_VOID_POBJ(FUNCTION, P1CLASS) \ 200 ASSERT_PARAM_COUNT(FUNCTION, 1); \ 201 FUNCTION((P1CLASS*)params[0].Ptr); \ 202 return RuntimeScriptValue((int32_t)0) 204 #define API_SCALL_VOID_POBJ_PINT(FUNCTION, P1CLASS) \ 205 ASSERT_PARAM_COUNT(FUNCTION, 2); \ 206 FUNCTION((P1CLASS*)params[0].Ptr, params[1].IValue); \ 207 return RuntimeScriptValue((int32_t)0) 209 #define API_SCALL_VOID_POBJ_PINT2(FUNCTION, P1CLASS) \ 210 ASSERT_PARAM_COUNT(FUNCTION, 3); \ 211 FUNCTION((P1CLASS*)params[0].Ptr, params[1].IValue, params[2].IValue); \ 212 return RuntimeScriptValue((int32_t)0) 214 #define API_SCALL_VOID_POBJ2(FUNCTION, P1CLASS, P2CLASS) \ 215 ASSERT_PARAM_COUNT(FUNCTION, 2); \ 216 FUNCTION((P1CLASS*)params[0].Ptr, (P2CLASS*)params[1].Ptr); \ 217 return RuntimeScriptValue((int32_t)0) 219 #define API_SCALL_INT(FUNCTION) \ 220 (void)params; (void)param_count; \ 221 return RuntimeScriptValue().SetInt32(FUNCTION()) 223 #define API_SCALL_INT_PINT(FUNCTION) \ 224 ASSERT_PARAM_COUNT(FUNCTION, 1); \ 225 return RuntimeScriptValue().SetInt32(FUNCTION(params[0].IValue)) 227 #define API_SCALL_INT_PINT2(FUNCTION) \ 228 ASSERT_PARAM_COUNT(FUNCTION, 2); \ 229 return RuntimeScriptValue().SetInt32(FUNCTION(params[0].IValue, params[1].IValue)) 231 #define API_SCALL_INT_PINT3(FUNCTION) \ 232 ASSERT_PARAM_COUNT(FUNCTION, 3); \ 233 return RuntimeScriptValue().SetInt32(FUNCTION(params[0].IValue, params[1].IValue, params[2].IValue)) 235 #define API_SCALL_INT_PINT4(FUNCTION) \ 236 ASSERT_PARAM_COUNT(FUNCTION, 4); \ 237 return RuntimeScriptValue().SetInt32(FUNCTION(params[0].IValue, params[1].IValue, params[2].IValue, params[3].IValue)) 239 #define API_SCALL_INT_PINT4_PFLOAT(FUNCTION) \ 240 ASSERT_PARAM_COUNT(FUNCTION, 5) \ 241 return RuntimeScriptValue().SetInt32(FUNCTION(params[0].IValue, params[1].IValue, params[2].IValue, params[3].IValue, params[3].FValue)) 243 #define API_SCALL_INT_PINT5(FUNCTION) \ 244 ASSERT_PARAM_COUNT(FUNCTION, 5); \ 245 return RuntimeScriptValue().SetInt32(FUNCTION(params[0].IValue, params[1].IValue, params[2].IValue, params[3].IValue, params[4].IValue)) 247 #define API_SCALL_INT_PFLOAT_PINT(FUNCTION) \ 248 ASSERT_PARAM_COUNT(FUNCTION, 2); \ 249 return RuntimeScriptValue().SetInt32(FUNCTION(params[0].FValue, params[1].IValue)) 251 #define API_SCALL_INT_POBJ(FUNCTION, P1CLASS) \ 252 ASSERT_PARAM_COUNT(FUNCTION, 1); \ 253 return RuntimeScriptValue().SetInt32(FUNCTION((P1CLASS*)params[0].Ptr)) 255 #define API_SCALL_INT_POBJ_PINT(FUNCTION, P1CLASS) \ 256 ASSERT_PARAM_COUNT(FUNCTION, 2); \ 257 return RuntimeScriptValue().SetInt32(FUNCTION((P1CLASS*)params[0].Ptr, params[1].IValue)) 259 #define API_SCALL_INT_POBJ_PINT2(FUNCTION, P1CLASS) \ 260 ASSERT_PARAM_COUNT(FUNCTION, 3); \ 261 return RuntimeScriptValue().SetInt32(FUNCTION((P1CLASS*)params[0].Ptr, params[1].IValue, params[2].IValue)) 263 #define API_SCALL_INT_POBJ2(FUNCTION, P1CLASS, P2CLASS) \ 264 ASSERT_PARAM_COUNT(FUNCTION, 2); \ 265 return RuntimeScriptValue().SetInt32(FUNCTION((P1CLASS*)params[0].Ptr, (P2CLASS*)params[1].Ptr)) 267 #define API_SCALL_INT_PINT_POBJ(FUNCTION, P1CLASS) \ 268 ASSERT_PARAM_COUNT(FUNCTION, 2); \ 269 return RuntimeScriptValue().SetInt32(FUNCTION(params[0].IValue, (P1CLASS*)params[1].Ptr)) 271 #define API_SCALL_FLOAT(FUNCTION) \ 272 (void)params; (void)param_count; \ 273 return RuntimeScriptValue().SetFloat(FUNCTION()) 275 #define API_SCALL_FLOAT_PINT(FUNCTION) \ 276 ASSERT_PARAM_COUNT(FUNCTION, 1); \ 277 return RuntimeScriptValue().SetFloat(FUNCTION(params[0].IValue)) 279 #define API_SCALL_FLOAT_PFLOAT(FUNCTION) \ 280 ASSERT_PARAM_COUNT(FUNCTION, 1); \ 281 return RuntimeScriptValue().SetFloat(FUNCTION(params[0].FValue)) 283 #define API_SCALL_FLOAT_PFLOAT2(FUNCTION) \ 284 ASSERT_PARAM_COUNT(FUNCTION, 2); \ 285 return RuntimeScriptValue().SetFloat(FUNCTION(params[0].FValue, params[1].FValue)) 287 #define API_SCALL_BOOL(FUNCTION) \ 288 (void)params; (void)param_count; \ 289 return RuntimeScriptValue().SetInt32AsBool(FUNCTION()) 291 #define API_SCALL_BOOL_POBJ(FUNCTION, P1CLASS) \ 292 ASSERT_PARAM_COUNT(FUNCTION, 1); \ 293 return RuntimeScriptValue().SetInt32AsBool(FUNCTION((P1CLASS*)params[0].Ptr)) 295 #define API_SCALL_BOOL_PINT(FUNCTION) \ 296 ASSERT_PARAM_COUNT(FUNCTION, 1); \ 297 return RuntimeScriptValue().SetInt32AsBool(FUNCTION(params[0].IValue)) 299 #define API_SCALL_BOOL_POBJ_PINT(FUNCTION, P1CLASS) \ 300 ASSERT_PARAM_COUNT(FUNCTION, 2); \ 301 return RuntimeScriptValue().SetInt32AsBool(FUNCTION((P1CLASS*)params[0].Ptr, params[1].IValue)) 303 #define API_SCALL_BOOL_POBJ2(FUNCTION, P1CLASS, P2CLASS) \ 304 ASSERT_PARAM_COUNT(FUNCTION, 2); \ 305 return RuntimeScriptValue().SetInt32AsBool(FUNCTION((P1CLASS*)params[0].Ptr, (P2CLASS*)params[1].Ptr)) 307 #define API_SCALL_OBJ(RET_CLASS, RET_MGR, FUNCTION) \ 308 (void)params; (void)param_count; \ 309 return RuntimeScriptValue().SetScriptObject(const_cast<void *>((const void *)(RET_CLASS*)FUNCTION()), &RET_MGR) 314 #define API_SCALL_OBJ_PINT(RET_CLASS, RET_MGR, FUNCTION) \ 315 ASSERT_PARAM_COUNT(FUNCTION, 1); \ 316 return RuntimeScriptValue().SetScriptObject(const_cast<void *>((const void *)(RET_CLASS*)FUNCTION(params[0].IValue)), &RET_MGR) 322 #define API_SCALL_OBJ_POBJ_PINT_PBOOL(RET_CLASS, RET_MGR, FUNCTION, P1CLASS) \ 323 ASSERT_PARAM_COUNT(FUNCTION, 3); \ 324 return RuntimeScriptValue().SetScriptObject((void*)(RET_CLASS*)FUNCTION((P1CLASS*)params[0].Ptr, params[1].IValue, params[2].GetAsBool()), &RET_MGR) 326 #define API_SCALL_OBJ_PINT2(RET_CLASS, RET_MGR, FUNCTION) \ 327 ASSERT_PARAM_COUNT(FUNCTION, 2); \ 328 return RuntimeScriptValue().SetScriptObject(const_cast<void *>((const void *)(RET_CLASS*)FUNCTION(params[0].IValue, params[1].IValue)), &RET_MGR) 334 #define API_SCALL_OBJ_PINT3_POBJ(RET_CLASS, RET_MGR, FUNCTION, P1CLASS) \ 335 ASSERT_PARAM_COUNT(FUNCTION, 4); \ 336 return RuntimeScriptValue().SetScriptObject((void*)(RET_CLASS*)FUNCTION(params[0].IValue, params[1].IValue, params[2].IValue, (P1CLASS*)params[3].Ptr), &RET_MGR) 338 #define API_SCALL_OBJ_POBJ(RET_CLASS, RET_MGR, FUNCTION, P1CLASS) \ 339 ASSERT_PARAM_COUNT(FUNCTION, 1); \ 340 return RuntimeScriptValue().SetScriptObject(const_cast<void *>((const void *)(RET_CLASS*)FUNCTION((P1CLASS*)params[0].Ptr)), &RET_MGR) 346 #define API_SCALL_OBJAUTO(RET_CLASS, FUNCTION) \ 347 (void)params; (void)param_count; \ 348 RET_CLASS* ret_obj = FUNCTION(); \ 349 return RuntimeScriptValue().SetScriptObject(ret_obj, ret_obj) 351 #define API_SCALL_OBJAUTO_PINT(RET_CLASS, FUNCTION) \ 352 ASSERT_PARAM_COUNT(FUNCTION, 1); \ 353 RET_CLASS* ret_obj = FUNCTION(params[0].IValue); \ 354 return RuntimeScriptValue().SetScriptObject(ret_obj, ret_obj) 356 #define API_SCALL_OBJAUTO_PINT2(RET_CLASS, FUNCTION) \ 357 ASSERT_PARAM_COUNT(FUNCTION, 2); \ 358 RET_CLASS* ret_obj = FUNCTION(params[0].IValue, params[1].IValue); \ 359 return RuntimeScriptValue().SetScriptObject(ret_obj, ret_obj) 361 #define API_SCALL_OBJAUTO_PINT3(RET_CLASS, FUNCTION) \ 362 ASSERT_PARAM_COUNT(FUNCTION, 3); \ 363 RET_CLASS* ret_obj = FUNCTION(params[0].IValue, params[1].IValue, params[2].IValue); \ 364 return RuntimeScriptValue().SetScriptObject(ret_obj, ret_obj) 366 #define API_SCALL_OBJAUTO_PINT4(RET_CLASS, FUNCTION) \ 367 ASSERT_PARAM_COUNT(FUNCTION, 4); \ 368 RET_CLASS* ret_obj = FUNCTION(params[0].IValue, params[1].IValue, params[2].IValue, params[3].IValue); \ 369 return RuntimeScriptValue().SetScriptObject(ret_obj, ret_obj) 371 #define API_SCALL_OBJAUTO_PINT5(RET_CLASS, FUNCTION) \ 372 ASSERT_PARAM_COUNT(FUNCTION, 5); \ 373 RET_CLASS* ret_obj = FUNCTION(params[0].IValue, params[1].IValue, params[2].IValue, params[3].IValue, params[4].IValue); \ 374 return RuntimeScriptValue().SetScriptObject(ret_obj, ret_obj) 376 #define API_SCALL_OBJAUTO_PINT2_PBOOL(RET_CLASS, FUNCTION) \ 377 ASSERT_PARAM_COUNT(FUNCTION, 3); \ 378 RET_CLASS *ret_obj = FUNCTION(params[0].IValue, params[1].IValue, params[2].GetAsBool()); \ 379 return RuntimeScriptValue().SetScriptObject(ret_obj, ret_obj) 381 #define API_SCALL_OBJAUTO_PINT3_PBOOL(RET_CLASS, FUNCTION) \ 382 ASSERT_PARAM_COUNT(FUNCTION, 4); \ 383 RET_CLASS *ret_obj = FUNCTION(params[0].IValue, params[1].IValue, params[2].IValue, params[3].GetAsBool()); \ 384 return RuntimeScriptValue().SetScriptObject(ret_obj, ret_obj) 386 #define API_SCALL_OBJAUTO_PINT3_PBOOL2(RET_CLASS, FUNCTION) \ 387 ASSERT_PARAM_COUNT(FUNCTION, 5); \ 388 RET_CLASS *ret_obj = FUNCTION(params[0].IValue, params[1].IValue, params[2].IValue, params[3].GetAsBool(), params[4].GetAsBool()); \ 389 return RuntimeScriptValue().SetScriptObject(ret_obj, ret_obj) 391 #define API_SCALL_OBJAUTO_PBOOL2(RET_CLASS, FUNCTION) \ 392 ASSERT_PARAM_COUNT(FUNCTION, 2); \ 393 RET_CLASS* ret_obj = FUNCTION(params[0].GetAsBool(), params[1].GetAsBool()); \ 394 return RuntimeScriptValue().SetScriptObject(ret_obj, ret_obj) 396 #define API_SCALL_OBJAUTO_POBJ(RET_CLASS, FUNCTION, P1CLASS) \ 397 ASSERT_PARAM_COUNT(FUNCTION, 1); \ 398 RET_CLASS* ret_obj = FUNCTION((P1CLASS*)params[0].Ptr); \ 399 return RuntimeScriptValue().SetScriptObject(ret_obj, ret_obj) 401 #define API_SCALL_OBJAUTO_POBJ_PINT(RET_CLASS, FUNCTION, P1CLASS) \ 402 ASSERT_PARAM_COUNT(FUNCTION, 2); \ 403 RET_CLASS* ret_obj = (RET_CLASS*)FUNCTION((P1CLASS*)params[0].Ptr, params[1].IValue); \ 404 return RuntimeScriptValue().SetScriptObject(ret_obj, ret_obj) 406 #define API_SCALL_OBJAUTO_POBJ_PINT4(RET_CLASS, FUNCTION, P1CLASS) \ 407 ASSERT_PARAM_COUNT(FUNCTION, 5); \ 408 RET_CLASS* ret_obj = FUNCTION((P1CLASS*)params[0].Ptr, params[1].IValue, params[2].IValue, params[3].IValue, params[4].IValue); \ 409 return RuntimeScriptValue().SetScriptObject(ret_obj, ret_obj) 412 #define API_SCALL_STOBJ_POBJ2(RET_CLASS, FUNCTION, P1CLASS, P2CLASS) \ 413 ASSERT_PARAM_COUNT(FUNCTION, 2); \ 414 RET_CLASS* ret_obj = FUNCTION((P1CLASS*)params[0].Ptr, (P2CLASS*)params[1].Ptr); \ 415 return RuntimeScriptValue().SetStaticObject(ret_obj, &_GP(GlobalStaticManager)) 420 #define API_OBJCALL_VOID(CLASS, METHOD) \ 421 ASSERT_SELF(METHOD); \ 422 METHOD((CLASS*)self); \ 423 return RuntimeScriptValue((int32_t)0) 425 #define API_OBJCALL_VOID_PINT(CLASS, METHOD) \ 426 ASSERT_OBJ_PARAM_COUNT(METHOD, 1); \ 427 METHOD((CLASS*)self, params[0].IValue); \ 428 return RuntimeScriptValue((int32_t)0) 430 #define API_OBJCALL_VOID_PINT2(CLASS, METHOD) \ 431 ASSERT_OBJ_PARAM_COUNT(METHOD, 2); \ 432 METHOD((CLASS*)self, params[0].IValue, params[1].IValue); \ 433 return RuntimeScriptValue((int32_t)0) 435 #define API_OBJCALL_VOID_PINT3(CLASS, METHOD) \ 436 ASSERT_OBJ_PARAM_COUNT(METHOD, 3); \ 437 METHOD((CLASS*)self, params[0].IValue, params[1].IValue, params[2].IValue); \ 438 return RuntimeScriptValue((int32_t)0) 440 #define API_OBJCALL_VOID_PINT4(CLASS, METHOD) \ 441 ASSERT_OBJ_PARAM_COUNT(METHOD, 4); \ 442 METHOD((CLASS*)self, params[0].IValue, params[1].IValue, params[2].IValue, params[3].IValue); \ 443 return RuntimeScriptValue((int32_t)0) 445 #define API_OBJCALL_VOID_PINT5(CLASS, METHOD) \ 446 ASSERT_OBJ_PARAM_COUNT(METHOD, 5); \ 447 METHOD((CLASS*)self, params[0].IValue, params[1].IValue, params[2].IValue, params[3].IValue, params[4].IValue); \ 448 return RuntimeScriptValue((int32_t)0) 450 #define API_OBJCALL_VOID_PINT6(CLASS, METHOD) \ 451 ASSERT_OBJ_PARAM_COUNT(METHOD, 6); \ 452 METHOD((CLASS*)self, params[0].IValue, params[1].IValue, params[2].IValue, params[3].IValue, params[4].IValue, params[5].IValue); \ 453 return RuntimeScriptValue((int32_t)0) 455 #define API_OBJCALL_VOID_PINT7(CLASS, METHOD) \ 456 ASSERT_OBJ_PARAM_COUNT(METHOD, 7); \ 457 METHOD((CLASS*)self, params[0].IValue, params[1].IValue, params[2].IValue, params[3].IValue, params[4].IValue, params[5].IValue, params[6].IValue); \ 458 return RuntimeScriptValue((int32_t)0) 460 #define API_OBJCALL_VOID_PINT8(CLASS, METHOD) \ 461 ASSERT_OBJ_PARAM_COUNT(METHOD, 8); \ 462 METHOD((CLASS*)self, params[0].IValue, params[1].IValue, params[2].IValue, params[3].IValue, params[4].IValue, params[5].IValue, params[6].IValue, params[7].IValue); \ 463 return RuntimeScriptValue((int32_t)0) 465 #define API_OBJCALL_VOID_PFLOAT(CLASS, METHOD) \ 466 ASSERT_OBJ_PARAM_COUNT(METHOD, 1); \ 467 METHOD((CLASS*)self, params[0].FValue); \ 468 return RuntimeScriptValue() 470 #define API_OBJCALL_VOID_PFLOAT2(CLASS, METHOD) \ 471 ASSERT_OBJ_PARAM_COUNT(METHOD, 2); \ 472 METHOD((CLASS*)self, params[0].FValue, params[1].FValue); \ 473 return RuntimeScriptValue() 475 #define API_OBJCALL_VOID_PBOOL(CLASS, METHOD) \ 476 ASSERT_OBJ_PARAM_COUNT(METHOD, 1); \ 477 METHOD((CLASS*)self, params[0].GetAsBool()); \ 478 return RuntimeScriptValue((int32_t)0) 480 #define API_OBJCALL_VOID_PINT_PBOOL(CLASS, METHOD) \ 481 ASSERT_OBJ_PARAM_COUNT(METHOD, 2); \ 482 METHOD((CLASS*)self, params[0].IValue, params[1].GetAsBool()); \ 483 return RuntimeScriptValue((int32_t)0) 485 #define API_OBJCALL_VOID_PINT_POBJ(CLASS, METHOD, P1CLASS) \ 486 ASSERT_OBJ_PARAM_COUNT(METHOD, 2); \ 487 METHOD((CLASS*)self, params[0].IValue, (P1CLASS*)params[1].Ptr); \ 488 return RuntimeScriptValue((int32_t)0) 490 #define API_OBJCALL_VOID_PINT3_POBJ(CLASS, METHOD, P1CLASS) \ 491 ASSERT_OBJ_PARAM_COUNT(METHOD, 4); \ 492 METHOD((CLASS*)self, params[0].IValue, params[1].IValue, params[2].IValue, (P1CLASS*)params[3].Ptr); \ 493 return RuntimeScriptValue((int32_t)0) 495 #define API_OBJCALL_VOID_PINT5_POBJ(CLASS, METHOD, P1CLASS) \ 496 ASSERT_OBJ_PARAM_COUNT(METHOD, 6); \ 497 METHOD((CLASS*)self, params[0].IValue, params[1].IValue, params[2].IValue, params[3].IValue, params[4].IValue, (P1CLASS*)params[5].Ptr); \ 498 return RuntimeScriptValue((int32_t)0) 500 #define API_OBJCALL_VOID_POBJ(CLASS, METHOD, P1CLASS) \ 501 ASSERT_OBJ_PARAM_COUNT(METHOD, 1); \ 502 METHOD((CLASS*)self, (P1CLASS*)params[0].Ptr); \ 503 return RuntimeScriptValue((int32_t)0) 505 #define API_OBJCALL_VOID_POBJ_PINT(CLASS, METHOD, P1CLASS) \ 506 ASSERT_OBJ_PARAM_COUNT(METHOD, 2); \ 507 METHOD((CLASS*)self, (P1CLASS*)params[0].Ptr, params[1].IValue); \ 508 return RuntimeScriptValue((int32_t)0) 510 #define API_OBJCALL_VOID_POBJ_PINT2(CLASS, METHOD, P1CLASS) \ 511 ASSERT_OBJ_PARAM_COUNT(METHOD, 3); \ 512 METHOD((CLASS*)self, (P1CLASS*)params[0].Ptr, params[1].IValue, params[2].IValue); \ 513 return RuntimeScriptValue((int32_t)0) 515 #define API_OBJCALL_VOID_POBJ2(CLASS, METHOD, P1CLASS, P2CLASS) \ 516 ASSERT_OBJ_PARAM_COUNT(METHOD, 2); \ 517 METHOD((CLASS*)self, (P1CLASS*)params[0].Ptr, (P2CLASS*)params[1].Ptr); \ 518 return RuntimeScriptValue((int32_t)0) 520 #define API_OBJCALL_INT(CLASS, METHOD) \ 521 ASSERT_SELF(METHOD); \ 522 return RuntimeScriptValue().SetInt32(METHOD((CLASS*)self)) 524 #define API_OBJCALL_INT_PINT(CLASS, METHOD) \ 525 ASSERT_OBJ_PARAM_COUNT(METHOD, 1); \ 526 return RuntimeScriptValue().SetInt32(METHOD((CLASS*)self, params[0].IValue)) 528 #define API_OBJCALL_INT_PINT_POBJ(CLASS, METHOD, P1CLASS) \ 529 ASSERT_OBJ_PARAM_COUNT(METHOD, 2); \ 530 return RuntimeScriptValue().SetInt32(METHOD((CLASS*)self, params[0].IValue, params[1].CStr)) 532 #define API_OBJCALL_INT_PINT2(CLASS, METHOD) \ 533 ASSERT_OBJ_PARAM_COUNT(METHOD, 2); \ 534 return RuntimeScriptValue().SetInt32(METHOD((CLASS*)self, params[0].IValue, params[1].IValue)) 536 #define API_OBJCALL_INT_POBJ(CLASS, METHOD, P1CLASS) \ 537 ASSERT_OBJ_PARAM_COUNT(METHOD, 1); \ 538 return RuntimeScriptValue().SetInt32(METHOD((CLASS*)self, (P1CLASS*)params[0].Ptr)) 540 #define API_OBJCALL_INT_POBJ_PINT(CLASS, METHOD, P1CLASS) \ 541 ASSERT_OBJ_PARAM_COUNT(METHOD, 2); \ 542 return RuntimeScriptValue().SetInt32(METHOD((CLASS*)self, (P1CLASS*)params[0].Ptr, params[1].IValue)) 544 #define API_OBJCALL_INT_POBJ_PBOOL(CLASS, METHOD, P1CLASS) \ 545 ASSERT_OBJ_PARAM_COUNT(METHOD, 2); \ 546 return RuntimeScriptValue().SetInt32(METHOD((CLASS*)self, (P1CLASS*)params[0].Ptr, params[1].GetAsBool())) 548 #define API_OBJCALL_FLOAT(CLASS, METHOD) \ 549 ASSERT_SELF(METHOD); \ 550 return RuntimeScriptValue().SetFloat(METHOD((CLASS*)self)) 552 #define API_OBJCALL_BOOL(CLASS, METHOD) \ 553 ASSERT_SELF(METHOD); \ 554 return RuntimeScriptValue().SetInt32AsBool(METHOD((CLASS*)self)) 556 #define API_OBJCALL_BOOL_PINT(CLASS, METHOD) \ 557 ASSERT_OBJ_PARAM_COUNT(METHOD, 1); \ 558 return RuntimeScriptValue().SetInt32AsBool(METHOD((CLASS*)self, params[0].IValue)) 560 #define API_OBJCALL_BOOL_POBJ(CLASS, METHOD, P1CLASS) \ 561 ASSERT_OBJ_PARAM_COUNT(METHOD, 1); \ 562 return RuntimeScriptValue().SetInt32AsBool(METHOD((CLASS*)self, (P1CLASS*)params[0].Ptr)) 564 #define API_OBJCALL_BOOL_POBJ_PINT(CLASS, METHOD, P1CLASS) \ 565 ASSERT_OBJ_PARAM_COUNT(METHOD, 2); \ 566 return RuntimeScriptValue().SetInt32AsBool(METHOD((CLASS*)self, (P1CLASS*)params[0].Ptr, params[1].IValue)) 568 #define API_OBJCALL_BOOL_POBJ2(CLASS, METHOD, P1CLASS, P2CLASS) \ 569 ASSERT_OBJ_PARAM_COUNT(METHOD, 2); \ 570 return RuntimeScriptValue().SetInt32AsBool(METHOD((CLASS*)self, (P1CLASS*)params[0].Ptr, (P2CLASS*)params[1].Ptr)) 572 #define API_OBJCALL_BOOL(CLASS, METHOD) \ 573 ASSERT_SELF(METHOD); \ 574 return RuntimeScriptValue().SetInt32AsBool(METHOD((CLASS*)self)) 576 #define API_OBJCALL_OBJ_PINT_POBJ(CLASS, RET_CLASS, RET_MGR, METHOD, P1CLASS) \ 577 ASSERT_OBJ_PARAM_COUNT(METHOD, 2); \ 578 return RuntimeScriptValue().SetScriptObject((void*)METHOD((CLASS*)self, params[0].IValue, (P1CLASS*)params[1].Ptr), &RET_MGR) 580 #define API_OBJCALL_OBJ_POBJ2_PINT(CLASS, RET_CLASS, RET_MGR, METHOD, P1CLASS, P2CLASS) \ 581 ASSERT_OBJ_PARAM_COUNT(METHOD, 3); \ 582 return RuntimeScriptValue().SetScriptObject((void*)METHOD((CLASS*)self, (P1CLASS*)params[0].Ptr, (P2CLASS*)params[1].Ptr, params[2].IValue), &RET_MGR) 584 #define API_OBJCALL_OBJ_POBJ2_PBOOL(CLASS, RET_CLASS, RET_MGR, METHOD, P1CLASS, P2CLASS) \ 585 ASSERT_OBJ_PARAM_COUNT(METHOD, 3); \ 586 return RuntimeScriptValue().SetScriptObject(const_cast<void *>((const void *)METHOD((CLASS*)self, (P1CLASS*)params[0].Ptr, (P2CLASS*)params[1].Ptr, params[2].GetAsBool())), &RET_MGR) 592 #define API_OBJCALL_OBJ(CLASS, RET_CLASS, RET_MGR, METHOD) \ 593 ASSERT_SELF(METHOD); \ 594 return RuntimeScriptValue().SetScriptObject(const_cast<void *>((const void *)(RET_CLASS*)METHOD((CLASS*)self)), &RET_MGR) 600 #define API_OBJCALL_OBJ_PINT(CLASS, RET_CLASS, RET_MGR, METHOD) \ 601 ASSERT_OBJ_PARAM_COUNT(METHOD, 1); \ 602 return RuntimeScriptValue().SetScriptObject(const_cast<void *>((const void *)(RET_CLASS*)METHOD((CLASS*)self, params[0].IValue)), &RET_MGR) 608 #define API_OBJCALL_OBJ_PINT2(CLASS, RET_CLASS, RET_MGR, METHOD) \ 609 ASSERT_OBJ_PARAM_COUNT(METHOD, 2); \ 610 return RuntimeScriptValue().SetScriptObject(const_cast<void *>((const void *)(RET_CLASS*)METHOD((CLASS*)self, params[0].IValue, params[1].IValue)), &RET_MGR) 616 #define API_OBJCALL_OBJ_PINT3(CLASS, RET_CLASS, RET_MGR, METHOD) \ 617 ASSERT_OBJ_PARAM_COUNT(METHOD, 3); \ 618 return RuntimeScriptValue().SetScriptObject((void*)(RET_CLASS*)METHOD((CLASS*)self, params[0].IValue, params[1].IValue, params[2].IValue), &RET_MGR) 620 #define API_OBJCALL_OBJ_POBJ(CLASS, RET_CLASS, RET_MGR, METHOD, P1CLASS) \ 621 ASSERT_OBJ_PARAM_COUNT(METHOD, 1); \ 622 return RuntimeScriptValue().SetScriptObject(const_cast<void *>((const void *)(RET_CLASS*)METHOD((CLASS*)self, (P1CLASS*)params[0].Ptr)), &RET_MGR) 628 #define API_OBJCALL_OBJAUTO(CLASS, RET_CLASS, METHOD) \ 629 ASSERT_SELF(METHOD); \ 630 RET_CLASS* ret_obj = METHOD((CLASS*)self); \ 631 return RuntimeScriptValue().SetScriptObject(ret_obj, ret_obj) 633 #define API_OBJCALL_OBJAUTO_PINT2_PBOOL(CLASS, RET_CLASS, METHOD) \ 634 ASSERT_OBJ_PARAM_COUNT(METHOD, 3); \ 635 RET_CLASS* ret_obj = METHOD((CLASS*)self, params[0].IValue, params[1].IValue, params[2].GetAsBool()); \ 636 return RuntimeScriptValue().SetScriptObject(ret_obj, ret_obj) 638 #define API_OBJCALL_OBJAUTO_POBJ(CLASS, RET_CLASS, METHOD, P1CLASS) \ 639 ASSERT_OBJ_PARAM_COUNT(METHOD, 1); \ 640 RET_CLASS* ret_obj = METHOD((CLASS*)self, (P1CLASS*)params[0].Ptr); \ 641 return RuntimeScriptValue().SetScriptObject(ret_obj, ret_obj)