/[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 2948 by schoenebeck, Fri Jul 15 15:29:04 2016 UTC revision 3035 by schoenebeck, Mon Oct 31 12:00:00 2016 UTC
# Line 168  namespace LinuxSampler { Line 168  namespace LinuxSampler {
168           * expression's constant value may be evaluated already at script           * expression's constant value may be evaluated already at script
169           * parse time, which may result in performance benefits during script           * parse time, which may result in performance benefits during script
170           * runtime.           * runtime.
171             *
172             * @b NOTE: A constant expression is per se always also non modifyable.
173             * But a non modifyable expression may not necessarily be a constant
174             * expression!
175             *
176             * @see isModifyable()
177           */           */
178          virtual bool isConstExpr() const = 0;          virtual bool isConstExpr() const = 0;
179    
180            /**
181             * Returns true in case this expression is allowed to be modified.
182             * If this method returns @c false then this expression must be handled
183             * as read-only expression, which means that assigning a new value to it
184             * is either not possible or not allowed.
185             *
186             * @b NOTE: A constant expression is per se always also non modifyable.
187             * But a non modifyable expression may not necessarily be a constant
188             * expression!
189             *
190             * @see isConstExpr()
191             */
192          bool isModifyable() const;          bool isModifyable() const;
193      };      };
194    
# Line 521  namespace LinuxSampler { Line 539  namespace LinuxSampler {
539          }          }
540      };      };
541    
542        #if HAVE_CXX_EMBEDDED_PRAGMA_DIAGNOSTICS
543        # define COMPILER_DISABLE_OFFSETOF_WARNING                    \
544            _Pragma("GCC diagnostic push")                            \
545            _Pragma("GCC diagnostic ignored \"-Winvalid-offsetof\"")
546        # define COMPILER_RESTORE_OFFSETOF_WARNING \
547            _Pragma("GCC diagnostic pop")
548        #else
549        # define COMPILER_DISABLE_OFFSETOF_WARNING
550        # define COMPILER_RESTORE_OFFSETOF_WARNING
551        #endif
552    
553      /**      /**
554       * Convenience macro for initializing VMIntRelPtr and VMInt8RelPtr       * Convenience macro for initializing VMIntRelPtr and VMInt8RelPtr
555       * structures. Usage example:       * structures. Usage example:
# Line 563  namespace LinuxSampler { Line 592  namespace LinuxSampler {
592       * complexity inside the sampler engines which provide the actual script       * complexity inside the sampler engines which provide the actual script
593       * functionalities.       * functionalities.
594       */       */
595      #define DECLARE_VMINT(basePtr, T_struct, T_member) ( \      #define DECLARE_VMINT(basePtr, T_struct, T_member) (          \
596          (VMRelPtr) {                                     \          /* Disable offsetof warning, trust us, we are cautios. */ \
597              (void**) &basePtr,                           \          COMPILER_DISABLE_OFFSETOF_WARNING                         \
598              offsetof(T_struct, T_member),                \          (VMRelPtr) {                                              \
599              false                                        \              (void**) &basePtr,                                    \
600          }                                                \              offsetof(T_struct, T_member),                         \
601      )                                                    \              false                                                 \
602            }                                                         \
603            COMPILER_RESTORE_OFFSETOF_WARNING                         \
604        )                                                             \
605    
606      /**      /**
607       * Same as DECLARE_VMINT(), but this one defines the VMIntRelPtr and       * Same as DECLARE_VMINT(), but this one defines the VMIntRelPtr and
# Line 585  namespace LinuxSampler { Line 617  namespace LinuxSampler {
617       * @see ScriptVM::builtInConstIntVariables()       * @see ScriptVM::builtInConstIntVariables()
618       */       */
619      #define DECLARE_VMINT_READONLY(basePtr, T_struct, T_member) ( \      #define DECLARE_VMINT_READONLY(basePtr, T_struct, T_member) ( \
620          (VMRelPtr) {                                          \          /* Disable offsetof warning, trust us, we are cautios. */ \
621              (void**) &basePtr,                                \          COMPILER_DISABLE_OFFSETOF_WARNING                         \
622              offsetof(T_struct, T_member),                     \          (VMRelPtr) {                                              \
623              true                                              \              (void**) &basePtr,                                    \
624          }                                                     \              offsetof(T_struct, T_member),                         \
625      )                                                         \              true                                                  \
626            }                                                         \
627            COMPILER_RESTORE_OFFSETOF_WARNING                         \
628        )                                                             \
629    
630      /** @brief Built-in VM 8 bit integer array variable.      /** @brief Built-in VM 8 bit integer array variable.
631       *       *
# Line 690  namespace LinuxSampler { Line 725  namespace LinuxSampler {
725           * @param expr - new value to be assigned to this variable           * @param expr - new value to be assigned to this variable
726           */           */
727          void assignExpr(VMExpr* expr) OVERRIDE {}          void assignExpr(VMExpr* expr) OVERRIDE {}
728    
729            virtual ~VMDynVar() {}
730      };      };
731    
732      /** @brief Dynamically executed variable (of integer data type).      /** @brief Dynamically executed variable (of integer data type).
# Line 830  namespace LinuxSampler { Line 867  namespace LinuxSampler {
867       * issue (either a parser error or parser warning), a human readable       * issue (either a parser error or parser warning), a human readable
868       * explanation text of the error or warning and the location of the       * explanation text of the error or warning and the location of the
869       * encountered parser issue within the script.       * encountered parser issue within the script.
870         *
871         * @see VMSourceToken for processing syntax highlighting instead.
872       */       */
873      struct ParserIssue {      struct ParserIssue {
874          String txt; ///< Human readable explanation text of the parser issue.          String txt; ///< Human readable explanation text of the parser issue.
# Line 948  namespace LinuxSampler { Line 987  namespace LinuxSampler {
987       * 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
988       * provided for external script editor applications. Primary purpose of       * provided for external script editor applications. Primary purpose of
989       * this class is syntax highlighting for external script editors.       * this class is syntax highlighting for external script editors.
990         *
991         * @see ParserIssue for processing compile errors and warnings instead.
992       */       */
993      class VMSourceToken {      class VMSourceToken {
994      public:      public:
# Line 960  namespace LinuxSampler { Line 1001  namespace LinuxSampler {
1001          String text() const;          String text() const;
1002    
1003          // position of token in script          // position of token in script
1004          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.
1005          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().
1006    
1007          // base types          // base types
1008          bool isEOF() const;          bool isEOF() const; ///< Returns true in case this source token represents the end of the source code file.
1009          bool isNewLine() const;          bool isNewLine() const; ///< Returns true in case this source token represents a line feed character (i.e. "\n" on Unix systems).
1010          bool isKeyword() const;          bool isKeyword() const; ///< Returns true in case this source token represents a language keyword (i.e. "while", "function", "declare", "on", etc.).
1011          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.
1012          bool isIdentifier() const;          bool isIdentifier() const; ///< Returns true in case this source token represents an identifier, which currently always means a function name.
1013          bool isNumberLiteral() const;          bool isNumberLiteral() const; ///< Returns true in case this source token represents a number literal (i.e. 123).
1014          bool isStringLiteral() const;          bool isStringLiteral() const; ///< Returns true in case this source token represents a string literal (i.e. "Some text").
1015          bool isComment() const;          bool isComment() const; ///< Returns true in case this source token represents a source code comment.
1016          bool isPreprocessor() const;          bool isPreprocessor() const; ///< Returns true in case this source token represents a preprocessor statement.
1017          bool isOther() const;          bool isOther() const; ///< Returns true in case this source token represents anything else not covered by the token types mentioned above.
1018    
1019          // extended types          // extended types
1020          bool isIntegerVariable() const;          bool isIntegerVariable() const; ///< Returns true in case this source token represents an integer variable name (i.e. "$someIntVariable").
1021          bool isStringVariable() const;          bool isStringVariable() const; ///< Returns true in case this source token represents an string variable name (i.e. "\@someStringVariable").
1022          bool isArrayVariable() const;          bool isArrayVariable() const; ///< Returns true in case this source token represents an array variable name (i.e. "%someArryVariable").
1023          bool isEventHandlerName() const;          bool isEventHandlerName() const; ///< Returns true in case this source token represents an event handler name (i.e. "note", "release", "controller").
1024    
1025          VMSourceToken& operator=(const VMSourceToken& other);          VMSourceToken& operator=(const VMSourceToken& other);
1026    

Legend:
Removed from v.2948  
changed lines
  Added in v.3035

  ViewVC Help
Powered by ViewVC