Bladeren bron

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

master
Kevin Larke 9 jaren geleden
bovenliggende
commit
3a94b42b32
2 gewijzigde bestanden met toevoegingen van 28 en 6 verwijderingen
  1. 18
    0
      dsp/cmDspValue.c
  2. 10
    6
      dsp/cmDspValue.h

+ 18
- 0
dsp/cmDspValue.c Bestand weergeven

@@ -85,6 +85,7 @@ bool cmDsvIsFloat(     const cmDspValue_t* vp ){ vp=_vcptr(vp); return  cmAllFla
85 85
 bool cmDsvIsDouble(    const cmDspValue_t* vp ){ vp=_vcptr(vp); return  cmAllFlags(vp->flags,kDoubleDsvFl);             }
86 86
 bool cmDsvIsSample(    const cmDspValue_t* vp ){ vp=_vcptr(vp); return  cmAllFlags(vp->flags,kSampleDsvFl);             }
87 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 89
 bool cmDsvIsStrz(      const cmDspValue_t* vp ){ vp=_vcptr(vp); return  cmAllFlags(vp->flags,kStrzDsvFl);               }
89 90
 bool cmDsvIsStrcz(     const cmDspValue_t* vp ){ vp=_vcptr(vp); return  cmAllFlags(vp->flags,kStrzDsvFl | kConstDsvFl); }
90 91
 bool cmDsvIsSymbol(    const cmDspValue_t* vp ){ vp=_vcptr(vp); return  cmAllFlags(vp->flags,kSymDsvFl);                }
@@ -125,6 +126,7 @@ bool cmDsvSetFromValist( cmDspValue_t* vp, unsigned flags, va_list vl )
125 126
     case kDoubleDsvFl: cmDsvSetDouble( vp, va_arg(vl,double        )); break;
126 127
     case kSampleDsvFl: cmDsvSetSample( vp, va_arg(vl,double        )); break;
127 128
     case kRealDsvFl:   cmDsvSetReal(   vp, va_arg(vl,double        )); break;
129
+    case kPtrDsvFl:    cmDsvSetPtr(    vp, va_arg(vl,void*         )); break;
128 130
     case kStrzDsvFl:   cmDsvSetStrz(   vp, va_arg(vl,cmChar_t*     )); break;
129 131
     default:
130 132
       return false;
@@ -146,6 +148,7 @@ void cmDsvSetFloat(  cmDspValue_t* vp, float v )          { vp->flags = kFloatDs
146 148
 void cmDsvSetDouble( cmDspValue_t* vp, double v )         { vp->flags = kDoubleDsvFl; vp->u.d = v;  }
147 149
 void cmDsvSetSample( cmDspValue_t* vp, cmSample_t v )     { vp->flags = kSampleDsvFl; vp->u.a = v;  }
148 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 152
 void cmDsvSetSymbol( cmDspValue_t* vp, unsigned v )       { vp->flags = kSymDsvFl;    vp->u.u = v;  }  
150 153
 void cmDsvSetStrz(   cmDspValue_t* vp, cmChar_t* v )      { vp->flags = kStrzDsvFl;   vp->u.z = v;  }  
151 154
 void cmDsvSetStrcz(  cmDspValue_t* vp, const cmChar_t* v ){ vp->flags = kStrzDsvFl | kConstDsvFl; vp->u.cz = v; }
@@ -235,6 +238,7 @@ float          cmDsvFloat(  const cmDspValue_t* vp ) { vp=_vcptr(vp); if(cmIsFla
235 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 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 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 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 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,6 +665,17 @@ cmReal_t       cmDsvGetReal(   const cmDspValue_t* vp  )
661 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 679
 unsigned int   cmDsvGetSymbol(   const cmDspValue_t* vp ) 
665 680
 {
666 681
   vp = _vcptr(vp);
@@ -1266,6 +1281,7 @@ unsigned  cmDsvSerialByteCount( const cmDspValue_t* vp )
1266 1281
       case kDoubleDsvFl:
1267 1282
       case kSampleDsvFl:
1268 1283
       case kRealDsvFl:
1284
+      case kPtrDsvFl:
1269 1285
       case kSymDsvFl:
1270 1286
         // these types are stored as part of the type record
1271 1287
         // and therefore don't need any extra storage
@@ -1371,6 +1387,7 @@ cmDsvRC_t cmDsvSerialize( const cmDspValue_t* vp, void* buf, unsigned bufByteCnt
1371 1387
       case kDoubleDsvFl:
1372 1388
       case kSampleDsvFl:
1373 1389
       case kRealDsvFl:
1390
+      case kPtrDsvFl:
1374 1391
       case kSymDsvFl:
1375 1392
         // these types are stored as part of the type record
1376 1393
         // and therefore don't need any extra storage
@@ -1501,6 +1518,7 @@ void cmDsvPrint( const cmDspValue_t* vp, const cmChar_t* label, cmRpt_t* rpt )
1501 1518
       case kDoubleDsvFl: cmRptPrintf(rpt,"%s%f ",lbl,vp->u.d);  break;
1502 1519
       case kSampleDsvFl: cmRptPrintf(rpt,"%s%f ",lbl,vp->u.a);  break;
1503 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 1522
       case kStrzDsvFl:   cmRptPrintf(rpt,"%s%s ",lbl,vp->u.z);  break;
1505 1523
       case kSymDsvFl:    cmRptPrintf(rpt,"%s%i ",lbl,vp->u.u); break;
1506 1524
       case kJsonDsvFl:   cmJsonPrintTree(vp->u.j,rpt);   break;    

+ 10
- 6
dsp/cmDspValue.h Bestand weergeven

@@ -33,12 +33,13 @@ extern "C" {
33 33
     kDoubleDsvFl   = 0x00000400,
34 34
     kSampleDsvFl   = 0x00000800,
35 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 44
     // Auxilliary Flags
44 45
     kInDsvFl       = 0x00100000,  // parameter which is input to the instance (represented by an input port)
@@ -177,6 +178,7 @@ extern "C" {
177 178
   void cmDsvSetDouble( cmDspValue_t* vp, double v );
178 179
   void cmDsvSetSample( cmDspValue_t* vp, cmSample_t v );
179 180
   void cmDsvSetReal(   cmDspValue_t* vp, cmReal_t v );
181
+  void cmDsvSetPtr(    cmDspValue_t* vp, void* v );
180 182
   void cmDsvSetSymbol( cmDspValue_t* vp, unsigned int v );
181 183
   void cmDsvSetStrz(   cmDspValue_t* vp, cmChar_t* v );  
182 184
   void cmDsvSetStrcz(  cmDspValue_t* vp, const cmChar_t* v );  
@@ -218,6 +220,7 @@ extern "C" {
218 220
   double         cmDsvDouble( const cmDspValue_t* vp );
219 221
   cmSample_t     cmDsvSample( const cmDspValue_t* vp );
220 222
   cmReal_t       cmDsvReal(   const cmDspValue_t* vp );
223
+  void*          cmDsvPtr(    const cmDspValue_t* vp );
221 224
   unsigned int   cmDsvSymbol( const cmDspValue_t* vp );
222 225
   cmChar_t*      cmDsvStrz(   const cmDspValue_t* vp );
223 226
   const cmChar_t*cmDsvStrcz(  const cmDspValue_t* vp );
@@ -277,6 +280,7 @@ extern "C" {
277 280
   double         cmDsvGetDouble( const cmDspValue_t* vp );
278 281
   cmSample_t     cmDsvGetSample( const cmDspValue_t* vp );
279 282
   cmReal_t       cmDsvGetReal(   const cmDspValue_t* vp );
283
+  void*          cmDsvGetPtr(    const cmDspValue_t* vp );
280 284
   unsigned       cmDsvGetSymbol( const cmDspValue_t* vp );
281 285
   cmChar_t*      cmDsvGetStrz(   const cmDspValue_t* vp );
282 286
   const cmChar_t*cmDsvGetStrcz(  const cmDspValue_t* vp );

Laden…
Annuleren
Opslaan