/[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 3034 by schoenebeck, Mon Oct 31 00:05:00 2016 UTC revision 3293 by schoenebeck, Tue Jun 27 22:19:19 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 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 157  namespace LinuxSampler { Line 158  namespace LinuxSampler {
158           * expressions to an array expression for you, instead this method will           * expressions to an array expression for you, instead this method will
159           * simply return NULL!           * simply return NULL!
160           *           *
161             * @b Note: this method is currently, and in contrast to its other
162             * counter parts, declared as virtual method. Some deriving classes are
163             * currently using this to override this default implementation in order
164             * to implement an "evaluate now as integer array" behavior. This has
165             * efficiency reasons, however this also currently makes this part of
166             * the API less clean and should thus be addressed in future with
167             * appropriate changes to the API.
168             *
169           * @see exprType()           * @see exprType()
170           */           */
171          VMIntArrayExpr* asIntArray() const;          virtual VMIntArrayExpr* asIntArray() const;
172    
173          /**          /**
174           * 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 548  namespace LinuxSampler {
548          }          }
549      };      };
550    
551        #if HAVE_CXX_EMBEDDED_PRAGMA_DIAGNOSTICS
552        # define COMPILER_DISABLE_OFFSETOF_WARNING                    \
553            _Pragma("GCC diagnostic push")                            \
554            _Pragma("GCC diagnostic ignored \"-Winvalid-offsetof\"")
555        # define COMPILER_RESTORE_OFFSETOF_WARNING \
556            _Pragma("GCC diagnostic pop")
557        #else
558        # define COMPILER_DISABLE_OFFSETOF_WARNING
559        # define COMPILER_RESTORE_OFFSETOF_WARNING
560        #endif
561    
562      /**      /**
563       * Convenience macro for initializing VMIntRelPtr and VMInt8RelPtr       * Convenience macro for initializing VMIntRelPtr and VMInt8RelPtr
564       * structures. Usage example:       * structures. Usage example:
# Line 583  namespace LinuxSampler { Line 603  namespace LinuxSampler {
603       */       */
604      #define DECLARE_VMINT(basePtr, T_struct, T_member) (          \      #define DECLARE_VMINT(basePtr, T_struct, T_member) (          \
605          /* Disable offsetof warning, trust us, we are cautios. */ \          /* Disable offsetof warning, trust us, we are cautios. */ \
606          _Pragma("GCC diagnostic push")                            \          COMPILER_DISABLE_OFFSETOF_WARNING                         \
         _Pragma("GCC diagnostic ignored \"-Winvalid-offsetof\"")  \  
607          (VMRelPtr) {                                              \          (VMRelPtr) {                                              \
608              (void**) &basePtr,                                    \              (void**) &basePtr,                                    \
609              offsetof(T_struct, T_member),                         \              offsetof(T_struct, T_member),                         \
610              false                                                 \              false                                                 \
611          }                                                         \          }                                                         \
612          _Pragma("GCC diagnostic pop")                             \          COMPILER_RESTORE_OFFSETOF_WARNING                         \
613      )                                                             \      )                                                             \
614    
615      /**      /**
# Line 608  namespace LinuxSampler { Line 627  namespace LinuxSampler {
627       */       */
628      #define DECLARE_VMINT_READONLY(basePtr, T_struct, T_member) ( \      #define DECLARE_VMINT_READONLY(basePtr, T_struct, T_member) ( \
629          /* Disable offsetof warning, trust us, we are cautios. */ \          /* Disable offsetof warning, trust us, we are cautios. */ \
630          _Pragma("GCC diagnostic push")                            \          COMPILER_DISABLE_OFFSETOF_WARNING                         \
         _Pragma("GCC diagnostic ignored \"-Winvalid-offsetof\"")  \  
631          (VMRelPtr) {                                              \          (VMRelPtr) {                                              \
632              (void**) &basePtr,                                    \              (void**) &basePtr,                                    \
633              offsetof(T_struct, T_member),                         \              offsetof(T_struct, T_member),                         \
634              true                                                  \              true                                                  \
635          }                                                         \          }                                                         \
636          _Pragma("GCC diagnostic pop")                             \          COMPILER_RESTORE_OFFSETOF_WARNING                         \
637      )                                                             \      )                                                             \
638    
639      /** @brief Built-in VM 8 bit integer array variable.      /** @brief Built-in VM 8 bit integer array variable.
# Line 627  namespace LinuxSampler { Line 645  namespace LinuxSampler {
645      struct VMInt8Array {      struct VMInt8Array {
646          int8_t* data;          int8_t* data;
647          int size;          int size;
648            bool readonly; ///< Whether the array data may be modified or just be read.
649    
650          VMInt8Array() : data(NULL), size(0) {}          VMInt8Array() : data(NULL), size(0), readonly(false) {}
651      };      };
652    
653      /** @brief Virtual machine script variable.      /** @brief Virtual machine script variable.
# Line 740  namespace LinuxSampler { Line 759  namespace LinuxSampler {
759      public:      public:
760      };      };
761    
762        /** @brief Dynamically executed variable (of integer array data type).
763         *
764         * This is the base class for all built-in integer array script variables
765         * whose variable content needs to be provided dynamically by executable
766         * native code on each script variable access.
767         */
768        class VMDynIntArrayVar : virtual public VMDynVar, virtual public VMIntArrayExpr {
769        public:
770        };
771    
772      /** @brief Provider for built-in script functions and variables.      /** @brief Provider for built-in script functions and variables.
773       *       *
774       * Abstract base class defining the high-level interface for all classes       * Abstract base class defining the high-level interface for all classes
# Line 823  namespace LinuxSampler { Line 852  namespace LinuxSampler {
852           * @see ScriptVM::exec()           * @see ScriptVM::exec()
853           */           */
854          virtual int suspensionTimeMicroseconds() const = 0;          virtual int suspensionTimeMicroseconds() const = 0;
855    
856            /**
857             * Causes all polyphonic variables to be reset to zero values. A
858             * polyphonic variable is expected to be zero when entering a new event
859             * handler instance. As an exception the values of polyphonic variables
860             * shall only be preserved from an note event handler instance to its
861             * correspending specific release handler instance. So in the latter
862             * case the script author may pass custom data from the note handler to
863             * the release handler, but only for the same specific note!
864             */
865            virtual void resetPolyphonicData() = 0;
866    
867            /**
868             * Returns amount of virtual machine instructions which have been
869             * performed the last time when this execution context was executing a
870             * script. So in case you need the overall amount of instructions
871             * instead, then you need to add them by yourself after each
872             * ScriptVM::exec() call.
873             */
874            virtual size_t instructionsPerformed() const = 0;
875    
876            /**
877             * Sends a signal to this script execution instance to abort its script
878             * execution as soon as possible. This method is called i.e. when one
879             * script execution instance intends to stop another script execution
880             * instance.
881             */
882            virtual void signalAbort() = 0;
883    
884            /**
885             * Copies the current entire execution state from this object to the
886             * given object. So this can be used to "fork" a new script thread which
887             * then may run independently with its own polyphonic data for instance.
888             */
889            virtual void forkTo(VMExecContext* ectx) const = 0;
890      };      };
891    
892      /** @brief Script callback for a certain event.      /** @brief Script callback for a certain event.
# Line 854  namespace LinuxSampler { Line 918  namespace LinuxSampler {
918      };      };
919    
920      /**      /**
921         * Reflects the precise position and span of a specific code block within
922         * a script. This is currently only used for the locations of commented
923         * code blocks due to preprocessor statements, and for parser errors and
924         * parser warnings.
925         *
926         * @see ParserIssue for code locations of parser errors and parser warnings
927         *
928         * @see VMParserContext::preprocessorComments() for locations of code which
929         *      have been filtered out by preprocessor statements
930         */
931        struct CodeBlock {
932            int firstLine; ///< The first line number of this code block within the script (indexed with 1 being the very first line).
933            int lastLine; ///< The last line number of this code block within the script.
934            int firstColumn; ///< The first column of this code block within the script (indexed with 1 being the very first column).
935            int lastColumn; ///< The last column of this code block within the script.
936        };
937    
938        /**
939       * Encapsulates a noteworty parser issue. This encompasses the type of the       * Encapsulates a noteworty parser issue. This encompasses the type of the
940       * issue (either a parser error or parser warning), a human readable       * issue (either a parser error or parser warning), a human readable
941       * explanation text of the error or warning and the location of the       * explanation text of the error or warning and the location of the
# Line 861  namespace LinuxSampler { Line 943  namespace LinuxSampler {
943       *       *
944       * @see VMSourceToken for processing syntax highlighting instead.       * @see VMSourceToken for processing syntax highlighting instead.
945       */       */
946      struct ParserIssue {      struct ParserIssue : CodeBlock {
947          String txt; ///< Human readable explanation text of the parser issue.          String txt; ///< Human readable explanation text of the parser issue.
         int firstLine; ///< The first line number within the script where this issue was encountered (indexed with 1 being the very first line).  
         int lastLine; ///< The last line number within the script where this issue was encountered.  
         int firstColumn; ///< The first column within the script where this issue was encountered (indexed with 1 being the very first column).  
         int lastColumn; ///< The last column within the script where this issue was encountered.  
948          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.
949    
950          /**          /**
# Line 946  namespace LinuxSampler { Line 1024  namespace LinuxSampler {
1024          virtual std::vector<ParserIssue> warnings() const = 0;          virtual std::vector<ParserIssue> warnings() const = 0;
1025    
1026          /**          /**
1027             * Returns all code blocks of the script which were filtered out by the
1028             * preprocessor.
1029             */
1030            virtual std::vector<CodeBlock> preprocessorComments() const = 0;
1031    
1032            /**
1033           * Returns the translated virtual machine representation of an event           * Returns the translated virtual machine representation of an event
1034           * handler block (i.e. "on note ... end on" code block) within the           * handler block (i.e. "on note ... end on" code block) within the
1035           * parsed script. This translated representation of the event handler           * parsed script. This translated representation of the event handler

Legend:
Removed from v.3034  
changed lines
  Added in v.3293

  ViewVC Help
Powered by ViewVC