| 379 | |
| 380 | |
| 381 | void ScriptCallable::pushArgs(CppiaCtx *ctx, hx::Object *inThis, Expressions &inArgs) |
| 382 | { |
| 383 | BCR_VCHECK; |
| 384 | int inCount = inArgs.size(); |
| 385 | bool badCount = argCount<inCount; |
| 386 | |
| 387 | for(int i=inCount;i<argCount && !badCount;i++) |
| 388 | if (!hasDefault[i]) |
| 389 | badCount = true; |
| 390 | |
| 391 | if (badCount) |
| 392 | { |
| 393 | printf("Arg count mismatch %d!=%d ?\n", argCount, (int)inArgs.size()); |
| 394 | printf(" %s at %s:%d %s\n", getName(), filename, line, functionName); |
| 395 | CPPIA_CHECK(0); |
| 396 | throw Dynamic(HX_CSTRING("Arg count error")); |
| 397 | //return; |
| 398 | } |
| 399 | |
| 400 | |
| 401 | ctx->push( inThis ); |
| 402 | |
| 403 | for(int a=0;a<argCount;a++) |
| 404 | { |
| 405 | CppiaStackVar &var = args[a]; |
| 406 | if (a>=inCount) |
| 407 | { |
| 408 | pushDefault(ctx,a); |
| 409 | } |
| 410 | else |
| 411 | { |
| 412 | switch(var.argType) |
| 413 | { |
| 414 | case etInt: |
| 415 | ctx->pushInt(inArgs[a]->runInt(ctx)); |
| 416 | break; |
| 417 | case etFloat: |
| 418 | ctx->pushFloat(inArgs[a]->runFloat(ctx)); |
| 419 | break; |
| 420 | case etString: |
| 421 | ctx->pushString(inArgs[a]->runString(ctx)); |
| 422 | break; |
| 423 | default: |
| 424 | ctx->pushObject(inArgs[a]->runObject(ctx)); |
| 425 | } |
| 426 | BCR_VCHECK; |
| 427 | } |
| 428 | } |
| 429 | } |
| 430 | |
| 431 | |
| 432 | |