/[svn]/linuxsampler/trunk/src/scriptvm/common.h
ViewVC logotype

Diff of /linuxsampler/trunk/src/scriptvm/common.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2885 by schoenebeck, Fri Apr 22 15:37:45 2016 UTC revision 3590 by schoenebeck, Mon Sep 2 09:03:31 2019 UTC
# Line 1  Line 1 
1  /*  /*
2   * Copyright (c) 2014-2016 Christian Schoenebeck   * Copyright (c) 2014-2019 Christian Schoenebeck
3   *   *
4   * http://www.linuxsampler.org   * http://www.linuxsampler.org
5   *   *
# Line 9  Line 9 
9    
10  // This header defines data types shared between the VM core implementation  // This header defines data types shared between the VM core implementation
11  // (inside the current source directory) and other parts of the sampler  // (inside the current source directory) and other parts of the sampler
12  // (located at other source directories).  // (located at other source directories). It also acts as public API of the
13    // Real-Time script engine for other applications.
14    
15  #ifndef LS_INSTR_SCRIPT_PARSER_COMMON_H  #ifndef LS_INSTR_SCRIPT_PARSER_COMMON_H
16  #define LS_INSTR_SCRIPT_PARSER_COMMON_H  #define LS_INSTR_SCRIPT_PARSER_COMMON_H
# Line 18  Line 19 
19  #include <vector>  #include <vector>
20  #include <map>  #include <map>
21  #include <stddef.h> // offsetof()  #include <stddef.h> // offsetof()
22    #include <functional> // std::function<>
23    
24  namespace LinuxSampler {  namespace LinuxSampler {
25    
26      /**      /**
27         * Native data type used by the script engine both internally, as well as
28         * for all integer data types used by scripts (i.e. for all $foo variables
29         * in NKSP scripts). Note that this is different from the original KSP which
30         * is limited to 32 bit for integer variables in KSP scripts.
31         */
32        typedef int64_t vmint;
33    
34        /**
35         * Native data type used internally by the script engine for all unsigned
36         * integer types. This type is currently not exposed to scripts.
37         */
38        typedef uint64_t vmuint;
39    
40        /**
41         * Native data type used by the script engine both internally for floating
42         * point data, as well as for all @c real data types used by scripts (i.e.
43         * for all ~foo variables in NKSP scripts).
44         */
45        typedef float vmfloat;
46    
47        /**
48       * Identifies the type of a noteworthy issue identified by the script       * Identifies the type of a noteworthy issue identified by the script
49       * parser. That's either a parser error or parser warning.       * parser. That's either a parser error or parser warning.
50       */       */
# Line 43  namespace LinuxSampler { Line 66  namespace LinuxSampler {
66          INT_ARR_EXPR, ///< integer array expression          INT_ARR_EXPR, ///< integer array expression
67          STRING_EXPR, ///< string expression          STRING_EXPR, ///< string expression
68          STRING_ARR_EXPR, ///< string array expression          STRING_ARR_EXPR, ///< string array expression
69            REAL_EXPR, ///< floating point (scalar) expression
70            REAL_ARR_EXPR, ///< floating point array expression
71      };      };
72    
73      /** @brief Result flags of a script statement or script function call.      /** @brief Result flags of a script statement or script function call.
# Line 80  namespace LinuxSampler { Line 105  namespace LinuxSampler {
105       *       *
106       * Identifies one of the possible event handler callback types defined by       * Identifies one of the possible event handler callback types defined by
107       * the NKSP script language.       * the NKSP script language.
108         *
109         * IMPORTANT: this type is forced to be emitted as int32_t type ATM, because
110         * that's the native size expected by the built-in instrument script
111         * variable bindings (see occurrences of VMInt32RelPtr and DECLARE_VMINT
112         * respectively. A native type mismatch between the two could lead to
113         * undefined behavior! Background: By definition the C/C++ compiler is free
114         * to choose a bit size for individual enums which it might find
115         * appropriate, which is usually decided by the compiler according to the
116         * biggest enum constant value defined (in practice it is usually 32 bit).
117       */       */
118      enum VMEventHandlerType_t {      enum VMEventHandlerType_t : int32_t {
119          VM_EVENT_HANDLER_INIT, ///< Initilization event handler, that is script's "on init ... end on" code block.          VM_EVENT_HANDLER_INIT, ///< Initilization event handler, that is script's "on init ... end on" code block.
120          VM_EVENT_HANDLER_NOTE, ///< Note event handler, that is script's "on note ... end on" code block.          VM_EVENT_HANDLER_NOTE, ///< Note event handler, that is script's "on note ... end on" code block.
121          VM_EVENT_HANDLER_RELEASE, ///< Release event handler, that is script's "on release ... end on" code block.          VM_EVENT_HANDLER_RELEASE, ///< Release event handler, that is script's "on release ... end on" code block.
122          VM_EVENT_HANDLER_CONTROLLER, ///< Controller event handler, that is script's "on controller ... end on" code block.          VM_EVENT_HANDLER_CONTROLLER, ///< Controller event handler, that is script's "on controller ... end on" code block.
123      };      };
124    
125        /**
126         * All metric unit prefixes (actually just scale factors) supported by this
127         * script engine.
128         */
129        enum MetricPrefix_t {
130            VM_NO_PREFIX = 0, ///< = 1
131            VM_KILO,          ///< = 10^3, short 'k'
132            VM_HECTO,         ///< = 10^2, short 'h'
133            VM_DECA,          ///< = 10, short 'da'
134            VM_DECI,          ///< = 10^-1, short 'd'
135            VM_CENTI,         ///< = 10^-2, short 'c' (this is also used for tuning "cents")
136            VM_MILLI,         ///< = 10^-3, short 'm'
137            VM_MICRO,         ///< = 10^-6, short 'u'
138        };
139    
140        /**
141         * This constant is used for comparison with Unit::unitFactor() to check
142         * whether a number does have any metric unit prefix at all.
143         *
144         * @see Unit::unitFactor()
145         */
146        static const vmfloat VM_NO_FACTOR = vmfloat(1);
147    
148        /**
149         * All measurement unit types supported by this script engine.
150         *
151         * @e Note: there is no standard unit "cents" here (for pitch/tuning), use
152         * @c VM_CENTI for the latter instad. That's because the commonly cited
153         * "cents" unit is actually no measurement unit type but rather a metric
154         * unit prefix.
155         *
156         * @see MetricPrefix_t
157         */
158        enum StdUnit_t {
159            VM_NO_UNIT = 0, ///< No unit used, the number is just an abstract number.
160            VM_SECOND,      ///< Measuring time.
161            VM_HERTZ,       ///< Measuring frequency.
162            VM_BEL,         ///< Measuring relation between two energy levels (in logarithmic scale). Since we are using it for accoustics, we are always referring to A-weighted Bels (i.e. dBA).
163        };
164    
165        //TODO: see Unit::hasUnitFactorEver()
166        enum EverTriState_t {
167            VM_NEVER = 0,
168            VM_MAYBE,
169            VM_ALWAYS,
170        };
171    
172      // just symbol prototyping      // just symbol prototyping
173      class VMIntExpr;      class VMIntExpr;
174        class VMRealExpr;
175      class VMStringExpr;      class VMStringExpr;
176        class VMNumberExpr;
177        class VMArrayExpr;
178      class VMIntArrayExpr;      class VMIntArrayExpr;
179        class VMRealArrayExpr;
180      class VMStringArrayExpr;      class VMStringArrayExpr;
181        class VMParserContext;
182    
183        /** @brief Virtual machine standard measuring unit.
184         *
185         * Abstract base class representing standard measurement units throughout
186         * the script engine. These might be e.g. "dB" (deci Bel) for loudness,
187         * "Hz" (Hertz) for frequencies or "s" for "seconds". These unit types can
188         * combined with metric prefixes, for instance "kHz" (kilo Hertz),
189         * "us" (micro second), etc.
190         *
191         * Originally the script engine only supported abstract integer values for
192         * controlling any synthesis parameter or built-in function argument or
193         * variable. Under certain situations it makes sense though for an
194         * instrument script author to provide values in real, standard measurement
195         * units to provide a more natural and intuitive approach for writing
196         * instrument scripts, for example by setting the frequency of some LFO
197         * directly to "20Hz" or reducing loudness by "-4.2dB". Hence support for
198         * standard units in scripts was added as an extension to the NKSP script
199         * engine.
200         *
201         * So a unit consists of 1) a sequence of metric prefixes as scale factor
202         * (e.g. "k" for kilo) and 2) the actual unit type (e.g. "Hz" for Hertz).
203         * The unit type is a constant feature of number literals and variables, so
204         * once a variable was declared with a unit type (or no unit type at all)
205         * then that unit type of that variable cannot be changed for the entire
206         * life time of the script. This is different from the unit's metric
207         * prefix(es) of variables which may freely be changed at runtime.
208         */
209        class VMUnit {
210        public:
211            /**
212             * Returns the metric prefix(es) of this unit as unit factor. A metric
213             * prefix essentially is just a mathematical scale factor that should be
214             * applied to the number associated with the measurement unit. Consider
215             * a string literal in an NKSP script like '3kHz' where 'k' (kilo) is
216             * the metric prefix, which essentically is a scale factor of 1000.
217             *
218             * Usually a unit either has exactly none or one metric prefix, but note
219             * that there might also be units with more than one prefix, for example
220             * @c mdB (milli deci Bel) is used sometimes which has two prefixes. The
221             * latter is an exception though and more than two prefixes is currently
222             * not supported by the script engine.
223             *
224             * The factor returned by this method is the final mathematical factor
225             * that should be multiplied against the number associated with this
226             * unit. This factor results from the sequence of metric prefixes of
227             * this unit.
228             *
229             * @see MetricPrefix_t, hasUnitFactorNow(), hasUnitFactorEver(),
230             *      VM_NO_FACTOR
231             * @returns current metric unit factor
232             */
233            virtual vmfloat unitFactor() const = 0;
234    
235            //TODO: this still needs to be implemented in tree.h/.pp, built-in functions and as 2nd pass of parser appropriately
236            /*virtual*/ EverTriState_t hasUnitFactorEver() const { return VM_NEVER; }
237    
238            /**
239             * Whether this unit currently does have any metric unit prefix.
240             *
241             * This is actually just a convenience method which returns @c true if
242             * unitFactor() is not @c 1.0.
243             *
244             * @see MetricPrefix_t, unitFactor(), hasUnitFactorEver(), VM_NO_FACTOR
245             * @returns @c true if this unit currently has any metric prefix
246             */
247            bool hasUnitFactorNow() const;
248    
249            /**
250             * This is the actual fundamental measuring unit base type of this unit,
251             * which might be either Hertz, second or Bel.
252             *
253             * Note that a number without a unit type may still have metric
254             * prefixes.
255             *
256             * @returns standard unit type identifier or VM_NO_UNIT if no unit type
257             *          is used for this object
258             */
259            virtual StdUnit_t unitType() const = 0;
260    
261            /**
262             * Returns the actual mathematical factor represented by the passed
263             * @a prefix argument.
264             */
265            static vmfloat unitFactor(MetricPrefix_t prefix);
266    
267            /**
268             * Returns the actual mathematical factor represented by the passed
269             * two @a prefix1 and @a prefix2 arguments.
270             *
271             * @returns scale factor of given metric unit prefixes
272             */
273            static vmfloat unitFactor(MetricPrefix_t prefix1, MetricPrefix_t prefix2);
274    
275            /**
276             * Returns the actual mathematical factor represented by the passed
277             * @a prefixes array. The passed array should always be terminated by a
278             * VM_NO_PREFIX value as last element.
279             *
280             * @param prefixes - sequence of metric prefixes
281             * @param size - max. amount of elements of array @a prefixes
282             * @returns scale factor of given metric unit prefixes
283             */
284            static vmfloat unitFactor(const MetricPrefix_t* prefixes, vmuint size = 2);
285        };
286    
287      /** @brief Virtual machine expression      /** @brief Virtual machine expression
288       *       *
# Line 125  namespace LinuxSampler { Line 315  namespace LinuxSampler {
315           * if this expression is i.e. actually a string expression like "12",           * if this expression is i.e. actually a string expression like "12",
316           * calling asInt() will @b not cast that numerical string expression to           * calling asInt() will @b not cast that numerical string expression to
317           * an integer expression 12 for you, instead this method will simply           * an integer expression 12 for you, instead this method will simply
318           * return NULL!           * return NULL! Same applies if this expression is actually a real
319             * number expression: asInt() would return NULL in that case as well.
320           *           *
321           * @see exprType()           * @see exprType(), asReal(), asNumber()
322           */           */
323          VMIntExpr* asInt() const;          VMIntExpr* asInt() const;
324    
325          /**          /**
326             * In case this expression is a real number (floating point) expression,
327             * then this method returns a casted pointer to that VMRealExpr object.
328             * It returns NULL if this expression is not a real number expression.
329             *
330             * @b Note: type casting performed by this method is strict! That means
331             * if this expression is i.e. actually a string expression like "12",
332             * calling asReal() will @b not cast that numerical string expression to
333             * a real number expression 12.0 for you, instead this method will
334             * simply return NULL! Same applies if this expression is actually an
335             * integer expression: asReal() would return NULL in that case as well.
336             *
337             * @see exprType(), asInt(), asNumber()
338             */
339            VMRealExpr* asReal() const;
340    
341            /**
342             * In case this expression is a scalar number expression, that is either
343             * an integer (scalar) expression or a real number (floating point
344             * scalar) expression, then this method returns a casted pointer to that
345             * VMNumberExpr base class object. It returns NULL if this
346             * expression is neither an integer (scalar), nor a real number (scalar)
347             * expression.
348             *
349             * Since the methods asInt() and asReal() are very strict, this method
350             * is provided as convenience access in case only very general
351             * information (e.g. which standard measurement unit is being used or
352             * whether final operator being effective to this expression) is
353             * intended to be retrieved of this scalar number expression independent
354             * from whether this expression is actually an integer or a real number
355             * expression.
356             *
357             * @see exprType(), asInt(), asReal()
358             */
359            VMNumberExpr* asNumber() const;
360    
361            /**
362           * In case this expression is a string expression, then this method           * In case this expression is a string expression, then this method
363           * returns a casted pointer to that VMStringExpr object. It returns NULL           * returns a casted pointer to that VMStringExpr object. It returns NULL
364           * if this expression is not a string expression.           * if this expression is not a string expression.
# Line 152  namespace LinuxSampler { Line 379  namespace LinuxSampler {
379           * returns NULL if this expression is not an integer array expression.           * returns NULL if this expression is not an integer array expression.
380           *           *
381           * @b Note: type casting performed by this method is strict! That means           * @b Note: type casting performed by this method is strict! That means
382           * if this expression is i.e. an integer expression or a string           * if this expression is i.e. an integer scalar expression, a real
383           * expression, calling asIntArray() will @b not cast those scalar           * number expression or a string expression, calling asIntArray() will
384           * expressions to an array expression for you, instead this method will           * @b not cast those expressions to an integer array expression for you,
385           * simply return NULL!           * instead this method will simply return NULL!
386             *
387             * @b Note: this method is currently, and in contrast to its other
388             * counter parts, declared as virtual method. Some deriving classes are
389             * currently using this to override this default implementation in order
390             * to implement an "evaluate now as integer array" behavior. This has
391             * efficiency reasons, however this also currently makes this part of
392             * the API less clean and should thus be addressed in future with
393             * appropriate changes to the API.
394           *           *
395           * @see exprType()           * @see exprType()
396           */           */
397          VMIntArrayExpr* asIntArray() const;          virtual VMIntArrayExpr* asIntArray() const;
398    
399            /**
400             * In case this expression is a real number (floating point) array
401             * expression, then this method returns a casted pointer to that
402             * VMRealArrayExpr object. It returns NULL if this expression is not a
403             * real number array expression.
404             *
405             * @b Note: type casting performed by this method is strict! That means
406             * if this expression is i.e. a real number scalar expression, an
407             * integer expression or a string expression, calling asRealArray() will
408             * @b not cast those scalar expressions to a real number array
409             * expression for you, instead this method will simply return NULL!
410             *
411             * @b Note: this method is currently, and in contrast to its other
412             * counter parts, declared as virtual method. Some deriving classes are
413             * currently using this to override this default implementation in order
414             * to implement an "evaluate now as real number array" behavior. This
415             * has efficiency reasons, however this also currently makes this part
416             * of the API less clean and should thus be addressed in future with
417             * appropriate changes to the API.
418             *
419             * @see exprType()
420             */
421            virtual VMRealArrayExpr* asRealArray() const;
422    
423            /**
424             * This is an alternative to calling either asIntArray() or
425             * asRealArray(). This method here might be used if the fundamental
426             * scalar data type (real or integer) of the array is not relevant,
427             * i.e. for just getting the size of the array. Since all as*() methods
428             * here are very strict regarding type casting, this asArray() method
429             * sometimes can reduce code complexity.
430             *
431             * Likewise calling this method only returns a valid pointer if the
432             * expression is some array type (currently either integer array or real
433             * number array). For any other expression type this method will return
434             * NULL instead.
435             *
436             * @see exprType()
437             */
438            VMArrayExpr* asArray() const;
439    
440            /**
441             * Returns true in case this expression can be considered to be a
442             * constant expression. A constant expression will retain the same
443             * value throughout the entire life time of a script and the
444             * expression's constant value may be evaluated already at script
445             * parse time, which may result in performance benefits during script
446             * runtime.
447             *
448             * @b NOTE: A constant expression is per se always also non modifyable.
449             * But a non modifyable expression may not necessarily be a constant
450             * expression!
451             *
452             * @see isModifyable()
453             */
454            virtual bool isConstExpr() const = 0;
455    
456            /**
457             * Returns true in case this expression is allowed to be modified.
458             * If this method returns @c false then this expression must be handled
459             * as read-only expression, which means that assigning a new value to it
460             * is either not possible or not allowed.
461             *
462             * @b NOTE: A constant expression is per se always also non modifyable.
463             * But a non modifyable expression may not necessarily be a constant
464             * expression!
465             *
466             * @see isConstExpr()
467             */
468            bool isModifyable() const;
469        };
470    
471        /** @brief Virtual machine scalar number expression
472         *
473         * This is the abstract base class for integer (scalar) expressions and
474         * real number (floating point scalar) expressions of scripts.
475         */
476        class VMNumberExpr : virtual public VMExpr, virtual public VMUnit {
477        public:
478            /**
479             * Returns @c true if the value of this expression should be applied
480             * as final value to the respective destination synthesis chain
481             * parameter.
482             *
483             * This property is somewhat special and dedicated for the purpose of
484             * this expression's (integer or real number) value to be applied as
485             * parameter to the synthesis chain of the sampler (i.e. for altering a
486             * filter cutoff frequency). Now historically and by default all values
487             * of scripts are applied relatively to the sampler's synthesis chain,
488             * that is the synthesis parameter value of a script is multiplied
489             * against other sources for the same synthesis parameter (i.e. an LFO
490             * or a dedicated MIDI controller either hard wired in the engine or
491             * defined by the instrument patch). So by default the resulting actual
492             * final synthesis parameter is a combination of all these sources. This
493             * has the advantage that it creates a very living and dynamic overall
494             * sound.
495             *
496             * However sometimes there are requirements by script authors where this
497             * is not what you want. Therefore the NKSP script engine added a
498             * language extension by prefixing a value in scripts with a @c !
499             * character the value will be defined as being the "final" value of the
500             * destination synthesis parameter, so that causes this value to be
501             * applied exclusively, and the values of all other sources are thus
502             * entirely ignored by the sampler's synthesis core as long as this
503             * value is assigned by the script engine as "final" value for the
504             * requested synthesis parameter.
505             */
506            virtual bool isFinal() const = 0;
507    
508            /**
509             * Calling this method evaluates the expression and returns the value
510             * of the expression as integer. If this scalar number expression is a
511             * real number expression then this method automatically casts the value
512             * from real number to integer.
513             */
514            vmint evalCastInt();
515    
516            /**
517             * Calling this method evaluates the expression and returns the value
518             * of the expression as integer and thus behaves similar to the previous
519             * method, however this overridden method automatically takes unit
520             * prefixes into account and returns a converted value corresponding to
521             * the given unit @a prefix expected by the caller.
522             *
523             * Example: Assume this expression was an integer expression '12kHz'
524             * then calling this method as @c evalCastInt(VM_MILLI) would return
525             * the value @c 12000000.
526             *
527             * @param prefix - measuring unit prefix expected for result by caller
528             */
529            vmint evalCastInt(MetricPrefix_t prefix);
530    
531            /**
532             * This method behaves like the previous method, just that it takes a
533             * measuring unit prefix with two elements (e.g. "milli cents" for
534             * tuning).
535             *
536             * @param prefix1 - 1st measuring unit prefix element expected by caller
537             * @param prefix2 - 2nd measuring unit prefix element expected by caller
538             */
539            vmint evalCastInt(MetricPrefix_t prefix1, MetricPrefix_t prefix2);
540    
541            /**
542             * Calling this method evaluates the expression and returns the value
543             * of the expression as real number. If this scalar number expression is
544             * an integer expression then this method automatically casts the value
545             * from integer to real number.
546             */
547            vmfloat evalCastReal();
548    
549            /**
550             * Calling this method evaluates the expression and returns the value
551             * of the expression as real number and thus behaves similar to the
552             * previous method, however this overridden method automatically takes
553             * unit prefixes into account and returns a converted value
554             * corresponding to the given unit @a prefix expected by the caller.
555             *
556             * Example: Assume this expression was an integer expression '8ms' then
557             * calling this method as @c evalCastReal(VM_NO_PREFIX) would return the
558             * value @c 0.008.
559             *
560             * @param prefix - measuring unit prefix expected for result by caller
561             */
562            vmfloat evalCastReal(MetricPrefix_t prefix);
563    
564            /**
565             * This method behaves like the previous method, just that it takes a
566             * measuring unit prefix with two elements (e.g. "milli cents" for
567             * tuning).
568             *
569             * @param prefix1 - 1st measuring unit prefix element expected by caller
570             * @param prefix2 - 2nd measuring unit prefix element expected by caller
571             */
572            vmfloat evalCastReal(MetricPrefix_t prefix1, MetricPrefix_t prefix2);
573      };      };
574    
575      /** @brief Virtual machine integer expression      /** @brief Virtual machine integer expression
# Line 169  namespace LinuxSampler { Line 579  namespace LinuxSampler {
579       * abstract method evalInt() to return the actual integer result value of       * abstract method evalInt() to return the actual integer result value of
580       * the expression.       * the expression.
581       */       */
582      class VMIntExpr : virtual public VMExpr {      class VMIntExpr : virtual public VMNumberExpr {
583      public:      public:
584          /**          /**
585           * Returns the result of this expression as integer (scalar) value.           * Returns the result of this expression as integer (scalar) value.
586           * This abstract method must be implemented by deriving classes.           * This abstract method must be implemented by deriving classes.
587           */           */
588          virtual int evalInt() = 0;          virtual vmint evalInt() = 0;
589    
590            /**
591             * Returns the result of this expression as integer (scalar) value and
592             * thus behaves similar to the previous method, however this overridden
593             * method automatically takes unit prefixes into account and returns a
594             * value corresponding to the expected given unit @a prefix.
595             *
596             * @param prefix - default measurement unit prefix expected by caller
597             */
598            vmint evalInt(MetricPrefix_t prefix);
599    
600            /**
601             * This method behaves like the previous method, just that it takes
602             * a default measurement prefix with two elements (i.e. "milli cents"
603             * for tuning).
604             */
605            vmint evalInt(MetricPrefix_t prefix1, MetricPrefix_t prefix2);
606    
607          /**          /**
608           * Returns always INT_EXPR for instances of this class.           * Returns always INT_EXPR for instances of this class.
# Line 183  namespace LinuxSampler { Line 610  namespace LinuxSampler {
610          ExprType_t exprType() const OVERRIDE { return INT_EXPR; }          ExprType_t exprType() const OVERRIDE { return INT_EXPR; }
611      };      };
612    
613        /** @brief Virtual machine real number (floating point scalar) expression
614         *
615         * This is the abstract base class for all expressions inside scripts which
616         * evaluate to a real number (floating point scalar) value. Deriving classes
617         * implement the abstract method evalReal() to return the actual floating
618         * point result value of the expression.
619         */
620        class VMRealExpr : virtual public VMNumberExpr {
621        public:
622            /**
623             * Returns the result of this expression as real number (floating point
624             * scalar) value. This abstract method must be implemented by deriving
625             * classes.
626             */
627            virtual vmfloat evalReal() = 0;
628    
629            /**
630             * Returns the result of this expression as real number (floating point
631             * scalar) value and thus behaves similar to the previous method,
632             * however this overridden method automatically takes unit prefixes into
633             * account and returns a value corresponding to the expected given unit
634             * @a prefix.
635             *
636             * @param prefix - default measurement unit prefix expected by caller
637             */
638            vmfloat evalReal(MetricPrefix_t prefix);
639    
640            /**
641             * This method behaves like the previous method, just that it takes
642             * a default measurement prefix with two elements (i.e. "milli cents"
643             * for tuning).
644             */
645            vmfloat evalReal(MetricPrefix_t prefix1, MetricPrefix_t prefix2);
646    
647            /**
648             * Returns always REAL_EXPR for instances of this class.
649             */
650            ExprType_t exprType() const OVERRIDE { return REAL_EXPR; }
651        };
652    
653      /** @brief Virtual machine string expression      /** @brief Virtual machine string expression
654       *       *
655       * This is the abstract base class for all expressions inside scripts which       * This is the abstract base class for all expressions inside scripts which
# Line 217  namespace LinuxSampler { Line 684  namespace LinuxSampler {
684           * Returns amount of elements in this array. This abstract method must           * Returns amount of elements in this array. This abstract method must
685           * be implemented by deriving classes.           * be implemented by deriving classes.
686           */           */
687          virtual int arraySize() const = 0;          virtual vmint arraySize() const = 0;
688        };
689    
690        /** @brief Virtual Machine Number Array Expression
691         *
692         * This is the abstract base class for all expressions which either evaluate
693         * to an integer array or real number array.
694         */
695        class VMNumberArrayExpr : virtual public VMArrayExpr {
696        public:
697            /**
698             * Returns the metric unit factor of the requested array element.
699             *
700             * @param i - array element index (must be between 0 .. arraySize() - 1)
701             * @see VMUnit::unitFactor() for details about metric unit factors
702             */
703            virtual vmfloat unitFactorOfElement(vmuint i) const = 0;
704    
705            /**
706             * Changes the current unit factor of the array element given by element
707             * index @a i.
708             *
709             * @param i - array element index (must be between 0 .. arraySize() - 1)
710             * @param factor - new unit factor to be assigned
711             * @see VMUnit::unitFactor() for details about metric unit factors
712             */
713            virtual void assignElementUnitFactor(vmuint i, vmfloat factor) = 0;
714      };      };
715    
716      /** @brief Virtual Machine Integer Array Expression      /** @brief Virtual Machine Integer Array Expression
# Line 227  namespace LinuxSampler { Line 720  namespace LinuxSampler {
720       * abstract methods arraySize(), evalIntElement() and assignIntElement() to       * abstract methods arraySize(), evalIntElement() and assignIntElement() to
721       * access the individual integer array values.       * access the individual integer array values.
722       */       */
723      class VMIntArrayExpr : virtual public VMArrayExpr {      class VMIntArrayExpr : virtual public VMNumberArrayExpr {
724      public:      public:
725          /**          /**
726           * Returns the (scalar) integer value of the array element given by           * Returns the (scalar) integer value of the array element given by
# Line 235  namespace LinuxSampler { Line 728  namespace LinuxSampler {
728           *           *
729           * @param i - array element index (must be between 0 .. arraySize() - 1)           * @param i - array element index (must be between 0 .. arraySize() - 1)
730           */           */
731          virtual int evalIntElement(uint i) = 0;          virtual vmint evalIntElement(vmuint i) = 0;
732    
733          /**          /**
734           * Changes the current value of an element (given by array element           * Changes the current value of an element (given by array element
# Line 244  namespace LinuxSampler { Line 737  namespace LinuxSampler {
737           * @param i - array element index (must be between 0 .. arraySize() - 1)           * @param i - array element index (must be between 0 .. arraySize() - 1)
738           * @param value - new integer scalar value to be assigned to that array element           * @param value - new integer scalar value to be assigned to that array element
739           */           */
740          virtual void assignIntElement(uint i, int value) = 0;          virtual void assignIntElement(vmuint i, vmint value) = 0;
741    
742          /**          /**
743           * Returns always INT_ARR_EXPR for instances of this class.           * Returns always INT_ARR_EXPR for instances of this class.
# Line 252  namespace LinuxSampler { Line 745  namespace LinuxSampler {
745          ExprType_t exprType() const OVERRIDE { return INT_ARR_EXPR; }          ExprType_t exprType() const OVERRIDE { return INT_ARR_EXPR; }
746      };      };
747    
748        /** @brief Virtual Machine Real Number Array Expression
749         *
750         * This is the abstract base class for all expressions inside scripts which
751         * evaluate to an array of real numbers (floating point values). Deriving
752         * classes implement the abstract methods arraySize(), evalRealElement() and
753         * assignRealElement() to access the array's individual real numbers.
754         */
755        class VMRealArrayExpr : virtual public VMNumberArrayExpr {
756        public:
757            /**
758             * Returns the (scalar) real mumber (floating point value) of the array
759             * element given by element index @a i.
760             *
761             * @param i - array element index (must be between 0 .. arraySize() - 1)
762             */
763            virtual vmfloat evalRealElement(vmuint i) = 0;
764    
765            /**
766             * Changes the current value of an element (given by array element
767             * index @a i) of this real number array.
768             *
769             * @param i - array element index (must be between 0 .. arraySize() - 1)
770             * @param value - new real number value to be assigned to that array element
771             */
772            virtual void assignRealElement(vmuint i, vmfloat value) = 0;
773    
774            /**
775             * Returns always REAL_ARR_EXPR for instances of this class.
776             */
777            ExprType_t exprType() const OVERRIDE { return REAL_ARR_EXPR; }
778        };
779    
780      /** @brief Arguments (parameters) for being passed to a built-in script function.      /** @brief Arguments (parameters) for being passed to a built-in script function.
781       *       *
782       * An argument or a set of arguments passed to a script function are       * An argument or a set of arguments passed to a script function are
# Line 266  namespace LinuxSampler { Line 791  namespace LinuxSampler {
791           * Returns the amount of arguments going to be passed to the script           * Returns the amount of arguments going to be passed to the script
792           * function.           * function.
793           */           */
794          virtual int argsCount() const = 0;          virtual vmint argsCount() const = 0;
795    
796          /**          /**
797           * Returns the respective argument (requested by argument index @a i) of           * Returns the respective argument (requested by argument index @a i) of
# Line 275  namespace LinuxSampler { Line 800  namespace LinuxSampler {
800           * argument passed to the function at runtime.           * argument passed to the function at runtime.
801           *           *
802           * @param i - function argument index (indexed from left to right)           * @param i - function argument index (indexed from left to right)
803             * @return requested function argument or NULL if @a i out of bounds
804           */           */
805          virtual VMExpr* arg(int i) = 0;          virtual VMExpr* arg(vmint i) = 0;
806      };      };
807    
808      /** @brief Result value returned from a call to a built-in script function.      /** @brief Result value returned from a call to a built-in script function.
# Line 332  namespace LinuxSampler { Line 858  namespace LinuxSampler {
858          /**          /**
859           * Script data type of the function's return value. If the function does           * Script data type of the function's return value. If the function does
860           * not return any value (void), then it returns EMPTY_EXPR here.           * not return any value (void), then it returns EMPTY_EXPR here.
861             *
862             * Some functions may have a different return type depending on the
863             * arguments to be passed to this function. That's what the @a args
864             * parameter is for, so that the method implementation can look ahead
865             * of what kind of parameters are going to be passed to the built-in
866             * function later on in order to decide which return value type would
867             * be used and returned by the function accordingly in that case.
868             *
869             * @param args - function arguments going to be passed for executing
870             *               this built-in function later on
871           */           */
872          virtual ExprType_t returnType() = 0;          virtual ExprType_t returnType(VMFnArgs* args) = 0;
873    
874            /**
875             * Standard measuring unit type of the function's result value
876             * (e.g. second, Hertz).
877             *
878             * Some functions may have a different standard measuring unit type for
879             * their return value depending on the arguments to be passed to this
880             * function. That's what the @a args parameter is for, so that the
881             * method implementation can look ahead of what kind of parameters are
882             * going to be passed to the built-in function later on in order to
883             * decide which return value type would be used and returned by the
884             * function accordingly in that case.
885             *
886             * @param args - function arguments going to be passed for executing
887             *               this built-in function later on
888             * @see Unit for details about standard measuring units
889             */
890            virtual StdUnit_t returnUnitType(VMFnArgs* args) = 0;
891    
892            /**
893             * Whether the result value returned by this built-in function is
894             * considered to be a 'final' value.
895             *
896             * Some functions may have a different 'final' feature for their return
897             * value depending on the arguments to be passed to this function.
898             * That's what the @a args parameter is for, so that the method
899             * implementation can look ahead of what kind of parameters are going to
900             * be passed to the built-in function later on in order to decide which
901             * return value type would be used and returned by the function
902             * accordingly in that case.
903             *
904             * @param args - function arguments going to be passed for executing
905             *               this built-in function later on
906             * @see VMNumberExpr::isFinal() for details about 'final' values
907             */
908            virtual bool returnsFinal(VMFnArgs* args) = 0;
909    
910          /**          /**
911           * Minimum amount of function arguments this function accepts. If a           * Minimum amount of function arguments this function accepts. If a
912           * script is calling this function with less arguments, the script           * script is calling this function with less arguments, the script
913           * parser will throw a parser error.           * parser will throw a parser error.
914           */           */
915          virtual int minRequiredArgs() const = 0;          virtual vmint minRequiredArgs() const = 0;
916    
917          /**          /**
918           * Maximum amount of function arguments this functions accepts. If a           * Maximum amount of function arguments this functions accepts. If a
919           * script is calling this function with more arguments, the script           * script is calling this function with more arguments, the script
920           * parser will throw a parser error.           * parser will throw a parser error.
921           */           */
922          virtual int maxAllowedArgs() const = 0;          virtual vmint maxAllowedArgs() const = 0;
923    
924          /**          /**
925           * Script data type of the function's @c iArg 'th function argument.           * This method is called by the parser to check whether arguments
926           * The information provided here is less strong than acceptsArgType().           * passed in scripts to this function are accepted by this function. If
927           * The parser will compare argument data types provided in scripts by           * a script calls this function with an argument's data type not
928           * calling acceptsArgType(). The return value of argType() is used by the           * accepted by this function, the parser will throw a parser error.
929           * parser instead to show an appropriate parser error which data type           *
930           * this function usually expects as "default" data type. Reason: a           * The parser will also use this method to assemble a list of actually
931           * function may accept multiple data types for a certain function           * supported data types accepted by this built-in function for the
932           * argument and would automatically cast the passed argument value in           * function argument in question, that is to provide an appropriate and
933           * that case to the type it actually needs.           * precise parser error message in such cases.
934           *           *
935           * @param iArg - index of the function argument in question           * @param iArg - index of the function argument in question
936           *               (must be between 0 .. maxAllowedArgs() - 1)           *               (must be between 0 .. maxAllowedArgs() - 1)
937             * @param type - script data type used for this function argument by
938             *               currently parsed script
939             * @return true if the given data type would be accepted for the
940             *         respective function argument by the function
941           */           */
942          virtual ExprType_t argType(int iArg) const = 0;          virtual bool acceptsArgType(vmint iArg, ExprType_t type) const = 0;
943    
944          /**          /**
945           * This function is called by the parser to check whether arguments           * This method is called by the parser to check whether arguments
946           * passed in scripts to this function are accepted by this function. If           * passed in scripts to this function are accepted by this function. If
947           * a script calls this function with an argument's data type not           * a script calls this function with an argument's measuremnt unit type
948           * accepted by this function, the parser will throw a parser error. On           * not accepted by this function, the parser will throw a parser error.
949           * such errors the data type returned by argType() will be used to           *
950           * assemble an appropriate error message regarding the precise misusage           * This default implementation of this method does not accept any
951           * of the built-in function.           * measurement unit. Deriving subclasses would override this method
952             * implementation in case they do accept any measurement unit for its
953             * function arguments.
954           *           *
955           * @param iArg - index of the function argument in question           * @param iArg - index of the function argument in question
956           *               (must be between 0 .. maxAllowedArgs() - 1)           *               (must be between 0 .. maxAllowedArgs() - 1)
957           * @param type - script data type used for this function argument by           * @param type - standard measurement unit data type used for this
958           *               currently parsed script           *               function argument by currently parsed script
959           * @return true if the given data type would be accepted for the           * @return true if the given standard measurement unit type would be
960           *         respective function argument by the function           *         accepted for the respective function argument by the function
961           */           */
962          virtual bool acceptsArgType(int iArg, ExprType_t type) const = 0;          virtual bool acceptsArgUnitType(vmint iArg, StdUnit_t type) const;
963    
964            /**
965             * This method is called by the parser to check whether arguments
966             * passed in scripts to this function are accepted by this function. If
967             * a script calls this function with a metric unit prefix and metric
968             * prefixes are not accepted for that argument by this function, then
969             * the parser will throw a parser error.
970             *
971             * This default implementation of this method does not accept any
972             * metric prefix. Deriving subclasses would override this method
973             * implementation in case they do accept any metric prefix for its
974             * function arguments.
975             *
976             * @param iArg - index of the function argument in question
977             *               (must be between 0 .. maxAllowedArgs() - 1)
978             * @param type - standard measurement unit data type used for that
979             *               function argument by currently parsed script
980             *
981             * @return true if a metric prefix would be accepted for the respective
982             *         function argument by this function
983             *
984             * @see MetricPrefix_t
985             */
986            virtual bool acceptsArgUnitPrefix(vmint iArg, StdUnit_t type) const;
987    
988            /**
989             * This method is called by the parser to check whether arguments
990             * passed in scripts to this function are accepted by this function. If
991             * a script calls this function with an argument that is declared to be
992             * a "final" value and this is not accepted by this function, the parser
993             * will throw a parser error.
994             *
995             * This default implementation of this method does not accept a "final"
996             * value. Deriving subclasses would override this method implementation
997             * in case they do accept a "final" value for its function arguments.
998             *
999             * @param iArg - index of the function argument in question
1000             *               (must be between 0 .. maxAllowedArgs() - 1)
1001             * @return true if a "final" value would be accepted for the respective
1002             *         function argument by the function
1003             *
1004             * @see VMNumberExpr::isFinal(), returnsFinal()
1005             */
1006            virtual bool acceptsArgFinal(vmint iArg) const;
1007    
1008            /**
1009             * This method is called by the parser to check whether some arguments
1010             * (and if yes which ones) passed to this script function will be
1011             * modified by this script function. Most script functions simply use
1012             * their arguments as inputs, that is they only read the argument's
1013             * values. However some script function may also use passed
1014             * argument(s) as output variables. In this case the function
1015             * implementation must return @c true for the respective argument
1016             * index here.
1017             *
1018             * @param iArg - index of the function argument in question
1019             *               (must be between 0 .. maxAllowedArgs() - 1)
1020             */
1021            virtual bool modifiesArg(vmint iArg) const = 0;
1022    
1023            /** @brief Parse-time check of function arguments.
1024             *
1025             * This method is called by the parser to let the built-in function
1026             * perform its own, individual parse time checks on the arguments to be
1027             * passed to the built-in function. So this method is the place for
1028             * implementing custom checks which are very specific to the individual
1029             * built-in function's purpose and its individual requirements.
1030             *
1031             * For instance the built-in 'in_range()' function uses this method to
1032             * check whether the last 2 of their 3 arguments are of same data type
1033             * and if not it triggers a parser error. 'in_range()' also checks
1034             * whether all of its 3 arguments do have the same standard measuring
1035             * unit type and likewise raises a parser error if not.
1036             *
1037             * For less critical issues built-in functions may also raise parser
1038             * warnings instead.
1039             *
1040             * It is recommended that classes implementing (that is overriding) this
1041             * method should always call their super class's implementation of this
1042             * method to ensure their potential parse time checks are always
1043             * performed as well.
1044             *
1045             * @param args - function arguments going to be passed for executing
1046             *               this built-in function later on
1047             * @param err - the parser's error handler to be called by this method
1048             *              implementation to trigger a parser error with the
1049             *              respective error message text
1050             * @param wrn - the parser's warning handler to be called by this method
1051             *              implementation to trigger a parser warning with the
1052             *              respective warning message text
1053             */
1054            virtual void checkArgs(VMFnArgs* args,
1055                                   std::function<void(String)> err,
1056                                   std::function<void(String)> wrn);
1057    
1058          /**          /**
1059           * Implements the actual function execution. This exec() method is           * Implements the actual function execution. This exec() method is
# Line 415  namespace LinuxSampler { Line 1087  namespace LinuxSampler {
1087    
1088      /** @brief Virtual machine relative pointer.      /** @brief Virtual machine relative pointer.
1089       *       *
1090       * POD base of VMIntRelPtr and VMInt8RelPtr structures. Not intended to be       * POD base of VMInt64RelPtr, VMInt32RelPtr and VMInt8RelPtr structures. Not
1091       * used directly. Use VMIntRelPtr or VMInt8RelPtr instead.       * intended to be used directly. Use VMInt64RelPtr, VMInt32RelPtr,
1092         * VMInt8RelPtr instead.
1093       *       *
1094       * @see VMIntRelPtr, VMInt8RelPtr       * @see VMInt64RelPtr, VMInt32RelPtr, VMInt8RelPtr
1095       */       */
1096      struct VMRelPtr {      struct VMRelPtr {
1097          void** base; ///< Base pointer.          void** base; ///< Base pointer.
1098          int offset;  ///< Offset (in bytes) relative to base pointer.          vmint offset;  ///< Offset (in bytes) relative to base pointer.
1099            bool readonly; ///< Whether the pointed data may be modified or just be read.
1100        };
1101    
1102        /** @brief Pointer to built-in VM integer variable (interface class).
1103         *
1104         * This class acts as an abstract interface to all built-in integer script
1105         * variables, independent of their actual native size (i.e. some built-in
1106         * script variables are internally using a native int size of 64 bit or 32
1107         * bit or 8 bit). The virtual machine is using this interface class instead
1108         * of its implementing descendants (VMInt64RelPtr, VMInt32RelPtr,
1109         * VMInt8RelPtr) in order for the virtual machine for not being required to
1110         * handle each of them differently.
1111         */
1112        struct VMIntPtr {
1113            virtual vmint evalInt() = 0;
1114            virtual void assign(vmint i) = 0;
1115            virtual bool isAssignable() const = 0;
1116        };
1117    
1118        /** @brief Pointer to built-in VM integer variable (of C/C++ type int64_t).
1119         *
1120         * Used for defining built-in 64 bit integer script variables.
1121         *
1122         * @b CAUTION: You may only use this class for pointing to C/C++ variables
1123         * of type "int64_t" (thus being exactly 64 bit in size). If the C/C++ int
1124         * variable you want to reference is only 32 bit in size then you @b must
1125         * use VMInt32RelPtr instead! Respectively for a referenced native variable
1126         * with only 8 bit in size you @b must use VMInt8RelPtr instead!
1127         *
1128         * For efficiency reasons the actual native C/C++ int variable is referenced
1129         * by two components here. The actual native int C/C++ variable in memory
1130         * is dereferenced at VM run-time by taking the @c base pointer dereference
1131         * and adding @c offset bytes. This has the advantage that for a large
1132         * number of built-in int variables, only one (or few) base pointer need
1133         * to be re-assigned before running a script, instead of updating each
1134         * built-in variable each time before a script is executed.
1135         *
1136         * Refer to DECLARE_VMINT() for example code.
1137         *
1138         * @see VMInt32RelPtr, VMInt8RelPtr, DECLARE_VMINT()
1139         */
1140        struct VMInt64RelPtr : VMRelPtr, VMIntPtr {
1141            VMInt64RelPtr() {
1142                base   = NULL;
1143                offset = 0;
1144                readonly = false;
1145            }
1146            VMInt64RelPtr(const VMRelPtr& data) {
1147                base   = data.base;
1148                offset = data.offset;
1149                readonly = false;
1150            }
1151            vmint evalInt() OVERRIDE {
1152                return (vmint)*(int64_t*)&(*(uint8_t**)base)[offset];
1153            }
1154            void assign(vmint i) OVERRIDE {
1155                *(int64_t*)&(*(uint8_t**)base)[offset] = (int64_t)i;
1156            }
1157            bool isAssignable() const OVERRIDE { return !readonly; }
1158      };      };
1159    
1160      /** @brief Pointer to built-in VM integer variable (of C/C++ type int).      /** @brief Pointer to built-in VM integer variable (of C/C++ type int32_t).
1161       *       *
1162       * Used for defining built-in 32 bit integer script variables.       * Used for defining built-in 32 bit integer script variables.
1163       *       *
1164       * @b CAUTION: You may only use this class for pointing to C/C++ variables       * @b CAUTION: You may only use this class for pointing to C/C++ variables
1165       * of type "int" (which on most systems is 32 bit in size). If the C/C++ int       * of type "int32_t" (thus being exactly 32 bit in size). If the C/C++ int
1166       * variable you want to reference is only 8 bit in size, then you @b must       * variable you want to reference is 64 bit in size then you @b must use
1167       * use VMInt8RelPtr instead!       * VMInt64RelPtr instead! Respectively for a referenced native variable with
1168         * only 8 bit in size you @b must use VMInt8RelPtr instead!
1169       *       *
1170       * For efficiency reasons the actual native C/C++ int variable is referenced       * For efficiency reasons the actual native C/C++ int variable is referenced
1171       * by two components here. The actual native int C/C++ variable in memory       * by two components here. The actual native int C/C++ variable in memory
# Line 444  namespace LinuxSampler { Line 1177  namespace LinuxSampler {
1177       *       *
1178       * Refer to DECLARE_VMINT() for example code.       * Refer to DECLARE_VMINT() for example code.
1179       *       *
1180       * @see VMInt8RelPtr, DECLARE_VMINT()       * @see VMInt64RelPtr, VMInt8RelPtr, DECLARE_VMINT()
1181       */       */
1182      struct VMIntRelPtr : VMRelPtr {      struct VMInt32RelPtr : VMRelPtr, VMIntPtr {
1183          VMIntRelPtr() {          VMInt32RelPtr() {
1184              base   = NULL;              base   = NULL;
1185              offset = 0;              offset = 0;
1186                readonly = false;
1187          }          }
1188          VMIntRelPtr(const VMRelPtr& data) {          VMInt32RelPtr(const VMRelPtr& data) {
1189              base   = data.base;              base   = data.base;
1190              offset = data.offset;              offset = data.offset;
1191                readonly = false;
1192            }
1193            vmint evalInt() OVERRIDE {
1194                return (vmint)*(int32_t*)&(*(uint8_t**)base)[offset];
1195            }
1196            void assign(vmint i) OVERRIDE {
1197                *(int32_t*)&(*(uint8_t**)base)[offset] = (int32_t)i;
1198          }          }
1199          virtual int evalInt() { return *(int*)&(*(uint8_t**)base)[offset]; }          bool isAssignable() const OVERRIDE { return !readonly; }
         virtual void assign(int i) { *(int*)&(*(uint8_t**)base)[offset] = i; }  
1200      };      };
1201    
1202      /** @brief Pointer to built-in VM integer variable (of C/C++ type int8_t).      /** @brief Pointer to built-in VM integer variable (of C/C++ type int8_t).
# Line 465  namespace LinuxSampler { Line 1205  namespace LinuxSampler {
1205       *       *
1206       * @b CAUTION: You may only use this class for pointing to C/C++ variables       * @b CAUTION: You may only use this class for pointing to C/C++ variables
1207       * of type "int8_t" (8 bit integer). If the C/C++ int variable you want to       * of type "int8_t" (8 bit integer). If the C/C++ int variable you want to
1208       * reference is an "int" type (which is 32 bit on most systems), then you       * reference is not exactly 8 bit in size then you @b must respectively use
1209       * @b must use VMIntRelPtr instead!       * either VMInt32RelPtr for native 32 bit variables or VMInt64RelPtrl for
1210         * native 64 bit variables instead!
1211       *       *
1212       * For efficiency reasons the actual native C/C++ int variable is referenced       * For efficiency reasons the actual native C/C++ int variable is referenced
1213       * by two components here. The actual native int C/C++ variable in memory       * by two components here. The actual native int C/C++ variable in memory
# Line 478  namespace LinuxSampler { Line 1219  namespace LinuxSampler {
1219       *       *
1220       * Refer to DECLARE_VMINT() for example code.       * Refer to DECLARE_VMINT() for example code.
1221       *       *
1222       * @see VMIntRelPtr, DECLARE_VMINT()       * @see VMIntRel32Ptr, VMIntRel64Ptr, DECLARE_VMINT()
1223       */       */
1224      struct VMInt8RelPtr : VMIntRelPtr {      struct VMInt8RelPtr : VMRelPtr, VMIntPtr {
1225          VMInt8RelPtr() : VMIntRelPtr() {}          VMInt8RelPtr() {
1226          VMInt8RelPtr(const VMRelPtr& data) : VMIntRelPtr(data) {}              base   = NULL;
1227          virtual int evalInt() OVERRIDE {              offset = 0;
1228              return *(uint8_t*)&(*(uint8_t**)base)[offset];              readonly = false;
1229          }          }
1230          virtual void assign(int i) OVERRIDE {          VMInt8RelPtr(const VMRelPtr& data) {
1231              *(uint8_t*)&(*(uint8_t**)base)[offset] = i;              base   = data.base;
1232                offset = data.offset;
1233                readonly = false;
1234            }
1235            vmint evalInt() OVERRIDE {
1236                return (vmint)*(uint8_t*)&(*(uint8_t**)base)[offset];
1237            }
1238            void assign(vmint i) OVERRIDE {
1239                *(uint8_t*)&(*(uint8_t**)base)[offset] = (uint8_t)i;
1240          }          }
1241            bool isAssignable() const OVERRIDE { return !readonly; }
1242      };      };
1243    
1244        /** @brief Pointer to built-in VM integer variable (of C/C++ type vmint).
1245         *
1246         * Use this typedef if the native variable to be pointed to is using the
1247         * typedef vmint. If the native C/C++ variable to be pointed to is using
1248         * another C/C++ type then better use one of VMInt64RelPtr or VMInt32RelPtr
1249         * instead.
1250         */
1251        typedef VMInt64RelPtr VMIntRelPtr;
1252    
1253        #if HAVE_CXX_EMBEDDED_PRAGMA_DIAGNOSTICS
1254        # define COMPILER_DISABLE_OFFSETOF_WARNING                    \
1255            _Pragma("GCC diagnostic push")                            \
1256            _Pragma("GCC diagnostic ignored \"-Winvalid-offsetof\"")
1257        # define COMPILER_RESTORE_OFFSETOF_WARNING \
1258            _Pragma("GCC diagnostic pop")
1259        #else
1260        # define COMPILER_DISABLE_OFFSETOF_WARNING
1261        # define COMPILER_RESTORE_OFFSETOF_WARNING
1262        #endif
1263    
1264      /**      /**
1265       * Convenience macro for initializing VMIntRelPtr and VMInt8RelPtr       * Convenience macro for initializing VMInt64RelPtr, VMInt32RelPtr and
1266       * structures. Usage example:       * VMInt8RelPtr structures. Usage example:
1267       * @code       * @code
1268       * struct Foo {       * struct Foo {
1269       *   uint8_t a; // native representation of a built-in integer script variable       *   uint8_t a; // native representation of a built-in integer script variable
1270       *   int b; // native representation of another built-in integer script variable       *   int64_t b; // native representation of another built-in integer script variable
1271       *   int c; // native representation of another built-in integer script variable       *   int64_t c; // native representation of another built-in integer script variable
1272       *   uint8_t d; // native representation of another built-in integer script variable       *   uint8_t d; // native representation of another built-in integer script variable
1273       * };       * };
1274       *       *
# Line 509  namespace LinuxSampler { Line 1279  namespace LinuxSampler {
1279       * Foo* pFoo;       * Foo* pFoo;
1280       *       *
1281       * VMInt8RelPtr varA = DECLARE_VMINT(pFoo, class Foo, a);       * VMInt8RelPtr varA = DECLARE_VMINT(pFoo, class Foo, a);
1282       * VMIntRelPtr  varB = DECLARE_VMINT(pFoo, class Foo, b);       * VMInt64RelPtr varB = DECLARE_VMINT(pFoo, class Foo, b);
1283       * VMIntRelPtr  varC = DECLARE_VMINT(pFoo, class Foo, c);       * VMInt64RelPtr varC = DECLARE_VMINT(pFoo, class Foo, c);
1284       * VMInt8RelPtr varD = DECLARE_VMINT(pFoo, class Foo, d);       * VMInt8RelPtr varD = DECLARE_VMINT(pFoo, class Foo, d);
1285       *       *
1286       * pFoo = &foo1;       * pFoo = &foo1;
# Line 533  namespace LinuxSampler { Line 1303  namespace LinuxSampler {
1303       * complexity inside the sampler engines which provide the actual script       * complexity inside the sampler engines which provide the actual script
1304       * functionalities.       * functionalities.
1305       */       */
1306      #define DECLARE_VMINT(basePtr, T_struct, T_member) ( \      #define DECLARE_VMINT(basePtr, T_struct, T_member) (          \
1307          (VMRelPtr) {                                     \          /* Disable offsetof warning, trust us, we are cautios. */ \
1308              (void**) &basePtr,                           \          COMPILER_DISABLE_OFFSETOF_WARNING                         \
1309              offsetof(T_struct, T_member)                 \          (VMRelPtr) {                                              \
1310          }                                                \              (void**) &basePtr,                                    \
1311      )                                                    \              offsetof(T_struct, T_member),                         \
1312                false                                                 \
1313            }                                                         \
1314            COMPILER_RESTORE_OFFSETOF_WARNING                         \
1315        )                                                             \
1316    
1317        /**
1318         * Same as DECLARE_VMINT(), but this one defines the VMInt64RelPtr,
1319         * VMInt32RelPtr and VMInt8RelPtr structures to be of read-only type.
1320         * That means the script parser will abort any script at parser time if the
1321         * script is trying to modify such a read-only built-in variable.
1322         *
1323         * @b NOTE: this is only intended for built-in read-only variables that
1324         * may change during runtime! If your built-in variable's data is rather
1325         * already available at parser time and won't change during runtime, then
1326         * you should rather register a built-in constant in your VM class instead!
1327         *
1328         * @see ScriptVM::builtInConstIntVariables()
1329         */
1330        #define DECLARE_VMINT_READONLY(basePtr, T_struct, T_member) ( \
1331            /* Disable offsetof warning, trust us, we are cautios. */ \
1332            COMPILER_DISABLE_OFFSETOF_WARNING                         \
1333            (VMRelPtr) {                                              \
1334                (void**) &basePtr,                                    \
1335                offsetof(T_struct, T_member),                         \
1336                true                                                  \
1337            }                                                         \
1338            COMPILER_RESTORE_OFFSETOF_WARNING                         \
1339        )                                                             \
1340    
1341      /** @brief Built-in VM 8 bit integer array variable.      /** @brief Built-in VM 8 bit integer array variable.
1342       *       *
1343       * Used for defining built-in integer array script variables (8 bit per       * Used for defining built-in integer array script variables (8 bit per
1344       * array element). Currently there is no support for any other kind of array       * array element). Currently there is no support for any other kind of
1345       * type. So all integer arrays of scripts use 8 bit data types.       * built-in array type. So all built-in integer arrays accessed by scripts
1346         * use 8 bit data types.
1347       */       */
1348      struct VMInt8Array {      struct VMInt8Array {
1349          int8_t* data;          int8_t* data;
1350          int size;          vmint size;
1351            bool readonly; ///< Whether the array data may be modified or just be read.
1352    
1353            VMInt8Array() : data(NULL), size(0), readonly(false) {}
1354        };
1355    
1356        /** @brief Virtual machine script variable.
1357         *
1358         * Common interface for all variables accessed in scripts, independent of
1359         * their precise data type.
1360         */
1361        class VMVariable : virtual public VMExpr {
1362        public:
1363            /**
1364             * Whether a script may modify the content of this variable by
1365             * assigning a new value to it.
1366             *
1367             * @see isConstExpr(), assign()
1368             */
1369            virtual bool isAssignable() const = 0;
1370    
1371          VMInt8Array() : data(NULL), size(0) {}          /**
1372             * In case this variable is assignable, this method will be called to
1373             * perform the value assignment to this variable with @a expr
1374             * reflecting the new value to be assigned.
1375             *
1376             * @param expr - new value to be assigned to this variable
1377             */
1378            virtual void assignExpr(VMExpr* expr) = 0;
1379        };
1380    
1381        /** @brief Dynamically executed variable (abstract base class).
1382         *
1383         * Interface for the implementation of a dynamically generated content of
1384         * a built-in script variable. Most built-in variables are simply pointers
1385         * to some native location in memory. So when a script reads them, the
1386         * memory location is simply read to get the value of the variable. A
1387         * dynamic variable however is not simply a memory location. For each access
1388         * to a dynamic variable some native code is executed to actually generate
1389         * and provide the content (value) of this type of variable.
1390         */
1391        class VMDynVar : public VMVariable {
1392        public:
1393            /**
1394             * Returns true in case this dynamic variable can be considered to be a
1395             * constant expression. A constant expression will retain the same value
1396             * throughout the entire life time of a script and the expression's
1397             * constant value may be evaluated already at script parse time, which
1398             * may result in performance benefits during script runtime.
1399             *
1400             * However due to the "dynamic" behavior of dynamic variables, almost
1401             * all dynamic variables are probably not constant expressions. That's
1402             * why this method returns @c false by default. If you are really sure
1403             * that your dynamic variable implementation can be considered a
1404             * constant expression then you may override this method and return
1405             * @c true instead. Note that when you return @c true here, your
1406             * dynamic variable will really just be executed once; and exectly
1407             * already when the script is loaded!
1408             *
1409             * As an example you may implement a "constant" built-in dynamic
1410             * variable that checks for a certain operating system feature and
1411             * returns the result of that OS feature check as content (value) of
1412             * this dynamic variable. Since the respective OS feature might become
1413             * available/unavailable after OS updates, software migration, etc. the
1414             * OS feature check should at least be performed once each time the
1415             * application is launched. And since the OS feature check might take a
1416             * certain amount of execution time, it might make sense to only
1417             * perform the check if the respective variable name is actually
1418             * referenced at all in the script to be loaded. Note that the dynamic
1419             * variable will still be evaluated again though if the script is
1420             * loaded again. So it is up to you to probably cache the result in the
1421             * implementation of your dynamic variable.
1422             *
1423             * On doubt, please rather consider to use a constant built-in script
1424             * variable instead of implementing a "constant" dynamic variable, due
1425             * to the runtime overhead a dynamic variable may cause.
1426             *
1427             * @see isAssignable()
1428             */
1429            bool isConstExpr() const OVERRIDE { return false; }
1430    
1431            /**
1432             * In case this dynamic variable is assignable, the new value (content)
1433             * to be assigned to this dynamic variable.
1434             *
1435             * By default this method does nothing. Override and implement this
1436             * method in your subclass in case your dynamic variable allows to
1437             * assign a new value by script.
1438             *
1439             * @param expr - new value to be assigned to this variable
1440             */
1441            void assignExpr(VMExpr* expr) OVERRIDE {}
1442    
1443            virtual ~VMDynVar() {}
1444        };
1445    
1446        /** @brief Dynamically executed variable (of integer data type).
1447         *
1448         * This is the base class for all built-in integer script variables whose
1449         * variable content needs to be provided dynamically by executable native
1450         * code on each script variable access.
1451         */
1452        class VMDynIntVar : virtual public VMDynVar, virtual public VMIntExpr {
1453        public:
1454            vmfloat unitFactor() const OVERRIDE { return VM_NO_FACTOR; }
1455            StdUnit_t unitType() const OVERRIDE { return VM_NO_UNIT; }
1456            bool isFinal() const OVERRIDE { return false; }
1457        };
1458    
1459        /** @brief Dynamically executed variable (of string data type).
1460         *
1461         * This is the base class for all built-in string script variables whose
1462         * variable content needs to be provided dynamically by executable native
1463         * code on each script variable access.
1464         */
1465        class VMDynStringVar : virtual public VMDynVar, virtual public VMStringExpr {
1466        public:
1467        };
1468    
1469        /** @brief Dynamically executed variable (of integer array data type).
1470         *
1471         * This is the base class for all built-in integer array script variables
1472         * whose variable content needs to be provided dynamically by executable
1473         * native code on each script variable access.
1474         */
1475        class VMDynIntArrayVar : virtual public VMDynVar, virtual public VMIntArrayExpr {
1476        public:
1477      };      };
1478    
1479      /** @brief Provider for built-in script functions and variables.      /** @brief Provider for built-in script functions and variables.
# Line 571  namespace LinuxSampler { Line 1494  namespace LinuxSampler {
1494          virtual VMFunction* functionByName(const String& name) = 0;          virtual VMFunction* functionByName(const String& name) = 0;
1495    
1496          /**          /**
1497             * Returns @c true if the passed built-in function is disabled and
1498             * should be ignored by the parser. This method is called by the
1499             * parser on preprocessor level for each built-in function call within
1500             * a script. Accordingly if this method returns @c true, then the
1501             * respective function call is completely filtered out on preprocessor
1502             * level, so that built-in function won't make into the result virtual
1503             * machine representation, nor would expressions of arguments passed to
1504             * that built-in function call be evaluated, nor would any check
1505             * regarding correct usage of the built-in function be performed.
1506             * In other words: a disabled function call ends up as a comment block.
1507             *
1508             * @param fn - built-in function to be checked
1509             * @param ctx - parser context at the position where the built-in
1510             *              function call is located within the script
1511             */
1512            virtual bool isFunctionDisabled(VMFunction* fn, VMParserContext* ctx) = 0;
1513    
1514            /**
1515           * Returns a variable name indexed map of all built-in script variables           * Returns a variable name indexed map of all built-in script variables
1516           * which point to native "int" scalar (usually 32 bit) variables.           * which point to native "int" scalar (usually 32 bit) variables.
1517           */           */
1518          virtual std::map<String,VMIntRelPtr*> builtInIntVariables() = 0;          virtual std::map<String,VMIntPtr*> builtInIntVariables() = 0;
1519    
1520          /**          /**
1521           * Returns a variable name indexed map of all built-in script integer           * Returns a variable name indexed map of all built-in script integer
# Line 584  namespace LinuxSampler { Line 1525  namespace LinuxSampler {
1525    
1526          /**          /**
1527           * Returns a variable name indexed map of all built-in constant script           * Returns a variable name indexed map of all built-in constant script
1528           * variables, which never change their value at runtime.           * variables of integer type, which never change their value at runtime.
1529           */           */
1530          virtual std::map<String,int> builtInConstIntVariables() = 0;          virtual std::map<String,vmint> builtInConstIntVariables() = 0;
1531    
1532            /**
1533             * Returns a variable name indexed map of all built-in constant script
1534             * variables of real number (floating point) type, which never change
1535             * their value at runtime.
1536             */
1537            virtual std::map<String,vmfloat> builtInConstRealVariables() = 0;
1538    
1539            /**
1540             * Returns a variable name indexed map of all built-in dynamic variables,
1541             * which are not simply data stores, rather each one of them executes
1542             * natively to provide or alter the respective script variable data.
1543             */
1544            virtual std::map<String,VMDynVar*> builtInDynamicVariables() = 0;
1545      };      };
1546    
1547      /** @brief Execution state of a virtual machine.      /** @brief Execution state of a virtual machine.
# Line 628  namespace LinuxSampler { Line 1583  namespace LinuxSampler {
1583           *           *
1584           * @see ScriptVM::exec()           * @see ScriptVM::exec()
1585           */           */
1586          virtual int suspensionTimeMicroseconds() const = 0;          virtual vmint suspensionTimeMicroseconds() const = 0;
1587    
1588            /**
1589             * Causes all polyphonic variables to be reset to zero values. A
1590             * polyphonic variable is expected to be zero when entering a new event
1591             * handler instance. As an exception the values of polyphonic variables
1592             * shall only be preserved from an note event handler instance to its
1593             * correspending specific release handler instance. So in the latter
1594             * case the script author may pass custom data from the note handler to
1595             * the release handler, but only for the same specific note!
1596             */
1597            virtual void resetPolyphonicData() = 0;
1598    
1599            /**
1600             * Returns amount of virtual machine instructions which have been
1601             * performed the last time when this execution context was executing a
1602             * script. So in case you need the overall amount of instructions
1603             * instead, then you need to add them by yourself after each
1604             * ScriptVM::exec() call.
1605             */
1606            virtual size_t instructionsPerformed() const = 0;
1607    
1608            /**
1609             * Sends a signal to this script execution instance to abort its script
1610             * execution as soon as possible. This method is called i.e. when one
1611             * script execution instance intends to stop another script execution
1612             * instance.
1613             */
1614            virtual void signalAbort() = 0;
1615    
1616            /**
1617             * Copies the current entire execution state from this object to the
1618             * given object. So this can be used to "fork" a new script thread which
1619             * then may run independently with its own polyphonic data for instance.
1620             */
1621            virtual void forkTo(VMExecContext* ectx) const = 0;
1622    
1623            /**
1624             * In case the script called the built-in exit() function and passed a
1625             * value as argument to the exit() function, then this method returns
1626             * the value that had been passed as argument to the exit() function.
1627             * Otherwise if the exit() function has not been called by the script
1628             * or no argument had been passed to the exit() function, then this
1629             * method returns NULL instead.
1630             *
1631             * Currently this is only used for automated test cases against the
1632             * script engine, which return some kind of value in the individual
1633             * test case scripts to check their behaviour in automated way. There
1634             * is no purpose for this mechanism in production use. Accordingly this
1635             * exit result value is @b always completely ignored by the sampler
1636             * engines.
1637             *
1638             * Officially the built-in exit() function does not expect any arguments
1639             * to be passed to its function call, and by default this feature is
1640             * hence disabled and will yield in a parser error unless
1641             * ScriptVM::setExitResultEnabled() was explicitly set.
1642             *
1643             * @see ScriptVM::setExitResultEnabled()
1644             */
1645            virtual VMExpr* exitResult() = 0;
1646      };      };
1647    
1648      /** @brief Script callback for a certain event.      /** @brief Script callback for a certain event.
# Line 660  namespace LinuxSampler { Line 1674  namespace LinuxSampler {
1674      };      };
1675    
1676      /**      /**
1677         * Reflects the precise position and span of a specific code block within
1678         * a script. This is currently only used for the locations of commented
1679         * code blocks due to preprocessor statements, and for parser errors and
1680         * parser warnings.
1681         *
1682         * @see ParserIssue for code locations of parser errors and parser warnings
1683         *
1684         * @see VMParserContext::preprocessorComments() for locations of code which
1685         *      have been filtered out by preprocessor statements
1686         */
1687        struct CodeBlock {
1688            int firstLine; ///< The first line number of this code block within the script (indexed with 1 being the very first line).
1689            int lastLine; ///< The last line number of this code block within the script.
1690            int firstColumn; ///< The first column of this code block within the script (indexed with 1 being the very first column).
1691            int lastColumn; ///< The last column of this code block within the script.
1692        };
1693    
1694        /**
1695       * Encapsulates a noteworty parser issue. This encompasses the type of the       * Encapsulates a noteworty parser issue. This encompasses the type of the
1696       * issue (either a parser error or parser warning), a human readable       * issue (either a parser error or parser warning), a human readable
1697       * explanation text of the error or warning and the location of the       * explanation text of the error or warning and the location of the
1698       * encountered parser issue within the script.       * encountered parser issue within the script.
1699         *
1700         * @see VMSourceToken for processing syntax highlighting instead.
1701       */       */
1702      struct ParserIssue {      struct ParserIssue : CodeBlock {
1703          String txt; ///< Human readable explanation text of the parser issue.          String txt; ///< Human readable explanation text of the parser issue.
         int line; ///< Line number within the script where this issue was encountered.  
1704          ParserIssueType_t type; ///< Whether this issue is either a parser error or just a parser warning.          ParserIssueType_t type; ///< Whether this issue is either a parser error or just a parser warning.
1705    
1706          /**          /**
# Line 676  namespace LinuxSampler { Line 1709  namespace LinuxSampler {
1709          inline void dump() {          inline void dump() {
1710              switch (type) {              switch (type) {
1711                  case PARSER_ERROR:                  case PARSER_ERROR:
1712                      printf("[ERROR] line %d: %s\n", line, txt.c_str());                      printf("[ERROR] line %d, column %d: %s\n", firstLine, firstColumn, txt.c_str());
1713                      break;                      break;
1714                  case PARSER_WARNING:                  case PARSER_WARNING:
1715                      printf("[Warning] line %d: %s\n", line, txt.c_str());                      printf("[Warning] line %d, column %d: %s\n", firstLine, firstColumn, txt.c_str());
1716                      break;                      break;
1717              }              }
1718          }          }
# Line 707  namespace LinuxSampler { Line 1740  namespace LinuxSampler {
1740              case EMPTY_EXPR: return "empty";              case EMPTY_EXPR: return "empty";
1741              case INT_EXPR: return "integer";              case INT_EXPR: return "integer";
1742              case INT_ARR_EXPR: return "integer array";              case INT_ARR_EXPR: return "integer array";
1743                case REAL_EXPR: return "real number";
1744                case REAL_ARR_EXPR: return "real number array";
1745              case STRING_EXPR: return "string";              case STRING_EXPR: return "string";
1746              case STRING_ARR_EXPR: return "string array";              case STRING_ARR_EXPR: return "string array";
1747          }          }
1748          return "invalid";          return "invalid";
1749      }      }
1750    
1751        /**
1752         * Returns @c true in case the passed data type is some array data type.
1753         */
1754        inline bool isArray(const ExprType_t& type) {
1755            return type == INT_ARR_EXPR || type == REAL_ARR_EXPR ||
1756                   type == STRING_ARR_EXPR;
1757        }
1758    
1759        /**
1760         * Returns @c true in case the passed data type is some scalar number type
1761         * (i.e. not an array and not a string).
1762         */
1763        inline bool isNumber(const ExprType_t& type) {
1764            return type == INT_EXPR || type == REAL_EXPR;
1765        }
1766    
1767        /**
1768         * Convenience function used for converting an StdUnit_t constant to a
1769         * string, i.e. for generating error message by the parser.
1770         */
1771        inline String unitTypeStr(const StdUnit_t& type) {
1772            switch (type) {
1773                case VM_NO_UNIT: return "none";
1774                case VM_SECOND: return "seconds";
1775                case VM_HERTZ: return "Hz";
1776                case VM_BEL: return "Bel";
1777            }
1778            return "invalid";
1779        }
1780    
1781      /** @brief Virtual machine representation of a script.      /** @brief Virtual machine representation of a script.
1782       *       *
1783       * An instance of this abstract base class represents a parsed script,       * An instance of this abstract base class represents a parsed script,
# Line 747  namespace LinuxSampler { Line 1812  namespace LinuxSampler {
1812          virtual std::vector<ParserIssue> warnings() const = 0;          virtual std::vector<ParserIssue> warnings() const = 0;
1813    
1814          /**          /**
1815             * Returns all code blocks of the script which were filtered out by the
1816             * preprocessor.
1817             */
1818            virtual std::vector<CodeBlock> preprocessorComments() const = 0;
1819    
1820            /**
1821           * Returns the translated virtual machine representation of an event           * Returns the translated virtual machine representation of an event
1822           * handler block (i.e. "on note ... end on" code block) within the           * handler block (i.e. "on note ... end on" code block) within the
1823           * parsed script. This translated representation of the event handler           * parsed script. This translated representation of the event handler
# Line 779  namespace LinuxSampler { Line 1850  namespace LinuxSampler {
1850       * This class is not actually used by the sampler itself. It is rather       * This class is not actually used by the sampler itself. It is rather
1851       * provided for external script editor applications. Primary purpose of       * provided for external script editor applications. Primary purpose of
1852       * this class is syntax highlighting for external script editors.       * this class is syntax highlighting for external script editors.
1853         *
1854         * @see ParserIssue for processing compile errors and warnings instead.
1855       */       */
1856      class VMSourceToken {      class VMSourceToken {
1857      public:      public:
# Line 791  namespace LinuxSampler { Line 1864  namespace LinuxSampler {
1864          String text() const;          String text() const;
1865    
1866          // position of token in script          // position of token in script
1867          int firstLine() const;          int firstLine() const; ///< First line this source token is located at in script source code (indexed with 0 being the very first line). Most source code tokens are not spanning over multiple lines, the only current exception are comments, in the latter case you need to process text() to get the last line and last column for the comment.
1868          int firstColumn() const;          int firstColumn() const; ///< First column on the first line this source token is located at in script source code (indexed with 0 being the very first column). To get the length of this token use text().length().
1869    
1870          // base types          // base types
1871          bool isEOF() const;          bool isEOF() const; ///< Returns true in case this source token represents the end of the source code file.
1872          bool isNewLine() const;          bool isNewLine() const; ///< Returns true in case this source token represents a line feed character (i.e. "\n" on Unix systems).
1873          bool isKeyword() const;          bool isKeyword() const; ///< Returns true in case this source token represents a language keyword (i.e. "while", "function", "declare", "on", etc.).
1874          bool isVariableName() const;          bool isVariableName() const; ///< Returns true in case this source token represents a variable name (i.e. "$someIntVariable", "%someArrayVariable", "\@someStringVariable"). @see isIntegerVariable(), isStringVariable(), isArrayVariable() for the precise variable type.
1875          bool isIdentifier() const;          bool isIdentifier() const; ///< Returns true in case this source token represents an identifier, which currently always means a function name.
1876          bool isNumberLiteral() const;          bool isNumberLiteral() const; ///< Returns true in case this source token represents a number literal (i.e. 123).
1877          bool isStringLiteral() const;          bool isStringLiteral() const; ///< Returns true in case this source token represents a string literal (i.e. "Some text").
1878          bool isComment() const;          bool isComment() const; ///< Returns true in case this source token represents a source code comment.
1879          bool isPreprocessor() const;          bool isPreprocessor() const; ///< Returns true in case this source token represents a preprocessor statement.
1880          bool isOther() const;          bool isMetricPrefix() const;
1881            bool isStdUnit() const;
1882            bool isOther() const; ///< Returns true in case this source token represents anything else not covered by the token types mentioned above.
1883    
1884          // extended types          // extended types
1885          bool isIntegerVariable() const;          bool isIntegerVariable() const; ///< Returns true in case this source token represents an integer variable name (i.e. "$someIntVariable").
1886          bool isStringVariable() const;          bool isRealVariable() const; ///< Returns true in case this source token represents a floating point variable name (i.e. "~someRealVariable").
1887          bool isArrayVariable() const;          bool isStringVariable() const; ///< Returns true in case this source token represents an string variable name (i.e. "\@someStringVariable").
1888          bool isEventHandlerName() const;          bool isIntArrayVariable() const; ///< Returns true in case this source token represents an integer array variable name (i.e. "%someArrayVariable").
1889            bool isRealArrayVariable() const; ///< Returns true in case this source token represents a real number array variable name (i.e. "?someArrayVariable").
1890            bool isArrayVariable() const DEPRECATED_API; ///< Returns true in case this source token represents an @b integer array variable name (i.e. "%someArrayVariable"). @deprecated This method will be removed, use isIntArrayVariable() instead.
1891            bool isEventHandlerName() const; ///< Returns true in case this source token represents an event handler name (i.e. "note", "release", "controller").
1892    
1893          VMSourceToken& operator=(const VMSourceToken& other);          VMSourceToken& operator=(const VMSourceToken& other);
1894    

Legend:
Removed from v.2885  
changed lines
  Added in v.3590

  ViewVC Help
Powered by ViewVC