Exemple #1
0
//
// printClass
//
void wb_print_wbl::printClass(wb_volume& v,
                              wb_attribute& attr,
                              wb_attribute& tattr,
                              wb_adef& adef) 
{
  pwr_tCid subClass = attr.subClass();
  wb_object templ;
  wb_object sysbo;
  wb_attribute tattr2;
  wb_attribute attr2;
  wb_adef adef2;

  //  if ( strcmp( attr.name(), "Template") == 0 && v.cid() == pwr_eClass_ClassVolume)
    // The parser can't handle subclasses in template objects yet...
  //  return;

  wb_cdef cdef = v.cdef(attr.cid());
  if (!cdef) {
    m_os << "! %WBDUMP-E-Error Unknown sub class: " << subClass << endl;
    m_errCnt++;
    return;
  }

  wb_bdef bdef = cdef.bdef(pwr_eBix_sys);
  if (!bdef) {
    m_os << "! %WBDUMP-E-Error sub class: " << subClass 
         << " not defined" << endl;
    m_errCnt++;
    return;
  }    

  for (int i = 0; i < adef.nElement(); i++) {
    attr2 = attr.first(i);
    tattr2 = tattr.first(i);
  
    while ( attr2.oddSts()) {

      adef2 = bdef.adef( attr2.attrName()); 
      
      printAttribute(v, attr2, tattr2, adef2, 0);
    
      attr2 = attr2.after();
      if ( tattr2.oddSts())
	tattr2 = tattr2.after();
    }
  }

#if 0
  wb_object co = v.object(cdh_ClassIdToObjid(subClass));
  if (!co) {
    m_os << "! %WBDUMP-E-Error Unknown sub class: " << subClass << endl;
    m_errCnt++;
    return;
  }

  wb_cdef cdef = v.cdef(subClass);
  if (!cdef) {
    m_os << "! %WBDUMP-E-Error Unknown sub class: " << subClass << endl;
    m_errCnt++;
    return;
  }

  wb_name t("Template");
  
  templ = co.child(t);
  if (!templ) {
    m_errCnt++;
    m_os << "! %WBDUMP-E-Error Template not found for class " << cdef.longName() << endl;
    return;
  }

  wb_bdef bdef = cdef.bdef(pwr_eBix_sys);
  if (!bdef) {
    m_os << "! %WBDUMP-E-Error sub class: " << subClass 
         << " not defined" << endl;
    m_errCnt++;
    return;
  }    
  bname = bdef.name();

  for (int i = 0; i < adef.nElement(); i++) {

    if (adef.flags() & PWR_MASK_ARRAY)
      indent(1) << "Buffer " << adef.name() << "[" << i << "]" << endl;
    else
      indent(1) << "Buffer " << adef.name() << endl;


    adef2 = bdef.adef(); 
    attr2 = attr.first(i);
    
    while (1) {
      tattr2 = templ.attribute(bname, adef2.name());
      printAttribute(v, attr2, tattr2, adef2, 0);

      if (!(adef2 = adef2.next()))
        break;
      
      if (!(attr2 = attr2.after()))
        break;
    }                   

    indent(-1) << "EndBuffer" << endl;

    if (adef.flags() & PWR_MASK_ARRAY)
      indent(1) << "Buffer " << adef.name() << "[" << i << "]" << endl;
    else
      indent(1) << "Buffer " << adef.name() << endl;


    adef2 = bdef.adef(); 
    attr2 = attr.first(i);
    
    while (1) {
      strcpy( aname, adef.subName());
      strcat( aname, ".");
      strcat( aname, attr2.name());

      attr2
      tattr2 = templ.attribute(bname, adef2.name());
      printAttribute(v, attr2, tattr2, adef2, 0);

      if (!(adef2 = adef2.next()))
        break;
      
      if (!(attr2 = attr2.after()))
        break;
    }                   

  }
#endif
}
Exemple #2
0
wb_attribute::wb_attribute(const wb_attribute& pa, int pidx, const char *aname, int aidx) :
  wb_status(LDH__NOSUCHATTR), m_orep(0), m_adrep(0), m_size(0), m_offset(0), m_tid(0),
  m_elements(1), m_is_elem(0), m_type(pwr_eType_), m_flags(0), m_bix(pwr_eBix__), m_body(0), 
  m_shadowed(false)
{
  pwr_tCid cid;
  wb_attrname n;
  pwr_tAName attrname;
  
  if ( !cdh_tidIsCid( pa.tid()) || pa.m_orep == 0)
    return;

  if ( pidx == -1)
    pidx = pa.m_idx;

  if ( pa.m_flags & PWR_MASK_ARRAY && !pa.m_is_elem &&
       (pidx < 0 || pidx >= pa.m_elements))
    throw wb_error_str("Invalid subscript");
    
  strcpy( attrname, pa.attrName());
  if ( pa.m_flags & PWR_MASK_ARRAY) {
    if ( attrname[strlen(attrname)-1] == ']') {
      // Replace the index
      char *s = strrchr( attrname, '[');
      if ( s)
	sprintf( s, "[%d]", pidx);
    }
    else
      // Add index
      sprintf( &attrname[strlen(attrname)], "[%d]", pidx);
  }
  strcat( attrname, ".");
  if ( aname != 0)
    strcat( attrname, aname);
  else {
    // First attribute
    if ( pa.isClass())
      cid = pa.subClass();
    else
      cid = pa.tid();
    wb_cdrep *cd = pa.m_orep->vrep()->merep()->cdrep(&m_sts, cid);
    if ( evenSts()) return;
    
    wb_bdrep* bd = cd->bdrep(&m_sts, pwr_eBix_sys);
    if ( evenSts()) { delete cd; return;}

    wb_adrep *adrep = bd->adrep(&m_sts);
    if ( evenSts()) { delete cd; delete bd; return;}

    strcat( attrname, adrep->name());
    delete adrep;
    delete bd;
    delete cd;
  }

  n = attrname;

  cid = pa.cid();

  wb_cdrep *cd = pa.m_orep->vrep()->merep()->cdrep(&m_sts, cid);
  if (evenSts()) return;

  wb_bdrep* bd = cd->bdrep(&m_sts, pwr_eBix_sys);
  if (evenSts()) {
    // Try devbody
    bd = cd->bdrep(&m_sts, pwr_eBix_dev);
    if (evenSts()) { delete cd; return;}
  }

  m_adrep = bd->adrep(&m_sts, n.attributesAllTrue());
  if (evenSts()) {
    // Try devbody
    bd = cd->bdrep(&m_sts, pwr_eBix_dev);
    if (evenSts()) { delete cd; return;}

    m_adrep = bd->adrep(&m_sts, n.attributesAllTrue());
    if (evenSts()) { delete cd; delete bd; return;}
  }
  m_adrep->ref();
  m_size = m_adrep->size();
  m_offset = m_adrep->offset();
  m_tid = m_original_tid = m_adrep->tid();
  m_elements = m_adrep->nElement();
  m_flags = m_adrep->flags();
  m_type = m_adrep->type();  
  m_idx = aidx;

  m_orep = pa.m_orep;
  m_orep->ref();
  m_bix = bd->bix();

  if ( m_flags & PWR_MASK_CASTATTR) {
    pwr_tCastId castid;

    castId( &castid);
    if ( castid != pwr_cNCastId)
      m_tid = castid;
  }

#if 0
  if ( pa.isClass()) {
    m_flags |= PWR_MASK_SUBCLASS;

    if (pa.m_flags & PWR_MASK_SUBCLASS)
      m_bix = pa.m_bix;
    else
      m_bix = pa.m_adrep->bix();
  }
  else
    m_bix = pa.m_bix;
#endif

  delete bd;
  delete cd;
}