Commit 815c6b26 authored by claes's avatar claes

*** empty log message ***

parent c5df7017
......@@ -284,13 +284,41 @@ void wb_attribute::check() const
//
pwr_sAttrRef wb_attribute::aref() const
{
check();
pwr_sAttrRef aref;
memset( &aref, 0, sizeof(aref));
aref.Objid = m_orep->oid();
aref.Offset = m_offset;
aref.Size = m_size;
if ( m_adrep) {
wb_bdrep *bd = m_adrep->bdrep();
aref.Body = bd->bcid();
delete bd;
}
return aref;
}
pwr_sAttrRef *wb_attribute::aref(pwr_sAttrRef *arp) const
{
check();
memset( arp, 0, sizeof(*arp));
arp->Objid = m_orep->oid();
arp->Offset = m_offset;
arp->Size = m_size;
if ( m_adrep) {
wb_bdrep *bd = m_adrep->bdrep();
arp->Body = bd->bcid();
delete bd;
}
return arp;
}
......
......@@ -101,6 +101,11 @@ pwr_tOid wb_bdrep::boid()
return m_orep->oid();
}
pwr_tCid wb_bdrep::bcid()
{
return m_orep->cid();
}
const char* wb_bdrep::name() const
{
......
......@@ -28,7 +28,7 @@ public:
int nAttribute();
pwr_eBix bix();
pwr_tOid boid();
pwr_tCid bcid();
const char* name() const; // get body name
wb_name longName() const;
......@@ -43,3 +43,4 @@ public:
};
#endif
......@@ -154,7 +154,7 @@ wb_adrep *wb_cdrep::adrep( pwr_tStatus *sts, const char *aname)
orep->ref();
if ( orep->cid() == pwr_eClass_ObjBodyDef) {
orep_attr = orep->vrep()->child( sts, orep, n);
if ( ODD(*sts)) {
if ( ODD(*sts) /* && aname.attributeIsEqual( orep_attr->name()) */ ) {
wb_adrep *adrep = new wb_adrep( *orep_attr);
orep->unref();
return adrep;
......
......@@ -439,23 +439,11 @@ ldh_GetAttrDef(ldh_tSession session, pwr_tCid cid, char *bname, char *aname, ldh
wb_adef a = sp->adef(cid, bname, aname);
if (!a) return a.sts();
#if NOT_YET_IMPLEMENTED
a.size();
a.offset();
a.name();
strcpy(adef->ParName, a.name());
adef->ParLevel = 1;
adef->ParClass = a.cid();
adef->Par.PgmName;
adef->Par.Type = a.type();
adef->Par.Offset = a.offset();
adef->Par.Size = a.size();
adef->Par.Flags = a.flags();
adef->Par.Elements = a.nElement();
adef->Par.ParamIndex = a.index();
#endif
return LDH__NYI;
adef->ParClass = (pwr_eClass) a.cid();
adef->Par = (pwr_uParDef *) a.body();
return LDH__SUCCESS;
}
pwr_tStatus
......@@ -463,13 +451,13 @@ ldh_GetAttrRef(ldh_tSession session, pwr_tOid oid, char *aname, pwr_sAttrRef *ar
{
wb_session *sp = (wb_session *)session;
wb_object o = sp->object(oid);
wb_name n(aname);
wb_attrname n(aname);
wb_attribute a = sp->attribute(o, n);
if (!a) return a.sts();
*aref = a.aref();
return LDH__NYI;
return LDH__SUCCESS;
}
pwr_tStatus
......@@ -479,8 +467,9 @@ ldh_GetAttrXRefDef(ldh_tSession session, pwr_sAttrRef *aref, pwr_sAttrXRef *xref
wb_attribute a = sp->attribute(aref);
if (!a) return a.sts();
// *xref = a.xref();
return LDH__NYI;
a.adrep()->body( xref);
return a.sts();
}
/* Get first child of an object. */
......@@ -690,7 +679,7 @@ ldh_GetObjXRefDef(ldh_tSession session, pwr_sAttrRef *aref, pwr_sObjXRef *ObjXRe
wb_attribute a = sp->attribute(aref);
if (!a) return a.sts();
//pwr_sObjXref *x = a.oxref();
a.adrep()->body( ObjXRef);
return a.sts();
}
......@@ -1069,7 +1058,10 @@ ldh_AttrRefToName(ldh_tSession session, pwr_sAttrRef *arp, ldh_eName nametype, c
wb_attribute a = sp->attribute(arp);
if (!a) return a.sts();
//wb_name n = a.name(nametype);
wb_name n = a.longName();
strcpy( str, n.name( nametype));
*aname = str;
*size = strlen(str);
break;
}
case ldh_eName_ArefExport:
......@@ -1178,15 +1170,10 @@ ldh_ReadAttribute(ldh_tSession session, pwr_sAttrRef *arp, void *value, int size
wb_attribute a = sp->attribute(arp);
if (!a) return a.sts();
#if NOT_YET_IMPLEMENTED
wb_value v(value, size);
if (!v) return v.sts();
v = a.value();
return v.sts();
#else
return LDH__NYI;
#endif
a.value( value);
return LDH__SUCCESS;
}
/* Reads a named body of an object into a buffer supplied in the call. */
......@@ -1355,11 +1342,15 @@ ldh_WriteAttribute(ldh_tSession session, pwr_sAttrRef *arp, void *value, int siz
wb_session *sp = (wb_session*)session;
wb_attribute a = sp->attribute(arp);
if (!a) return a.sts();
//wb_value v(value, size);
//if (!v) return v.sts();
//return a.value(v);
return LDH__NYI;
try {
sp->writeAttribute(a, value);
return sp->sts();
}
catch (wb_error& e) {
return e.sts();
}
return LDH__SUCCESS;
}
/* Returns 1 if object is owned by the volume attached to
......
......@@ -141,6 +141,7 @@ public:
bool objectIsEqual( const char *n) const throw (wb_error) { check(); return m_nrep->objectIsEqual( n);}
bool segmentIsEqual( const char *n, int idx = 0) const throw (wb_error) { check(); return m_nrep->segmentIsEqual( n, idx);}
bool attributeIsEqual( const char *n, int idx = 0) const throw (wb_error) { check(); return m_nrep->attributeIsEqual( n, idx);}
char *wholeAttr() const throw (wb_error) { check(); return m_nrep->wholeAttr();}
// Id representation
char *vid( char *res = 0) const throw (wb_error) { check(); return m_nrep->volume( res);}
......
......@@ -832,6 +832,32 @@ char *wb_nrep::unatName(const char *name)
return result;
}
char *wb_nrep::wholeAttr(char *res)
{
static char result[256];
if ( num_attr == 0) {
if ( res) {
strcpy( res, "");
return res;
}
else {
strcpy( result, "");
return result;
}
}
else {
if ( res) {
strcpy( res, oname + attr[0].offs);
return res;
}
else {
strcpy( result, oname + attr[0].offs);
return result;
}
}
}
bool wb_nrep::checkObjectName( const char *name)
{
const char *s;
......@@ -847,3 +873,5 @@ bool wb_nrep::checkObjectName( const char *name)
......@@ -108,6 +108,7 @@ public:
bool attributeIsEqual( const char *n, int idx = 0);
int bodyOffset() const { return b_offset;}
int bodySize() const { return b_size;}
char *wholeAttr( char *res = 0);
static char *unatName( const char *name);
static bool checkObjectName( const char *name);
......
......@@ -157,10 +157,12 @@ wb_adef wb_volume::adef( pwr_tCid cid, const char *bname, const char *aname)
pwr_tStatus sts;
wb_cdrep *cdrep = m_vrep->merep()->cdrep( &sts, cid);
if ( EVEN(sts)) return 0;
if ( EVEN(sts)) return wb_adef();
wb_cdef cdef = wb_cdef(cdrep);
wb_bdef bdef = cdef.bdef( bname);
if ( !bdef)
return wb_adef();
return bdef.adef( aname);
}
......@@ -217,6 +219,44 @@ wb_attribute wb_volume::attribute(pwr_tOid oid, const char *bname, const char *a
return a;
}
wb_attribute wb_volume::attribute( wb_name aname)
{
pwr_tStatus sts;
wb_object o = object( aname.name());
if ( !o)
return wb_attribute();
if ( !aname.hasAttribute())
return wb_attribute( LDH__SUCCESS, (wb_orep *)o);
wb_cdef cd = cdef(o);
if ( !cd)
return wb_attribute();
wb_adrep *adrep = ((wb_cdrep *)cd)->adrep( &sts, aname.wholeAttr());
if ( ODD(sts))
return wb_attribute( sts, (wb_orep *)o, adrep);
return wb_attribute();
}
wb_attribute wb_volume::attribute( wb_object o, wb_attrname aname)
{
pwr_tStatus sts;
if ( !o)
return wb_attribute();
wb_cdef cd = cdef(o);
if ( !cd)
return wb_attribute();
wb_adrep *adrep = ((wb_cdrep *)cd)->adrep( &sts, aname.wholeAttr());
if ( ODD(sts))
return wb_attribute( sts, (wb_orep *)o, adrep);
return wb_attribute();
}
wb_attribute wb_volume::attribute(pwr_tOid oid, const char *bname) const
{
pwr_tStatus sts;
......
......@@ -11,6 +11,7 @@
#include "wb_cdef.h"
#include "wb_tdef.h"
#include "wb_name.h"
#include "wb_attrname.h"
class wb_env;
class wb_vrep;
......@@ -55,8 +56,8 @@ public:
wb_attribute attribute(pwr_tOid oid, const char *bname, const char *aname) const;
wb_attribute attribute(pwr_tOid oid, const 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
wb_attribute attribute(wb_object o, wb_attrname aname);
wb_attribute attribute(wb_name aname);
wb_attribute attribute(const pwr_sAttrRef *arp) const;
wb_attribute attribute() { wb_attribute a; return a;}; // Fix
......
......@@ -244,7 +244,7 @@ mem_object *wb_vrepmem::find( const char *name)
{
wb_name oname = wb_name(name);
if ( oname.evenSts() || (oname.hasVolume() && !oname.volumeIsEqual(volume_name)))
if ( oname.evenSts() || (oname.hasVolume() && !oname.volumeIsEqual(this->name())))
return 0;
if ( root_object)
......
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