Commit dd4cba1c authored by lw's avatar lw

*** empty log message ***

parent e3d93f0b
......@@ -106,7 +106,7 @@ wb_attribute::wb_attribute(pwr_tStatus sts, wb_orep* orep, char const* bname, co
m_adrep->ref();
if ( !m_orep->vrep()->merep()->getAttrInfoRec( &n, m_adrep->bix(),
m_orep->cid(), (int *) &m_size,
m_orep->cid(), &m_size,
&m_offset, &m_tid, &m_elements,
&m_type,
&m_flags, 0)) {
......@@ -165,7 +165,7 @@ wb_attribute::wb_attribute(wb_attribute& pa, int idx, const char* aname) :
m_adrep->ref();
if (!m_orep->vrep()->merep()->getAttrInfoRec( &n, m_adrep->bix(),
cid, (int *) &m_size,
cid, &m_size,
&m_offset, &m_tid, &m_elements,
&m_type,
&m_flags, 0)) {
......@@ -265,7 +265,7 @@ size_t wb_attribute::size()
return m_size;
}
int wb_attribute::offset()
size_t wb_attribute::offset()
{
check();
return m_offset;
......
......@@ -31,7 +31,7 @@ class wb_attribute : public wb_status
wb_adrep *m_adrep;
size_t m_size;
int m_offset;
size_t m_offset;
pwr_tTid m_tid;
int m_elements;
pwr_eType m_type;
......@@ -64,7 +64,7 @@ public:
pwr_sAttrRef aref();
pwr_sAttrRef *aref(pwr_sAttrRef *arp);
size_t size();
int offset();
size_t offset();
pwr_eType type();
int nElement();
int index();
......
......@@ -295,7 +295,7 @@ bool wb_db::importVolume(wb_export *e)
bool wb_db::importHead(pwr_tOid oid, pwr_tCid cid, pwr_tOid poid,
pwr_tOid boid, pwr_tOid aoid, pwr_tOid foid, pwr_tOid loid,
pwr_tObjName name, pwr_tObjName normname,
const char *name, const char *normname,
pwr_tTime ohTime, pwr_tTime rbTime, pwr_tTime dbTime,
size_t rbSize, size_t dbSize)
{
......
......@@ -78,7 +78,7 @@ public:
bool importVolume(wb_export *e);
bool importHead(pwr_tOid oid, pwr_tCid cid, pwr_tOid poid, pwr_tOid boid, pwr_tOid aoid, pwr_tOid foid,
pwr_tOid loid, pwr_tObjName name, pwr_tObjName normname, pwr_tTime ohTime,
pwr_tOid loid, const char *name, const char *normname, pwr_tTime ohTime,
pwr_tTime rbTime, pwr_tTime dbTime, size_t rbSize, size_t dbSize);
bool importRbody(pwr_tOid oid, size_t size, void *body);
......@@ -105,7 +105,7 @@ public:
wb_db_ohead(wb_db *db, wb_db_txn *txn, pwr_tOid oid);
wb_db_ohead(wb_db *db, pwr_tOid oid, pwr_tCid cid,
pwr_tOid poid, pwr_tOid boid, pwr_tOid aoid, pwr_tOid foid, pwr_tOid loid,
pwr_tObjName name, pwr_tObjName normname,
const char *name, const char *normname,
pwr_tTime ohTime, pwr_tTime rbTime, pwr_tTime dbTime,
size_t rbSize, size_t dbSize);
......
......@@ -171,7 +171,7 @@ wb_dbs::checkObject(sOentry *oep)
bool
wb_dbs::importHead(pwr_tOid oid, pwr_tCid cid, pwr_tOid poid, pwr_tOid aoid, pwr_tOid boid, pwr_tOid foid,
pwr_tOid loid, pwr_tObjName name, pwr_tObjName normname, pwr_tTime time,
pwr_tOid loid, const char *name, const char *normname, pwr_tTime time,
pwr_tTime rbTime, pwr_tTime dbTime, size_t rbSize, size_t dbSize)
{
sNentry *nep;
......
......@@ -112,11 +112,6 @@ public:
// ldhi_sObjHead *getAliasServer(sLCB *lcbp, ldhi_sObjHead *o, pwr_tOid *soid);
// pwr_tStatus getMountServer(sLCB *lcbp, ldhi_sObjHead *o, pwr_tOid *soid);
pwr_tStatus installObject(pwr_tOid oid, pwr_tCid cid, pwr_tOid poid, pwr_tOid boid, pwr_tOid aoid, pwr_tOid foid,
pwr_tOid loid, pwr_tObjName name, pwr_tObjName normname, pwr_tTime ohTime,
pwr_tTime rbTime, pwr_tTime dbTime, size_t rbSize, size_t dbSize);
pwr_tStatus installRbody(pwr_tOid oid, void *body);
pwr_tStatus installDbody(pwr_tOid oid, void *body);
void classInsert(sOentry *oep);
pwr_tStatus openFile();
pwr_tStatus writeSectFile();
......@@ -135,7 +130,7 @@ public:
virtual bool importHead(pwr_tOid oid, pwr_tCid cid, pwr_tOid poid,
pwr_tOid boid, pwr_tOid aoid, pwr_tOid foid, pwr_tOid loid,
pwr_tObjName name, pwr_tObjName normname,
const char *name, const char *normname,
pwr_tTime ohTime, pwr_tTime rbTime, pwr_tTime dbTime,
size_t rbSize, size_t dbSize);
......
#ifndef wb_import_h
#define wb_import_h
#include "pwr.h"
#include "co_dbs.h"
class wb_export;
......@@ -13,7 +14,7 @@ public:
virtual bool importHead(pwr_tOid oid, pwr_tCid cid, pwr_tOid poid,
pwr_tOid boid, pwr_tOid aoid, pwr_tOid foid, pwr_tOid loid,
pwr_tObjName name, pwr_tObjName normname,
const char *name, const char *normname,
pwr_tTime ohTime, pwr_tTime rbTime, pwr_tTime dbTime,
size_t rbSize, size_t dbSize) = 0;
......
......@@ -159,8 +159,8 @@ wb_tdrep *wb_merep::tdrep( pwr_tStatus *sts, wb_name name)
return 0;
}
int wb_merep::getAttrInfoRec( wb_attrname *attr, pwr_eBix bix, pwr_tCid cid, int *size,
int *offset, pwr_tTid *tid, int *elements,
int wb_merep::getAttrInfoRec( wb_attrname *attr, pwr_eBix bix, pwr_tCid cid, size_t *size,
size_t *offset, pwr_tTid *tid, int *elements,
pwr_eType *type, int *flags, int level)
{
pwr_tStatus sts;
......
......@@ -35,8 +35,8 @@ public:
wb_tdrep *tdrep( pwr_tStatus *sts, pwr_tTid tid);
wb_tdrep *tdrep( pwr_tStatus *sts, wb_name name);
int getAttrInfoRec( wb_attrname *attr, pwr_eBix bix, pwr_tCid cid, int *size,
int *offset, pwr_tTid *tid, int *elements,
int getAttrInfoRec( wb_attrname *attr, pwr_eBix bix, pwr_tCid cid, size_t *size,
size_t *offset, pwr_tTid *tid, int *elements,
pwr_eType *type, int *flags, int level);
};
......
......@@ -11,6 +11,8 @@
#include "wb_orepwbl.h"
#include "wb_ldh_msg.h"
#include "wb_dbs.h"
#include "wb_bdrep.h"
#include "wb_cdrep.h"
#include "wb_erep.h"
#include "wb_merep.h"
#include "wb_tdrep.h"
......@@ -299,7 +301,7 @@ ref_wblnode wb_vrepwbl::findType( pwr_tTid tid)
}
int wb_vrepwbl::getTypeInfo( const char *name, pwr_tTid *tid, pwr_eType *type, int *size,
int wb_vrepwbl::getTypeInfo( const char *name, pwr_tTid *tid, pwr_eType *type, size_t *size,
int *elements)
{
bool type_extern = false;
......@@ -387,7 +389,7 @@ int wb_vrepwbl::getTypeInfo( const char *name, pwr_tTid *tid, pwr_eType *type, i
return 1;
}
int wb_vrepwbl::getTypeInfo( pwr_tTid tid, pwr_eType *type, int *size,
int wb_vrepwbl::getTypeInfo( pwr_tTid tid, pwr_eType *type, size_t *size,
int *elements)
{
switch ( tid) {
......@@ -529,7 +531,7 @@ int wb_vrepwbl::getTypeInfo( pwr_tTid tid, pwr_eType *type, int *size,
return 1;
}
int wb_vrepwbl::getClassInfo( pwr_tCid cid, int *rsize, int *dsize)
int wb_vrepwbl::getClassInfo( pwr_tCid cid, size_t *rsize, size_t *dsize)
{
// Search type in this volume
ref_wblnode n = findClass( cid);
......@@ -589,11 +591,11 @@ int wb_vrepwbl::getClassInfo( pwr_tCid cid, int *rsize, int *dsize)
*elements = elem; }
int wb_vrepwbl::getAttrInfo( const char *attr, pwr_eBix bix, pwr_tCid cid, int *size,
int *offset, pwr_tTid *tid, int *elements, pwr_eType *type)
int wb_vrepwbl::getAttrInfo( const char *attr, pwr_eBix bix, pwr_tCid cid, size_t *size,
size_t *offset, pwr_tTid *tid, int *elements, pwr_eType *type)
{
int a_size;
int a_offset = 0;
size_t a_size;
size_t a_offset = 0;
pwr_tTid a_tid;
int a_elements;
pwr_eType a_type;
......@@ -614,8 +616,8 @@ int wb_vrepwbl::getAttrInfo( const char *attr, pwr_eBix bix, pwr_tCid cid, int *
return 0;
}
int wb_vrepwbl::getAttrInfoRec( wb_attrname *attr, pwr_eBix bix, pwr_tCid cid, int *size,
int *offset, pwr_tTid *tid, int *elements, pwr_eType *type,
int wb_vrepwbl::getAttrInfoRec( wb_attrname *attr, pwr_eBix bix, pwr_tCid cid, size_t *size,
size_t *offset, pwr_tTid *tid, int *elements, pwr_eType *type,
int level)
{
if ( level > 0)
......@@ -850,8 +852,8 @@ int wb_vrepwbl::nameToAttrRef( const char *name, pwr_sAttrRef *attrref)
{
pwr_tOid oid;
pwr_tStatus sts;
int a_size;
int a_offset;
size_t a_size;
size_t a_offset;
pwr_tTid a_tid;
int a_elements;
pwr_eType a_type;
......@@ -930,7 +932,7 @@ int wb_vrepwbl::nameToAttrRef( const char *name, pwr_sAttrRef *attrref)
return LDH__SUCCESS;
}
int wb_vrepwbl::getTemplateBody( pwr_tCid cid, pwr_eBix bix, int *size, void **body)
int wb_vrepwbl::getTemplateBody( pwr_tCid cid, pwr_eBix bix, size_t *size, void **body)
{
switch ( cid) {
case pwr_eClass_Type:
......
......@@ -55,14 +55,6 @@ public:
virtual bool createSnapshot(const char *fileName);
#if 0
void iterObject( void *udata,
pwr_tStatus (*bc)(void *,pwr_tOid, pwr_tCid, pwr_tOid, pwr_tOid,
pwr_tOid, pwr_tOid, pwr_tOid, const char *,
pwr_tTime, int, int));
void iterBody( void *udata,
pwr_tStatus (*bc)(void *,pwr_tOid, void *, void *));
#endif
int load( const char *fname);
int load_files( const char *file_spec);
void info();
......@@ -78,16 +70,16 @@ public:
bool registerObject( pwr_tOix oix, ref_wblnode node);
int nextOix() { return ++next_oix; }
int classNameToCid( const char *name, pwr_tCid *cid);
int getTemplateBody( pwr_tCid cid, pwr_eBix bix, int *size, void **body);
int getTypeInfo( pwr_tTid tid, pwr_eType *type, int *size,
int getTemplateBody( pwr_tCid cid, pwr_eBix bix, size_t *size, void **body);
int getTypeInfo( pwr_tTid tid, pwr_eType *type, size_t *size,
int *elements);
int getTypeInfo( const char *type, pwr_tTid *tid, pwr_eType *type, int *size,
int getTypeInfo( const char *type, pwr_tTid *tid, pwr_eType *type, size_t *size,
int *elements);
int getClassInfo( pwr_tCid cid, int *rsize, int *dsize);
int getAttrInfo( const char *attr, pwr_eBix bix, pwr_tCid cid, int *size,
int *offset, pwr_tTid *tid, int *elements, pwr_eType *type);
int getAttrInfoRec( wb_attrname *attr, pwr_eBix bix, pwr_tCid cid, int *size,
int *offset, pwr_tTid *tid, int *elements,
int getClassInfo( pwr_tCid cid, size_t *rsize, size_t *dsize);
int getAttrInfo( const char *attr, pwr_eBix bix, pwr_tCid cid, size_t *size,
size_t *offset, pwr_tTid *tid, int *elements, pwr_eType *type);
int getAttrInfoRec( wb_attrname *attr, pwr_eBix bix, pwr_tCid cid, size_t *size,
size_t *offset, pwr_tTid *tid, int *elements,
pwr_eType *type, int level);
ref_wblnode findObject( pwr_tOix oix);
ref_wblnode findClass( const char *name);
......@@ -158,9 +150,9 @@ public:
bool commit(pwr_tStatus *sts) {return false;}
bool abort(pwr_tStatus *sts) {return false;}
virtual bool writeAttribute(pwr_tStatus *sts, wb_orep *o, pwr_eBix bix, unsigned int offset, unsigned int size, void *p) {return false;}
virtual bool writeAttribute(pwr_tStatus *sts, wb_orep *o, pwr_eBix bix, size_t offset, size_t size, void *p) {return false;}
virtual void *readAttribute(pwr_tStatus *sts, wb_orep *o, pwr_eBix bix, unsigned int offset, unsigned int size, void *p);
virtual void *readAttribute(pwr_tStatus *sts, wb_orep *o, pwr_eBix bix, size_t offset, size_t size, void *p);
virtual void *readBody(pwr_tStatus *sts, wb_orep *o, pwr_eBix bix, void *p);
......
#include "pwr_class.h"
#include "co_cdh.h"
#include "co_time.h"
#include "wb_wblnode.h"
#include "wb_vrepwbl.h"
#include "wb_merep.h"
#include "wb_cdrep.h"
#include "wb_wblvocabTokenTypes.hpp"
#include "wb_dbs.h"
extern "C" {
#include "pwr_class.h"
#include "co_cdh.h"
#include "co_time.h"
}
#include "wb_name.h"
struct wb_wblvocabTokenTypes tokens;
/* Datatypes */
static wbl_sSym datatypes[] =
{
{ "pwr_eType_Boolean", pwr_eType_Boolean }
{ "pwr_eType_Boolean", pwr_eType_Boolean }
,{ "pwr_eTix_Boolean", pwr_eTix_Boolean }
,{ "pwr_eType_Float32", pwr_eType_Float32 }
,{ "pwr_eTix_Float32", pwr_eTix_Float32 }
......@@ -76,7 +74,7 @@ static wbl_sSym datatypes[] =
/* System Classes */
static wbl_sSym classes[] =
{
{ "pwr_eClass_ClassDef", pwr_eClass_ClassDef }
{ "pwr_eClass_ClassDef", pwr_eClass_ClassDef }
,{ "pwr_eCix_ClassDef", pwr_eCix_ClassDef }
,{ "pwr_eClass_Type", pwr_eClass_Type }
,{ "pwr_eCix_Type", pwr_eCix_Type }
......@@ -199,7 +197,7 @@ static wbl_sSym classes[] =
/* Datatypes */
static wbl_sSym editor[] =
{
{ "pwr_eEditor_HiEd", pwr_eEditor_HiEd }
{ "pwr_eEditor_HiEd", pwr_eEditor_HiEd }
,{ "pwr_eEditor_PlcEd", pwr_eEditor_PlcEd }
,{ "pwr_eEditor_AttrEd", pwr_eEditor_AttrEd }
,{ "pwr_eEditor_ClassEd", pwr_eEditor_ClassEd }
......@@ -224,7 +222,7 @@ static wbl_sSym attr_flags[] =
{
/* Bitmask for flags */
{ "PWR_MASK_POINTER", PWR_MASK_POINTER }
{ "PWR_MASK_POINTER", PWR_MASK_POINTER }
,{ "PWR_MASK_ARRAY", PWR_MASK_ARRAY }
,{ "PWR_MASK_BACKUP", PWR_MASK_BACKUP }
,{ "PWR_MASK_CHANGELOG", PWR_MASK_CHANGELOG }
......@@ -328,28 +326,28 @@ int wb_wblnode::convconst( int *val, char *str)
ref_wblnode wb_wblnode::find( wb_name *oname, int level)
{
switch ( getType()) {
case tokens.OBJECT:
if ( oname->segmentIsEqual( name(), level)) {
if ( !oname->hasSegment(level+1))
return this;
else if ( o_fch)
return o_fch->find( oname, level+1);
else
return 0;
}
else if ( o_fws)
return o_fws->find( oname, level);
else
return 0;
case tokens.VOLUME:
if ( oname->volumeIsEqual( name()) && !oname->hasSegment(0))
case tokens.OBJECT:
if ( oname->segmentIsEqual( name(), level)) {
if ( !oname->hasSegment(level+1))
return this;
else if ( o_fch)
return o_fch->find( oname, 0);
return o_fch->find( oname, level+1);
else
return 0;
default:
;
}
else if ( o_fws)
return o_fws->find( oname, level);
else
return 0;
case tokens.VOLUME:
if ( oname->volumeIsEqual( name()) && !oname->hasSegment(0))
return this;
else if ( o_fch)
return o_fch->find( oname, 0);
else
return 0;
default:
;
}
return 0;
}
......@@ -433,36 +431,36 @@ void wb_wblnode::build( bool recursive)
if ( child->isObjBodyDef()) {
child->buildObjBodyDef( this);
((pwr_sClassDef *)rbody)->NumOfObjBodies++;
if ( cdh_oixToBix( child->m_oid.oix) == pwr_eBix_rt)
((pwr_sClassDef *)rbody)->Flags.b.RtBody = 1;
wb_wblnode *attr = child->o_fch;
while( attr) {
if ( attr->isAttribute()) {
switch ( attr->m_cid) {
case pwr_eClass_ObjXRef:
((pwr_sClassDef *)rbody)->Flags.b.ObjXRef = 1;
break;
case pwr_eClass_AttrXRef:
((pwr_sClassDef *)rbody)->Flags.b.AttrXRef = 1;
break;
case pwr_eClass_Input:
case pwr_eClass_Output:
case pwr_eClass_Intern:
case pwr_eClass_Param:
if ( attr->a_type == pwr_eType_AttrRef)
((pwr_sClassDef *)rbody)->Flags.b.AttrRef = 1;
else if ( attr->a_type == pwr_eType_AttrRef)
((pwr_sClassDef *)rbody)->Flags.b.ObjRef = 1;
break;
default:
;
}
}
attr = attr->o_fws;
}
}
((pwr_sClassDef *)rbody)->NumOfObjBodies++;
if ( cdh_oixToBix( child->m_oid.oix) == pwr_eBix_rt)
((pwr_sClassDef *)rbody)->Flags.b.RtBody = 1;
wb_wblnode *attr = child->o_fch;
while( attr) {
if ( attr->isAttribute()) {
switch ( attr->m_cid) {
case pwr_eClass_ObjXRef:
((pwr_sClassDef *)rbody)->Flags.b.ObjXRef = 1;
break;
case pwr_eClass_AttrXRef:
((pwr_sClassDef *)rbody)->Flags.b.AttrXRef = 1;
break;
case pwr_eClass_Input:
case pwr_eClass_Output:
case pwr_eClass_Intern:
case pwr_eClass_Param:
if ( attr->a_type == pwr_eType_AttrRef)
((pwr_sClassDef *)rbody)->Flags.b.AttrRef = 1;
else if ( attr->a_type == pwr_eType_AttrRef)
((pwr_sClassDef *)rbody)->Flags.b.ObjRef = 1;
break;
default:
;
}
}
attr = attr->o_fws;
}
}
child = child->o_fws;
}
is_built = 1;
......@@ -500,14 +498,14 @@ void wb_wblnode::build( bool recursive)
}
else {
if( !m_vrep->registerObject( m_oid.oix, this)) {
// Print error message
char name[120];
char msg[180];
pwr_tStatus sts;
wb_orep *o = m_vrep->object( &sts, m_oid);
m_vrep->objectName( o, name);
sprintf( msg, "Duplicate object index %d (%s)", m_oid.oix, name);
// Print error message
char name[120];
char msg[180];
pwr_tStatus sts;
wb_orep *o = m_vrep->object( &sts, m_oid);
m_vrep->objectName( o, name);
sprintf( msg, "Duplicate object index %d (%s)", m_oid.oix, name);
m_vrep->error( msg, getFileName(), line_number);
}
}
......@@ -541,10 +539,10 @@ void wb_wblnode::buildObjBodyDef( ref_wblnode classdef)
}
void wb_wblnode::buildAttribute( ref_wblnode classdef, ref_wblnode objbodydef,
int *bindex, int *boffset)
int *bindex, size_t *boffset)
{
pwr_eType type;
int size;
size_t size;
int elements;
m_oid.oix = cdh_cixToOix( classdef->c_cix, objbodydef->b_bix, m_oid.oix);
......@@ -594,9 +592,9 @@ void wb_wblnode::buildAttribute( ref_wblnode classdef, ref_wblnode objbodydef,
}
void wb_wblnode::buildBuffer( ref_wblnode classdef, ref_wblnode objbodydef,
int *bindex, int *boffset)
int *bindex, size_t *boffset)
{
int rsize, dsize;
size_t rsize, dsize;
m_oid.oix = cdh_cixToOix( classdef->c_cix, objbodydef->b_bix, m_oid.oix);
if ( !m_vrep->registerObject( m_oid.oix, this))
......@@ -635,12 +633,12 @@ void wb_wblnode::buildTemplate( ref_wblnode classdef)
wb_wblnode *objbodydef = classdef->o_fch;
m_oid.oix = cdh_cixToOix( classdef->c_cix, pwr_eBix_template, 0);
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) {
if ( objbodydef->isObjBodyDef()) {
if ( objbodydef->b_bix == pwr_eBix_sys ||
objbodydef->b_bix == pwr_eBix_rt) {
objbodydef->b_bix == pwr_eBix_rt) {
rbody_size = objbodydef->b_size;
if ( rbody_size) {
rbody = calloc( 1, rbody_size);
......@@ -662,46 +660,47 @@ void wb_wblnode::buildTemplate( ref_wblnode classdef)
void wb_wblnode::buildBody( ref_wblnode object)
{
int bix;
pwr_eBix bix;
ref_wblnode first_child;
ref_wblnode next_sibling;
switch ( getType()) {
case tokens.BODY:
if ( cdh_NoCaseStrcmp( name(), "SysBody") == 0)
bix = pwr_eBix_sys;
else if ( cdh_NoCaseStrcmp( name(), "RtBody") == 0)
bix = pwr_eBix_rt;
else if ( cdh_NoCaseStrcmp( name(), "DevBody") == 0)
bix = pwr_eBix_dev;
else {
// Body exception
m_vrep->error( "Bad body name", getFileName(), line_number);
}
case tokens.BODY:
if ( cdh_NoCaseStrcmp( name(), "SysBody") == 0)
bix = pwr_eBix_sys;
else if ( cdh_NoCaseStrcmp( name(), "RtBody") == 0)
bix = pwr_eBix_rt;
else if ( cdh_NoCaseStrcmp( name(), "DevBody") == 0)
bix = pwr_eBix_dev;
else {
// Body exception
m_vrep->error( "Bad body name", getFileName(), line_number);
}
first_child = getFirstChild();
if ( first_child)
first_child->buildAttr( object, bix);
first_child = getFirstChild();
if ( first_child)
first_child->buildAttr( object, bix);
next_sibling = getNextSibling();
if ( next_sibling)
next_sibling->buildBody( object);
break;
default:
next_sibling = getNextSibling();
if ( next_sibling)
next_sibling->buildBody( object);
next_sibling = getNextSibling();
if ( next_sibling)
next_sibling->buildBody( object);
break;
default:
next_sibling = getNextSibling();
if ( next_sibling)
next_sibling->buildBody( object);
}
}
void wb_wblnode::buildAttr( ref_wblnode object, int bix)
void wb_wblnode::buildAttr( ref_wblnode object, pwr_eBix bix)
{
ref_wblnode first_child;
ref_wblnode second_child;
ref_wblnode next_sibling;
int oper;
char value[2048];
int size, offset, elements;
size_t size, offset;
int elements;
pwr_tTypeId tid;
pwr_eType type;
char buf[2048];
......@@ -710,124 +709,124 @@ void wb_wblnode::buildAttr( ref_wblnode object, int bix)
switch ( getType()) {
case tokens.ATTRIBUTE:
{
first_child = getFirstChild();
if ( !first_child) {
// Attr exception
m_vrep->error( "Attribute syntax", getFileName(), line_number);
goto error_continue;
}
{
first_child = getFirstChild();
if ( !first_child) {
// Attr exception
m_vrep->error( "Attribute syntax", getFileName(), line_number);
goto error_continue;
}
switch ( oper = first_child->getType()) {
case tokens.OREQ:
case tokens.EQ:
break;
default:
// Attr exception
m_vrep->error( "Attribute value required", getFileName(), line_number);
goto error_continue;
}
switch ( oper = first_child->getType()) {
case tokens.OREQ:
case tokens.EQ:
break;
default:
// Attr exception
m_vrep->error( "Attribute value required", getFileName(), line_number);
goto error_continue;
}
if ( !m_vrep->getAttrInfo( name(), (pwr_eBix) bix, object->m_cid, &size, &offset,
&tid, &elements, &type)) {
// This might be string special syntax
wb_attrname n = wb_attrname( name());
if ( n.hasAttrIndex() &&
m_vrep->getAttrInfo( n.attribute(), (pwr_eBix) bix, object->m_cid, &size,
&offset, &tid, &elements, &type) &&
elements == 1 &&
(type == pwr_eType_String || type == pwr_eType_Text)) {
// Index in string attribute marks a new row
int index = n.attrIndex();
if ( index > 0) {
add_newline = true;
index--;
}
offset += index;
size = size - index;
}
else {
// Attr exception
m_vrep->error( "Unknown attribute", getFileName(), line_number);
goto error_continue;
}
if ( !m_vrep->getAttrInfo( name(), (pwr_eBix) bix, object->m_cid, &size, &offset,
&tid, &elements, &type)) {
// This might be string special syntax
wb_attrname n = wb_attrname( name());
if ( n.hasAttrIndex() &&
m_vrep->getAttrInfo( n.attribute(), (pwr_eBix) bix, object->m_cid, &size,
&offset, &tid, &elements, &type) &&
elements == 1 &&
(type == pwr_eType_String || type == pwr_eType_Text)) {
// Index in string attribute marks a new row
int index = n.attrIndex();
if ( index > 0) {
add_newline = true;
index--;
}
offset += index;
size = size - index;
}
second_child = first_child->getNextSibling();
if ( !second_child) {
// Attr exception
m_vrep->error( "Attribute value required", getFileName(), line_number);
goto error_continue;
else {
// Attr exception
m_vrep->error( "Unknown attribute", getFileName(), line_number);
goto error_continue;
}
}
if ( ((bix == pwr_eBix_rt || bix == pwr_eBix_sys) &&
object->rbody_size == 0) ||
(bix == pwr_eBix_dev && object->dbody_size == 0)) {
m_vrep->error( "Attribute body", getFileName(), line_number);
return;
}
second_child = first_child->getNextSibling();
if ( !second_child) {
// Attr exception
m_vrep->error( "Attribute value required", getFileName(), line_number);
goto error_continue;
}
if ( ((bix == pwr_eBix_rt || bix == pwr_eBix_sys) &&
offset + size > object->rbody_size) ||
( bix == pwr_eBix_rt &&
offset + size > object->rbody_size)) {
m_vrep->error( "Mismatch in attribute offset", getFileName(), line_number);
return;
}
if ( ((bix == pwr_eBix_rt || bix == pwr_eBix_sys) &&
object->rbody_size == 0) ||
(bix == pwr_eBix_dev && object->dbody_size == 0)) {
m_vrep->error( "Attribute body", getFileName(), line_number);
return;
}
if ( !add_newline)
strncpy( value, second_child->name(), sizeof(value));
else {
strncpy( &value[1], second_child->name(), sizeof(value)-1);
value[0] = '\n';
}
if ( ((bix == pwr_eBix_rt || bix == pwr_eBix_sys) &&
offset + size > object->rbody_size) ||
( bix == pwr_eBix_rt &&
offset + size > object->rbody_size)) {
m_vrep->error( "Mismatch in attribute offset", getFileName(), line_number);
return;
}
// printf( "Attr %s %s %d %d %s\n", object->name, name, size, offset, value);
if ( size == sizeof(int_val) && convconst( &int_val, value)) {
if ( oper == tokens.EQ) {
if ( bix == pwr_eBix_rt || bix == pwr_eBix_sys)
memcpy( (char *)((unsigned int) object->rbody + offset),
&int_val, size);
else if ( bix == pwr_eBix_dev)
memcpy( (char *)((unsigned int) object->dbody + offset),
&int_val, size);
}
else if ( oper == tokens.OREQ) {
if ( bix == pwr_eBix_rt || bix == pwr_eBix_sys) {
current_int_val = *(int *) ((unsigned int) object->rbody + offset);
int_val |= current_int_val;
memcpy( (char *)((unsigned int) object->rbody + offset),
&int_val, size);
}
else if ( bix == pwr_eBix_dev) {
current_int_val = *(int *) ((unsigned int) object->dbody + offset);
int_val |= current_int_val;
memcpy( (char *)((unsigned int) object->dbody + offset),
&int_val, size);
}
}
}
else if ( attrStringToValue( type, value, buf, sizeof( buf), size)) {
if ( bix == pwr_eBix_rt || bix == pwr_eBix_sys)
memcpy( (char *)((unsigned int) object->rbody + offset),
buf, size);
else if ( bix == pwr_eBix_dev)
memcpy( (char *)((unsigned int) object->dbody + offset),
buf, size);
if ( !add_newline)
strncpy( value, second_child->name(), sizeof(value));
else {
strncpy( &value[1], second_child->name(), sizeof(value)-1);
value[0] = '\n';
}
// printf( "Attr %s %s %d %d %s\n", object->name, name, size, offset, value);
if ( size == sizeof(int_val) && convconst( &int_val, value)) {
if ( oper == tokens.EQ) {
if ( bix == pwr_eBix_rt || bix == pwr_eBix_sys)
memcpy( (char *)((unsigned int) object->rbody + offset),
&int_val, size);
else if ( bix == pwr_eBix_dev)
memcpy( (char *)((unsigned int) object->dbody + offset),
&int_val, size);
}
else {
// Attr conversion exception
m_vrep->error( "Unable to convert string to value", getFileName(), line_number);
else if ( oper == tokens.OREQ) {
if ( bix == pwr_eBix_rt || bix == pwr_eBix_sys) {
current_int_val = *(int *) ((unsigned int) object->rbody + offset);
int_val |= current_int_val;
memcpy( (char *)((unsigned int) object->rbody + offset),
&int_val, size);
}
else if ( bix == pwr_eBix_dev) {
current_int_val = *(int *) ((unsigned int) object->dbody + offset);
int_val |= current_int_val;
memcpy( (char *)((unsigned int) object->dbody + offset),
&int_val, size);
}
}
error_continue:
break;
}
case tokens.BUFFER:
{
buildBuff( object, bix, 0, 0, 0);
break;
else if ( attrStringToValue( type, value, buf, sizeof( buf), size)) {
if ( bix == pwr_eBix_rt || bix == pwr_eBix_sys)
memcpy( (char *)((unsigned int) object->rbody + offset),
buf, size);
else if ( bix == pwr_eBix_dev)
memcpy( (char *)((unsigned int) object->dbody + offset),
buf, size);
}
else {
// Attr conversion exception
m_vrep->error( "Unable to convert string to value", getFileName(), line_number);
}
error_continue:
break;
}
case tokens.BUFFER:
{
buildBuff( object, bix, 0, 0, 0);
break;
}
default:
;
}
......@@ -836,8 +835,8 @@ void wb_wblnode::buildAttr( ref_wblnode object, int bix)
next_sibling->buildAttr( object, bix);
}
void wb_wblnode::buildBuff( ref_wblnode object, int bix, pwr_tCid buffer_cid,
int buffer_offset, int buffer_size)
void wb_wblnode::buildBuff( ref_wblnode object, pwr_eBix bix, pwr_tCid buffer_cid,
int buffer_offset, int buffer_size)
{
ref_wblnode first_child;
int size, offset, elements;
......@@ -894,15 +893,16 @@ void wb_wblnode::buildBuff( ref_wblnode object, int bix, pwr_tCid buffer_cid,
first_child->buildBuffAttr( object, bix, cid, offset, size);
}
void wb_wblnode::buildBuffAttr( ref_wblnode object, int bix, pwr_tCid buffer_cid,
int buffer_offset, int buffer_size)
void wb_wblnode::buildBuffAttr( ref_wblnode object, pwr_eBix bix, pwr_tCid buffer_cid,
size_t buffer_offset, size_t buffer_size)
{
ref_wblnode first_child;
ref_wblnode second_child;
ref_wblnode next_sibling;
int oper;
char value[2048];
int size, offset, elements;
size_t size, offset;
int elements;
pwr_tTypeId tid;
pwr_eType type;
char buf[2048];
......@@ -913,136 +913,136 @@ void wb_wblnode::buildBuffAttr( ref_wblnode object, int bix, pwr_tCid buffer_cid
switch ( getType()) {
case tokens.ATTRIBUTE:
{
first_child = getFirstChild();
if ( !first_child) {
// Attr exception
m_vrep->error( "Attribute syntax", getFileName(), line_number);
goto error_continue;
}
switch ( oper = first_child->getType()) {
case tokens.OREQ:
case tokens.EQ:
break;
default:
// Attr exception
m_vrep->error( "Attribute value required", getFileName(), line_number);
goto error_continue;
}
{
first_child = getFirstChild();
if ( !first_child) {
// Attr exception
m_vrep->error( "Attribute syntax", getFileName(), line_number);
goto error_continue;
}
pwr_tStatus sts;
cdrep = m_vrep->merep()->cdrep( &sts, buffer_cid);
if ( EVEN(sts)) {
m_vrep->error( "Error in buffer class", getFileName(), line_number);
goto error_continue;
}
switch ( oper = first_child->getType()) {
case tokens.OREQ:
case tokens.EQ:
break;
default:
// Attr exception
m_vrep->error( "Attribute value required", getFileName(), line_number);
goto error_continue;
}
aname = wb_attrname( name());
pwr_tStatus sts;
cdrep = m_vrep->merep()->cdrep( &sts, buffer_cid);
if ( EVEN(sts)) {
m_vrep->error( "Error in buffer class", getFileName(), line_number);
goto error_continue;
}
// Backward compability with V3.4 : classid was named class
// This section can be removed in later versions
if ( strcmp( name(), "class") == 0 &&
(strcmp( cdrep->name(), "$PlcProgram") == 0 ||
strcmp( cdrep->name(), "$PlcWindow") == 0 ||
strcmp( cdrep->name(), "$PlcNode") == 0 ||
strcmp( cdrep->name(), "$PlcConnection") == 0))
adrep = cdrep->adrep( &sts, "classid");
else
aname = wb_attrname( name());
// Backward compability with V3.4 : classid was named class
// This section can be removed in later versions
if ( strcmp( name(), "class") == 0 &&
(strcmp( cdrep->name(), "$PlcProgram") == 0 ||
strcmp( cdrep->name(), "$PlcWindow") == 0 ||
strcmp( cdrep->name(), "$PlcNode") == 0 ||
strcmp( cdrep->name(), "$PlcConnection") == 0))
adrep = cdrep->adrep( &sts, "classid");
else
// end of compability section
adrep = cdrep->adrep( &sts, aname.attribute());
if ( EVEN(sts)) {
m_vrep->error( "Unknown buffer attribute", getFileName(), line_number);
delete cdrep;
goto error_continue;
}
size = adrep->size();
offset = adrep->offset() + buffer_offset;
tid = adrep->tid();
elements = adrep->nElement();
type = adrep->type();
if ( aname.hasAttrIndex()) {
int index = aname.attrIndex();
if ( index >= elements) {
m_vrep->error( "Max attribute index exceeded", getFileName(), line_number);
goto error_continue;
}
offset += index * size / elements;
}
adrep = cdrep->adrep( &sts, aname.attribute());
if ( EVEN(sts)) {
m_vrep->error( "Unknown buffer attribute", getFileName(), line_number);
delete cdrep;
delete adrep;
goto error_continue;
}
second_child = first_child->getNextSibling();
if ( !second_child) {
// Attr exception
m_vrep->error( "Attribute value required", getFileName(), line_number);
goto error_continue;
size = adrep->size();
offset = adrep->offset() + buffer_offset;
tid = adrep->tid();
elements = adrep->nElement();
type = adrep->type();
if ( aname.hasAttrIndex()) {
int index = aname.attrIndex();
if ( index >= elements) {
m_vrep->error( "Max attribute index exceeded", getFileName(), line_number);
goto error_continue;
}
offset += index * size / elements;
}
delete cdrep;
delete adrep;
if ( ((bix == pwr_eBix_rt || bix == pwr_eBix_sys) &&
object->rbody_size == 0) ||
(bix == pwr_eBix_dev && object->dbody_size == 0)) {
m_vrep->error( "Attribute body", getFileName(), line_number);
return;
}
second_child = first_child->getNextSibling();
if ( !second_child) {
// Attr exception
m_vrep->error( "Attribute value required", getFileName(), line_number);
goto error_continue;
}
if ( ((bix == pwr_eBix_rt || bix == pwr_eBix_sys) &&
offset + size/elements > object->rbody_size) ||
( bix == pwr_eBix_rt &&
offset + size/elements > object->rbody_size)) {
m_vrep->error( "Mismatch in attribute offset", getFileName(), line_number);
return;
}
if ( ((bix == pwr_eBix_rt || bix == pwr_eBix_sys) &&
object->rbody_size == 0) ||
(bix == pwr_eBix_dev && object->dbody_size == 0)) {
m_vrep->error( "Attribute body", getFileName(), line_number);
return;
}
strcpy( value, second_child->name());
// 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 == pwr_eBix_rt || bix == pwr_eBix_sys)
memcpy( (char *)((unsigned int) object->rbody + offset),
&int_val, size/elements);
else if ( bix == pwr_eBix_dev)
memcpy( (char *)((unsigned int) object->dbody + offset),
&int_val, size/elements);
}
else if ( oper == tokens.OREQ) {
if ( bix == pwr_eBix_rt || bix == pwr_eBix_sys) {
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 == pwr_eBix_dev) {
current_int_val = *(int *) ((unsigned int) object->dbody + offset);
int_val |= current_int_val;
memcpy( (char *)((unsigned int) object->dbody + offset),
&int_val, size/elements);
}
}
}
else if ( attrStringToValue( type, value, buf, sizeof( buf), size)) {
if ( bix == pwr_eBix_rt || bix == pwr_eBix_sys)
memcpy( (char *)((unsigned int) object->rbody + offset),
buf, size/elements);
else if ( bix == pwr_eBix_dev)
memcpy( (char *)((unsigned int) object->dbody + offset),
buf, size/elements);
if ( ((bix == pwr_eBix_rt || bix == pwr_eBix_sys) &&
offset + size/elements > object->rbody_size) ||
( bix == pwr_eBix_rt &&
offset + size/elements > object->rbody_size)) {
m_vrep->error( "Mismatch in attribute offset", getFileName(), line_number);
return;
}
strcpy( value, second_child->name());
// 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 == pwr_eBix_rt || bix == pwr_eBix_sys)
memcpy( (char *)((unsigned int) object->rbody + offset),
&int_val, size/elements);
else if ( bix == pwr_eBix_dev)
memcpy( (char *)((unsigned int) object->dbody + offset),
&int_val, size/elements);
}
else {
// Attr conversion exception
m_vrep->error( "Unable to convert string to value", getFileName(), line_number);
else if ( oper == tokens.OREQ) {
if ( bix == pwr_eBix_rt || bix == pwr_eBix_sys) {
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 == pwr_eBix_dev) {
current_int_val = *(int *) ((unsigned int) object->dbody + offset);
int_val |= current_int_val;
memcpy( (char *)((unsigned int) object->dbody + offset),
&int_val, size/elements);
}
}
error_continue:
break;
}
case tokens.BUFFER:
{
buildBuff( object, bix, buffer_cid, buffer_offset, buffer_size);
break;
else if ( attrStringToValue( type, value, buf, sizeof( buf), size)) {
if ( bix == pwr_eBix_rt || bix == pwr_eBix_sys)
memcpy( (char *)((unsigned int) object->rbody + offset),
buf, size/elements);
else if ( bix == pwr_eBix_dev)
memcpy( (char *)((unsigned int) object->dbody + offset),
buf, size/elements);
}
else {
// Attr conversion exception
m_vrep->error( "Unable to convert string to value", getFileName(), line_number);
}
error_continue:
break;
}
case tokens.BUFFER:
{
buildBuff( object, bix, buffer_cid, buffer_offset, buffer_size);
break;
}
default:
;
}
......@@ -1057,55 +1057,55 @@ void wb_wblnode::link( wb_vrepwbl *vol, ref_wblnode father)
ref_wblnode next_sibling;
switch ( getType()) {
case tokens.OBJECT:
case tokens.VOLUME:
if ( !father) {
// Volume root
vol->root_object = this;
}
o_fth = father;
if ( o_fth) {
o_bws = o_fth->get_o_lch();
if ( o_bws)
o_bws->o_fws = this;
else
o_fth->o_fch = this;
}
first_child = getFirstChild();
if ( first_child)
first_child->link( vol, this);
case tokens.OBJECT:
case tokens.VOLUME:
if ( !father) {
// Volume root
vol->root_object = this;
}
o_fth = father;
if ( o_fth) {
o_bws = o_fth->get_o_lch();
if ( o_bws)
o_bws->o_fws = this;
else
o_fth->o_fch = this;
}
first_child = getFirstChild();
if ( first_child)
first_child->link( vol, this);
next_sibling = getNextSibling();
if ( next_sibling)
next_sibling->link( vol, father);
next_sibling = getNextSibling();
if ( next_sibling)
next_sibling->link( vol, father);
// cout << "Linking " << name << endl;
break;
case tokens.SOBJECT:
{
ref_wblnode snode = m_vrep->find( name());
if ( !snode) {
// SObject exception
m_vrep->error( "SObject syntax", getFileName(), line_number);
}
// cout << "Linking " << name << endl;
break;
case tokens.SOBJECT:
{
ref_wblnode snode = m_vrep->find( name());
if ( !snode) {
// SObject exception
m_vrep->error( "SObject syntax", getFileName(), line_number);
}
first_child = getFirstChild();
if ( first_child)
first_child->link( vol, snode);
first_child = getFirstChild();
if ( first_child)
first_child->link( vol, snode);
next_sibling = getNextSibling();
if ( next_sibling)
next_sibling->link( vol, father);
break;
}
default:
first_child = getFirstChild();
if ( first_child)
first_child->link( vol, father);
next_sibling = getNextSibling();
if ( next_sibling)
next_sibling->link( vol, father);
break;
}
default:
first_child = getFirstChild();
if ( first_child)
first_child->link( vol, father);
next_sibling = getNextSibling();
if ( next_sibling)
next_sibling->link( vol, father);
next_sibling = getNextSibling();
if ( next_sibling)
next_sibling->link( vol, father);
}
}
......@@ -1115,254 +1115,254 @@ void wb_wblnode::registerNode( wb_vrepwbl *vol)
m_vrep = vol;
switch ( getType()) {
case tokens.OBJECT:
{
if ( !wb_name::checkObjectName( name())) {
m_vrep->error( "Bad object name", getFileName(), line_number);
}
case tokens.OBJECT:
{
if ( !wb_name::checkObjectName( name())) {
m_vrep->error( "Bad object name", getFileName(), line_number);
}
// Get class
if ( first_child) {
string class_name = first_child->getText();
strcpy( cname, class_name.c_str());
// Get class
if ( first_child) {
string class_name = first_child->getText();
strcpy( cname, class_name.c_str());
if ( !classNameToCid( cname, &m_cid)) {
m_vrep->error( "Unknown class", getFileName(), line_number);
}
if ( !classNameToCid( cname, &m_cid)) {
m_vrep->error( "Unknown class", getFileName(), line_number);
}
// If $ClassDef, register class in classlist
if ( !isTemplate()) {
if ( first_child->getType() == tokens.VALUE &&
// If $ClassDef, register class in classlist
if ( !isTemplate()) {
if ( first_child->getType() == tokens.VALUE &&
(strcmp( cname, "$ClassDef") == 0 ||
strcmp( cname, "pwr_eClass_ClassDef") == 0)) {
node_type = wbl_eNodeType_ClassDef;
}
else if ( first_child->getType() == tokens.VALUE &&
( strcmp( cname, "$Type") == 0 ||
strcmp( cname, "pwr_eClass_Type") == 0)) {
node_type = wbl_eNodeType_Type;
}
else if ( first_child->getType() == tokens.VALUE &&
( strcmp( cname, "$TypeDef") == 0 ||
strcmp( cname, "pwr_eClass_TypeDef") == 0)) {
node_type = wbl_eNodeType_TypeDef;
}
else if ( first_child->getType() == tokens.VALUE &&
( strcmp( cname, "$ObjBodyDef") == 0 ||
strcmp( cname, "pwr_eClass_ObjBodyDef") == 0)) {
node_type = wbl_eNodeType_ObjBodyDef;
}
else if ( first_child->getType() == tokens.VALUE &&
( strcmp( cname, "$Attribute") == 0 ||
strcmp( cname, "$Input") == 0 ||
strcmp( cname, "$Output") == 0 ||
strcmp( cname, "$Intern") == 0 ||
strcmp( cname, "$ObjXRef") == 0 ||
strcmp( cname, "$AttrXRef") == 0 ||
strcmp( cname, "pwr_eClass_Param") == 0)) {
node_type = wbl_eNodeType_Attribute;
}
else if ( first_child->getType() == tokens.VALUE &&
( strcmp( cname, "$Buffer") == 0)) {
node_type = wbl_eNodeType_Buffer;
}
else if ( first_child->getType() == tokens.VALUE &&
( strcmp( cname, "$Param") == 0)) {
m_vrep->error( "Obsolete attribute class, use $Attribute instead",
getFileName(), line_number);
}
}
// Get oix
ref_wblnode second_child = first_child->getNextSibling();
if ( second_child) {
switch ( second_child->getType()) {
case tokens.VALUE:
case tokens.INT:
{
string oixstr = second_child->getText();
if ( !stringToOix( oixstr.c_str(), &m_oid.oix)) {
m_oid.oix = m_vrep->nextOix();
}
break;
}
case tokens.ENDOBJECT:
case tokens.OBJECT:
case tokens.BODY:
m_oid.oix = m_vrep->nextOix();
break;
default:
; // Syntax exception -- oix
m_vrep->error( "Syntax", getFileName(), line_number);
}
strcmp( cname, "pwr_eClass_ClassDef") == 0)) {
node_type = wbl_eNodeType_ClassDef;
}
else {
if ( isClassDef() || isType() || isTypeDef() || isObjBodyDef()) {
// Syntax exception -- no cix or tix
m_vrep->error( "Missing index", getFileName(), line_number);
}
else {
if ( !isTemplate())
m_oid.oix = m_vrep->nextOix();
}
else if ( first_child->getType() == tokens.VALUE &&
( strcmp( cname, "$Type") == 0 ||
strcmp( cname, "pwr_eClass_Type") == 0)) {
node_type = wbl_eNodeType_Type;
}
else if ( first_child->getType() == tokens.VALUE &&
( strcmp( cname, "$TypeDef") == 0 ||
strcmp( cname, "pwr_eClass_TypeDef") == 0)) {
node_type = wbl_eNodeType_TypeDef;
}
else if ( first_child->getType() == tokens.VALUE &&
( strcmp( cname, "$ObjBodyDef") == 0 ||
strcmp( cname, "pwr_eClass_ObjBodyDef") == 0)) {
node_type = wbl_eNodeType_ObjBodyDef;
}
else if ( first_child->getType() == tokens.VALUE &&
( strcmp( cname, "$Attribute") == 0 ||
strcmp( cname, "$Input") == 0 ||
strcmp( cname, "$Output") == 0 ||
strcmp( cname, "$Intern") == 0 ||
strcmp( cname, "$ObjXRef") == 0 ||
strcmp( cname, "$AttrXRef") == 0 ||
strcmp( cname, "pwr_eClass_Param") == 0)) {
node_type = wbl_eNodeType_Attribute;
}
else if ( first_child->getType() == tokens.VALUE &&
( strcmp( cname, "$Buffer") == 0)) {
node_type = wbl_eNodeType_Buffer;
}
else if ( first_child->getType() == tokens.VALUE &&
( strcmp( cname, "$Param") == 0)) {
m_vrep->error( "Obsolete attribute class, use $Attribute instead",
getFileName(), line_number);
}
}
else if ( isTemplate() && strcmp( cname, "") != 0) {
// Created template object
// Get oix
ref_wblnode second_child = first_child->getNextSibling();
if ( second_child) {
switch ( second_child->getType()) {
case tokens.VALUE:
case tokens.INT:
{
string oixstr = second_child->getText();
if ( !stringToOix( oixstr.c_str(), &m_oid.oix)) {
m_oid.oix = m_vrep->nextOix();
}
break;
}
case tokens.ENDOBJECT:
case tokens.OBJECT:
case tokens.BODY:
m_oid.oix = m_vrep->nextOix();
break;
default:
; // Syntax exception -- oix
m_vrep->error( "Syntax", getFileName(), line_number);
}
}
else {
// Syntax exception -- No class
m_vrep->error( "Missing class", getFileName(), line_number);
if ( isClassDef() || isType() || isTypeDef() || isObjBodyDef()) {
// Syntax exception -- no cix or tix
m_vrep->error( "Missing index", getFileName(), line_number);
}
else {
if ( !isTemplate())
m_oid.oix = m_vrep->nextOix();
}
}
}
else if ( isTemplate() && strcmp( cname, "") != 0) {
// Created template object
}
else {
// Syntax exception -- No class
m_vrep->error( "Missing class", getFileName(), line_number);
}
if ( isClassDef()) {
c_cid = cdh_cixToCid( m_vrep->vid(), m_oid.oix);
c_cix = m_oid.oix;
m_vrep->registerClass( name(), c_cid, this);
// Find Template object
ref_wblnode child = first_child;
ref_wblnode last_child = child;
string childname;
while ( child) {
if ( child->getType() == tokens.OBJECT) {
childname = child->getText();
if ( strcmp( childname.c_str(), "Template") == 0) {
c_template = child;
c_template->node_type = wbl_eNodeType_Template;
break;
}
}
last_child = child;
child = child->getNextSibling();
}
if ( !c_template) {
// Create a template node
c_template = new wb_wblnode();
c_template->setType( tokens.OBJECT);
string tname("Template");
c_template->setText( tname);
if ( last_child)
last_child->setNextSibling( (RefAST)c_template);
else
setFirstChild( (RefAST)c_template);
strcpy( c_template->cname, name());
// c_template->m_oid.oix = m_vrep->nextOix();
c_template->m_cid = c_cid;
c_template->node_type = wbl_eNodeType_Template;
if ( isClassDef()) {
c_cid = cdh_cixToCid( m_vrep->vid(), m_oid.oix);
c_cix = m_oid.oix;
m_vrep->registerClass( name(), c_cid, this);
// Find Template object
ref_wblnode child = first_child;
ref_wblnode last_child = child;
string childname;
while ( child) {
if ( child->getType() == tokens.OBJECT) {
childname = child->getText();
if ( strcmp( childname.c_str(), "Template") == 0) {
c_template = child;
c_template->node_type = wbl_eNodeType_Template;
break;
}
}
last_child = child;
child = child->getNextSibling();
}
else if ( isType()) {
m_tid = cdh_tixToTid( m_vrep->vid(), 0, m_oid.oix);
m_vrep->registerType( name(), m_tid, this);
}
else if ( isTypeDef()) {
m_tid = cdh_tixToTid( m_vrep->vid(), 1, m_oid.oix);
m_vrep->registerType( name(), m_tid, this);
}
else if ( isObjBodyDef()) {
b_bix = m_oid.oix;
if ( !(b_bix == pwr_eBix_rt || b_bix == pwr_eBix_sys || b_bix == pwr_eBix_dev))
m_vrep->error( "Bad body index", getFileName(), line_number);
if ( !c_template) {
// Create a template node
c_template = new wb_wblnode();
c_template->setType( tokens.OBJECT);
string tname("Template");
c_template->setText( tname);
if ( last_child)
last_child->setNextSibling( (RefAST)c_template);
else
setFirstChild( (RefAST)c_template);
strcpy( c_template->cname, name());
// c_template->m_oid.oix = m_vrep->nextOix();
c_template->m_cid = c_cid;
c_template->node_type = wbl_eNodeType_Template;
}
break;
}
case tokens.VOLUME:
{
pwr_tVid vid;
int sts;
else if ( isType()) {
m_tid = cdh_tixToTid( m_vrep->vid(), 0, m_oid.oix);
m_vrep->registerType( name(), m_tid, this);
}
else if ( isTypeDef()) {
m_tid = cdh_tixToTid( m_vrep->vid(), 1, m_oid.oix);
m_vrep->registerType( name(), m_tid, this);
}
else if ( isObjBodyDef()) {
b_bix = (pwr_eBix)m_oid.oix;
if ( !(b_bix == pwr_eBix_rt || b_bix == pwr_eBix_sys || b_bix == pwr_eBix_dev))
m_vrep->error( "Bad body index", getFileName(), line_number);
}
break;
}
case tokens.VOLUME:
{
pwr_tVid vid;
int sts;
// Get class
if ( first_child) {
string class_name = first_child->getText();
strcpy( cname, class_name.c_str());
// Get class
if ( first_child) {
string class_name = first_child->getText();
strcpy( cname, class_name.c_str());
if ( !classNameToCid( cname, &m_cid)) {
// Syntax exception -- vid
m_vrep->error( "Unkowon class", getFileName(), line_number);
}
if ( !classNameToCid( cname, &m_cid)) {
// Syntax exception -- vid
m_vrep->error( "Unkowon class", getFileName(), line_number);
}
// Get oid
ref_wblnode second_child = first_child->getNextSibling();
if ( second_child) {
switch ( second_child->getType()) {
case tokens.OID:
{
string vidstring = second_child->getText();
sts = cdh_StringToVolumeId( (char *)vidstring.c_str(), &vid);
if ( EVEN(sts)) {
// Syntax exception -- vid
m_vrep->error( "Volume id syntax", getFileName(), line_number);
}
break;
}
default:
// Syntax exception -- vid
m_vrep->error( "Volume syntax", getFileName(), line_number);
// Get oid
ref_wblnode second_child = first_child->getNextSibling();
if ( second_child) {
switch ( second_child->getType()) {
case tokens.OID:
{
string vidstring = second_child->getText();
sts = cdh_StringToVolumeId( (char *)vidstring.c_str(), &vid);
if ( EVEN(sts)) {
// Syntax exception -- vid
m_vrep->error( "Volume id syntax", getFileName(), line_number);
}
break;
}
default:
// Syntax exception -- vid
m_vrep->error( "Volume syntax", getFileName(), line_number);
}
else {
// Syntax exception -- no cix
m_vrep->error( "Volume id is missing", getFileName(), line_number);
}
node_type = wbl_eNodeType_Volume;
}
else {
// Syntax exception -- No class
m_vrep->error( "Volume class is missing", getFileName(), line_number);
}
// Register volume
m_vrep->registerVolume( name(), m_cid, vid, this);
break;
}
case tokens.ATTRIBUTE:
case tokens.SOBJECT:
case tokens.BODY:
case tokens.VALUE:
case tokens.INT:
case tokens.NUM_FLOAT:
{
break;
}
case tokens.CHAR_LITERAL:
{
// Remove quotes
char str[10];
string text = getText();
const char *text_p = text.c_str();
strncpy( str, &text_p[1], sizeof(str));
str[strlen(str)-1] = 0;
string new_text(str);
setText(new_text);
break;
// Syntax exception -- no cix
m_vrep->error( "Volume id is missing", getFileName(), line_number);
}
node_type = wbl_eNodeType_Volume;
}
case tokens.STRING_LITERAL:
{
// Remove quotes and replace \" with "
char str[2048];
const char *s;
char *t;
bool first = true;
t = str;
for ( s = getText().c_str(); *s; s++) {
if ( first) {
first = false;
continue;
}
if ( *s == '"' && *(s-1) == '\\')
t--;
*t = *s;
t++;
else {
// Syntax exception -- No class
m_vrep->error( "Volume class is missing", getFileName(), line_number);
}
// Register volume
m_vrep->registerVolume( name(), m_cid, vid, this);
break;
}
case tokens.ATTRIBUTE:
case tokens.SOBJECT:
case tokens.BODY:
case tokens.VALUE:
case tokens.INT:
case tokens.NUM_FLOAT:
{
break;
}
case tokens.CHAR_LITERAL:
{
// Remove quotes
char str[10];
string text = getText();
const char *text_p = text.c_str();
strncpy( str, &text_p[1], sizeof(str));
str[strlen(str)-1] = 0;
string new_text(str);
setText(new_text);
break;
}
case tokens.STRING_LITERAL:
{
// Remove quotes and replace \" with "
char str[2048];
const char *s;
char *t;
bool first = true;
t = str;
for ( s = getText().c_str(); *s; s++) {
if ( first) {
first = false;
continue;
}
t--;
*t = 0;
string new_text(str);
setText(new_text);
break;
if ( *s == '"' && *(s-1) == '\\')
t--;
*t = *s;
t++;
}
default:
;
t--;
*t = 0;
string new_text(str);
setText(new_text);
break;
}
default:
;
}
if ( first_child)
......@@ -1386,8 +1386,8 @@ void wb_wblnode::iterObject( wb_dbs *dbs)
wb_name n = wb_name(name());
dbs->installObject( m_oid, m_cid, fthoid, fwsoid, bwsoid, fchoid, lchoid,
(char *)name(), n.normName(cdh_mName_object),
getFileTime(), getFileTime(), getFileTime(), rbody_size, dbody_size);
(char *)name(), n.normName(cdh_mName_object),
getFileTime(), getFileTime(), getFileTime(), rbody_size, dbody_size);
if ( o_fch)
o_fch->iterObject( dbs);
......@@ -1427,10 +1427,10 @@ bool wb_wblnode::exportHead(wb_import &i)
pwr_tOid bwsoid = o_bws ? o_bws->m_oid : pwr_cNOid;
pwr_tOid fchoid = o_fch ? o_fch->m_oid : pwr_cNOid;
pwr_tOid lchoid = o_lch ? o_lch->m_oid : pwr_cNOid;
wb_name n = wb_name(name);
wb_name n = wb_name(name());
i.importHead( m_oid, m_cid, fthoid, fwsoid, bwsoid, fchoid, lchoid, name, n.normName(cdh_mName_object),
getFileTime(), getFileTime(), getFileTime(), rbody_size, dbody_size);
i.importHead( m_oid, m_cid, fthoid, fwsoid, bwsoid, fchoid, lchoid, name(), n.normName(cdh_mName_object),
getFileTime(), getFileTime(), getFileTime(), rbody_size, dbody_size);
if ( o_fch)
o_fch->exportHead( i);
......@@ -1482,12 +1482,12 @@ void wb_wblnode::setFile( wb_wblfile *f)
int wb_wblnode::attrStringToValue( int type_id, char *value_str,
void *buffer_ptr, int buff_size, int attr_size)
void *buffer_ptr, size_t buff_size, size_t attr_size)
{
int sts;
switch ( type_id )
{
{
case pwr_eType_Boolean:
{
if ( sscanf( value_str, "%d", (pwr_tBoolean *)buffer_ptr) != 1)
......@@ -1568,7 +1568,7 @@ int wb_wblnode::attrStringToValue( int type_id, char *value_str,
case pwr_eType_Text:
case pwr_eType_String:
{
if ( (int) strlen( value_str) >= attr_size)
if ( strlen( value_str) >= attr_size)
return 0;
strncpy( (char *)buffer_ptr, value_str, min(attr_size, buff_size));
break;
......@@ -1597,11 +1597,12 @@ int wb_wblnode::attrStringToValue( int type_id, char *value_str,
{
pwr_tTypeId val_typeid;
pwr_eType type;
int size, elements;
size_t size;
int elements;
// sts = m_vrep->nameToOid( value_str, &objid);
if ( m_vrep->getTypeInfo( value_str, &val_typeid, &type,
&size, &elements))
&size, &elements))
memcpy( buffer_ptr, (char *) &val_typeid, sizeof(val_typeid));
else
return 0;
......@@ -1613,7 +1614,7 @@ int wb_wblnode::attrStringToValue( int type_id, char *value_str,
sts = cdh_StringToObjectIx( value_str, &objectix);
if (EVEN(sts)) return 0;
memcpy( buffer_ptr, (char *) &objectix, sizeof(objectix));
memcpy( buffer_ptr, (char *) &objectix, sizeof(objectix));
break;
}
case pwr_eType_VolumeId:
......@@ -1622,7 +1623,7 @@ int wb_wblnode::attrStringToValue( int type_id, char *value_str,
sts = cdh_StringToVolumeId( value_str, &volumeid);
if (EVEN(sts)) return 0;
memcpy( buffer_ptr, (char *) &volumeid, sizeof(volumeid));
memcpy( buffer_ptr, (char *) &volumeid, sizeof(volumeid));
break;
}
case pwr_eType_RefId:
......@@ -1631,7 +1632,7 @@ int wb_wblnode::attrStringToValue( int type_id, char *value_str,
sts = cdh_StringToSubid( value_str, &subid);
if (EVEN(sts)) return 0;
memcpy( buffer_ptr, (char *) &subid, sizeof(subid));
memcpy( buffer_ptr, (char *) &subid, sizeof(subid));
break;
}
case pwr_eType_AttrRef:
......@@ -1650,7 +1651,7 @@ int wb_wblnode::attrStringToValue( int type_id, char *value_str,
sts = time_AsciiToA( value_str, &time);
if (EVEN(sts)) return 0;
memcpy( buffer_ptr, (char *) &time, sizeof(time));
memcpy( buffer_ptr, (char *) &time, sizeof(time));
break;
}
case pwr_eType_DeltaTime:
......@@ -1659,18 +1660,11 @@ int wb_wblnode::attrStringToValue( int type_id, char *value_str,
sts = time_AsciiToD( value_str, &deltatime);
if (EVEN(sts)) return 0;
memcpy( buffer_ptr, (char *) &deltatime, sizeof(deltatime));
memcpy( buffer_ptr, (char *) &deltatime, sizeof(deltatime));
break;
}
default:
return 0;
}
}
return 1;
}
......@@ -48,7 +48,7 @@ public:
rbody_size(0), dbody_size(0), rbody(0), dbody(0), m_cid(0),
m_tid(0), m_oid(pwr_cNOid), m_vrep(0), o_fth(0), o_bws(0), o_fws(0), o_fch(0),
line_number(0), file(0), is_built(0), c_cid(0), c_cix(0), c_template(0),
b_bix(0), a_tid(0), a_size(0), a_offset(0), a_elements(0), a_flags(0)
b_bix(pwr_eBix__), a_tid(0), a_size(0), a_offset(0), a_elements(0), a_flags(0)
{
strcpy( cname, "");
}
......@@ -57,7 +57,7 @@ public:
rbody_size(0), dbody_size(0), rbody(0), dbody(0), m_cid(0),
m_tid(0), m_oid(pwr_cNOid), m_vrep(0), o_fth(0), o_bws(0), o_fws(0), o_fch(0),
line_number(0), file(0), is_built(0), c_cid(0), c_cix(0), c_template(0),
b_bix(0), a_tid(0), a_size(0), a_offset(0), a_elements(0), a_flags(0)
b_bix(pwr_eBix__), a_tid(0), a_size(0), a_offset(0), a_elements(0), a_flags(0)
{
CommonAST::setType(t->getType());
CommonAST::setText(t->getText());
......@@ -165,16 +165,16 @@ public:
void build( bool recursive);
void buildObjBodyDef( ref_wblnode classdef);
void buildAttribute( ref_wblnode classdef, ref_wblnode objbodydef,
int *bindex, int *boffset);
int *bindex, size_t *boffset);
void buildBuffer( ref_wblnode classdef, ref_wblnode objbodydef,
int *bindex, int *boffset);
int *bindex, size_t *boffset);
void buildTemplate( ref_wblnode classdef);
void buildBody( ref_wblnode object);
void buildAttr( ref_wblnode object, int bix);
void buildBuff( ref_wblnode object, int bix, pwr_tCid buffer_cid,
void buildAttr( ref_wblnode object, pwr_eBix bix);
void buildBuff( ref_wblnode object, pwr_eBix bix, pwr_tCid buffer_cid,
int buffer_offset, int buffer_size);
void buildBuffAttr( ref_wblnode object, int bix, pwr_tCid buffer_cid,
int buffer_offset, int buffer_size);
void buildBuffAttr( ref_wblnode object, pwr_eBix bix, pwr_tCid buffer_cid,
size_t buffer_offset, size_t buffer_size);
void link( wb_vrepwbl *vol, ref_wblnode father_node);
void info_link( int level);
ref_wblnode find( wb_name *oname, int level);
......@@ -183,16 +183,17 @@ public:
int stringToOix( const char *buf, pwr_tOix *oix) const;
pwr_tCid Cid() { return c_cid;}
int attrStringToValue( int type_id, char *value_str,
void *buffer_ptr, int buff_size, int attr_size);
void *buffer_ptr, size_t buff_size, size_t attr_size);
bool exportHead(wb_import &i);
bool exportDbody(wb_import &i);
bool exportRbody(wb_import &i);
#if 0
void iterObject(wb_dbs *);
void iterRbody(wb_dbs *);
void iterDbody(wb_dbs *);
#if 0
void iterObject( void *udata,
pwr_tStatus (*bc)(void *, pwr_tOid, pwr_tCid, pwr_tOid, pwr_tOid,
pwr_tOid, pwr_tOid, pwr_tOid, char *,
......@@ -206,8 +207,8 @@ public:
wbl_eNodeType node_type;
int rbody_size;
int dbody_size;
size_t rbody_size;
size_t dbody_size;
void *rbody;
void *dbody;
pwr_tCid m_cid;
......@@ -233,16 +234,16 @@ public:
pwr_tTid ty_tid;
pwr_eType ty_type;
int ty_elements;
int ty_size;
size_t ty_size;
// ObjBodyDef stuff
int b_bix;
int b_size;
pwr_eBix b_bix;
size_t b_size;
// Attribute stuff
pwr_tTid a_tid;
int a_size;
int a_offset;
size_t a_size;
size_t a_offset;
int a_elements;
int a_flags;
int a_index;
......
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