Example #1
0
void StrucViewItem::initState()
//-----------------------------
// if i represent a variable, i must find my type
// if the base type is a ClassType, then i am Collapsed
// else i am LeafNode
{
    bool        do_inherited = false;
    ClassType * classType;
    dr_sym_type stype = _info->symtype();

    REQUIRE( stype != DR_SYM_NOT_SYM,"strucview::initstate ack");

    if( !_initialized ) {
        if( _classNode != NULL ) {
            REQUIRE( stype == DR_SYM_CLASS,"strucview::initstate nak");
            classType = (ClassType *)_info;
            _type = _name;
        } else {
            classType = flattenTypeDesc( _info, _type );
            _name = _info->name();
        }

        if( classType ) {
            WVList kidInfos;
            FilterFlags flags = _parent->getFilter();
            if( ( flags & FILT_INHERITED ) || ( flags & FILT_ALL_INHERITED )) {
                do_inherited = true;
                FILT_RESET_INHERITED( flags );
            }

            classType->dataMembers( kidInfos, flags );
            if( kidInfos.count() != 0 ) {
                _expandState = Collapsed;
                _parent->addSeen( this );
                for( int i = 0; i < kidInfos.count(); i++ ) {
                    _kids.add( new StrucViewItem( _parent, ((Symbol *)kidInfos[i]),
                                                  _indentLevel + 1 ) );
                }
            } else {
                _expandState = LeafNode;
            }
            if( classType != _info ) {
                delete classType;
            }

            if( do_inherited ) {
                startInherited();
            }
        } else {
            _expandState = LeafNode;
        }
        _initialized = true;
    }
}
Example #2
0
bool StrucViewItem::inhHook( DerivationPtr & ptr, void * info )
//-------------------------------------------------------------
{
    InheritedData * data = (InheritedData *) info;
    WString         name( *data->name );
    StrucViewItem * item = NULL;

    name.concat( "::" );
    name.concat( ptr._class->name() );

    if( ptr._virtuality == DR_VIRTUALITY_VIRTUAL ) {
        WVList * list = data->me->_parent->getSeen();
        for( int i = list->count(); i > 0; i -= 1 ) {
            StrucViewItem * test = (StrucViewItem *) (*list)[ i - 1 ];
            if( test->_info->getHandle() == ptr._class->getHandle() ) {
                item = test;
            }
        }
    }
    if( item != NULL ) {
        item->_name.concat( ", " );
        item->_name.concat( name );
    } else {
        item = new StrucViewItem( data->me->_parent, ptr._class,
                                  data->me->_indentLevel );
        item->_name = name;
        item->initState();
        data->me->_kids.add( item );
    }

    return true;
}
Example #3
0
void MItem::pruneStates( WVList& states )
{
    for( int i=states.count(); i>0; ) {
        i--;
        MState* s = (MState*)states[i];
        if( !s->legal() ) {
            delete states.removeAt( i );
        }
    }
}
Example #4
0
int MConfig::findMatchingRules( WFileName& fn, WString& mask, WVList& list )
{
    int icount = _rules.count();
    for( int i=0; i<icount; i++ ) {
        MRule* rule = (MRule*)_rules[i];
        if( rule->match( mask, fn ) ) {
            list.add( rule );
        }
    }
    return( list.count() );
}
Example #5
0
int MItem::expandAction( const WString& actionName, WString& command )
{
    WVList actions;
    addActions( actions );
    for( int i=0; i<actions.count(); i++ ) {
        MAction* action = (MAction*)actions[i];
        if( action->name().match( actionName ) ) {
            return( expandAction( action, command ) );
        }
    }
    return( -1 );
}
Example #6
0
void MItem::addActions( WFileName& fn, WVList& list )
{
    WVList rules;
    if( _config->findMatchingRules( fn, _component->mask(), rules ) ) {
        for( int i=0; i<rules.count(); i++ ) {
            MRule* r = (MRule*)rules[i];
            for( int j=0; j<r->actions().count(); j++ ) {
                list.add( r->actions()[j] );
            }
        }
    }
}
Example #7
0
void DTViewClass::load()
//----------------------
{
    WVList          dataMembers;
    WVList          methods;
    WVList          friends;
    int             i;
    WString         str;
    ClassType *     cls = (ClassType *) _symbol;
    Symbol *        s;

    _members->clearAndDestroy();

    cls->dataMembers( dataMembers );
    cls->memberFunctions( methods );
    cls->friendFunctions( friends );

    for( i = 0; i < friends.count(); i += 1 ) {
        s = (Symbol *) friends[ i ];
        str.printf( "    friend %s;", s->scopedName( FALSE ) );
        _members->insert( new ClassMember( s, str.gets() ) );
    }

    for( i = 0; i < dataMembers.count(); i += 1 ) {
        s = (Symbol *) dataMembers[ i ];

        str.printf( "    %s;", s->scopedName( FALSE ) );
        _members->insert( new ClassMember( s, str.gets() ) );
    }

    for( i = 0; i < methods.count(); i += 1 ) {
        s = (Symbol *) methods[ i ];

        str.printf( "    %s;", s->scopedName( FALSE ) );
        _members->insert( new ClassMember( s, str.gets() ) );
    }

    addDescriptions();
    fillBox();
}
Example #8
0
void MC2Switch::getText( WString& str, WVList* states, SwMode mode )
{
    bool state = _state[mode];
    WVList found;
    findStates( states, found );
    int icount = found.count();
    for( int i=0; i<icount; i++ ) {
        MCState* st = (MCState*)found[i];
        if( st->mode() == mode ) {
            state = st->state();
        }
    }
    addone( str, state );
}
Example #9
0
MRule* MConfig::findMatchingRule( WFileName& fn, MRule* tgtRule, WString& mask )
{
    WVList list;
    WVList& symbols = tgtRule->symbols();
    int icount = symbols.count();
    for( int i=0; i<icount; i++ ) {
        MSymbol& sym = *(MSymbol*)symbols[i];
        addRules( fn, sym.mask(), list, mask );
        if( list.count() > 0 ) {
            return( (MRule*)list[0] );
        }
    }
    return( nilRule() );
}
Example #10
0
void FunctionSym::callers( WVList & list )
//----------------------------------------
{
    int i;

    getModule()->findRefSyms( &list, this );

    for( i = 0; i < list.count(); i += 1 ) {
        Symbol * sym = (Symbol *) list[ i ];
        if( sym->symtype() != DR_SYM_FUNCTION ) {
            list.removeAt( i );
        }
    }
}
Example #11
0
static bool referenceHook( drmem_hdl, dr_ref_info * refinfo, char * name,
                           void * info )
