Commit 2fbf2c86 authored by claes's avatar claes

*** empty log message ***

parent e5b50bc9
......@@ -103,7 +103,7 @@ wb_name wb_cdef::name(ldh_eName type)
return m_cdrep->name(type);
}
wb_bdef wb_cdef::bdef( char *bname) // Fix
wb_bdef wb_cdef::bdef( char *bname)
{
check();
pwr_tStatus sts;
......@@ -111,10 +111,20 @@ wb_bdef wb_cdef::bdef( char *bname) // Fix
wb_bdrep *bdrep = m_cdrep->bdrep( &sts, bname);
if ( ODD(sts))
return wb_bdef( bdrep);
else {
delete bdrep;
else
return wb_bdef();
}
wb_bdef wb_cdef::bdef( pwr_tOix bix)
{
check();
pwr_tStatus sts;
wb_bdrep *bdrep = m_cdrep->bdrep( &sts, bix);
if ( ODD(sts))
return wb_bdef( bdrep);
else
return wb_bdef();
}
}
......
......@@ -90,6 +90,26 @@ wb_bdrep *wb_cdrep::bdrep( pwr_tStatus *sts, char *bname)
return bdrep;
}
wb_bdrep *wb_cdrep::bdrep( pwr_tStatus *sts, int bix)
{
wb_orepdbs *orep = (wb_orepdbs *)m_orep->m_vrep->first( sts, m_orep);
wb_orepdbs *old;
while ( ODD(*sts)) {
if ( orep->cid() == pwr_eClass_ObjBodyDef &&
cdh_oixToBix( orep->oid().oix) == (unsigned int) bix) {
wb_bdrep *bdrep = new wb_bdrep( *orep);
return bdrep;
}
old = orep;
orep = (wb_orepdbs *)m_orep->m_vrep->next( sts, orep);
// Delete
old->ref();
old->unref();
}
return 0;
}
wb_adrep *wb_cdrep::adrep( pwr_tStatus *sts, char *aname)
{
wb_orepdbs *orep_attr;
......
......@@ -41,6 +41,7 @@ class wb_cdrep
void name(const char *name);
void name(wb_name *name);
wb_bdrep *bdrep( pwr_tStatus *sts, int bix);
wb_bdrep *bdrep( pwr_tStatus *sts, char *bname);
wb_adrep *adrep( pwr_tStatus *sts, char *aname);
......
......@@ -918,6 +918,23 @@ ldh_ObjidToName(ldh_tSession session, pwr_tOid oid, ldh_eName type, char *buf, i
switch ( type) {
case ldh_eName_Object:
{
wb_object o = sp->object(oid);
if (!o) return o.sts();
try {
char name[200];
strcpy( name, o.name());
*size = strlen( name);
if ( *size > maxsize - 1)
return LDH__NAMEBUF;
strcpy( buf, name);
}
catch ( wb_error& e) {
return e.sts();
}
break;
}
case ldh_eName_Hierarchy:
case ldh_eName_Path:
case ldh_eName_VolPath:
......
......@@ -315,6 +315,7 @@ int wb_vrepwbl::getTypeInfo( char *name, pwr_tTid *tid, pwr_eType *type, int *si
}
}
if ( type_extern) {
// Fetch from other volume
pwr_tStatus sts;
wb_tdrep *tdrep = m_merep->tdrep( &sts, wname);
......@@ -324,7 +325,7 @@ int wb_vrepwbl::getTypeInfo( char *name, pwr_tTid *tid, pwr_eType *type, int *si
*type = tdrep->type();
*size = tdrep->size();
*elements = tdrep->nElement();
return 1;
delete tdrep;
}
return 1;
}
......@@ -455,8 +456,16 @@ int wb_vrepwbl::getTypeInfo( pwr_tTid tid, pwr_eType *type, int *size,
*elements = 1;
}
else {
// Search type in other volumes TODO...
return 0;
// Search type in other volumes
pwr_tStatus sts;
wb_tdrep *tdrep = m_merep->tdrep( &sts, tid);
if ( EVEN(sts)) return 0;
*type = tdrep->type();
*size = tdrep->size();
*elements = tdrep->nElement();
delete tdrep;
}
}
}
......@@ -487,7 +496,29 @@ int wb_vrepwbl::getClassInfo( pwr_tCid cid, int *rsize, int *dsize)
}
else {
// Search type in other volumes TODO...
return 0;
pwr_tStatus sts;
wb_cdrep *cdrep = m_merep->cdrep( &sts, cid);
if ( EVEN(sts)) return 0;
wb_bdrep *bdrep = cdrep->bdrep( &sts, cdh_eBix_RtBody);
if ( ODD(sts)) {
*rsize = bdrep->size();
delete bdrep;
}
else
*rsize = 0;
bdrep = cdrep->bdrep( &sts, cdh_eBix_DevBody);
if ( ODD(sts)) {
*dsize = bdrep->size();
delete bdrep;
}
else
*dsize = 0;
delete cdrep;
return 1;
}
return 0;
}
......@@ -535,7 +566,7 @@ int wb_vrepwbl::getAttrInfoRec( wb_name *attr, int bix, pwr_tCid cid, int *size,
{
pwr_sType o;
if ( bix != wbl_eBix_SysBody)
if ( bix != cdh_eBix_SysBody)
return 0;
if ( attr->attributeIsEqual("Type", level)) {
*size = sizeof( o.Type);
......@@ -555,7 +586,7 @@ int wb_vrepwbl::getAttrInfoRec( wb_name *attr, int bix, pwr_tCid cid, int *size,
{
pwr_sTypeDef o;
if ( bix != wbl_eBix_SysBody)
if ( bix != cdh_eBix_SysBody)
return 0;
IF_ATTR( Type, pwr_eType_UInt32, 1, level)
else IF_ATTR( Size, pwr_eType_Int32, 1, level)
......@@ -567,7 +598,7 @@ int wb_vrepwbl::getAttrInfoRec( wb_name *attr, int bix, pwr_tCid cid, int *size,
{
pwr_sClassDef o;
if ( bix != wbl_eBix_SysBody)
if ( bix != cdh_eBix_SysBody)
return 0;
IF_ATTR( Editor, pwr_eType_UInt32, 1, level)
else IF_ATTR( Method, pwr_eType_UInt32, 1, level)
......@@ -580,7 +611,7 @@ int wb_vrepwbl::getAttrInfoRec( wb_name *attr, int bix, pwr_tCid cid, int *size,
{
pwr_sClassVolume o;
if ( bix != wbl_eBix_SysBody)
if ( bix != cdh_eBix_SysBody)
return 0;
IF_ATTR( Description, pwr_eType_String, 1, level)
else IF_ATTR( NextOix, pwr_eType_ObjectIx, 1, level)
......@@ -599,7 +630,7 @@ int wb_vrepwbl::getAttrInfoRec( wb_name *attr, int bix, pwr_tCid cid, int *size,
{
pwr_sObjBodyDef o;
if ( bix != wbl_eBix_SysBody)
if ( bix != cdh_eBix_SysBody)
return 0;
IF_ATTR( StructName, pwr_eType_String, 1, level)
else IF_ATTR( NumOfParams, pwr_eType_UInt32, 1, level)
......@@ -612,7 +643,7 @@ int wb_vrepwbl::getAttrInfoRec( wb_name *attr, int bix, pwr_tCid cid, int *size,
{
pwr_sParam o;
if ( bix != wbl_eBix_SysBody)
if ( bix != cdh_eBix_SysBody)
return 0;
if ( attr->attributeIsEqual( "PgmName", level)) {
*size = sizeof( o.Info.PgmName);
......@@ -731,49 +762,49 @@ int wb_vrepwbl::getTemplateBody( pwr_tCid cid, int bix, int *size, void **body)
{
switch ( cid) {
case pwr_eClass_Type:
if ( bix != wbl_eBix_SysBody)
if ( bix != cdh_eBix_SysBody)
return 0;
*size = sizeof( pwr_sType);
*body = calloc( 1, *size);
return 1;
case pwr_eClass_TypeDef:
if ( bix != wbl_eBix_SysBody)
if ( bix != cdh_eBix_SysBody)
return 0;
*size = sizeof( pwr_sTypeDef);
*body = calloc( 1, *size);
return 1;
case pwr_eClass_ClassDef:
if ( bix != wbl_eBix_SysBody)
if ( bix != cdh_eBix_SysBody)
return 0;
*size = sizeof( pwr_sClassDef);
*body = calloc( 1, *size);
return 1;
case pwr_eClass_ClassVolume:
if ( bix != wbl_eBix_SysBody)
if ( bix != cdh_eBix_SysBody)
return 0;
*size = sizeof( pwr_sClassVolume);
*body = calloc( 1, *size);
return 1;
case pwr_eClass_ClassHier:
if ( bix != wbl_eBix_SysBody)
if ( bix != cdh_eBix_SysBody)
return 0;
*size = 0;
*body = 0;
return 1;
case pwr_eClass_TypeHier:
if ( bix != wbl_eBix_SysBody)
if ( bix != cdh_eBix_SysBody)
return 0;
*size = 0;
*body = 0;
return 1;
case pwr_eClass_ObjBodyDef:
if ( bix != wbl_eBix_SysBody)
if ( bix != cdh_eBix_SysBody)
return 0;
*size = sizeof( pwr_sObjBodyDef);
*body = calloc( 1, *size);
return 1;
case pwr_eClass_Param:
if ( bix != wbl_eBix_SysBody)
if ( bix != cdh_eBix_SysBody)
return 0;
*size = sizeof( pwr_sParam);
*body = calloc( 1, *size);
......@@ -789,14 +820,14 @@ int wb_vrepwbl::getTemplateBody( pwr_tCid cid, int bix, int *size, void **body)
if ( !n->c_template)
return 0;
if ( bix == wbl_eBix_SysBody || bix == wbl_eBix_RtBody) {
if ( bix == cdh_eBix_SysBody || bix == cdh_eBix_RtBody) {
*size = n->c_template->rbody_size;
if ( *size) {
*body = calloc( 1, *size);
memcpy( *body, n->c_template->rbody, *size);
}
}
else if ( bix == wbl_eBix_DevBody) {
else if ( bix == cdh_eBix_DevBody) {
*size = n->c_template->dbody_size;
if ( *size) {
*body = calloc( 1, *size);
......
......@@ -378,10 +378,10 @@ void wb_wblnode::build( bool recursive)
m_oid.vid = m_vrep->vid();
if ( isClassDef()) {
m_vrep->getTemplateBody( m_cid, wbl_eBix_SysBody, &rbody_size, &rbody);
m_vrep->getTemplateBody( m_cid, cdh_eBix_SysBody, &rbody_size, &rbody);
}
else if ( isType() || isTypeDef()) {
m_vrep->getTemplateBody( m_cid, wbl_eBix_SysBody, &rbody_size, &rbody);
m_vrep->getTemplateBody( m_cid, cdh_eBix_SysBody, &rbody_size, &rbody);
}
else if ( isTemplate()) {
// Build later by classdef
......@@ -390,8 +390,8 @@ void wb_wblnode::build( bool recursive)
return;
}
else {
m_vrep->getTemplateBody( m_cid, wbl_eBix_RtBody, &rbody_size, &rbody);
m_vrep->getTemplateBody( m_cid, wbl_eBix_DevBody, &dbody_size, &dbody);
m_vrep->getTemplateBody( m_cid, cdh_eBix_RtBody, &rbody_size, &rbody);
m_vrep->getTemplateBody( m_cid, cdh_eBix_DevBody, &dbody_size, &dbody);
}
ref_wblnode first_child;
......@@ -404,7 +404,7 @@ void wb_wblnode::build( bool recursive)
o_fch->build( 1);
if ( isClassDef()) {
m_oid.oix = wbl_cixToOix( m_oid.oix, 0, 0);
m_oid.oix = cdh_cixToOix( m_oid.oix, 0, 0);
if ( !m_vrep->registerObject( m_oid.oix, this))
m_vrep->error( "Duplicate class index", getFileName(), line_number);
......@@ -421,7 +421,7 @@ void wb_wblnode::build( bool recursive)
c_template->buildTemplate( this);
}
else if ( isType()) {
m_oid.oix = wbl_tixToOix( 0, m_oid.oix);
m_oid.oix = cdh_tixToOix( 0, m_oid.oix);
if ( !m_vrep->registerObject( m_oid.oix, this))
m_vrep->error( "Duplicate type index", getFileName(), line_number);
......@@ -430,7 +430,7 @@ void wb_wblnode::build( bool recursive)
ty_elements = 1;
}
else if ( isTypeDef()) {
m_oid.oix = wbl_tixToOix( 1, m_oid.oix);
m_oid.oix = cdh_tixToOix( 1, m_oid.oix);
if ( !m_vrep->registerObject( m_oid.oix, this))
m_vrep->error( "Duplicate type index", getFileName(), line_number);
......@@ -459,7 +459,7 @@ void wb_wblnode::build( bool recursive)
void wb_wblnode::buildObjBodyDef( ref_wblnode classdef)
{
m_oid.oix = wbl_cixToOix( classdef->c_cix, m_oid.oix, 0);
m_oid.oix = cdh_cixToOix( classdef->c_cix, m_oid.oix, 0);
if ( !m_vrep->registerObject( m_oid.oix, this))
m_vrep->error( "Duplicate objbodydef index", getFileName(), line_number);
......@@ -482,7 +482,7 @@ void wb_wblnode::buildAttribute( ref_wblnode classdef, ref_wblnode objbodydef,
int size;
int elements;
m_oid.oix = wbl_cixToOix( classdef->c_cix, objbodydef->b_bix, m_oid.oix);
m_oid.oix = cdh_cixToOix( classdef->c_cix, objbodydef->b_bix, m_oid.oix);
if ( !m_vrep->registerObject( m_oid.oix, this))
m_vrep->error( "Duplicate attribute index", getFileName(), line_number);
......@@ -524,7 +524,7 @@ void wb_wblnode::buildBuffer( ref_wblnode classdef, ref_wblnode objbodydef,
{
int rsize, dsize;
m_oid.oix = wbl_cixToOix( classdef->c_cix, objbodydef->b_bix, m_oid.oix);
m_oid.oix = cdh_cixToOix( classdef->c_cix, objbodydef->b_bix, m_oid.oix);
if ( !m_vrep->registerObject( m_oid.oix, this))
m_vrep->error( "Duplicate buffer index", getFileName(), line_number);
......@@ -558,17 +558,20 @@ void wb_wblnode::buildBuffer( ref_wblnode classdef, ref_wblnode objbodydef,
void wb_wblnode::buildTemplate( ref_wblnode classdef)
{
wb_wblnode *objbodydef = classdef->o_fch;
m_oid.oix = cdh_cixToOix( classdef->c_cix, 7, 0);
if ( !m_vrep->registerObject( m_oid.oix, this))
m_vrep->error( "Duplicate template oix", getFileName(), line_number);
while ( objbodydef) {
if ( objbodydef->isObjBodyDef()) {
if ( objbodydef->b_bix == wbl_eBix_SysBody ||
objbodydef->b_bix == wbl_eBix_RtBody) {
if ( objbodydef->b_bix == cdh_eBix_SysBody ||
objbodydef->b_bix == cdh_eBix_RtBody) {
rbody_size = objbodydef->b_size;
if ( rbody_size) {
rbody = calloc( 1, rbody_size);
}
}
if ( objbodydef->b_bix == wbl_eBix_DevBody) {
if ( objbodydef->b_bix == cdh_eBix_DevBody) {
dbody_size = objbodydef->b_size;
if ( dbody_size)
dbody = calloc( 1, dbody_size);
......@@ -591,11 +594,11 @@ void wb_wblnode::buildBody( ref_wblnode object)
switch ( getType()) {
case tokens.BODY:
if ( strcmp( name, "SysBody") == 0)
bix = wbl_eBix_SysBody;
bix = cdh_eBix_SysBody;
else if ( strcmp( name, "RtBody") == 0)
bix = wbl_eBix_RtBody;
bix = cdh_eBix_RtBody;
else if ( strcmp( name, "DevBody") == 0)
bix = wbl_eBix_SysBody;
bix = cdh_eBix_SysBody;
else {
// Body exception
m_vrep->error( "Bad body name", getFileName(), line_number);
......@@ -649,16 +652,16 @@ void wb_wblnode::buildAttr( ref_wblnode object, int bix)
m_vrep->error( "Attribute syntax", getFileName(), line_number);
}
else {
if ( ((bix == wbl_eBix_RtBody || bix == wbl_eBix_SysBody) &&
if ( ((bix == cdh_eBix_RtBody || bix == cdh_eBix_SysBody) &&
object->rbody_size == 0) ||
(bix == wbl_eBix_DevBody && object->dbody_size == 0)) {
(bix == cdh_eBix_DevBody && object->dbody_size == 0)) {
m_vrep->error( "Attribute body", getFileName(), line_number);
return;
}
if ( ((bix == wbl_eBix_RtBody || bix == wbl_eBix_SysBody) &&
if ( ((bix == cdh_eBix_RtBody || bix == cdh_eBix_SysBody) &&
offset + size/elements > object->rbody_size) ||
( bix == wbl_eBix_RtBody &&
( bix == cdh_eBix_RtBody &&
offset + size/elements > object->rbody_size)) {
m_vrep->error( "Mismatch in attribute offset", getFileName(), line_number);
return;
......@@ -667,21 +670,21 @@ void wb_wblnode::buildAttr( ref_wblnode object, int bix)
// printf( "Attr %s %s %d %d %s\n", object->name, name, size, offset, value);
if ( size/elements == sizeof(int_val) && convconst( &int_val, value)) {
if ( oper == tokens.EQ) {
if ( bix == wbl_eBix_RtBody || bix == wbl_eBix_SysBody)
if ( bix == cdh_eBix_RtBody || bix == cdh_eBix_SysBody)
memcpy( (char *)((unsigned int) object->rbody + offset),
&int_val, size/elements);
else if ( bix == wbl_eBix_DevBody)
else if ( bix == cdh_eBix_DevBody)
memcpy( (char *)((unsigned int) object->dbody + offset),
&int_val, size/elements);
}
else if ( oper == tokens.OREQ) {
if ( bix == wbl_eBix_RtBody || bix == wbl_eBix_SysBody) {
if ( bix == cdh_eBix_RtBody || bix == cdh_eBix_SysBody) {
current_int_val = *(int *) ((unsigned int) object->rbody + offset);
int_val |= current_int_val;
memcpy( (char *)((unsigned int) object->rbody + offset),
&int_val, size/elements);
}
else if ( bix == wbl_eBix_DevBody) {
else if ( bix == cdh_eBix_DevBody) {
current_int_val = *(int *) ((unsigned int) object->dbody + offset);
int_val |= current_int_val;
memcpy( (char *)((unsigned int) object->dbody + offset),
......@@ -690,10 +693,10 @@ void wb_wblnode::buildAttr( ref_wblnode object, int bix)
}
}
else if ( attrStringToValue( tid, value, buf, sizeof( buf), size)) {
if ( bix == wbl_eBix_RtBody || bix == wbl_eBix_SysBody)
if ( bix == cdh_eBix_RtBody || bix == cdh_eBix_SysBody)
memcpy( (char *)((unsigned int) object->rbody + offset),
buf, size/elements);
else if ( bix == wbl_eBix_DevBody)
else if ( bix == cdh_eBix_DevBody)
memcpy( (char *)((unsigned int) object->dbody + offset),
buf, size/elements);
}
......@@ -869,7 +872,8 @@ void wb_wblnode::registerNode( wb_vrepwbl *vol)
m_vrep->error( "Missing index", getFileName(), line_number);
}
else {
m_oid.oix = m_vrep->nextOix();
if ( !isTemplate())
m_oid.oix = m_vrep->nextOix();
}
}
}
......@@ -882,7 +886,7 @@ void wb_wblnode::registerNode( wb_vrepwbl *vol)
}
if ( isClassDef()) {
c_cid = wbl_cixToCid( m_vrep->vid(), m_oid.oix);
c_cid = cdh_cixToCid( m_vrep->vid(), m_oid.oix);
c_cix = m_oid.oix;
m_vrep->registerClass( name, c_cid, this);
......@@ -913,17 +917,17 @@ void wb_wblnode::registerNode( wb_vrepwbl *vol)
else
setFirstChild( (RefAST)c_template);
strcpy( c_template->cname, name);
c_template->m_oid.oix = m_vrep->nextOix();
// c_template->m_oid.oix = m_vrep->nextOix();
c_template->m_cid = c_cid;
c_template->node_type = wbl_eNodeType_Template;
}
}
else if ( isType()) {
m_tid = wbl_tixToTid( m_vrep->vid(), 0, m_oid.oix);
m_tid = cdh_tixToTid( m_vrep->vid(), 0, m_oid.oix);
m_vrep->registerType( name, m_tid, this);
}
else if ( isTypeDef()) {
m_tid = wbl_tixToTid( m_vrep->vid(), 1, m_oid.oix);
m_tid = cdh_tixToTid( m_vrep->vid(), 1, m_oid.oix);
m_vrep->registerType( name, m_tid, this);
}
else if ( isObjBodyDef()) {
......
......@@ -15,11 +15,6 @@ class wb_wblnode;
class wb_vrepwbl;
class wb_dbs;
#define wbl_cixToCid( Vid, Cix) (0 + (Vid << 16) + (Cix << 3))
#define wbl_tixToTid( Vid, Tyg, Tix) (0 + (Vid << 16) + (1 << 15) + (Tyg << 11) + Tix)
#define wbl_cixToOix( Cix, Bix, Aix) (0 + (1 << 31) + (Cix << 18) + (Bix << 15) + Aix)
#define wbl_tixToOix( Tyg, Tix) (0 + (1 << 31) + (1 << 30) + (Tyg << 26) + (Tix << 15))
typedef enum {
wbl_eNodeType_No,
wbl_eNodeType_Type,
......
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