Browse Source

cmDspValue.h/c : Added the 'ptr' type to represent void*.

master
Kevin Larke 9 years ago
parent
commit
3a94b42b32
2 changed files with 28 additions and 6 deletions
  1. 18
    0
      dsp/cmDspValue.c
  2. 10
    6
      dsp/cmDspValue.h

+ 18
- 0
dsp/cmDspValue.c View File

85
 bool cmDsvIsDouble(    const cmDspValue_t* vp ){ vp=_vcptr(vp); return  cmAllFlags(vp->flags,kDoubleDsvFl);             }
85
 bool cmDsvIsDouble(    const cmDspValue_t* vp ){ vp=_vcptr(vp); return  cmAllFlags(vp->flags,kDoubleDsvFl);             }
86
 bool cmDsvIsSample(    const cmDspValue_t* vp ){ vp=_vcptr(vp); return  cmAllFlags(vp->flags,kSampleDsvFl);             }
86
 bool cmDsvIsSample(    const cmDspValue_t* vp ){ vp=_vcptr(vp); return  cmAllFlags(vp->flags,kSampleDsvFl);             }
87
 bool cmDsvIsReal(      const cmDspValue_t* vp ){ vp=_vcptr(vp); return  cmAllFlags(vp->flags,kRealDsvFl);               }
87
 bool cmDsvIsReal(      const cmDspValue_t* vp ){ vp=_vcptr(vp); return  cmAllFlags(vp->flags,kRealDsvFl);               }
88
+bool cmDsvIsPtr(       const cmDspValue_t* vp ){ vp=_vcptr(vp); return  cmAllFlags(vp->flags,kPtrDsvFl);                }
88
 bool cmDsvIsStrz(      const cmDspValue_t* vp ){ vp=_vcptr(vp); return  cmAllFlags(vp->flags,kStrzDsvFl);               }
89
 bool cmDsvIsStrz(      const cmDspValue_t* vp ){ vp=_vcptr(vp); return  cmAllFlags(vp->flags,kStrzDsvFl);               }
89
 bool cmDsvIsStrcz(     const cmDspValue_t* vp ){ vp=_vcptr(vp); return  cmAllFlags(vp->flags,kStrzDsvFl | kConstDsvFl); }
90
 bool cmDsvIsStrcz(     const cmDspValue_t* vp ){ vp=_vcptr(vp); return  cmAllFlags(vp->flags,kStrzDsvFl | kConstDsvFl); }
90
 bool cmDsvIsSymbol(    const cmDspValue_t* vp ){ vp=_vcptr(vp); return  cmAllFlags(vp->flags,kSymDsvFl);                }
91
 bool cmDsvIsSymbol(    const cmDspValue_t* vp ){ vp=_vcptr(vp); return  cmAllFlags(vp->flags,kSymDsvFl);                }
125
     case kDoubleDsvFl: cmDsvSetDouble( vp, va_arg(vl,double        )); break;
126
     case kDoubleDsvFl: cmDsvSetDouble( vp, va_arg(vl,double        )); break;
126
     case kSampleDsvFl: cmDsvSetSample( vp, va_arg(vl,double        )); break;
127
     case kSampleDsvFl: cmDsvSetSample( vp, va_arg(vl,double        )); break;
127
     case kRealDsvFl:   cmDsvSetReal(   vp, va_arg(vl,double        )); break;
128
     case kRealDsvFl:   cmDsvSetReal(   vp, va_arg(vl,double        )); break;
129
+    case kPtrDsvFl:    cmDsvSetPtr(    vp, va_arg(vl,void*         )); break;
128
     case kStrzDsvFl:   cmDsvSetStrz(   vp, va_arg(vl,cmChar_t*     )); break;
130
     case kStrzDsvFl:   cmDsvSetStrz(   vp, va_arg(vl,cmChar_t*     )); break;
129
     default:
131
     default:
130
       return false;
132
       return false;
146
 void cmDsvSetDouble( cmDspValue_t* vp, double v )         { vp->flags = kDoubleDsvFl; vp->u.d = v;  }
148
 void cmDsvSetDouble( cmDspValue_t* vp, double v )         { vp->flags = kDoubleDsvFl; vp->u.d = v;  }
147
 void cmDsvSetSample( cmDspValue_t* vp, cmSample_t v )     { vp->flags = kSampleDsvFl; vp->u.a = v;  }