//-----------------------------------------------------------------------
{
    Reference * ref;
    WVList *    list = (WVList *) info;

    for( int i = 0; i < list->count(); i++ ) {
        ref = (Reference *) (*list)[i];
        if( ref->line() == refinfo->line && ref->column() == refinfo->column
                && strcmp( ref->sourceFile(), refinfo->file ) == 0 ) {
            WBRFree( name );
            return true;
        }
    }
    list->add( new Reference( refinfo, name ) );
    return true;    // keep going
}
Example #12
0
int MItem::addActions( WVList& list )
{
    if( !_isTarget ) {
        //add actions for Source
        addActions( *this, list );
    }
    //add actions for result
    int ocount = list.count();
    int icount = _rule->actions().count();
    for( int i=0; i<icount; i++ ) {
        list.add( _rule->actions()[i] );
    }
    WFileName fn;
    if( result( fn ) ) {
        addActions( fn, list );
    }
    return( ocount );
}
Example #13
0
int MItem::expandAction( MAction* action, WString& command )
{
    WFileName fn;
    if( _isTarget ) {
        absName( fn );
    } else {
        WVList actions;
        int ocount = addActions( actions );
        if( !action ) {
            int icount = actions.count();
            if( icount > 0 ) {
                for( int i=0; i<icount; i++ ) {
                    MAction* act = (MAction*)actions[i];
                    if( act->defAction() ) {
                        if( act->okForMask() || !isMask() ) {
                            action = act;
                            break;
                        }
                    }
                }
            }
        }
        if( action ) {
            int ix = actions.indexOfSame( action );
            if( ix < 0 ) {
                action = NULL;
            } else if( ix >= ocount ) {
                absResult( fn );
            } else {
                absName( fn );
            }
        }
    }
    if( action ) {
        WVList* states = findActionStates( action );
        return( action->expand( command, &fn, _component->mask(), states, _component->mode() ) );
    }
    return( -1 );
}
Example #14
0
DescriptionPaint::DescriptionPaint( WBRWindow * prnt, const WRect & r,
                                    Symbol * sym )
                    : _parent( prnt )
                    , _rect( r )
                    , _current( -1 )
