21 #include <torquescript/nativefunction.hpp>
22 #include <torquescript/executionscope.hpp>
23 #include <torquescript/interpreter.hpp>
24 #include <torquescript/executionstate.hpp>
25 #include <torquescript/storedvaluestack.hpp>
26 #include <torquescript/consoleobject.hpp>
27 #include <torquescript/fileobject.hpp>
31 static void GetRandomBuiltIn(std::shared_ptr<ConsoleObject> thisObject, std::shared_ptr<ExecutionState> state,
const std::size_t argumentCount)
33 StoredValueStack& stack = state->mExecutionScope.getStack();
36 const float result = (float)std::rand() / RAND_MAX;
37 stack.push_back(StoredValue(result));
40 static void registerMathLibrary(Interpreter* interpreter)
42 interpreter->addFunction(std::shared_ptr<Function>(
new NativeFunction(GetRandomBuiltIn, PACKAGE_EMPTY, NAMESPACE_EMPTY,
"getRandom")));