Commit 39d185b2 authored by claes's avatar claes

*** empty log message ***

parent 8250da92
......@@ -131,8 +131,8 @@ wb_name wb_adef::longName()
return m_adrep->longName();
}
void wb_adef::body( void **p)
void *wb_adef::body( void *p)
{
check();
m_adrep->body( p);
return m_adrep->body( p);
}
......@@ -49,7 +49,7 @@ public:
char *name();
wb_name longName();
void body( void **p);
void *body( void *p = 0);
private:
void check();
......
......@@ -222,7 +222,7 @@ wb_name wb_adrep::longName()
return m_orep->longName();
}
void wb_adrep::body( void **p)
void *wb_adrep::body( void *p)
{
pwr_tStatus sts;
int size;
......@@ -249,7 +249,5 @@ void wb_adrep::body( void **p)
throw wb_error(LDH__NYI);
}
*p = calloc( 1, size);
m_orep->m_vrep->readBody( &sts, m_orep, cdh_eBix_sys, *p);
if ( EVEN(sts)) throw wb_error(sts);
return m_orep->m_vrep->readBody( &sts, m_orep, cdh_eBix_sys, p);
}
......@@ -54,7 +54,7 @@ class wb_adrep
char *name();
wb_name longName();
void body( void **p);
void *body( void *p = 0);
wb_vrep *vrep() const;
};
......
#include "wb_attribute.h"
#include "wb_cdrep.h"
#include "wb_merep.h"
#include "wb_attrname.h"
#include "pwr.h"
wb_attribute::wb_attribute() : wb_status(LDH__NOSUCHATTR), m_orep(0), m_adrep(0)
wb_attribute::wb_attribute() : wb_status(LDH__NOSUCHATTR), m_orep(0), m_adrep(0),
m_size(0), m_offset(0), m_tid(0), m_elements(0),
m_type(pwr_eType_), m_flags(0)
{
}
wb_attribute::wb_attribute(const wb_attribute& x) : wb_status(x.m_sts),m_orep(x.m_orep),
m_adrep(x.m_adrep)
wb_attribute::wb_attribute(const wb_attribute& x) :
wb_status(x.m_sts),m_orep(x.m_orep), m_adrep( x.m_adrep), m_size(x.m_size),
m_offset(x.m_offset), m_tid(x.m_tid), m_elements(x.m_elements), m_type(x.m_type),
m_flags(x.m_flags)
{
if ( m_orep)
m_orep->ref();
......@@ -16,52 +22,118 @@ wb_attribute::wb_attribute(const wb_attribute& x) : wb_status(x.m_sts),m_orep(x.
m_adrep->ref();
}
wb_attribute::wb_attribute(pwr_tStatus sts, wb_orep * const orep) : wb_status(sts),
m_orep(orep), m_adrep(0)
wb_attribute::wb_attribute(pwr_tStatus sts, wb_orep * const orep) :
wb_status(sts), m_orep(orep), m_adrep(0), m_size(0), m_offset(0), m_tid(0),
m_elements(0), m_type(pwr_eType_), m_flags(0)
{
if ( orep == 0)
m_sts = LDH__NOSUCHATTR;
else
else {
m_orep->ref();
// m_size == get rtbody size... Fix
}
}
wb_attribute::wb_attribute(pwr_tStatus sts, wb_orep * const orep, char *name) :
wb_status(sts), m_orep(orep), m_adrep(0)
wb_attribute::wb_attribute(pwr_tStatus sts, wb_orep * const orep, wb_adrep * const adrep) :
wb_status(sts), m_orep(orep), m_adrep(adrep), m_size(0), m_offset(0), m_tid(0),
m_elements(0), m_type(pwr_eType_), m_flags(0)
{
wb_cdrep *cdrep = new wb_cdrep( *orep);
cdrep->ref();
if ( orep == 0)
m_sts = LDH__NOSUCHATTR;
else {
m_orep->ref();
m_adrep = cdrep->adrep( &m_sts, name);
if ( oddSts())
m_adrep->ref();
if ( m_adrep) {
m_adrep->ref();
m_size = m_adrep->size();
m_offset = m_adrep->offset();
m_type = m_adrep->type();
m_tid = m_adrep->tid();
m_flags = m_adrep->flags();
}
else {
// m_size == get rtbody size... Fix
}
}
}
cdrep->unref();
wb_attribute::wb_attribute(pwr_tStatus sts, wb_orep * const orep, char *aname, char *bname) :
wb_status(sts), m_orep(orep)
{
if ( orep == 0)
m_sts = LDH__NOSUCHATTR;
else {
wb_attrname n = wb_attrname(aname);
wb_bdrep *bd = 0;
wb_cdrep *cd = m_orep->vrep()->merep()->cdrep( &m_sts, m_orep->cid());
if ( oddSts()) {
if ( bname) {
bd = cd->bdrep( &m_sts, bname);
if ( oddSts())
m_adrep = bd->adrep( &m_sts, n.attribute(0));
}
else {
m_adrep = cd->adrep( &m_sts, n.attribute(0));
}
if ( oddSts()) {
m_adrep->ref();
if ( !m_orep->vrep()->merep()->getAttrInfoRec( &n, m_adrep->bix(),
m_orep->cid(), (int *) &m_size,
&m_offset, &m_tid, &m_elements,
&m_type,
&m_flags, 0)) {
m_adrep->unref();
m_sts = LDH__NOSUCHATTR;
}
}
delete cd;
if ( bd) delete bd;
}
if ( oddSts())
m_orep->ref();
}
}
wb_attribute::~wb_attribute()
{
if ( m_orep)
m_orep->unref();
if ( m_adrep)
m_adrep->unref();
}
wb_attribute& wb_attribute::operator=(const wb_attribute& x)
{
if ( x.m_orep)
x.m_orep->ref();
if ( x.m_adrep)
x.m_adrep->ref();
if ( m_orep)
m_orep->unref();
if ( x.m_adrep)
x.m_adrep->ref();
if ( m_adrep)
m_adrep->unref();
m_orep = x.m_orep;
m_adrep = x.m_adrep;
m_sts = x.m_sts;
m_size = x.m_size;
m_offset = x.m_offset;
m_tid = x.m_tid;
m_type = x.m_type;
m_flags = x.m_flags;
return *this;
}
//
// Return object identifier of attribute.
//
pwr_tOid wb_attribute::aoid()
void wb_attribute::check()
{
return m_adrep->aoid();
if ( evenSts())
throw wb_error( m_sts);
}
//
// Return object identifier of attribute.
//
pwr_sAttrRef wb_attribute::aref()
{
pwr_sAttrRef aref;
......@@ -76,85 +148,93 @@ pwr_sAttrRef *wb_attribute::aref(pwr_sAttrRef *arp)
size_t wb_attribute::size()
{
return m_adrep->size();
check();
return m_size;
}
int wb_attribute::offset()
{
return m_adrep->offset();
check();
return m_offset;
}
int wb_attribute::type()
pwr_eType wb_attribute::type()
{
return m_adrep->type();
check();
return m_type;
}
int wb_attribute::nElement()
{
return m_adrep->nElement();
check();
return m_elements;
}
int wb_attribute::index()
{
if ( m_adrep)
return m_adrep->index();
return 0;
}
int wb_attribute::flags()
{
return m_adrep->flags();
check();
return m_flags;
}
pwr_tAix wb_attribute::aix()
{
return m_adrep->aix();
return 0; // Fix
}
pwr_tCid wb_attribute::cid()
{
return m_adrep->cid();
check();
return m_orep->cid();
}
pwr_tAix wb_attribute::bix()
{
return m_adrep->bix();
return 0; // Fix
}
pwr_tOid wb_attribute::boid()
{
return m_adrep->boid();
pwr_tOid oid;
return oid; // Fix
}
bool wb_attribute::checkXref()
{
return true;
return true; // Fix
}
pwr_sAttrXRef *wb_attribute::xref()
{
return (pwr_sAttrXRef*)0;
return (pwr_sAttrXRef*)0; // Fix
}
pwr_sObjXRef *wb_attribute::oxref()
{
return (pwr_sObjXRef*)0;
return (pwr_sObjXRef*)0; // Fix
}
void *wb_attribute::value()
void *wb_attribute::value( void *p)
{
return (void*)0;
}
pwr_tStatus sts;
check();
pwr_tStatus wb_attribute::value(void *vp)
{
pwr_tStatus sts;
return sts;
if ( m_adrep == 0) {
return m_orep->vrep()->readBody( &sts, m_orep, cdh_eBix_rt, p);
}
return m_orep->vrep()->readAttribute( &sts, m_orep, (cdh_eBix) m_adrep->bix(), m_offset,
m_size, p);
}
pwr_tStatus wb_attribute::value(void *vp, size_t size)
void *wb_attribute::value(void *vp, size_t size, pwr_tStatus *sts)
{
pwr_tStatus sts;
return sts;
return 0;
}
......@@ -208,3 +288,4 @@ void wb_attribute::name(const char *name)
void wb_attribute::name(wb_name *name)
{
}
......@@ -3,7 +3,6 @@
#include "pwr.h"
#include "wb_orep.h"
#include "wb_adrep.h"
#include "wb_name.h"
#include "wb_object.h"
#include "wb_ldh.h"
......@@ -31,17 +30,24 @@ class wb_attribute : public wb_status
wb_orep *m_orep;
wb_adrep *m_adrep;
size_t m_size;
int m_offset;
pwr_tTid m_tid;
int m_elements;
pwr_eType m_type;
int m_flags;
public:
wb_attribute();
wb_attribute(const wb_attribute&); // x = other_object
wb_attribute(pwr_tStatus, wb_orep* const ); // x = other orep
wb_attribute(pwr_tStatus, wb_orep* const, char*);
wb_attribute(pwr_tStatus, wb_orep* const, wb_adrep* const) {};
wb_attribute(const wb_attribute&);
wb_attribute(pwr_tStatus, wb_orep* const );
wb_attribute(pwr_tStatus, wb_orep* const, wb_adrep* const);
wb_attribute(pwr_tStatus, wb_orep* const, char* aname, char* bname = 0);
~wb_attribute();
wb_attribute& operator=(const wb_attribute&);
operator bool() const { return (m_adrep != 0);} // Fix
operator bool() const { return evenSts();}
operator wb_orep*() const;
operator wb_adrep*() const;
bool operator==(wb_attribute&);
//wb_object& operator=(const wb_orep&);
......@@ -49,9 +55,9 @@ public:
pwr_tOid aoid(); // get objects object id
pwr_sAttrRef aref();
pwr_sAttrRef *aref(pwr_sAttrRef *arp);
size_t size(); // get objects runtime body size
size_t size();
int offset();
int type();
pwr_eType type();
int nElement();
int index();
int flags();
......@@ -64,9 +70,8 @@ public:
pwr_sAttrXRef *xref();
pwr_sObjXRef *oxref();
void *value();
pwr_tStatus value(void *vp);
pwr_tStatus value(void *vp, size_t size);
void *value( void *p = 0);
void *value(void *vp, size_t size, pwr_tStatus*);
string toString();
pwr_tStatus fromString(string);
......@@ -85,6 +90,9 @@ public:
pwr_tStatus sts() { return m_sts;}
private:
void check();
void init();
};
#endif
......@@ -921,7 +921,7 @@ static int cmd_attribute_func (
}
if ( found )
break;
XtFree((char *) bodydef);
free((char *) bodydef);
}
if ( !found)
{
......
......@@ -416,7 +416,7 @@ vldh_t_node node;
}
i++;
}
XtFree((char *) bodydef);
free((char *) bodydef);
}
/* Check the nodes connected with executer order connections */
......@@ -589,7 +589,7 @@ vldh_t_node node;
}
i++;
}
XtFree((char *) bodydef);
free((char *) bodydef);
/* Check the nodes connected with executer order connections */
......
......@@ -910,7 +910,7 @@ static pwr_tStatus gen_m4 (
if ( !found )
{
XtFree((char *) parvalue);
XtFree((char *) bodydef);
free((char *) bodydef);
return FOE__SUCCESS;
}
......@@ -919,7 +919,7 @@ static pwr_tStatus gen_m4 (
if( EVEN(sts))
{
XtFree((char *) parvalue);
XtFree((char *) bodydef);
free((char *) bodydef);
return FOE__SUCCESS;
}
XtFree((char *) parvalue);
......@@ -934,7 +934,7 @@ static pwr_tStatus gen_m4 (
fprintf( genctx->file, "/%s=%s.%s\n", (bodydef[i].ParName),
object_name, parameter);
XtFree((char *) parameter);
XtFree((char *) bodydef);
free((char *) bodydef);
return FOE__SUCCESS;
}
......@@ -1426,7 +1426,7 @@ static pwr_tStatus gen_m8 (
XtFree( parvalue);
}
XtFree((char *) bodydef);
free((char *) bodydef);
/* Get the objdid for order children of this node */
found = 0;
......@@ -2034,7 +2034,7 @@ static pwr_tStatus gen_print_inputs (
}
}
XtFree((char *) bodydef);
free((char *) bodydef);
return GSX__SUCCESS;
}
......@@ -2310,7 +2310,7 @@ static pwr_tStatus gen_print_interns (
XtFree( object_par);
XtFree( template_par);
}
XtFree((char *) bodydef);
free((char *) bodydef);
}
......
......@@ -550,7 +550,7 @@ ldh_GetObjectBody(ldh_tSession session, pwr_tOid oid, char *bname, void **buff,
*buff = XtMalloc(a.size());
if (*buff == NULL) return LDH__INSVIRMEM;
memcpy(*buff, a.value(), a.size());
memcpy(*buff, a.value( 0), a.size());
if (size != NULL) *size = a.size();
return LDH__SUCCESS;
......@@ -575,7 +575,7 @@ ldh_GetObjectBodyDef(ldh_tSession session, pwr_tCid cid, char *bname,
strcpy((*bdef)[a.index()].ParName, a.name());
(*bdef)[a.index()].ParLevel = 1;
(*bdef)[a.index()].ParClass = (pwr_eClass)a.cid();
a.body( (void **) &(*bdef)[a.index()].Par);
(*bdef)[a.index()].Par = (pwr_uParDef *) a.body();
}
return LDH__SUCCESS;
......
......@@ -154,23 +154,39 @@ wb_tdrep *wb_merep::tdrep( pwr_tStatus *sts, wb_name name)
int wb_merep::getAttrInfoRec( wb_attrname *attr, int bix, pwr_tCid cid, int *size,
int *offset, pwr_tTid *tid, int *elements,
pwr_eType *type, int level)
pwr_eType *type, int *flags, int level)
{
pwr_tStatus sts;
if ( level > 0)
bix = cdh_eBix_rt;
wb_cdrep *cd = cdrep( &sts, cid);
if ( EVEN(sts)) return 0;
wb_bdrep *bd = cd->bdrep( &sts, bix);
if ( EVEN(sts)) {
delete cd;
return 0;
wb_adrep *adrep;
wb_bdrep *bd = 0;
if ( bix == 0) {
// Search in all bodies
adrep = cd->adrep( &sts, attr->attribute(level));
if ( EVEN(sts)) {
delete cd;
return 0;
}
}
wb_adrep *adrep = bd->adrep( &sts, attr->attribute(level));
if ( EVEN(sts)) {
delete cd;
delete bd;
return 0;
else {
// Search in specified body
bd = cd->bdrep( &sts, bix);
if ( EVEN(sts)) {
delete cd;
return 0;
}
adrep = bd->adrep( &sts, attr->attribute(level));
if ( EVEN(sts)) {
delete cd;
delete bd;
return 0;
}
}
if ( attr->hasAttrIndex( level)) {
......@@ -187,16 +203,22 @@ int wb_merep::getAttrInfoRec( wb_attrname *attr, int bix, pwr_tCid cid, int *siz
}
if ( attr->hasAttribute( level + 1)) {
// Fix , Subclass: get cid from type of attr
if ( !getAttrInfoRec( attr, bix, cid, size, offset, tid, elements, type,
level + 1))
if ( !getAttrInfoRec( attr, bix, cid, size, offset, tid, elements, type, flags,
level + 1)) {
delete cd;
if ( bd) delete bd;
delete adrep;
return 0;
}
}
else {
*tid = adrep->tid();
*type = adrep->type();
*elements = adrep->nElement();
*flags = adrep->flags();
}
*tid = adrep->tid();
*type = adrep->type();
*elements = adrep->nElement();
delete cd;
delete bd;
if ( bd) delete bd;
delete adrep;
return 1;
}
......@@ -36,7 +36,7 @@ class wb_merep {
int getAttrInfoRec( wb_attrname *attr, int bix, pwr_tCid cid, int *size,
int *offset, pwr_tTid *tid, int *elements,
pwr_eType *type, int level);
pwr_eType *type, int *flags, int level);
};
......
......@@ -197,6 +197,22 @@ wb_cdef wb_volume::cdef(wb_name n)
return wb_cdef(m_vrep->merep()->cdrep( &sts, n));
}
wb_attribute wb_volume::attribute(pwr_tOid oid, char *aname, char *bname) const
{
pwr_tStatus sts;
wb_orep *orep;
if (oid.vid == m_vrep->vid())
// This volume
orep = m_vrep->object( &sts, oid);
else
// Other volume
orep = m_vrep->erep()->object(&sts, oid);
wb_attribute a = wb_attribute(sts, orep, aname, bname);
return a;
}
......
......@@ -51,7 +51,7 @@ public:
wb_object object(pwr_tCid cid) const { wb_object o; return o;} // Fix
wb_object object(char *name) const;
wb_attribute attribute(pwr_tOid oid, char *bname, char *aname) { wb_attribute a; return a;}; // Fix
wb_attribute attribute(pwr_tOid oid, char *aname, char *bname) const;
wb_attribute attribute(wb_object o, wb_adef adef) { wb_attribute a; return a;}; // Fix
wb_attribute attribute(wb_object o, wb_name aname) { wb_attribute a; return a;}; // Fix
wb_attribute attribute(wb_name aname) { wb_attribute a; return a;}; // Fix
......
......@@ -563,6 +563,9 @@ int wb_vrepwbl::getAttrInfoRec( wb_attrname *attr, int bix, pwr_tCid cid, int *s
int *offset, pwr_tTid *tid, int *elements, pwr_eType *type,
int level)
{
if ( level > 0)
bix = cdh_eBix_rt;
switch( cid) {
case pwr_eClass_Type:
{
......@@ -746,7 +749,9 @@ int wb_vrepwbl::getAttrInfoRec( wb_attrname *attr, int bix, pwr_tCid cid, int *s
}
else {
// Search type in other volumes
return m_erep->merep()->getAttrInfoRec( attr, bix, cid, size, offset, tid, elements, type, level);
int flags;
return m_erep->merep()->getAttrInfoRec( attr, bix, cid, size, offset, tid,
elements, type, &flags, level);
}
}
}
......
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