//--------------------------------------------------------------------
{
    int             i;
    WVList          desc;
    Description *   entry;
    WString         buf;
    const char *    uDefSymName;
    int             x = r.x();
    int             w;
    int             h;

    _parts = new WCPtrOrderedVector<DescriptionPart>;

    sym->description( desc );

    for( i = 0; i < desc.count(); i += 1 ) {
        entry = (Description *) desc[i];
        if( entry->symbol() ) {
            if( sym->isEqual( entry->symbol() ) ) {

                // don't hilight the symbol we're describing
                buf.concat( entry->name() );
                delete entry->symbol();

            } else {

                if( buf != "" ) { // flush buf
                    w = prnt->getTextExtentX( buf );
                    h = prnt->getTextExtentY( buf );
                    _parts->append( new DescriptionPart( buf.gets(), NULL,
                                        WRect(x,r.y(),w, h ) ) );

                    buf="";
                    x+=w;
                }

                uDefSymName = entry->name();
                w = prnt->getTextExtentX( uDefSymName );
                h = prnt->getTextExtentY( uDefSymName );
                _parts->append( new DescriptionPart( uDefSymName,
                                                     entry->symbol(),
                                                     WRect(x,r.y(),w, h ) ) );
                x+=w;
            }
        } else {
            buf.concat( entry->name() );
        }
    }

    desc.deleteContents();


    if( buf != "" ) { // flush buf
        w = prnt->getTextExtentX( buf );
        h = prnt->getTextExtentY( buf );
        _parts->append( new DescriptionPart( buf, NULL,
                                WRect(x,r.y(),w, h ) ) );

        buf="";
        x+=w;
    }

    _rect.w( x - abs( _rect.x() ) );
}
Example #15
0
ClassType * StrucViewItem::flattenTypeDesc( Symbol * sym, WString & desc )
//------------------------------------------------------------------------
{
    ClassType *     classType = NULL;
    char *          str = NULL;
    WVList          typeParts;
    Description *   entry;
    int             i;

    REQUIRE( sym != NULL, "strucview::flatten passed null symbol!" );
    dr_sym_type stype = sym->symtype();
    REQUIRE( stype != DR_SYM_NOT_SYM,"strucview::flatten bad set");

    switch( stype ) {
    case DR_SYM_VARIABLE:
        // need to find out the type of the data member
        ((VariableSym *) sym)->loadTypeInfo( typeParts );
        for( i = 0; i < typeParts.count(); i++ ) {
            entry = (Description *) typeParts[i];
            if( entry->_nameGoesHere ) {
                desc.concat( entry->u.text );
            } else {
                if( !sym->isEqual( entry->u.sym ) ){
                    if( classType == NULL ) {
                        classType = flattenTypeDesc( entry->u.sym, desc );
                    } else {
                        desc.concat( entry->u.sym->name() );
                    }
                }
            }
        }
        break;

    case DR_SYM_TYPEDEF:
    case DR_SYM_ENUM:
        sym->description( typeParts );
        for( i = 0; i < typeParts.count(); i++ ) {
            entry = (Description *) typeParts[ i ];
            if( entry->_isUserDefined ) {
                if( entry->u.sym->symtype() == DR_SYM_CLASS && classType == NULL ) {
                    classType = (ClassType *) entry->u.sym;
                }
            }
        }
        desc.concat( sym->name() );
        break;

    case DR_SYM_CLASS:
        if( _parent->isSeen( sym ) ) {
            desc.concat( sym->name() );
            classType = NULL;
        } else {
            classType = (ClassType *) sym;
            desc.concat( classType->name() );
        }
        break;

    default: {}
    }

    for( i=0; i < typeParts.count(); i++ ) {
        entry = (Description *) typeParts[ i ];
        if( entry->_isUserDefined && entry->u.sym != classType &&
            entry->u.sym != sym ) {
            delete entry->u.sym;
        }
    }
    typeParts.deleteContents();

    return classType;
}