| 1366 | extern S32 executeBlock(StmtNode *block, ExprEvalState *state); |
| 1367 | |
| 1368 | ConsoleValue Namespace::Entry::execute(S32 argc, ConsoleValue *argv, ExprEvalState *state) |
| 1369 | { |
| 1370 | STR.clearFunctionOffset(); |
| 1371 | |
| 1372 | if (mType == ConsoleFunctionType) |
| 1373 | { |
| 1374 | if (mFunctionOffset) |
| 1375 | { |
| 1376 | return std::move(mCode->exec(mFunctionOffset, argv[0].getString(), mNamespace, argc, argv, false, mPackage)); |
| 1377 | } |
| 1378 | else |
| 1379 | { |
| 1380 | return std::move(ConsoleValue()); |
| 1381 | } |
| 1382 | } |
| 1383 | |
| 1384 | #ifndef TORQUE_DEBUG |
| 1385 | // [tom, 12/13/2006] This stops tools functions from working in the console, |
| 1386 | // which is useful behavior when debugging so I'm ifdefing this out for debug builds. |
| 1387 | if (mToolOnly && !Con::isCurrentScriptToolScript()) |
| 1388 | { |
| 1389 | Con::errorf(ConsoleLogEntry::Script, "%s::%s - attempting to call tools only function from outside of tools", mNamespace->mName, mFunctionName); |
| 1390 | return std::move(ConsoleValue()); |
| 1391 | } |
| 1392 | #endif |
| 1393 | |
| 1394 | if ((mMinArgs && argc < mMinArgs) || (mMaxArgs && argc > mMaxArgs)) |
| 1395 | { |
| 1396 | Con::warnf(ConsoleLogEntry::Script, "%s::%s - wrong number of arguments.", mNamespace->mName, mFunctionName); |
| 1397 | Con::warnf(ConsoleLogEntry::Script, "usage: %s", mUsage); |
| 1398 | return std::move(ConsoleValue()); |
| 1399 | } |
| 1400 | |
| 1401 | ConsoleValue result; |
| 1402 | switch (mType) |
| 1403 | { |
| 1404 | case StringCallbackType: |
| 1405 | { |
| 1406 | const char* str = cb.mStringCallbackFunc(state->thisObject, argc, argv); |
| 1407 | result.setString(str); |
| 1408 | break; |
| 1409 | } |
| 1410 | case IntCallbackType: |
| 1411 | result.setInt(cb.mIntCallbackFunc(state->thisObject, argc, argv)); |
| 1412 | break; |
| 1413 | case FloatCallbackType: |
| 1414 | result.setFloat(cb.mFloatCallbackFunc(state->thisObject, argc, argv)); |
| 1415 | break; |
| 1416 | case VoidCallbackType: |
| 1417 | cb.mVoidCallbackFunc(state->thisObject, argc, argv); |
| 1418 | break; |
| 1419 | case BoolCallbackType: |
| 1420 | result.setBool(cb.mBoolCallbackFunc(state->thisObject, argc, argv)); |
| 1421 | break; |
| 1422 | } |
| 1423 | |
| 1424 | return std::move(result); |
| 1425 | } |
no test coverage detected