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

This commit is contained in:
Kevin Larke 2015-03-30 13:08:08 -07:00
parent bd5daa08bd
commit 3a94b42b32
2 changed files with 28 additions and 6 deletions

View File

@ -85,6 +85,7 @@ bool cmDsvIsFloat( const cmDspValue_t* vp ){ vp=_vcptr(vp); return cmAllFla
bool cmDsvIsDouble( const cmDspValue_t* vp ){ vp=_vcptr(vp); return cmAllFlags(vp->flags,kDoubleDsvFl); } bool cmDsvIsDouble( const cmDspValue_t* vp ){ vp=_vcptr(vp); return cmAllFlags(vp->flags,kDoubleDsvFl); }
bool cmDsvIsSample( const cmDspValue_t* vp ){ vp=_vcptr(vp); return cmAllFlags(vp->flags,kSampleDsvFl); } bool cmDsvIsSample( const cmDspValue_t* vp ){ vp=_vcptr(vp); return cmAllFlags(vp->flags,kSampleDsvFl); }
bool cmDsvIsReal( const cmDspValue_t* vp ){ vp=_vcptr(vp); return cmAllFlags(vp->flags,kRealDsvFl); } bool cmDsvIsReal( const cmDspValue_t* vp ){ vp=_vcptr(vp); return cmAllFlags(vp->flags,kRealDsvFl); }
bool cmDsvIsPtr( const cmDspValue_t* vp ){ vp=_vcptr(vp); return cmAllFlags(vp->flags,kPtrDsvFl); }
bool cmDsvIsStrz( const cmDspValue_t* vp ){ vp=_vcptr(vp); return cmAllFlags(vp->flags,kStrzDsvFl); } bool cmDsvIsStrz( const cmDspValue_t* vp ){ vp=_vcptr(vp); return cmAllFlags(vp->flags,kStrzDsvFl); }
bool cmDsvIsStrcz( const cmDspValue_t* vp ){ vp=_vcptr(vp); return cmAllFlags(vp->flags,kStrzDsvFl | kConstDsvFl); } bool cmDsvIsStrcz( const cmDspValue_t* vp ){ vp=_vcptr(vp); return cmAllFlags(vp->flags,kStrzDsvFl | kConstDsvFl); }
bool cmDsvIsSymbol( const cmDspValue_t* vp ){ vp=_vcptr(vp); return cmAllFlags(vp->flags,kSymDsvFl); } 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 )
case kDoubleDsvFl: cmDsvSetDouble( vp, va_arg(vl,double )); break; case kDoubleDsvFl: cmDsvSetDouble( vp, va_arg(vl,double )); break;
case kSampleDsvFl: cmDsvSetSample( vp, va_arg(vl,double )); break; case kSampleDsvFl: cmDsvSetSample( vp, va_arg(vl,double )); break;
case kRealDsvFl: cmDsvSetReal( vp, va_arg(vl,double )); break; case kRealDsvFl: cmDsvSetReal( vp, va_arg(vl,double )); break;
case kPtrDsvFl: cmDsvSetPtr( vp, va_arg(vl,void* )); break;
case kStrzDsvFl: cmDsvSetStrz( vp, va_arg(vl,cmChar_t* )); break; case kStrzDsvFl: cmDsvSetStrz( vp, va_arg(vl,cmChar_t* )); break;
default: default:
return false; return false;
@ -146,6 +148,7 @@ void cmDsvSetFloat( cmDspValue_t* vp, float v ) { vp->flags = kFloatDs
void cmDsvSetDouble( cmDspValue_t* vp, double v ) { vp->flags = kDoubleDsvFl; vp->u.d = v; } void cmDsvSetDouble( cmDspValue_t* vp, double v ) { vp->flags = kDoubleDsvFl; vp->u.d = v; }
void cmDsvSetSample( cmDspValue_t* vp, cmSample_t v ) { vp->flags = kSampleDsvFl; vp->u.a = v; } void cmDsvSetSample( cmDspValue_t* vp, cmSample_t v ) { vp->flags = kSampleDsvFl; vp->u.a = v; }
void cmDsvSetReal( cmDspValue_t* vp, cmReal_t v ) { vp->flags = kRealDsvFl; vp->u.r = v; } void cmDsvSetReal( cmDspValue_t* vp, cmReal_t v ) { vp->flags = kRealDsvFl; vp->u.r = v; }
void cmDsvSetPtr( cmDspValue_t* vp, void* v ) { vp->flags = kPtrDsvFl; vp->u.vp = v; }
void cmDsvSetSymbol( cmDspValue_t* vp, unsigned v ) { vp->flags = kSymDsvFl; vp->u.u = v; } void cmDsvSetSymbol( cmDspValue_t* vp, unsigned v ) { vp->flags = kSymDsvFl; vp->u.u = v; }
void cmDsvSetStrz( cmDspValue_t* vp, cmChar_t* v ) { vp->flags = kStrzDsvFl; vp->u.z = v; } void cmDsvSetStrz( cmDspValue_t* vp, cmChar_t* v ) { vp->flags = kStrzDsvFl; vp->u.z = v; }
void cmDsvSetStrcz( cmDspValue_t* vp, const cmChar_t* v ){ vp->flags = kStrzDsvFl | kConstDsvFl; vp->u.cz = v; } 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
double cmDsvDouble( const cmDspValue_t* vp ) { vp=_vcptr(vp); if(cmIsFlag((vp->flags & kTypeDsvMask),kDoubleDsvFl)) return vp->u.d; assert(0); return 0; } double cmDsvDouble( const cmDspValue_t* vp ) { vp=_vcptr(vp); if(cmIsFlag((vp->flags & kTypeDsvMask),kDoubleDsvFl)) return vp->u.d; assert(0); return 0; }
cmSample_t cmDsvSample( const cmDspValue_t* vp ) { vp=_vcptr(vp); if(cmIsFlag((vp->flags & kTypeDsvMask),kSampleDsvFl)) return vp->u.a; assert(0); return 0; } cmSample_t cmDsvSample( const cmDspValue_t* vp ) { vp=_vcptr(vp); if(cmIsFlag((vp->flags & kTypeDsvMask),kSampleDsvFl)) return vp->u.a; assert(0); return 0; }
cmReal_t cmDsvReal( const cmDspValue_t* vp ) { vp=_vcptr(vp); if(cmIsFlag((vp->flags & kTypeDsvMask),kRealDsvFl)) return vp->u.r; assert(0); return 0; } cmReal_t cmDsvReal( const cmDspValue_t* vp ) { vp=_vcptr(vp); if(cmIsFlag((vp->flags & kTypeDsvMask),kRealDsvFl)) return vp->u.r; assert(0); return 0; }
void* cmDsvPtr( const cmDspValue_t* vp ) { vp=_vcptr(vp); if(cmIsFlag((vp->flags & kTypeDsvMask),kPtrDsvFl)) return vp->u.vp; assert(0); return 0; }
unsigned int cmDsvSymbol( const cmDspValue_t* vp ) { vp=_vcptr(vp); if(cmIsFlag((vp->flags & kTypeDsvMask),kSymDsvFl)) return vp->u.u; assert(0); return cmInvalidId; } unsigned int cmDsvSymbol( const cmDspValue_t* vp ) { vp=_vcptr(vp); if(cmIsFlag((vp->flags & kTypeDsvMask),kSymDsvFl)) return vp->u.u; assert(0); return cmInvalidId; }
cmJsonNode_t* cmDsvJson( const cmDspValue_t* vp ) { vp=_vcptr(vp); if(cmIsFlag((vp->flags & kTypeDsvMask),kJsonDsvFl)) return vp->u.j; assert(0); return NULL; } cmJsonNode_t* cmDsvJson( const cmDspValue_t* vp ) { vp=_vcptr(vp); if(cmIsFlag((vp->flags & kTypeDsvMask),kJsonDsvFl)) return vp->u.j; assert(0); return NULL; }
@ -661,6 +665,17 @@ cmReal_t cmDsvGetReal( const cmDspValue_t* vp )
return 0; return 0;
} }
void* cmDsvGetPtr( const cmDspValue_t* vp )
{
vp = _vcptr(vp);
if( (vp->flags & kTypeDsvMask) == kPtrDsvFl )
return vp->u.vp;
return NULL;
}
unsigned int cmDsvGetSymbol( const cmDspValue_t* vp ) unsigned int cmDsvGetSymbol( const cmDspValue_t* vp )
{ {
vp = _vcptr(vp); vp = _vcptr(vp);
@ -1266,6 +1281,7 @@ unsigned cmDsvSerialByteCount( const cmDspValue_t* vp )
case kDoubleDsvFl: case kDoubleDsvFl:
case kSampleDsvFl: case kSampleDsvFl:
case kRealDsvFl: case kRealDsvFl:
case kPtrDsvFl:
case kSymDsvFl: case kSymDsvFl:
// these types are stored as part of the type record // these types are stored as part of the type record
// and therefore don't need any extra storage // and therefore don't need any extra storage
@ -1371,6 +1387,7 @@ cmDsvRC_t cmDsvSerialize( const cmDspValue_t* vp, void* buf, unsigned bufByteCnt
case kDoubleDsvFl: case kDoubleDsvFl:
case kSampleDsvFl: case kSampleDsvFl:
case kRealDsvFl: case kRealDsvFl:
case kPtrDsvFl:
case kSymDsvFl: case kSymDsvFl:
// these types are stored as part of the type record // these types are stored as part of the type record
// and therefore don't need any extra storage // 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 )
case kDoubleDsvFl: cmRptPrintf(rpt,"%s%f ",lbl,vp->u.d); break; case kDoubleDsvFl: cmRptPrintf(rpt,"%s%f ",lbl,vp->u.d); break;
case kSampleDsvFl: cmRptPrintf(rpt,"%s%f ",lbl,vp->u.a); break; case kSampleDsvFl: cmRptPrintf(rpt,"%s%f ",lbl,vp->u.a); break;
case kRealDsvFl: cmRptPrintf(rpt,"%s%f ",lbl,vp->u.r); break; case kRealDsvFl: cmRptPrintf(rpt,"%s%f ",lbl,vp->u.r); break;
case kPtrDsvFl: cmRptPrintf(rpt,"%s%p ",lbl,vp->u.vp); break;
case kStrzDsvFl: cmRptPrintf(rpt,"%s%s ",lbl,vp->u.z); break; case kStrzDsvFl: cmRptPrintf(rpt,"%s%s ",lbl,vp->u.z); break;
case kSymDsvFl: cmRptPrintf(rpt,"%s%i ",lbl,vp->u.u); break; case kSymDsvFl: cmRptPrintf(rpt,"%s%i ",lbl,vp->u.u); break;
case kJsonDsvFl: cmJsonPrintTree(vp->u.j,rpt); break; case kJsonDsvFl: cmJsonPrintTree(vp->u.j,rpt); break;

View File

@ -33,12 +33,13 @@ extern "C" {
kDoubleDsvFl = 0x00000400, kDoubleDsvFl = 0x00000400,
kSampleDsvFl = 0x00000800, kSampleDsvFl = 0x00000800,
kRealDsvFl = 0x00001000, kRealDsvFl = 0x00001000,
kStrzDsvFl = 0x00002000, kPtrDsvFl = 0x00002000,
kSymDsvFl = 0x00004000, kStrzDsvFl = 0x00004000,
kJsonDsvFl = 0x00008000, kSymDsvFl = 0x00008000,
kMtxDsvFl = 0x00010000, kJsonDsvFl = 0x00010000,
kTypeDsvMask = 0x0001ffff, kMtxDsvFl = 0x00020000,
kProxyDsvFl = 0x00020000, kTypeDsvMask = 0x0003ffff,
kProxyDsvFl = 0x00040000,
// Auxilliary Flags // Auxilliary Flags
kInDsvFl = 0x00100000, // parameter which is input to the instance (represented by an input port) kInDsvFl = 0x00100000, // parameter which is input to the instance (represented by an input port)
@ -177,6 +178,7 @@ extern "C" {
void cmDsvSetDouble( cmDspValue_t* vp, double v ); void cmDsvSetDouble( cmDspValue_t* vp, double v );
void cmDsvSetSample( cmDspValue_t* vp, cmSample_t v ); void cmDsvSetSample( cmDspValue_t* vp, cmSample_t v );
void cmDsvSetReal( cmDspValue_t* vp, cmReal_t v ); void cmDsvSetReal( cmDspValue_t* vp, cmReal_t v );
void cmDsvSetPtr( cmDspValue_t* vp, void* v );
void cmDsvSetSymbol( cmDspValue_t* vp, unsigned int v ); void cmDsvSetSymbol( cmDspValue_t* vp, unsigned int v );
void cmDsvSetStrz( cmDspValue_t* vp, cmChar_t* v ); void cmDsvSetStrz( cmDspValue_t* vp, cmChar_t* v );
void cmDsvSetStrcz( cmDspValue_t* vp, const cmChar_t* v ); void cmDsvSetStrcz( cmDspValue_t* vp, const cmChar_t* v );
@ -218,6 +220,7 @@ extern "C" {
double cmDsvDouble( const cmDspValue_t* vp ); double cmDsvDouble( const cmDspValue_t* vp );
cmSample_t cmDsvSample( const cmDspValue_t* vp ); cmSample_t cmDsvSample( const cmDspValue_t* vp );
cmReal_t cmDsvReal( const cmDspValue_t* vp ); cmReal_t cmDsvReal( const cmDspValue_t* vp );
void* cmDsvPtr( const cmDspValue_t* vp );
unsigned int cmDsvSymbol( const cmDspValue_t* vp ); unsigned int cmDsvSymbol( const cmDspValue_t* vp );
cmChar_t* cmDsvStrz( const cmDspValue_t* vp ); cmChar_t* cmDsvStrz( const cmDspValue_t* vp );
const cmChar_t*cmDsvStrcz( const cmDspValue_t* vp ); const cmChar_t*cmDsvStrcz( const cmDspValue_t* vp );
@ -277,6 +280,7 @@ extern "C" {
double cmDsvGetDouble( const cmDspValue_t* vp ); double cmDsvGetDouble( const cmDspValue_t* vp );
cmSample_t cmDsvGetSample( const cmDspValue_t* vp ); cmSample_t cmDsvGetSample( const cmDspValue_t* vp );
cmReal_t cmDsvGetReal( const cmDspValue_t* vp ); cmReal_t cmDsvGetReal( const cmDspValue_t* vp );
void* cmDsvGetPtr( const cmDspValue_t* vp );
unsigned cmDsvGetSymbol( const cmDspValue_t* vp ); unsigned cmDsvGetSymbol( const cmDspValue_t* vp );
cmChar_t* cmDsvGetStrz( const cmDspValue_t* vp ); cmChar_t* cmDsvGetStrz( const cmDspValue_t* vp );
const cmChar_t*cmDsvGetStrcz( const cmDspValue_t* vp ); const cmChar_t*cmDsvGetStrcz( const cmDspValue_t* vp );