/[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 2945 by schoenebeck, Thu Jul 14 00:22:26 2016 UTC revision 2960 by schoenebeck, Sun Jul 17 12:10:06 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 450  namespace LinuxSampler { Line 468  namespace LinuxSampler {
468      struct VMRelPtr {      struct VMRelPtr {
469          void** base; ///< Base pointer.          void** base; ///< Base pointer.
470          int offset;  ///< Offset (in bytes) relative to base pointer.          int offset;  ///< Offset (in bytes) relative to base pointer.
471            bool readonly; ///< Whether the pointed data may be modified or just be read.
472      };      };
473    
474      /** @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 int).
# Line 477  namespace LinuxSampler { Line 496  namespace LinuxSampler {
496          VMIntRelPtr() {          VMIntRelPtr() {
497              base   = NULL;              base   = NULL;
498              offset = 0;              offset = 0;
499                readonly = false;
500          }          }
501          VMIntRelPtr(const VMRelPtr& data) {          VMIntRelPtr(const VMRelPtr& data) {
502              base   = data.base;              base   = data.base;
503              offset = data.offset;              offset = data.offset;
504                readonly = false;
505          }          }
506          virtual int evalInt() { return *(int*)&(*(uint8_t**)base)[offset]; }          virtual int evalInt() { return *(int*)&(*(uint8_t**)base)[offset]; }
507          virtual void assign(int i) { *(int*)&(*(uint8_t**)base)[offset] = i; }          virtual void assign(int i) { *(int*)&(*(uint8_t**)base)[offset] = i; }
# Line 563  namespace LinuxSampler { Line 584  namespace LinuxSampler {
584      #define DECLARE_VMINT(basePtr, T_struct, T_member) ( \      #define DECLARE_VMINT(basePtr, T_struct, T_member) ( \
585          (VMRelPtr) {                                     \          (VMRelPtr) {                                     \
586              (void**) &basePtr,                           \              (void**) &basePtr,                           \
587              offsetof(T_struct, T_member)                 \              offsetof(T_struct, T_member),                \
588                false                                        \
589          }                                                \          }                                                \
590      )                                                    \      )                                                    \
591    
592        /**
593         * Same as DECLARE_VMINT(), but this one defines the VMIntRelPtr and
594         * VMInt8RelPtr structures to be of read-only type. That means the script
595         * parser will abort any script at parser time if the script is trying to
596         * modify such a read-only built-in variable.
597         *
598         * @b NOTE: this is only intended for built-in read-only variables that
599         * may change during runtime! If your built-in variable's data is rather
600         * already available at parser time and won't change during runtime, then
601         * you should rather register a built-in constant in your VM class instead!
602         *
603         * @see ScriptVM::builtInConstIntVariables()
604         */
605        #define DECLARE_VMINT_READONLY(basePtr, T_struct, T_member) ( \
606            (VMRelPtr) {                                          \
607                (void**) &basePtr,                                \
608                offsetof(T_struct, T_member),                     \
609                true                                              \
610            }                                                     \
611        )                                                         \
612    
613      /** @brief Built-in VM 8 bit integer array variable.      /** @brief Built-in VM 8 bit integer array variable.
614       *       *
615       * Used for defining built-in integer array script variables (8 bit per       * Used for defining built-in integer array script variables (8 bit per

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

  ViewVC Help
Powered by ViewVC