149
 void cmDsvSetSample( cmDspValue_t* vp, cmSample_t v )     { vp->flags = kSampleDsvFl; vp->u.a = v;  }
148
 void cmDsvSetReal(   cmDspValue_t* vp, cmReal_t v )       { vp->flags = kRealDsvFl;   vp->u.r = v;  }
150
 void cmDsvSetReal(   cmDspValue_t* vp, cmReal_t v )       { vp->flags = kRealDsvFl;   vp->u.r = v;  }
151
+void cmDsvSetPtr(    cmDspValue_t* vp, void* v )          { vp->flags = kPtrDsvFl;    vp->u.vp = v;  }
149
 void cmDsvSetSymbol( cmDspValue_t* vp, unsigned v )       { vp->flags = kSymDsvFl;    vp->u.u = v;  }  
152
 void cmDsvSetSymbol( cmDspValue_t* vp, unsigned v )       { vp->flags = kSymDsvFl;    vp->u.u = v;  }  
150
 void cmDsvSetStrz(   cmDspValue_t* vp, cmChar_t* v )      { vp->flags = kStrzDsvFl;   vp->u.z = v;  }  
153
 void cmDsvSetStrz(   cmDspValue_t* vp, cmChar_t* v )      { vp->flags = kStrzDsvFl;   vp->u.z = v;  }  
151
 void cmDsvSetStrcz(  cmDspValue_t* vp, const cmChar_t* v ){ vp->flags = kStrzDsvFl | kConstDsvFl; vp->u.cz = v; }
154
 void cmDsvSetStrcz(  cmDspValue_t* vp, const cmChar_t* v ){ vp->flags = kStrzDsvFl | kConstDsvFl; vp->u.cz = v; }
235
 double         cmDsvDouble( const cmDspValue_t* vp ) { vp=_vcptr(vp); if(cmIsFlag((vp->flags & kTypeDsvMask),kDoubleDsvFl)) return vp->u.d;  assert(0); return 0; }
238
 double         cmDsvDouble( const cmDspValue_t* vp ) { vp=_vcptr(vp); if(cmIsFlag((vp->flags & kTypeDsvMask),kDoubleDsvFl)) return vp->u.d;  assert(0); return 0; }
236
 cmSample_t     cmDsvSample( const cmDspValue_t* vp ) { vp=_vcptr(vp); if(cmIsFlag((vp->flags & kTypeDsvMask),kSampleDsvFl)) return vp->u.a;  assert(0); return 0; }
239
 cmSample_t     cmDsvSample( const cmDspValue_t* vp ) { vp=_vcptr(vp); if(cmIsFlag((vp->flags & kTypeDsvMask),kSampleDsvFl)) return vp->u.a;  assert(0); return 0; }
237
 cmReal_t       cmDsvReal(   const cmDspValue_t* vp ) { vp=_vcptr(vp); if(cmIsFlag((vp->flags & kTypeDsvMask),kRealDsvFl))   return vp->u.r;  assert(0); return 0; } 
240
 cmReal_t       cmDsvReal(   const cmDspValue_t* vp ) { vp=_vcptr(vp); if(cmIsFlag((vp->flags & kTypeDsvMask),kRealDsvFl))   return vp->u.r;  assert(0); return 0; } 
241
+void*          cmDsvPtr(    const cmDspValue_t* vp ) { vp=_vcptr(vp); if(cmIsFlag((vp->flags & kTypeDsvMask),kPtrDsvFl))    return vp->u.vp; assert(0); return 0; } 
238
 unsigned int   cmDsvSymbol( const cmDspValue_t* vp ) { vp=_vcptr(vp); if(cmIsFlag((vp->flags & kTypeDsvMask),kSymDsvFl))    return vp->u.u;  assert(0); return cmInvalidId; } 
242
 unsigned int   cmDsvSymbol( const cmDspValue_t* vp ) { vp=_vcptr(vp); if(cmIsFlag((vp->flags & kTypeDsvMask),kSymDsvFl))    return vp->u.u;  assert(0); return cmInvalidId; } 
239
 cmJsonNode_t*  cmDsvJson(   const cmDspValue_t* vp ) { vp=_vcptr(vp); if(cmIsFlag((vp->flags & kTypeDsvMask),kJsonDsvFl))   return vp->u.j;  assert(0); return NULL; }
