--- linuxsampler/trunk/src/scriptvm/ScriptVM.h 2017/05/26 18:30:42 3221 +++ linuxsampler/trunk/src/scriptvm/ScriptVM.h 2019/08/18 00:06:04 3557 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2017 Christian Schoenebeck + * Copyright (c) 2014-2019 Christian Schoenebeck * * http://www.linuxsampler.org * @@ -173,6 +173,17 @@ VMFunction* functionByName(const String& name) OVERRIDE; /** + * Whether the passed built-in function is disabled and should thus be + * ignored by the parser at the passed parser context (parser state + * where the built-in function call occurs). + * + * @param fn - built-in function to be checked + * @param ctx - parser context at the position where the built-in + * function call is located within the script + */ + bool isFunctionDisabled(VMFunction* fn, VMParserContext* ctx) OVERRIDE; + + /** * Returns all built-in integer script variables. This method returns a * STL map, where the map's key is the variable name and the map's value * is the native pointer to the actual built-in variable. @@ -180,7 +191,7 @@ * This method is re-implemented by deriving classes to add more use * case specific built-in variables. */ - std::map builtInIntVariables() OVERRIDE; + std::map builtInIntVariables() OVERRIDE; /** * Returns all built-in (8 bit) integer array script variables. This @@ -216,7 +227,7 @@ * DECLARE_VMINT_READONLY() to define the variable for read-only * access by scripts. */ - std::map builtInConstIntVariables() OVERRIDE; + std::map builtInConstIntVariables() OVERRIDE; /** * Returns all built-in dynamic variables. This method returns a STL @@ -256,6 +267,29 @@ */ bool isAutoSuspendEnabled() const; + /** + * By default (i.e. in production use) the built-in exit() function + * prohibits any arguments to be passed to its function by scripts. So + * by default, scripts trying to pass any arguments to the built-in + * exit() function will yield in a parser error. + * + * By calling this method the built-in exit() function will optionally + * accept one argument to be passed to its function call by scripts. The + * value of that function argument will become available by calling + * VMExecContext::exitResult() after execution of the script. + * + * @see VMExecContext::exitResult() + */ + void setExitResultEnabled(bool b = true); + + /** + * Returns @c true if the built-in exit() function optionally accepts + * a function argument by scripts. + * + * @see setExitResultEnabled() + */ + bool isExitResultEnabled() const; + VMEventHandler* currentVMEventHandler(); //TODO: should be protected (only usable during exec() calls, intended only for VMFunctions) VMParserContext* currentVMParserContext(); //TODO: should be protected (only usable during exec() calls, intended only for VMFunctions) VMExecContext* currentVMExecContext(); //TODO: should be protected (only usable during exec() calls, intended only for VMFunctions) @@ -264,6 +298,7 @@ VMEventHandler* m_eventHandler; ParserContext* m_parserContext; bool m_autoSuspend; + bool m_acceptExitRes; class CoreVMFunction_message* m_fnMessage; class CoreVMFunction_exit* m_fnExit; class CoreVMFunction_wait* m_fnWait;