1 |
/* |
/* |
2 |
* Copyright (c) 2014-2019 Christian Schoenebeck |
* Copyright (c) 2014-2020 Christian Schoenebeck |
3 |
* |
* |
4 |
* http://www.linuxsampler.org |
* http://www.linuxsampler.org |
5 |
* |
* |
69 |
* It is your responsibility to free the returned VMParserContext |
* It is your responsibility to free the returned VMParserContext |
70 |
* object once you don't need it anymore. |
* object once you don't need it anymore. |
71 |
* |
* |
72 |
|
* The NKSP language supports so called 'patch' variables, which are |
73 |
|
* declared by the dedicated keyword 'patch' (as variable qualifier) in |
74 |
|
* real-time instrument scripts, like e.g.: |
75 |
|
* @code |
76 |
|
* on init |
77 |
|
* declare patch ~foo := 0.435 |
78 |
|
* end on |
79 |
|
* @endcode |
80 |
|
* These 'patch' variables allow to override their initial value (i.e. |
81 |
|
* on a per instrument basis). In the example above, the script variable |
82 |
|
* @c ~foo would be initialized with value @c 0.435 by default. However |
83 |
|
* by simply passing an appropriate key-value pair with argument |
84 |
|
* @p patchVars when calling this method, the NKSP parser will replace |
85 |
|
* that default initialization value by the passed replacement value. |
86 |
|
* So key of the optional @p patchVars map argument is the ('patch') |
87 |
|
* variable name to be patched, and value is the replacement |
88 |
|
* initialization value for the respective variable. You can see this as |
89 |
|
* kind of preprocessor mechanism of the NKSP parser, so you are not |
90 |
|
* limited to simply replace a scalar value with a different scalar |
91 |
|
* value, you can actually replace any complex default initialization |
92 |
|
* expression with a new (potentially complex) replacement expression, |
93 |
|
* e.g. including function calls, formulas, etc. |
94 |
|
* |
95 |
|
* The optional 3rd argument @p patchVarsDef allows you to retrieve the |
96 |
|
* default initialization value(s) of all 'patch' variables declared in |
97 |
|
* the passed script itself. This is useful for instrument editors. |
98 |
|
* |
99 |
* @param s - entire source code of the script to be loaded |
* @param s - entire source code of the script to be loaded |
100 |
|
* @param patchVars - (optional) replacement value for patch variables |
101 |
|
* @param patchVarsDef - (optional) output of original values of patch |
102 |
|
* variables |
103 |
* @returns parsed representation of the script |
* @returns parsed representation of the script |
104 |
*/ |
*/ |
105 |
VMParserContext* loadScript(const String& s); |
VMParserContext* loadScript(const String& s, |
106 |
|
const std::map<String,String>& patchVars = |
107 |
|
std::map<String,String>(), |
108 |
|
std::map<String,String>* patchVarsDef = NULL); |
109 |
|
|
110 |
/** |
/** |
111 |
* Same as above's loadScript() method, but this one reads the script's |
* Same as above's loadScript() method, but this one reads the script's |
113 |
* |
* |
114 |
* @param is - input stream from which the entire source code of the |
* @param is - input stream from which the entire source code of the |
115 |
* script is to be read and loaded from |
* script is to be read and loaded from |
116 |
|
* @param patchVars - (optional) replacement value for patch variables |
117 |
|
* @param patchVarsDef - (optional) output of original values of patch |
118 |
|
* variables |
119 |
* @returns parsed representation of the script |
* @returns parsed representation of the script |
120 |
*/ |
*/ |
121 |
VMParserContext* loadScript(std::istream* is); |
VMParserContext* loadScript(std::istream* is, |
122 |
|
const std::map<String,String>& patchVars = |
123 |
|
std::map<String,String>(), |
124 |
|
std::map<String,String>* patchVarsDef = NULL); |
125 |
|
|
126 |
/** |
/** |
127 |
* Parses a script's source code (passed as argument @a s to this |
* Parses a script's source code (passed as argument @a s to this |
351 |
VMParserContext* currentVMParserContext(); //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) |
352 |
VMExecContext* currentVMExecContext(); //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) |
353 |
|
|
354 |
|
private: |
355 |
|
VMParserContext* loadScriptOnePass(const String& s); |
356 |
protected: |
protected: |
357 |
VMEventHandler* m_eventHandler; |
VMEventHandler* m_eventHandler; |
358 |
ParserContext* m_parserContext; |
ParserContext* m_parserContext; |