243
 cmJsonNode_t*  cmDsvJson(   const cmDspValue_t* vp ) { vp=_vcptr(vp); if(cmIsFlag((vp->flags & kTypeDsvMask),kJsonDsvFl))   return vp->u.j;  assert(0); return NULL; }
240
 
244
 
661
   return 0;
665
   return 0;
662
 } 
666
 } 
663
 
667
 
668
+void*       cmDsvGetPtr(   const cmDspValue_t* vp  )
669
+{
670
+  vp = _vcptr(vp);
671
+
672
+
673
+  if( (vp->flags & kTypeDsvMask) == kPtrDsvFl )
674
+    return vp->u.vp;
675
+
676
+  return NULL;
677
+} 
678
+
664
 unsigned int   cmDsvGetSymbol(   const cmDspValue_t* vp ) 
679
 unsigned int   cmDsvGetSymbol(   const cmDspValue_t* vp ) 
665
 {
680
 {
666
   vp = _vcptr(vp);
681
   vp = _vcptr(vp);
1266
       case kDoubleDsvFl:
1281
       case kDoubleDsvFl:
1267
       case kSampleDsvFl:
1282
       case kSampleDsvFl:
1268
       case kRealDsvFl:
1283
       case kRealDsvFl:
1284
+      case kPtrDsvFl:
1269
       case kSymDsvFl:
1285
       case kSymDsvFl:
1270
         // these types are stored as part of the type record
1286
         // these types are stored as part of the type record
1271
         // and therefore don't need any extra storage
1287
         // and therefore don't need any extra storage
1371
       case kDoubleDsvFl:
1387
       case kDoubleDsvFl:
1372
       case kSampleDsvFl:
1388
       case kSampleDsvFl:
1373
       case kRealDsvFl:
1389
       case kRealDsvFl:
1390
+      case kPtrDsvFl:
1374
       case kSymDsvFl:
1391
       case kSymDsvFl:
1375
         // these types are stored as part of the type record
1392
         // these types are stored as part of the type record
1376
         // and therefore don't need any extra storage
1393
         // and therefore don't need any extra storage
1501
       case kDoubleDsvFl: cmRptPrintf(rpt,"%s%f ",lbl,vp->u.d);  break;
1518
       case kDoubleDsvFl: cmRptPrintf(rpt,"%s%f ",lbl,vp->u.d);  break;
1502
       case kSampleDsvFl: cmRptPrintf(rpt,"%s%f ",lbl,vp->u.a);  break;
1519
       case kSampleDsvFl: cmRptPrintf(rpt,"%s%f ",lbl,vp->u.a);  break;
1503
       case kRealDsvFl:   cmRptPrintf(rpt,"%s%f ",lbl,vp->u.r);  break;
1520
       case kRealDsvFl:   cmRptPrintf(rpt,"%s%f ",lbl,vp->u.r);  break;
1521
+      case kPtrDsvFl:    cmRptPrintf(rpt,"%s%p ",lbl,vp->u.vp); break;
1504
       case kStrzDsvFl:   cmRptPrintf(rpt,"%s%s ",lbl,vp->u.z);  break;
1522
       case kStrzDsvFl:   cmRptPrintf(rpt,"%s%s ",lbl,vp->u.z);  break;
1505
       case kSymDsvFl:    cmRptPrintf(rpt,"%s%i ",lbl,vp->u.u); break;
1523
       case kSymDsvFl:    cmRptPrintf(rpt,"%s%i ",lbl,vp->u.u); break;
1506
       case kJsonDsvFl:   cmJsonPrintTree(vp->u.j,rpt);   break;    
1524
       case kJsonDsvFl:   cmJsonPrintTree(vp->u.j,rpt);   break;    

+ 10
- 6
dsp/cmDspValue.h View File

33
     kDoubleDsvFl   = 0x00000400,
33
     kDoubleDsvFl   = 0x00000400,
34
     kSampleDsvFl   = 0x00000800,
34
     kSampleDsvFl   = 0x00000800,
35
     kRealDsvFl     = 0x00001000,
35
     kRealDsvFl     = 0x00001000,
36
-    kStrzDsvFl     = 0x00002000,
37
-    kSymDsvFl      = 0x00004000,
38
-    kJsonDsvFl     = 0x00008000,
39
-    kMtxDsvFl      = 0x00010000,
40
-    kTypeDsvMask   = 0x0001ffff,
41
-    kProxyDsvFl    = 0x00020000,
36
+    kPtrDsvFl      = 0x00002000,
37
+    kStrzDsvFl     = 0x00004000,
38
+    kSymDsvFl      = 0x00008000,
39
+    kJsonDsvFl     = 0x00010000,
40
+    kMtxDsvFl      = 0x00020000,
41
+    kTypeDsvMask   = 0x0003ffff,
42
+    kProxyDsvFl    = 0x00040000,
42
 
43
 
43
     // Auxilliary Flags
44
     // Auxilliary Flags
44
     kInDsvFl       = 0x00100000,  // parameter which is input to the instance (represented by an input port)
45
     kInDsvFl       = 0x00100000,  // parameter which is input to the instance (represented by an input port)
177
   void cmDsvSetDouble( cmDspValue_t* vp, double v );
178
   void cmDsvSetDouble( cmDspValue_t* vp, double v );
178
   void cmDsvSetSample( cmDspValue_t* vp, cmSample_t v );
179
   void cmDsvSetSample( cmDspValue_t* vp, cmSample_t v );
179
   void cmDsvSetReal(   cmDspValue_t* vp, cmReal_t v );
180
   void cmDsvSetReal(   cmDspValue_t* vp, cmReal_t v );
181
+  void cmDsvSetPtr(    cmDspValue_t* vp, void* v );
180
   void cmDsvSetSymbol( cmDspValue_t* vp, unsigned int v );
182
   void cmDsvSetSymbol( cmDspValue_t* vp, unsigned int v );
181
   void cmDsvSetStrz(   cmDspValue_t* vp, cmChar_t* v );  
183
   void cmDsvSetStrz(   cmDspValue_t* vp, cmChar_t* v );  
182
   void cmDsvSetStrcz(  cmDspValue_t* vp, const cmChar_t* v );  
184
   void cmDsvSetStrcz(  cmDspValue_t* vp, const cmChar_t* v );  
218
   double         cmDsvDouble( const cmDspValue_t* vp );
220
   double         cmDsvDouble( const cmDspValue_t* vp );
219
   cmSample_t     cmDsvSample( const cmDspValue_t* vp );
221
   cmSample_t     cmDsvSample( const cmDspValue_t* vp );
220
   cmReal_t       cmDsvReal(   const cmDspValue_t* vp );
222
   cmReal_t       cmDsvReal(   const cmDspValue_t* vp );
223
+  void*          cmDsvPtr(    const cmDspValue_t* vp );
221
   unsigned int   cmDsvSymbol( const cmDspValue_t* vp );
224
   unsigned int   cmDsvSymbol( const cmDspValue_t* vp );
222
   cmChar_t*      cmDsvStrz(   const cmDspValue_t* vp );
225
   cmChar_t*      cmDsvStrz(   const cmDspValue_t* vp );
223
   const cmChar_t*cmDsvStrcz(  const cmDspValue_t* vp );
226
   const cmChar_t*cmDsvStrcz(  const cmDspValue_t* vp );
277
   double         cmDsvGetDouble( const cmDspValue_t* vp );
280
   double         cmDsvGetDouble( const cmDspValue_t* vp );
278
   cmSample_t     cmDsvGetSample( const cmDspValue_t* vp );
281
   cmSample_t     cmDsvGetSample( const cmDspValue_t* vp );
279
   cmReal_t       cmDsvGetReal(   const cmDspValue_t* vp );
282
   cmReal_t       cmDsvGetReal(   const cmDspValue_t* vp );
283
+  void*          cmDsvGetPtr(    const cmDspValue_t* vp );
280
   unsigned       cmDsvGetSymbol( const cmDspValue_t* vp );
284
   unsigned       cmDsvGetSymbol( const cmDspValue_t* vp );
281
   cmChar_t*      cmDsvGetStrz(   const cmDspValue_t* vp );
285
   cmChar_t*      cmDsvGetStrz(   const cmDspValue_t* vp );
282
   const cmChar_t*cmDsvGetStrcz(  const cmDspValue_t* vp );
286
   const cmChar_t*cmDsvGetStrcz(  const cmDspValue_t* vp );

Loading…
Cancel
Save