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

Function DefineConsoleFunction

Engine/source/cinterface/cinterface.cpp:438–461  ·  view source on GitHub ↗

This function is solely to test the TorqueScript <-> Javascript binding By default, it is marked as secure by the web plugins and then can be called from Javascript on the web page to ensure that function calls across the language boundry are working with arguments and return values

Source from the content-addressed store, hash-verified

436// Javascript on the web page to ensure that function calls across the language
437// boundry are working with arguments and return values
438DefineConsoleFunction( testJavaScriptBridge, const char *, (const char* arg1, const char* arg2, const char* arg3), , "testBridge(arg1, arg2, arg3)")
439{
440 S32 failed = 0;
441 if (dStrcmp(arg1,"one"))
442 failed = 2;
443 if (dStrcmp(arg2,"two"))
444 failed = 2;
445 if (dStrcmp(arg3,"three"))
446 failed = 2;
447
448
449 //attempt to call from TorqueScript -> JavaScript
450 const char* jret = Con::evaluate("JS::bridgeCallback(\"one\",\"two\",\"three\");");
451
452 if (dStrcmp(jret,"42"))
453 failed = 3;
454
455 static const U32 bufSize = 256;
456 char *ret = Con::getReturnBuffer(bufSize);
457
458 dSprintf(ret, bufSize, "%i", failed);
459
460 return ret;
461}
462
463
464

Callers

nothing calls this directly

Calls 4

evaluateFunction · 0.85
getReturnBufferFunction · 0.85
dSprintfFunction · 0.85
dStrcmpFunction · 0.50

Tested by

no test coverage detected