Exemplo n.º 1
0
MComponent* MProject::attachComponent( WFileName& filename )
{
    MComponent* comp = NULL;
    WObjectFile ot;
    if( ot.open( filename, OStyleReadB ) ) {
        _recursing = true;
        if( ot.version() < 34 ) {
            ot.readObject( this );
            comp = (MComponent*)ot.readObject();
            comp->setRelFilename( filename );
            _components.add( comp );
            setDirty();
        } else {
            char ident[sizeof( _targetIdent ) + 1];
            ot.readObject( ident, sizeof( ident ) - 1 );
            if( !streq( ident, _targetIdent ) ) {
                //bad file format
            } else {
                ot.readObject( this );
                comp = (MComponent*)ot.readObject();
                comp->setRelFilename( filename );
                _components.add( comp );
                setDirty();
            }
        }
        _recursing = false;
        ot.close();
    }
    return( comp );
}
Exemplo n.º 2
0
MComponent *DocumentController::createNewComponent(MPackage *parent)
{
    MComponent *newComponent = new MComponent();
    newComponent->setName(tr("New Component"));
    m_modelController->addObject(parent, newComponent);
    return newComponent;
}
Exemplo n.º 3
0
MComponent* MProject::findComponent( WFileName& fn )
{
    int icount = _components.count();
    for( int i=0; i<icount; i++ ) {
        MComponent* comp = (MComponent*)_components[i];
        if( comp->relFilename() == fn ) {
            return( comp );
        }
    }
    return( NULL );
}
Exemplo n.º 4
0
void MProject::refresh( bool autotrack_only )
{
    MComponent  *comp;

    int icount = _components.count();
    for( int i=0; i<icount; i++ ) {
        comp = (MComponent*)_components[i];
        if( !autotrack_only || comp->autotrack() ) {
            comp->refresh();
        }
    }
}
Exemplo n.º 5
0
MItem* MProject::findSameResult( MItem* item, MComponent** compp )
{
    int icount = _components.count();
    for( int i=0; i<icount; i++ ) {
        MComponent* comp = (MComponent*)_components[i];
        MItem* m = comp->findSameResult( item );
        if( m ) {
            *compp = comp;
            return( m );
        }
    }
    return( NULL );
}
Exemplo n.º 6
0
bool MProject::makeMakeFile( bool long_lines )
{
    bool ok = true;
    if( needsMake() || !_makefile.attribs() ) {
        _filename.setCWD();
        ContFile        pmak;
        if( long_lines )
            pmak.long_lines();
        if( !pmak.open( _makefile, OStyleWrite ) ) {
            ok = false;
        } else {
            expand( pmak, _before, ".before" );
            expand( pmak, _after, ".after" );
            pmak.puts( "project :" );
            int icount = _components.count();
            int i;
            for( i=0; i<icount; i++ ) {
                MComponent* comp = (MComponent*)_components[i];
                if( comp->rule()->ismakeable() ) {
                    WFileName fn;
                    comp->target()->absName( fn );
                    if( fn.needQuotes() ) {
                        fn.addQuotes();
                    }
                    pmak.puts( " " );
                    pmak.puts( fn );
                    fn.removeQuotes();
                }
            }
            pmak.puts( " .SYMBOLIC\n" );
            pmak.puts( "\n" );

            for( i=0; i<icount; i++ ) {
                MComponent* comp = (MComponent*)_components[i];
                if( comp->rule()->ismakeable() ) {
                    comp->addMakeFile( pmak );
                }
            }
            pmak.close();
            ok = pmak.ok();
        }
    }
    if( ok ) {
        int icount = _components.count();
        for( int i=0; i<icount; i++ ) {
            MComponent* comp = (MComponent*)_components[i];
            if( comp->rule()->ismakeable() ) {
                ok = ok & comp->makeMakeFile( long_lines );
            }
        }
    }
    if( ok ) setNeedsMake( false );
    return( ok );
}
Exemplo n.º 7
0
void VpeMain::cForPBProject( WFileName &pj, bool nt ) {

    WString     mask( "wp6d" );

    if( nt ) {
        mask = "np2d";
    }
#ifdef __NT__
    mask.concat( 'n' );
#else
    mask.concat( 'w' );
#endif
    if( _project == NULL || _project->filename() != pj && okToClear() ) {
        clearProject();
        // eventually access should be provided by WCLASS
        if( !access( pj, F_OK ) ) {
            loadProject( pj );
        } else {
            _project = new MProject( pj );
            attachModel( _project );
            WFileName targname( pj );
            targname.setExt( ".dll" );
            MRule *rule = _config->findMatchingRule( targname, mask );
            MComponent* mcomp = new MComponent( _project, rule, mask, targname );
            _project->addComponent( mcomp );
            VComponent* vcomp = new VComponent( this, mcomp, vCompStyle() );
            _compViews.add( vcomp );
            mcomp->updateItemList();
        }
    }
    // update targets
    if( _project != NULL ) {
        unsigned        cnt;
        MComponent      *mcomp;

        cnt = _project->components().count();
        for( ; cnt > 0; cnt -- ) {
            mcomp = (MComponent *)(_project->components()[cnt - 1] );
            mcomp->updateItemList();
        }
    }
}
Exemplo n.º 8
0
void WEXPORT MProject::writeSelf( WObjectFile& p )
{
    if( !_recursing ) {
        p.writeObject( &_before );
        p.writeObject( &_after );
        int icount = _components.count();
        p.writeObject( icount );
        for( int i=0; i<icount; i++ ) {
            MComponent* comp = (MComponent*)_components[i];
            WFileName tgtFile( comp->relFilename() );
            p.writeObject( &tgtFile, FORCE );
            if( comp->isDirty() ) {
                if( !tryOpenTargetFile( p.version(), true, comp ) ) {
                    p.setObjOk( false );
                }
            }
        }
        _dirty = false;
    }
}
Exemplo n.º 9
0
bool VCompDialog::checkName()
{
    WFileName fn( *_fn );
    fn.absoluteTo( _project->filename() );
    int icount = _project->components().count();
    for( int i=0; i<icount; i++ ) {
        MComponent* m = (MComponent*)_project->components()[i];
        if( m != _comp ) {
            WFileName cn;
            m->target()->absName( cn );
            if( fn.match( cn, matchDrive|matchDir ) ) {
                if( fn.match( cn, matchFName ) ) {
                    WMessageDialog::messagef( this, MsgError, MsgOk, _viperError,
                        "Targets '%s' and '%s' have the same name and must be in different directories.", (const char*)*_fn, (const char*)*m->target() );
                    return FALSE;
                }
            }
        }
    }
    return TRUE;
}
Exemplo n.º 10
0
bool MComponent::addFromFilename( WFileName& filename, WString& err )
{
    if( filename.isMask() ) {
        return( addFromMask( filename, err ) );
    }

    MRule* rule = _config->findMatchingRule( filename, _target->rule(), _mask );
    if( rule ) {
        if( rule == _config->nilRule() ) {
            unsigned    cnt;

            cnt = _items.count();
            for( ; cnt > 0; cnt-- ) {
                if( *(MItem *)_items[cnt - 1] == filename ) break;
            }
            if( cnt == 0 ) {
                MItem* item = new MItem( filename, this, rule );
                newItem( item );
            } else {
                return( false );
            }
        } else {
            MItem* item = new MItem( filename, this, rule );
            MComponent* comp = NULL;
            MItem* m = _project->findSameResult( item, &comp );
            if( !m ) {
                newItem( item );
            } else {
                delete item;
                if( comp != this ) {
                    err.printf( "Conflicting file '%s' found in target '%s'",
                        (const char*)*m, (const char*)*comp->target() );
                    return( false );
                }
            }
        }
        return( true );
    }
    return( false );
}