/[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 3689 by schoenebeck, Mon Sep 2 09:03:31 2019 UTC revision 3690 by schoenebeck, Fri Jan 3 10:18:21 2020 UTC
# Line 1  Line 1 
1  /*  /*
2   * Copyright (c) 2014-2019 Christian Schoenebeck   * Copyright (c) 2014-2020 Christian Schoenebeck
3   *   *
4   * http://www.linuxsampler.org   * http://www.linuxsampler.org
5   *   *
# Line 120  namespace LinuxSampler { Line 120  namespace LinuxSampler {
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            VM_EVENT_HANDLER_RPN, ///< RPN event handler, that is script's "on rpn ... end on" code block.
124            VM_EVENT_HANDLER_NRPN, ///< NRPN event handler, that is script's "on nrpn ... end on" code block.
125      };      };
126    
127      /**      /**
# Line 1135  namespace LinuxSampler { Line 1137  namespace LinuxSampler {
1137       *       *
1138       * Refer to DECLARE_VMINT() for example code.       * Refer to DECLARE_VMINT() for example code.
1139       *       *
1140       * @see VMInt32RelPtr, VMInt8RelPtr, DECLARE_VMINT()       * @see VMInt32RelPtr, VMInt16RelPtr, VMInt8RelPtr, DECLARE_VMINT()
1141       */       */
1142      struct VMInt64RelPtr : VMRelPtr, VMIntPtr {      struct VMInt64RelPtr : VMRelPtr, VMIntPtr {
1143          VMInt64RelPtr() {          VMInt64RelPtr() {
# Line 1177  namespace LinuxSampler { Line 1179  namespace LinuxSampler {
1179       *       *
1180       * Refer to DECLARE_VMINT() for example code.       * Refer to DECLARE_VMINT() for example code.
1181       *       *
1182       * @see VMInt64RelPtr, VMInt8RelPtr, DECLARE_VMINT()       * @see VMInt64RelPtr, VMInt16RelPtr, VMInt8RelPtr, DECLARE_VMINT()
1183       */       */
1184      struct VMInt32RelPtr : VMRelPtr, VMIntPtr {      struct VMInt32RelPtr : VMRelPtr, VMIntPtr {
1185          VMInt32RelPtr() {          VMInt32RelPtr() {
# Line 1199  namespace LinuxSampler { Line 1201  namespace LinuxSampler {
1201          bool isAssignable() const OVERRIDE { return !readonly; }          bool isAssignable() const OVERRIDE { return !readonly; }
1202      };      };
1203    
1204        /** @brief Pointer to built-in VM integer variable (of C/C++ type int16_t).
1205         *
1206         * Used for defining built-in 16 bit integer script variables.
1207         *
1208         * @b CAUTION: You may only use this class for pointing to C/C++ variables
1209         * of type "int16_t" (thus being exactly 16 bit in size). If the C/C++ int
1210         * variable you want to reference is 64 bit in size then you @b must use
1211         * VMInt64RelPtr instead! Respectively for a referenced native variable with
1212         * only 8 bit in size you @b must use VMInt8RelPtr instead!
1213         *
1214         * For efficiency reasons the actual native C/C++ int variable is referenced
1215         * by two components here. The actual native int C/C++ variable in memory
1216         * is dereferenced at VM run-time by taking the @c base pointer dereference
1217         * and adding @c offset bytes. This has the advantage that for a large
1218         * number of built-in int variables, only one (or few) base pointer need
1219         * to be re-assigned before running a script, instead of updating each
1220         * built-in variable each time before a script is executed.
1221         *
1222         * Refer to DECLARE_VMINT() for example code.
1223         *
1224         * @see VMInt64RelPtr, VMInt32RelPtr, VMInt8RelPtr, DECLARE_VMINT()
1225         */
1226        struct VMInt16RelPtr : VMRelPtr, VMIntPtr {
1227            VMInt16RelPtr() {
1228                base   = NULL;
1229                offset = 0;
1230                readonly = false;
1231            }
1232            VMInt16RelPtr(const VMRelPtr& data) {
1233                base   = data.base;
1234                offset = data.offset;
1235                readonly = false;
1236            }
1237            vmint evalInt() OVERRIDE {
1238                return (vmint)*(int16_t*)&(*(uint8_t**)base)[offset];
1239            }
1240            void assign(vmint i) OVERRIDE {
1241                *(int16_t*)&(*(uint8_t**)base)[offset] = (int16_t)i;
1242            }
1243            bool isAssignable() const OVERRIDE { return !readonly; }
1244        };
1245    
1246      /** @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).
1247       *       *
1248       * Used for defining built-in 8 bit integer script variables.       * Used for defining built-in 8 bit integer script variables.
# Line 1219  namespace LinuxSampler { Line 1263  namespace LinuxSampler {
1263       *       *
1264       * Refer to DECLARE_VMINT() for example code.       * Refer to DECLARE_VMINT() for example code.
1265       *       *
1266       * @see VMIntRel32Ptr, VMIntRel64Ptr, DECLARE_VMINT()       * @see VMInt16RelPtr, VMIntRel32Ptr, VMIntRel64Ptr, DECLARE_VMINT()
1267       */       */
1268      struct VMInt8RelPtr : VMRelPtr, VMIntPtr {      struct VMInt8RelPtr : VMRelPtr, VMIntPtr {
1269          VMInt8RelPtr() {          VMInt8RelPtr() {
# Line 1262  namespace LinuxSampler { Line 1306  namespace LinuxSampler {
1306      #endif      #endif
1307    
1308      /**      /**
1309       * Convenience macro for initializing VMInt64RelPtr, VMInt32RelPtr and       * Convenience macro for initializing VMInt64RelPtr, VMInt32RelPtr,
1310       * VMInt8RelPtr structures. Usage example:       * VMInt16RelPtr and VMInt8RelPtr structures. Usage example:
1311       * @code       * @code
1312       * struct Foo {       * struct Foo {
1313       *   uint8_t a; // native representation of a built-in integer script variable       *   uint8_t a; // native representation of a built-in integer script variable
# Line 1316  namespace LinuxSampler { Line 1360  namespace LinuxSampler {
1360    
1361      /**      /**
1362       * Same as DECLARE_VMINT(), but this one defines the VMInt64RelPtr,       * Same as DECLARE_VMINT(), but this one defines the VMInt64RelPtr,
1363       * VMInt32RelPtr and VMInt8RelPtr structures to be of read-only type.       * VMInt32RelPtr, VMInt16RelPtr and VMInt8RelPtr structures to be of
1364       * That means the script parser will abort any script at parser time if the       * read-only type. That means the script parser will abort any script at
1365       * script is trying to modify such a read-only built-in variable.       * parser time if the script is trying to modify such a read-only built-in
1366         * variable.
1367       *       *
1368       * @b NOTE: this is only intended for built-in read-only variables that       * @b NOTE: this is only intended for built-in read-only variables that
1369       * may change during runtime! If your built-in variable's data is rather       * may change during runtime! If your built-in variable's data is rather

Legend:
Removed from v.3689  
changed lines
  Added in v.3690

  ViewVC Help
Powered by ViewVC