MCPcopy Create free account
hub / github.com/GarageGames/Torque3D / execute

Method execute

Engine/source/console/consoleInternal.cpp:1383–1432  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1381extern S32 executeBlock(StmtNode *block, ExprEvalState *state);
1382
1383ConsoleValueRef Namespace::Entry::execute(S32 argc, ConsoleValueRef *argv, ExprEvalState *state)
1384{
1385 STR.clearFunctionOffset();
1386
1387 if(mType == ConsoleFunctionType)
1388 {
1389 if(mFunctionOffset)
1390 {
1391 return mCode->exec(mFunctionOffset, argv[0], mNamespace, argc, argv, false, mPackage);
1392 }
1393 else
1394 {
1395 return ConsoleValueRef();
1396 }
1397 }
1398
1399#ifndef TORQUE_DEBUG
1400 // [tom, 12/13/2006] This stops tools functions from working in the console,
1401 // which is useful behavior when debugging so I'm ifdefing this out for debug builds.
1402 if(mToolOnly && ! Con::isCurrentScriptToolScript())
1403 {
1404 Con::errorf(ConsoleLogEntry::Script, "%s::%s - attempting to call tools only function from outside of tools", mNamespace->mName, mFunctionName);
1405 return ConsoleValueRef();
1406 }
1407#endif
1408
1409 if((mMinArgs && argc < mMinArgs) || (mMaxArgs && argc > mMaxArgs))
1410 {
1411 Con::warnf(ConsoleLogEntry::Script, "%s::%s - wrong number of arguments.", mNamespace->mName, mFunctionName);
1412 Con::warnf(ConsoleLogEntry::Script, "usage: %s", mUsage);
1413 return ConsoleValueRef();
1414 }
1415
1416 switch(mType)
1417 {
1418 case StringCallbackType:
1419 return ConsoleValueRef::fromValue(CSTK.pushStackString(cb.mStringCallbackFunc(state->thisObject, argc, argv)));
1420 case IntCallbackType:
1421 return ConsoleValueRef::fromValue(CSTK.pushUINT((U32)cb.mBoolCallbackFunc(state->thisObject, argc, argv)));
1422 case FloatCallbackType:
1423 return ConsoleValueRef::fromValue(CSTK.pushFLT((U32)cb.mBoolCallbackFunc(state->thisObject, argc, argv)));
1424 case VoidCallbackType:
1425 cb.mVoidCallbackFunc(state->thisObject, argc, argv);
1426 return ConsoleValueRef();
1427 case BoolCallbackType:
1428 return ConsoleValueRef::fromValue(CSTK.pushUINT((U32)cb.mBoolCallbackFunc(state->thisObject, argc, argv)));
1429 }
1430
1431 return ConsoleValueRef();
1432}
1433
1434//-----------------------------------------------------------------------------
1435// Doc string code.

Callers 4

processMethod · 0.45
_internalExecuteFunction · 0.45

Calls 9

errorfFunction · 0.85
warnfFunction · 0.85
clearFunctionOffsetMethod · 0.80
pushStackStringMethod · 0.80
pushUINTMethod · 0.80
pushFLTMethod · 0.80
ConsoleValueRefClass · 0.70
execMethod · 0.45

Tested by

no test coverage detected