/[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 2960 by schoenebeck, Sun Jul 17 12:10:06 2016 UTC revision 3221 by schoenebeck, Fri May 26 18:30:42 2017 UTC
# Line 1  Line 1 
1  /*  /*
2   * Copyright (c) 2014-2016 Christian Schoenebeck   * Copyright (c) 2014-2017 Christian Schoenebeck
3   *   *
4   * http://www.linuxsampler.org   * http://www.linuxsampler.org
5   *   *
# Line 157  namespace LinuxSampler { Line 157  namespace LinuxSampler {
157           * expressions to an array expression for you, instead this method will           * expressions to an array expression for you, instead this method will
158           * simply return NULL!           * simply return NULL!
159           *           *
160             * @b Note: this method is currently, and in contrast to its other
161             * counter parts, declared as virtual method. Some deriving classes are
162             * currently using this to override this default implementation in order
163             * to implement an "evaluate now as integer array" behavior. This has
164             * efficiency reasons, however this also currently makes this part of
165             * the API less clean and should thus be addressed in future with
166             * appropriate changes to the API.
167             *
168           * @see exprType()           * @see exprType()
169           */           */
170          VMIntArrayExpr* asIntArray() const;          virtual VMIntArrayExpr* asIntArray() const;
171    
172          /**          /**
173           * Returns true in case this expression can be considered to be a           * Returns true in case this expression can be considered to be a
# Line 539  namespace LinuxSampler { Line 547  namespace LinuxSampler {
547          }          }
548      };      };
549    
550        #if HAVE_CXX_EMBEDDED_PRAGMA_DIAGNOSTICS
551        # define COMPILER_DISABLE_OFFSETOF_WARNING                    \
552            _Pragma("GCC diagnostic push")                            \
553            _Pragma("GCC diagnostic ignored \"-Winvalid-offsetof\"")
554        # define COMPILER_RESTORE_OFFSETOF_WARNING \
555            _Pragma("GCC diagnostic pop")
556        #else
557        # define COMPILER_DISABLE_OFFSETOF_WARNING
558        # define COMPILER_RESTORE_OFFSETOF_WARNING
559        #endif
560    
561      /**      /**
562       * Convenience macro for initializing VMIntRelPtr and VMInt8RelPtr       * Convenience macro for initializing VMIntRelPtr and VMInt8RelPtr
563       * structures. Usage example:       * structures. Usage example:
# Line 581  namespace LinuxSampler { Line 600  namespace LinuxSampler {
600       * complexity inside the sampler engines which provide the actual script       * complexity inside the sampler engines which provide the actual script
601       * functionalities.       * functionalities.
602       */       */
603      #define DECLARE_VMINT(basePtr, T_struct, T_member) ( \      #define DECLARE_VMINT(basePtr, T_struct, T_member) (          \
604          (VMRelPtr) {                                     \          /* Disable offsetof warning, trust us, we are cautios. */ \
605              (void**) &basePtr,                           \          COMPILER_DISABLE_OFFSETOF_WARNING                         \
606              offsetof(T_struct, T_member),                \          (VMRelPtr) {                                              \
607              false                                        \              (void**) &basePtr,                                    \
608          }                                                \              offsetof(T_struct, T_member),                         \
609      )                                                    \              false                                                 \
610            }                                                         \
611            COMPILER_RESTORE_OFFSETOF_WARNING                         \
612        )                                                             \
613    
614      /**      /**
615       * Same as DECLARE_VMINT(), but this one defines the VMIntRelPtr and       * Same as DECLARE_VMINT(), but this one defines the VMIntRelPtr and
# Line 603  namespace LinuxSampler { Line 625  namespace LinuxSampler {
625       * @see ScriptVM::builtInConstIntVariables()       * @see ScriptVM::builtInConstIntVariables()
626       */       */
627      #define DECLARE_VMINT_READONLY(basePtr, T_struct, T_member) ( \      #define DECLARE_VMINT_READONLY(basePtr, T_struct, T_member) ( \
628          (VMRelPtr) {                                          \          /* Disable offsetof warning, trust us, we are cautios. */ \
629              (void**) &basePtr,                                \          COMPILER_DISABLE_OFFSETOF_WARNING                         \
630              offsetof(T_struct, T_member),                     \          (VMRelPtr) {                                              \
631              true                                              \              (void**) &basePtr,                                    \
632          }                                                     \              offsetof(T_struct, T_member),                         \
633      )                                                         \              true                                                  \
634            }                                                         \
635            COMPILER_RESTORE_OFFSETOF_WARNING                         \
636        )                                                             \
637    
638      /** @brief Built-in VM 8 bit integer array variable.      /** @brief Built-in VM 8 bit integer array variable.
639       *       *
# Line 708  namespace LinuxSampler { Line 733  namespace LinuxSampler {
733           * @param expr - new value to be assigned to this variable           * @param expr - new value to be assigned to this variable
734           */           */
735          void assignExpr(VMExpr* expr) OVERRIDE {}          void assignExpr(VMExpr* expr) OVERRIDE {}
736    
737            virtual ~VMDynVar() {}
738      };      };
739    
740      /** @brief Dynamically executed variable (of integer data type).      /** @brief Dynamically executed variable (of integer data type).
# Line 730  namespace LinuxSampler { Line 757  namespace LinuxSampler {
757      public:      public:
758      };      };
759    
760        /** @brief Dynamically executed variable (of integer array data type).
761         *
762         * This is the base class for all built-in integer array script variables
763         * whose variable content needs to be provided dynamically by executable
764         * native code on each script variable access.
765         */
766        class VMDynIntArrayVar : virtual public VMDynVar, virtual public VMIntArrayExpr {
767        public:
768        };
769    
770      /** @brief Provider for built-in script functions and variables.      /** @brief Provider for built-in script functions and variables.
771       *       *
772       * Abstract base class defining the high-level interface for all classes       * Abstract base class defining the high-level interface for all classes
# Line 813  namespace LinuxSampler { Line 850  namespace LinuxSampler {
850           * @see ScriptVM::exec()           * @see ScriptVM::exec()
851           */           */
852          virtual int suspensionTimeMicroseconds() const = 0;          virtual int suspensionTimeMicroseconds() const = 0;
853    
854            /**
855             * Causes all polyphonic variables to be reset to zero values. A
856             * polyphonic variable is expected to be zero when entering a new event
857             * handler instance. As an exception the values of polyphonic variables
858             * shall only be preserved from an note event handler instance to its
859             * correspending specific release handler instance. So in the latter
860             * case the script author may pass custom data from the note handler to
861             * the release handler, but only for the same specific note!
862             */
863            virtual void resetPolyphonicData() = 0;
864    
865            /**
866             * Returns amount of virtual machine instructions which have been
867             * performed the last time when this execution context was executing a
868             * script. So in case you need the overall amount of instructions
869             * instead, then you need to add them by yourself after each
870             * ScriptVM::exec() call.
871             */
872            virtual size_t instructionsPerformed() const = 0;
873      };      };
874    
875      /** @brief Script callback for a certain event.      /** @brief Script callback for a certain event.
# Line 848  namespace LinuxSampler { Line 905  namespace LinuxSampler {
905       * issue (either a parser error or parser warning), a human readable       * issue (either a parser error or parser warning), a human readable
906       * explanation text of the error or warning and the location of the       * explanation text of the error or warning and the location of the
907       * encountered parser issue within the script.       * encountered parser issue within the script.
908         *
909         * @see VMSourceToken for processing syntax highlighting instead.
910       */       */
911      struct ParserIssue {      struct ParserIssue {
912          String txt; ///< Human readable explanation text of the parser issue.          String txt; ///< Human readable explanation text of the parser issue.
# Line 966  namespace LinuxSampler { Line 1025  namespace LinuxSampler {
1025       * 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
1026       * provided for external script editor applications. Primary purpose of       * provided for external script editor applications. Primary purpose of
1027       * this class is syntax highlighting for external script editors.       * this class is syntax highlighting for external script editors.
1028         *
1029         * @see ParserIssue for processing compile errors and warnings instead.
1030       */       */
1031      class VMSourceToken {      class VMSourceToken {
1032      public:      public:
# Line 978  namespace LinuxSampler { Line 1039  namespace LinuxSampler {
1039          String text() const;          String text() const;
1040    
1041          // position of token in script          // position of token in script
1042          int firstLine() const; ///< First line this source token is located at in script source code (indexed with 0 being the very first line).          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.
1043          int firstColumn() const; ///< Last line this source token is located at in script source code.          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().
1044    
1045          // base types          // base types
1046          bool isEOF() const;          bool isEOF() const; ///< Returns true in case this source token represents the end of the source code file.
1047          bool isNewLine() const;          bool isNewLine() const; ///< Returns true in case this source token represents a line feed character (i.e. "\n" on Unix systems).
1048          bool isKeyword() const;          bool isKeyword() const; ///< Returns true in case this source token represents a language keyword (i.e. "while", "function", "declare", "on", etc.).
1049          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.
1050          bool isIdentifier() const;          bool isIdentifier() const; ///< Returns true in case this source token represents an identifier, which currently always means a function name.
1051          bool isNumberLiteral() const;          bool isNumberLiteral() const; ///< Returns true in case this source token represents a number literal (i.e. 123).
1052          bool isStringLiteral() const;          bool isStringLiteral() const; ///< Returns true in case this source token represents a string literal (i.e. "Some text").
1053          bool isComment() const;          bool isComment() const; ///< Returns true in case this source token represents a source code comment.
1054          bool isPreprocessor() const;          bool isPreprocessor() const; ///< Returns true in case this source token represents a preprocessor statement.
1055          bool isOther() const;          bool isOther() const; ///< Returns true in case this source token represents anything else not covered by the token types mentioned above.
1056    
1057          // extended types          // extended types
1058          bool isIntegerVariable() const;          bool isIntegerVariable() const; ///< Returns true in case this source token represents an integer variable name (i.e. "$someIntVariable").
1059          bool isStringVariable() const;          bool isStringVariable() const; ///< Returns true in case this source token represents an string variable name (i.e. "\@someStringVariable").
1060          bool isArrayVariable() const;          bool isArrayVariable() const; ///< Returns true in case this source token represents an array variable name (i.e. "%someArryVariable").
1061          bool isEventHandlerName() const;          bool isEventHandlerName() const; ///< Returns true in case this source token represents an event handler name (i.e. "note", "release", "controller").
1062    
1063          VMSourceToken& operator=(const VMSourceToken& other);          VMSourceToken& operator=(const VMSourceToken& other);
1064    

Legend:
Removed from v.2960  
changed lines
  Added in v.3221

  ViewVC Help
Powered by ViewVC