Commit 8c6407f0 authored by claes's avatar claes

New interpretation of enum and mask

parent 4bfdd690
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#include <float.h> #include <float.h>
#include "pwr.h" #include "pwr.h"
#include "pwr_class.h" #include "pwr_class.h"
#include "pwrb_c_cyclesup.h" #include "pwr_baseclasses.h"
#include "co_time.h" #include "co_time.h"
#include "co_cdh.h" #include "co_cdh.h"
#include "rt_gdh.h" #include "rt_gdh.h"
......
...@@ -866,7 +866,7 @@ gdh_GetAttrRefTid ( ...@@ -866,7 +866,7 @@ gdh_GetAttrRefTid (
} gdh_ScopeUnlock; } gdh_ScopeUnlock;
if (ap != NULL) if (ap != NULL)
*tid = ap->tid; *tid = ap->adef->TypeRef;
return sts; return sts;
} }
...@@ -3315,6 +3315,150 @@ gdh_GetSuperClass( ...@@ -3315,6 +3315,150 @@ gdh_GetSuperClass(
return sts; return sts;
} }
pwr_tStatus
gdh_GetEnumValueDef( pwr_tTid tid, gdh_sValueDef **vd, int *rows)
{
gdb_sObject *top;
gdb_sObject *vop;
pwr_tOid valoid;
int vcnt;
pwr_tStatus sts = GDH__SUCCESS;
pwr_sValue *valp;
gdh_ScopeLock {
top = vol_OidToObject(&sts, cdh_TypeIdToObjid( tid), gdb_mLo_local, vol_mTrans_none,
cvol_eHint_none);
if ( top == NULL) goto error_sts;
if ( !top->g.flags.b.isParent) {
sts = GDH__NOSUCHOBJ;
goto error_sts;
}
vcnt = 0;
valoid = top->g.soid;
vop = vol_OidToObject(&sts, valoid, gdb_mLo_local, vol_mTrans_none, cvol_eHint_none);
if (vop == NULL) goto error_sts;
while (1) {
valoid.oix = vop->g.sib.blink;
if ( valoid.oix == top->g.soid.oix)
break;
vop = vol_OidToObject(&sts, valoid, gdb_mLo_local, vol_mTrans_none, cvol_eHint_none);
if (vop == NULL) goto error_sts;
if ( vop->g.cid == pwr_eClass_Value)
vcnt++;
}
/* Allocate buffer */
*vd = (gdh_sValueDef *)calloc( vcnt, sizeof(gdh_sValueDef));
*rows = vcnt;
vcnt = 0;
valoid = top->g.soid;
vop = vol_OidToObject(&sts, valoid, gdb_mLo_local, vol_mTrans_none, cvol_eHint_none);
if (vop == NULL) goto error_sts;
while (1) {
valoid.oix = vop->g.sib.blink;
if ( valoid.oix == top->g.soid.oix)
break;
vop = vol_OidToObject(&sts, valoid, gdb_mLo_local, vol_mTrans_none, cvol_eHint_none);
if (vop == NULL) goto error_sts;
if ( vop->g.cid == pwr_eClass_Value) {
valp = (pwr_sValue *) vol_ObjectToAddress(&sts, vop);
if (valp == NULL) goto error_sts;
strcpy( (*vd)[vcnt].Name, vop->g.f.name.orig);
(*vd)[vcnt].Value = valp;
vcnt++;
}
}
error_sts: {
}
} gdh_ScopeUnlock;
return sts;
}
pwr_tStatus
gdh_GetMaskBitDef( pwr_tTid tid, gdh_sBitDef **bd, int *rows)
{
gdb_sObject *top;
gdb_sObject *bop;
pwr_tOid boid;
int bcnt;
pwr_tStatus sts = GDH__SUCCESS;
pwr_sBit *bp;
gdh_ScopeLock {
top = vol_OidToObject(&sts, cdh_TypeIdToObjid( tid), gdb_mLo_local, vol_mTrans_none,
cvol_eHint_none);
if ( top == NULL) goto error_sts;
if ( !top->g.flags.b.isParent) {
sts = GDH__NOSUCHOBJ;
goto error_sts;
}
bcnt = 0;
boid = top->g.soid;
bop = vol_OidToObject(&sts, boid, gdb_mLo_local, vol_mTrans_none, cvol_eHint_none);
if (bop == NULL) goto error_sts;
while (1) {
boid.oix = bop->g.sib.blink;
if ( boid.oix == top->g.soid.oix)
break;
bop = vol_OidToObject(&sts, boid, gdb_mLo_local, vol_mTrans_none, cvol_eHint_none);
if (bop == NULL) goto error_sts;
if ( bop->g.cid == pwr_eClass_Bit)
bcnt++;
}
/* Allocate buffer */
*bd = (gdh_sBitDef *)calloc( bcnt, sizeof(gdh_sBitDef));
*rows = bcnt;
bcnt = 0;
boid = top->g.soid;
bop = vol_OidToObject(&sts, boid, gdb_mLo_local, vol_mTrans_none, cvol_eHint_none);
if (bop == NULL) goto error_sts;
while (1) {
boid.oix = bop->g.sib.blink;
if ( boid.oix == top->g.soid.oix)
break;
bop = vol_OidToObject(&sts, boid, gdb_mLo_local, vol_mTrans_none, cvol_eHint_none);
if (bop == NULL) goto error_sts;
if ( bop->g.cid == pwr_eClass_Bit) {
bp = (pwr_sBit *) vol_ObjectToAddress(&sts, bop);
if (bp == NULL) goto error_sts;
strcpy( (*bd)[bcnt].Name, bop->g.f.name.orig);
(*bd)[bcnt].Bit = bp;
bcnt++;
}
}
error_sts: {
}
} gdh_ScopeUnlock;
return sts;
}
......
...@@ -118,6 +118,27 @@ typedef struct { ...@@ -118,6 +118,27 @@ typedef struct {
} gdh_sAttrDef; } gdh_sAttrDef;
/**
* Enum value info
*/
typedef struct {
pwr_tObjName Name; /**< Value name */
pwr_sValue *Value; /**< Pointer to value object */
} gdh_sValueDef;
/**
* Mask bit info
*/
typedef struct {
pwr_tObjName Name; /**< Value name */
pwr_sBit *Bit; /**< Pointer to bit object */
} gdh_sBitDef;
/* GDH entrypoints (as function prototypes). */ /* GDH entrypoints (as function prototypes). */
/** @} */ /** @} */
...@@ -723,6 +744,20 @@ gdh_GetSuperClass( ...@@ -723,6 +744,20 @@ gdh_GetSuperClass(
pwr_tCid *supercid pwr_tCid *supercid
); );
pwr_tStatus
gdh_GetEnumValueDef(
pwr_tTid tid,
gdh_sValueDef **vd,
int *rows
);
pwr_tStatus
gdh_GetMaskBitDef(
pwr_tTid tid,
gdh_sBitDef **bd,
int *rows
);
/* Undocumented routines. For internal use only. */ /* Undocumented routines. For internal use only. */
pwr_tStatus pwr_tStatus
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment