Commit 03bf7fa6 authored by claes's avatar claes

*** empty log message ***

parent 1364c5c3
...@@ -50,3 +50,18 @@ wb_adrep *wb_bdrep::adrep( pwr_tStatus *sts, char *aname) ...@@ -50,3 +50,18 @@ wb_adrep *wb_bdrep::adrep( pwr_tStatus *sts, char *aname)
return adrep; return adrep;
} }
cdh_eBix wb_bdrep::bix()
{
return (cdh_eBix) cdh_oixToBix( m_orep->oid().oix);
}
size_t wb_bdrep::size()
{
pwr_tStatus sts;
pwr_sObjBodyDef body;
m_orep->m_vrep->readBody( &sts, m_orep, bix(), (void *) &body);
if ( EVEN(sts)) throw wb_error(sts);
return body.Size;
}
...@@ -26,9 +26,9 @@ public: ...@@ -26,9 +26,9 @@ public:
wb_bdrep *ref(); wb_bdrep *ref();
pwr_sAttrRef aref() { pwr_sAttrRef a; return a;} // Fix pwr_sAttrRef aref() { pwr_sAttrRef a; return a;} // Fix
size_t size() { return 0;} // Fix // get objects runtime body size size_t size();
int nAttribute() { return 0;} // Fix int nAttribute() { return 0;} // Fix
int bix() { return 0;} // Fix cdh_eBix bix();
pwr_tOid boid() { pwr_tOid o; return o;} // Fix pwr_tOid boid() { pwr_tOid o; return o;} // Fix
......
...@@ -17,9 +17,10 @@ class wb_mvrep; ...@@ -17,9 +17,10 @@ class wb_mvrep;
class wb_cdef : public wb_status class wb_cdef : public wb_status
{ {
wb_cdrep *m_cdrep;
public: public:
wb_cdrep *m_cdrep;
wb_cdef(); wb_cdef();
wb_cdef( wb_cdrep *cdrep); wb_cdef( wb_cdrep *cdrep);
wb_cdef( wb_adef&); // x = other_object wb_cdef( wb_adef&); // x = other_object
......
...@@ -137,3 +137,21 @@ pwr_tCid wb_cdrep::cid() ...@@ -137,3 +137,21 @@ pwr_tCid wb_cdrep::cid()
{ {
return cdh_ClassObjidToId( m_orep->oid()); return cdh_ClassObjidToId( m_orep->oid());
} }
void wb_cdrep::templateBody( pwr_tStatus *sts, cdh_eBix bix, void *p)
{
// Get objid for template object
pwr_tOid oid;
int cix = cdh_oixToCix( m_orep->oid().oix);
oid.vid = m_orep->oid().vid;
oid.oix = cdh_cixToOix( cix, cdh_eBix_template, 0);
wb_orepdbs *orep = (wb_orepdbs *)m_orep->m_vrep->object( sts, oid);
if ( EVEN(*sts)) return;
m_orep->m_vrep->readBody( sts, orep, bix, p);
// Delete
orep->ref();
orep->unref();
}
...@@ -45,6 +45,8 @@ class wb_cdrep ...@@ -45,6 +45,8 @@ class wb_cdrep
wb_bdrep *bdrep( pwr_tStatus *sts, char *bname); wb_bdrep *bdrep( pwr_tStatus *sts, char *bname);
wb_adrep *adrep( pwr_tStatus *sts, char *aname); wb_adrep *adrep( pwr_tStatus *sts, char *aname);
void templateBody( pwr_tStatus *sts, cdh_eBix bix, void *p);
pwr_tStatus sts() { return m_sts;} pwr_tStatus sts() { return m_sts;}
}; };
......
...@@ -501,7 +501,7 @@ int wb_vrepwbl::getClassInfo( pwr_tCid cid, int *rsize, int *dsize) ...@@ -501,7 +501,7 @@ int wb_vrepwbl::getClassInfo( pwr_tCid cid, int *rsize, int *dsize)
wb_cdrep *cdrep = m_merep->cdrep( &sts, cid); wb_cdrep *cdrep = m_merep->cdrep( &sts, cid);
if ( EVEN(sts)) return 0; if ( EVEN(sts)) return 0;
wb_bdrep *bdrep = cdrep->bdrep( &sts, cdh_eBix_RtBody); wb_bdrep *bdrep = cdrep->bdrep( &sts, cdh_eBix_rt);
if ( ODD(sts)) { if ( ODD(sts)) {
*rsize = bdrep->size(); *rsize = bdrep->size();
delete bdrep; delete bdrep;
...@@ -509,7 +509,7 @@ int wb_vrepwbl::getClassInfo( pwr_tCid cid, int *rsize, int *dsize) ...@@ -509,7 +509,7 @@ int wb_vrepwbl::getClassInfo( pwr_tCid cid, int *rsize, int *dsize)
else else
*rsize = 0; *rsize = 0;
bdrep = cdrep->bdrep( &sts, cdh_eBix_DevBody); bdrep = cdrep->bdrep( &sts, cdh_eBix_dev);
if ( ODD(sts)) { if ( ODD(sts)) {
*dsize = bdrep->size(); *dsize = bdrep->size();
delete bdrep; delete bdrep;
...@@ -566,7 +566,7 @@ int wb_vrepwbl::getAttrInfoRec( wb_name *attr, int bix, pwr_tCid cid, int *size, ...@@ -566,7 +566,7 @@ int wb_vrepwbl::getAttrInfoRec( wb_name *attr, int bix, pwr_tCid cid, int *size,
{ {
pwr_sType o; pwr_sType o;
if ( bix != cdh_eBix_SysBody) if ( bix != cdh_eBix_sys)
return 0; return 0;
if ( attr->attributeIsEqual("Type", level)) { if ( attr->attributeIsEqual("Type", level)) {
*size = sizeof( o.Type); *size = sizeof( o.Type);
...@@ -586,7 +586,7 @@ int wb_vrepwbl::getAttrInfoRec( wb_name *attr, int bix, pwr_tCid cid, int *size, ...@@ -586,7 +586,7 @@ int wb_vrepwbl::getAttrInfoRec( wb_name *attr, int bix, pwr_tCid cid, int *size,
{ {
pwr_sTypeDef o; pwr_sTypeDef o;
if ( bix != cdh_eBix_SysBody) if ( bix != cdh_eBix_sys)
return 0; return 0;
IF_ATTR( Type, pwr_eType_UInt32, 1, level) IF_ATTR( Type, pwr_eType_UInt32, 1, level)
else IF_ATTR( Size, pwr_eType_Int32, 1, level) else IF_ATTR( Size, pwr_eType_Int32, 1, level)
...@@ -598,7 +598,7 @@ int wb_vrepwbl::getAttrInfoRec( wb_name *attr, int bix, pwr_tCid cid, int *size, ...@@ -598,7 +598,7 @@ int wb_vrepwbl::getAttrInfoRec( wb_name *attr, int bix, pwr_tCid cid, int *size,
{ {
pwr_sClassDef o; pwr_sClassDef o;
if ( bix != cdh_eBix_SysBody) if ( bix != cdh_eBix_sys)
return 0; return 0;
IF_ATTR( Editor, pwr_eType_UInt32, 1, level) IF_ATTR( Editor, pwr_eType_UInt32, 1, level)
else IF_ATTR( Method, pwr_eType_UInt32, 1, level) else IF_ATTR( Method, pwr_eType_UInt32, 1, level)
...@@ -611,7 +611,7 @@ int wb_vrepwbl::getAttrInfoRec( wb_name *attr, int bix, pwr_tCid cid, int *size, ...@@ -611,7 +611,7 @@ int wb_vrepwbl::getAttrInfoRec( wb_name *attr, int bix, pwr_tCid cid, int *size,
{ {
pwr_sClassVolume o; pwr_sClassVolume o;
if ( bix != cdh_eBix_SysBody) if ( bix != cdh_eBix_sys)
return 0; return 0;
IF_ATTR( Description, pwr_eType_String, 1, level) IF_ATTR( Description, pwr_eType_String, 1, level)
else IF_ATTR( NextOix, pwr_eType_ObjectIx, 1, level) else IF_ATTR( NextOix, pwr_eType_ObjectIx, 1, level)
...@@ -630,7 +630,7 @@ int wb_vrepwbl::getAttrInfoRec( wb_name *attr, int bix, pwr_tCid cid, int *size, ...@@ -630,7 +630,7 @@ int wb_vrepwbl::getAttrInfoRec( wb_name *attr, int bix, pwr_tCid cid, int *size,
{ {
pwr_sObjBodyDef o; pwr_sObjBodyDef o;
if ( bix != cdh_eBix_SysBody) if ( bix != cdh_eBix_sys)
return 0; return 0;
IF_ATTR( StructName, pwr_eType_String, 1, level) IF_ATTR( StructName, pwr_eType_String, 1, level)
else IF_ATTR( NumOfParams, pwr_eType_UInt32, 1, level) else IF_ATTR( NumOfParams, pwr_eType_UInt32, 1, level)
...@@ -643,7 +643,7 @@ int wb_vrepwbl::getAttrInfoRec( wb_name *attr, int bix, pwr_tCid cid, int *size, ...@@ -643,7 +643,7 @@ int wb_vrepwbl::getAttrInfoRec( wb_name *attr, int bix, pwr_tCid cid, int *size,
{ {
pwr_sParam o; pwr_sParam o;
if ( bix != cdh_eBix_SysBody) if ( bix != cdh_eBix_sys)
return 0; return 0;
if ( attr->attributeIsEqual( "PgmName", level)) { if ( attr->attributeIsEqual( "PgmName", level)) {
*size = sizeof( o.Info.PgmName); *size = sizeof( o.Info.PgmName);
...@@ -762,49 +762,49 @@ int wb_vrepwbl::getTemplateBody( pwr_tCid cid, int bix, int *size, void **body) ...@@ -762,49 +762,49 @@ int wb_vrepwbl::getTemplateBody( pwr_tCid cid, int bix, int *size, void **body)
{ {
switch ( cid) { switch ( cid) {
case pwr_eClass_Type: case pwr_eClass_Type:
if ( bix != cdh_eBix_SysBody) if ( bix != cdh_eBix_sys)
return 0; return 0;
*size = sizeof( pwr_sType); *size = sizeof( pwr_sType);
*body = calloc( 1, *size); *body = calloc( 1, *size);
return 1; return 1;
case pwr_eClass_TypeDef: case pwr_eClass_TypeDef:
if ( bix != cdh_eBix_SysBody) if ( bix != cdh_eBix_sys)
return 0; return 0;
*size = sizeof( pwr_sTypeDef); *size = sizeof( pwr_sTypeDef);
*body = calloc( 1, *size); *body = calloc( 1, *size);
return 1; return 1;
case pwr_eClass_ClassDef: case pwr_eClass_ClassDef:
if ( bix != cdh_eBix_SysBody) if ( bix != cdh_eBix_sys)
return 0; return 0;
*size = sizeof( pwr_sClassDef); *size = sizeof( pwr_sClassDef);
*body = calloc( 1, *size); *body = calloc( 1, *size);
return 1; return 1;
case pwr_eClass_ClassVolume: case pwr_eClass_ClassVolume:
if ( bix != cdh_eBix_SysBody) if ( bix != cdh_eBix_sys)
return 0; return 0;
*size = sizeof( pwr_sClassVolume); *size = sizeof( pwr_sClassVolume);
*body = calloc( 1, *size); *body = calloc( 1, *size);
return 1; return 1;
case pwr_eClass_ClassHier: case pwr_eClass_ClassHier:
if ( bix != cdh_eBix_SysBody) if ( bix != cdh_eBix_sys)
return 0; return 0;
*size = 0; *size = 0;
*body = 0; *body = 0;
return 1; return 1;
case pwr_eClass_TypeHier: case pwr_eClass_TypeHier:
if ( bix != cdh_eBix_SysBody) if ( bix != cdh_eBix_sys)
return 0; return 0;
*size = 0; *size = 0;
*body = 0; *body = 0;
return 1; return 1;
case pwr_eClass_ObjBodyDef: case pwr_eClass_ObjBodyDef:
if ( bix != cdh_eBix_SysBody) if ( bix != cdh_eBix_sys)
return 0; return 0;
*size = sizeof( pwr_sObjBodyDef); *size = sizeof( pwr_sObjBodyDef);
*body = calloc( 1, *size); *body = calloc( 1, *size);
return 1; return 1;
case pwr_eClass_Param: case pwr_eClass_Param:
if ( bix != cdh_eBix_SysBody) if ( bix != cdh_eBix_sys)
return 0; return 0;
*size = sizeof( pwr_sParam); *size = sizeof( pwr_sParam);
*body = calloc( 1, *size); *body = calloc( 1, *size);
...@@ -820,14 +820,14 @@ int wb_vrepwbl::getTemplateBody( pwr_tCid cid, int bix, int *size, void **body) ...@@ -820,14 +820,14 @@ int wb_vrepwbl::getTemplateBody( pwr_tCid cid, int bix, int *size, void **body)
if ( !n->c_template) if ( !n->c_template)
return 0; return 0;
if ( bix == cdh_eBix_SysBody || bix == cdh_eBix_RtBody) { if ( bix == cdh_eBix_sys || bix == cdh_eBix_rt) {
*size = n->c_template->rbody_size; *size = n->c_template->rbody_size;
if ( *size) { if ( *size) {
*body = calloc( 1, *size); *body = calloc( 1, *size);
memcpy( *body, n->c_template->rbody, *size); memcpy( *body, n->c_template->rbody, *size);
} }
} }
else if ( bix == cdh_eBix_DevBody) { else if ( bix == cdh_eBix_dev) {
*size = n->c_template->dbody_size; *size = n->c_template->dbody_size;
if ( *size) { if ( *size) {
*body = calloc( 1, *size); *body = calloc( 1, *size);
...@@ -838,8 +838,27 @@ int wb_vrepwbl::getTemplateBody( pwr_tCid cid, int bix, int *size, void **body) ...@@ -838,8 +838,27 @@ int wb_vrepwbl::getTemplateBody( pwr_tCid cid, int bix, int *size, void **body)
} }
else { else {
// Search type in other volumes TODO... // Search type in other volumes TODO...
pwr_tStatus sts;
wb_cdrep *cdrep = m_merep->cdrep( &sts, cid);
if ( EVEN(sts)) return 0;
wb_bdrep *bdrep = cdrep->bdrep( &sts, bix);
if ( EVEN(sts)) return 0;
*size = bdrep->size();
delete bdrep;
*body = calloc( 1, *size);
cdrep->templateBody( &sts, (cdh_eBix) bix, body);
delete cdrep;
if ( EVEN(sts)) {
free( body);
return 0; return 0;
} }
return 1;
}
} }
} }
return 0; return 0;
......
...@@ -378,10 +378,10 @@ void wb_wblnode::build( bool recursive) ...@@ -378,10 +378,10 @@ void wb_wblnode::build( bool recursive)
m_oid.vid = m_vrep->vid(); m_oid.vid = m_vrep->vid();
if ( isClassDef()) { if ( isClassDef()) {
m_vrep->getTemplateBody( m_cid, cdh_eBix_SysBody, &rbody_size, &rbody); m_vrep->getTemplateBody( m_cid, cdh_eBix_sys, &rbody_size, &rbody);
} }
else if ( isType() || isTypeDef()) { else if ( isType() || isTypeDef()) {
m_vrep->getTemplateBody( m_cid, cdh_eBix_SysBody, &rbody_size, &rbody); m_vrep->getTemplateBody( m_cid, cdh_eBix_sys, &rbody_size, &rbody);
} }
else if ( isTemplate()) { else if ( isTemplate()) {
// Build later by classdef // Build later by classdef
...@@ -390,8 +390,8 @@ void wb_wblnode::build( bool recursive) ...@@ -390,8 +390,8 @@ void wb_wblnode::build( bool recursive)
return; return;
} }
else { else {
m_vrep->getTemplateBody( m_cid, cdh_eBix_RtBody, &rbody_size, &rbody); m_vrep->getTemplateBody( m_cid, cdh_eBix_rt, &rbody_size, &rbody);
m_vrep->getTemplateBody( m_cid, cdh_eBix_DevBody, &dbody_size, &dbody); m_vrep->getTemplateBody( m_cid, cdh_eBix_dev, &dbody_size, &dbody);
} }
ref_wblnode first_child; ref_wblnode first_child;
...@@ -558,20 +558,20 @@ void wb_wblnode::buildBuffer( ref_wblnode classdef, ref_wblnode objbodydef, ...@@ -558,20 +558,20 @@ void wb_wblnode::buildBuffer( ref_wblnode classdef, ref_wblnode objbodydef,
void wb_wblnode::buildTemplate( ref_wblnode classdef) void wb_wblnode::buildTemplate( ref_wblnode classdef)
{ {
wb_wblnode *objbodydef = classdef->o_fch; wb_wblnode *objbodydef = classdef->o_fch;
m_oid.oix = cdh_cixToOix( classdef->c_cix, 7, 0); m_oid.oix = cdh_cixToOix( classdef->c_cix, cdh_eBix_template, 0);
if ( !m_vrep->registerObject( m_oid.oix, this)) if ( !m_vrep->registerObject( m_oid.oix, this))
m_vrep->error( "Duplicate template oix", getFileName(), line_number); m_vrep->error( "Duplicate template oix", getFileName(), line_number);
while ( objbodydef) { while ( objbodydef) {
if ( objbodydef->isObjBodyDef()) { if ( objbodydef->isObjBodyDef()) {
if ( objbodydef->b_bix == cdh_eBix_SysBody || if ( objbodydef->b_bix == cdh_eBix_sys ||
objbodydef->b_bix == cdh_eBix_RtBody) { objbodydef->b_bix == cdh_eBix_rt) {
rbody_size = objbodydef->b_size; rbody_size = objbodydef->b_size;
if ( rbody_size) { if ( rbody_size) {
rbody = calloc( 1, rbody_size); rbody = calloc( 1, rbody_size);
} }
} }
if ( objbodydef->b_bix == cdh_eBix_DevBody) { if ( objbodydef->b_bix == cdh_eBix_dev) {
dbody_size = objbodydef->b_size; dbody_size = objbodydef->b_size;
if ( dbody_size) if ( dbody_size)
dbody = calloc( 1, dbody_size); dbody = calloc( 1, dbody_size);
...@@ -594,11 +594,11 @@ void wb_wblnode::buildBody( ref_wblnode object) ...@@ -594,11 +594,11 @@ void wb_wblnode::buildBody( ref_wblnode object)
switch ( getType()) { switch ( getType()) {
case tokens.BODY: case tokens.BODY:
if ( strcmp( name, "SysBody") == 0) if ( strcmp( name, "SysBody") == 0)
bix = cdh_eBix_SysBody; bix = cdh_eBix_sys;
else if ( strcmp( name, "RtBody") == 0) else if ( strcmp( name, "RtBody") == 0)
bix = cdh_eBix_RtBody; bix = cdh_eBix_rt;
else if ( strcmp( name, "DevBody") == 0) else if ( strcmp( name, "DevBody") == 0)
bix = cdh_eBix_SysBody; bix = cdh_eBix_sys;
else { else {
// Body exception // Body exception
m_vrep->error( "Bad body name", getFileName(), line_number); m_vrep->error( "Bad body name", getFileName(), line_number);
...@@ -652,16 +652,16 @@ void wb_wblnode::buildAttr( ref_wblnode object, int bix) ...@@ -652,16 +652,16 @@ void wb_wblnode::buildAttr( ref_wblnode object, int bix)
m_vrep->error( "Attribute syntax", getFileName(), line_number); m_vrep->error( "Attribute syntax", getFileName(), line_number);
} }
else { else {
if ( ((bix == cdh_eBix_RtBody || bix == cdh_eBix_SysBody) && if ( ((bix == cdh_eBix_rt || bix == cdh_eBix_sys) &&
object->rbody_size == 0) || object->rbody_size == 0) ||
(bix == cdh_eBix_DevBody && object->dbody_size == 0)) { (bix == cdh_eBix_dev && object->dbody_size == 0)) {
m_vrep->error( "Attribute body", getFileName(), line_number); m_vrep->error( "Attribute body", getFileName(), line_number);
return; return;
} }
if ( ((bix == cdh_eBix_RtBody || bix == cdh_eBix_SysBody) && if ( ((bix == cdh_eBix_rt || bix == cdh_eBix_sys) &&
offset + size/elements > object->rbody_size) || offset + size/elements > object->rbody_size) ||
( bix == cdh_eBix_RtBody && ( bix == cdh_eBix_rt &&
offset + size/elements > object->rbody_size)) { offset + size/elements > object->rbody_size)) {
m_vrep->error( "Mismatch in attribute offset", getFileName(), line_number); m_vrep->error( "Mismatch in attribute offset", getFileName(), line_number);
return; return;
...@@ -670,21 +670,21 @@ void wb_wblnode::buildAttr( ref_wblnode object, int bix) ...@@ -670,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); // 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 ( size/elements == sizeof(int_val) && convconst( &int_val, value)) {
if ( oper == tokens.EQ) { if ( oper == tokens.EQ) {
if ( bix == cdh_eBix_RtBody || bix == cdh_eBix_SysBody) if ( bix == cdh_eBix_rt || bix == cdh_eBix_sys)
memcpy( (char *)((unsigned int) object->rbody + offset), memcpy( (char *)((unsigned int) object->rbody + offset),
&int_val, size/elements); &int_val, size/elements);
else if ( bix == cdh_eBix_DevBody) else if ( bix == cdh_eBix_dev)
memcpy( (char *)((unsigned int) object->dbody + offset), memcpy( (char *)((unsigned int) object->dbody + offset),
&int_val, size/elements); &int_val, size/elements);
} }
else if ( oper == tokens.OREQ) { else if ( oper == tokens.OREQ) {
if ( bix == cdh_eBix_RtBody || bix == cdh_eBix_SysBody) { if ( bix == cdh_eBix_rt || bix == cdh_eBix_sys) {
current_int_val = *(int *) ((unsigned int) object->rbody + offset); current_int_val = *(int *) ((unsigned int) object->rbody + offset);
int_val |= current_int_val; int_val |= current_int_val;
memcpy( (char *)((unsigned int) object->rbody + offset), memcpy( (char *)((unsigned int) object->rbody + offset),
&int_val, size/elements); &int_val, size/elements);
} }
else if ( bix == cdh_eBix_DevBody) { else if ( bix == cdh_eBix_dev) {
current_int_val = *(int *) ((unsigned int) object->dbody + offset); current_int_val = *(int *) ((unsigned int) object->dbody + offset);
int_val |= current_int_val; int_val |= current_int_val;
memcpy( (char *)((unsigned int) object->dbody + offset), memcpy( (char *)((unsigned int) object->dbody + offset),
...@@ -693,10 +693,10 @@ void wb_wblnode::buildAttr( ref_wblnode object, int bix) ...@@ -693,10 +693,10 @@ void wb_wblnode::buildAttr( ref_wblnode object, int bix)
} }
} }
else if ( attrStringToValue( tid, value, buf, sizeof( buf), size)) { else if ( attrStringToValue( tid, value, buf, sizeof( buf), size)) {
if ( bix == cdh_eBix_RtBody || bix == cdh_eBix_SysBody) if ( bix == cdh_eBix_rt || bix == cdh_eBix_sys)
memcpy( (char *)((unsigned int) object->rbody + offset), memcpy( (char *)((unsigned int) object->rbody + offset),
buf, size/elements); buf, size/elements);
else if ( bix == cdh_eBix_DevBody) else if ( bix == cdh_eBix_dev)
memcpy( (char *)((unsigned int) object->dbody + offset), memcpy( (char *)((unsigned int) object->dbody + offset),
buf, size/elements); buf, size/elements);
} }
......
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