--- linuxsampler/trunk/src/scriptvm/ScriptVM.h 2016/04/19 14:07:53 2879 +++ linuxsampler/trunk/src/scriptvm/ScriptVM.h 2016/07/13 15:51:06 2942 @@ -15,7 +15,6 @@ #include "../common/global.h" #include "common.h" -#include "CoreVMFunctions.h" namespace LinuxSampler { @@ -67,6 +66,9 @@ * parser errors, you may pass the VMParserContext object to method * exec() for actually executing the script. * + * It is your responsibility to free the returned VMParserContext + * object once you don't need it anymore. + * * @param s - entire source code of the script to be loaded * @returns parsed representation of the script */ @@ -83,6 +85,33 @@ VMParserContext* loadScript(std::istream* is); /** + * Parses a script's source code (passed as argument @a s to this + * method), splits that input up in its individual tokens (i.e. + * keyword, variable name, event name, etc.) and returns all those + * tokens, for the purpose that the caller can provide syntax syntax + * highlighting for the passed script. + * + * This method is actually not used by the sampler at all, it is rather + * provided for external script editor applications, to provide them a + * convenient backend for parsing scripts and providing syntax + * highlighting. + * + * @returns recognized tokens of passed script's source code + */ + std::vector syntaxHighlighting(const String& s); + + /** + * Same as above's syntaxHighlighting() method, but this one reads the + * script's source code from an input stream object (i.e. stdin or a + * file). + * + * @param is - input stream from which the entire source code of the + * script is to be read and loaded from + * @returns recognized tokens of passed script's source code + */ + std::vector syntaxHighlighting(std::istream* is); + + /** * Dumps the translated tree of the already parsed script, given by * argument @a context, to stdout. This method is for debugging purposes * only. @@ -181,6 +210,18 @@ */ std::map builtInConstIntVariables() OVERRIDE; + /** + * Returns all built-in dynamic variables. This method returns a STL + * map, where the map's key is the dynamic variable's name and the + * map's value is the pointer to the actual object implementing the + * behavior which is actually generating the content of the dynamic + * variable. + * + * This method is re-implemented by deriving classes to add more use + * case specific built-in dynamic variables. + */ + std::map builtInDynamicVariables() OVERRIDE; + 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) @@ -188,12 +229,14 @@ protected: VMEventHandler* m_eventHandler; ParserContext* m_parserContext; - CoreVMFunction_message fnMessage; - CoreVMFunction_exit fnExit; - CoreVMFunction_wait fnWait; - CoreVMFunction_abs fnAbs; - CoreVMFunction_random fnRandom; - CoreVMFunction_num_elements fnNumElements; + class CoreVMFunction_message* m_fnMessage; + class CoreVMFunction_exit* m_fnExit; + class CoreVMFunction_wait* m_fnWait; + class CoreVMFunction_abs* m_fnAbs; + class CoreVMFunction_random* m_fnRandom; + class CoreVMFunction_num_elements* m_fnNumElements; + class CoreVMDynVar_NKSP_REAL_TIMER* m_varRealTimer; + class CoreVMDynVar_NKSP_PERF_TIMER* m_varPerfTimer; }; } // namespace LinuxSampler