Ignore:
Timestamp:
Mar 27, 2008, 2:29:35 AM (16 years ago)
Author:
dai_9181
Message:

いくつかのグローバル変数をProgram/Debuggerクラスにまとめた。

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ab5.0/abdev/BasicCompiler_Common/BasicCompiler.cpp

    r465 r467  
    11#include "stdafx.h"
    2 
    3 #include <shlwapi.h>
    42
    53#include <jenga/include/common/Path.h>
     
    320318}
    321319void MakeMessageText(char *buffer,char *msg,int flag){
    322     char temporary[MAX_PATH];
    323     if(bClipCompileView){
     320    if( program.IsClipCompileView() ){
    324321        //ProjectView埋め込みがたインターフェイスのとき
    325322
    326323        //生成するファイルの相対パスを取得
    327         lstrcpy(temporary,OutputFileName);
    328         GetRelationalPath(temporary,BasicCurDir);
     324        char relationalPath[MAX_PATH];
     325        lstrcpy( relationalPath, program.GetOutputFilePath().c_str() );
     326        GetRelationalPath( relationalPath, BasicCurDir );
    329327
    330328        //////////
     
    336334            if(compiler.IsDll())
    337335            {
    338                 sprintf(buffer,"DLLファイル \"%s\"     [ %s ]",temporary,msg);
    339             }
    340             else sprintf(buffer,"実行ファイル \"%s\"     [ %s ]",temporary,msg);
    341         }
    342         if(flag==1) sprintf(buffer,"\"%s\" を生成しています     [ %s ]",temporary,msg);
     336                sprintf(buffer,"DLLファイル \"%s\"     [ %s ]",relationalPath,msg);
     337            }
     338            else sprintf(buffer,"実行ファイル \"%s\"     [ %s ]",relationalPath,msg);
     339        }
     340        if(flag==1) sprintf(buffer,"\"%s\" を生成しています     [ %s ]",relationalPath,msg);
    343341        if(flag==2) lstrcpy(buffer,msg);
    344342#else
    345343        //英語
    346344        if(flag==0){
    347             if(compiler.IsDll()) sprintf(buffer,"DLL file \"%s\"     [ %s ]",temporary,msg);
    348             else sprintf(buffer,"Execution file \"%s\"     [ %s ]",temporary,msg);
    349         }
    350         if(flag==1) sprintf(buffer,"Creating \"%s\"     [ %s ]",temporary,msg);
     345            if(compiler.IsDll()) sprintf(buffer,"DLL file \"%s\"     [ %s ]",relationalPath,msg);
     346            else sprintf(buffer,"Execution file \"%s\"     [ %s ]",relationalPath,msg);
     347        }
     348        if(flag==1) sprintf(buffer,"Creating \"%s\"     [ %s ]",relationalPath,msg);
    351349        if(flag==2) lstrcpy(buffer,msg);
    352350#endif
     
    378376    extern HANDLE hDebugProcess;
    379377    char temporary[MAX_PATH];
    380     DWORD dw;
    381378    RECT rect;
    382379    POINT pos;
     
    393390            MoveWindow(hwnd,pos.x,pos.y,size.cx,size.cy,1);
    394391
    395             lstrcpy(temporary,OutputFileName);
    396             GetRelationalPath(temporary,BasicCurDir);
    397             SetDlgItemText(hwnd,IDC_EXEPATH,temporary);
     392            char relationalPath[MAX_PATH];
     393            lstrcpy(relationalPath,program.GetOutputFilePath().c_str());
     394            GetRelationalPath(relationalPath,BasicCurDir);
     395            SetDlgItemText(hwnd,IDC_EXEPATH,relationalPath);
    398396
    399397            //"エラー無し"
     
    428426                    //STRING_COMPILE = "コンパイル"
    429427                    if(lstrcmp(temporary,STRING_COMPILE)==0){
    430                         GetDlgItemText(hwnd,IDC_EXEPATH,OutputFileName,MAX_PATH);
    431                         GetFullPath(OutputFileName,BasicCurDir);
    432                         CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)MainThread,0,0,&dw);
     428                        char tempOutputFileName[MAX_PATH];
     429                        GetDlgItemText(hwnd,IDC_EXEPATH,tempOutputFileName,MAX_PATH);
     430                        program.SetOutputFilePath(
     431                            Jenga::Common::Path::MakeFullPath( tempOutputFileName, BasicCurDir )
     432                        );
     433                        _beginthread( &MainThread, NULL, NULL );
    433434                    }
    434435
     
    493494            break;
    494495        case WM_SHOWVARLIST:
    495             if(bClipCompileView){
     496            if( program.IsClipCompileView() ){
    496497                //埋め込み表示
    497498                CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_DEBUGGER),hOwnerEditor,(DLGPROC)DlgDebugger,lParam);
     
    507508            return 1;
    508509        case WM_SIZE:
    509             if(bClipCompileView){
     510            if( program.IsClipCompileView() ){
    510511                //エラーリストの位置
    511512                MoveWindow(GetDlgItem(hwnd,IDC_ERRORLIST),
     
    536537            GetWindowRect(hwnd,&rect);
    537538
    538             if(!bClipCompileView){
     539            if( !program.IsClipCompileView() ){
    539540                pobj_nv->MainDlgPos.x=rect.left;
    540541                pobj_nv->MainDlgPos.y=rect.top;
     
    567568}
    568569
    569 bool AnalysisCommandLines( bool &isFromEditor )
    570 {
    571     // 値を初期化
    572     isFromEditor = false;
    573 
    574     // コマンドラインを解析
    575     const Jenga::Common::CmdLines cmdLines( PathGetArgs( GetCommandLine() ) );
    576     int cmdLineIndex = 0;
    577 
    578     if( cmdLines.size() == 0 )
    579     {
    580         // 何も指定されていないとき
    581         return true;
    582     }
    583 
    584     if( cmdLines[cmdLineIndex].IsNamelessCommand() )
    585     {
    586         // 先頭に無名コマンドがきた場合、ソースファイル名として認識する
    587         lstrcpy( SourceFileName, cmdLines[cmdLineIndex].GetParameter().c_str() );
    588 
    589         cmdLineIndex ++;
    590 
    591         if( cmdLines.size() == 1 )
    592         {
    593             // ソースファイル名のみの指定だったとき
    594             return true;
    595         }
    596 
    597         // 出力ファイル名を取得
    598         if( cmdLines[cmdLineIndex].IsNamelessCommand() )
    599         {
    600             // 二番目にも無名コマンドがきた場合、ソースファイル名として認識する
    601             lstrcpy( OutputFileName, cmdLines[cmdLineIndex].GetParameter().c_str() );
    602 
    603             cmdLineIndex ++;
    604         }
    605     }
    606 
    607     for( ; cmdLineIndex < static_cast<int>(cmdLines.size()); cmdLineIndex++ )
    608     {
    609         const Jenga::Common::CmdLine &cmdLine = cmdLines[cmdLineIndex];
    610 
    611         if( cmdLine.GetCommand() == "wnd" )
    612         {
    613             // 親エディタのウィンドウ ハンドル
    614             isFromEditor = true;
    615             sscanf( cmdLine.GetParameter().c_str(), "%08x", &hOwnerEditor );
    616         }
    617         else if( cmdLine.GetCommand() == "debug" )
    618         {
    619             // デバッグ ビルド
    620             compiler.SetDebugMark( true );
    621         }
    622         else if( cmdLine.GetCommand() == "run" )
    623         {
    624             // デバッグ実行
    625             bDebugRun = 1;
    626         }
    627         else if( cmdLine.GetCommand() == "attach" )
    628         {
    629             // アタッチ
    630             bDebugRun=1;
    631             bAttach=1;
    632             sscanf( cmdLine.GetParameter().c_str(), "%08x", &dwAttachProcessId );
    633         }
    634         else if( cmdLine.GetCommand() == "dll" )
    635         {
    636             // DLLとしてビルド
    637             compiler.SetTargetModuleType( Compiler::Dll );
    638         }
    639         else if( cmdLine.GetCommand() == "static_library" )
    640         {
    641             // 静的リンクライブラリとしてビルド
    642             compiler.SetTargetModuleType( Compiler::StaticLibrary );
    643         }
    644         else if( cmdLine.GetCommand() == "unicode" )
    645         {
    646             // Unicode
    647             compiler.SetUnicodeMark( true );
    648             typeOfPtrChar = MAKE_PTR_TYPE(DEF_WORD,1);
    649             typeOfPtrUChar = MAKE_PTR_TYPE(DEF_WORD,1);
    650         }
    651         else if( cmdLine.GetCommand() == "clip_compile_view" )
    652         {
    653             //埋め込み型コンパイラビュー
    654             bClipCompileView = 1;
    655         }
    656         else if( cmdLine.GetCommand() == "include_dir" )
    657         {
    658             //インクルード ディレクトリ
    659             lstrcpy( szIncludeDir, cmdLine.GetParameter().c_str() );
    660         }
    661         else
    662         {
    663             // 不正なコマンド
    664             std::string keyword = cmdLine.GetCommand();
    665             if( keyword.size() == 0 )
    666             {
    667                 keyword = cmdLine.GetParameter();
    668             }
    669             std::cout << keyword << " コマンドとして認識できません。" << std::endl;
    670             return false;
    671         }
    672     }
    673 
    674     return true;
    675 }
    676 
    677570void _Test()
    678571{
     
    704597    pobj_nv->load();
    705598
    706     bool isFromEditor;
    707     if( !AnalysisCommandLines( isFromEditor ) )
     599    if( !program.AnalysisCommandLines() )
    708600    {
    709601        // コマンドラインが不正
     
    712604
    713605    //ソースファイル名が与えられなかったとき
    714     if(SourceFileName[0]=='\0'){
    715         if(!GetFilePathDialog(0,SourceFileName,BasicFileFilter,"コンパイルするファイルを指定して下さい",1))
     606    if( program.GetSourceFilePath().size() == 0 )
     607    {
     608        char temp[MAX_PATH];
     609        if(!GetFilePathDialog(0,temp,BasicFileFilter,"コンパイルするファイルを指定して下さい",1))
     610        {
    716611            return 0;
     612        }
     613        program.SetSourceFilePath( temp );
    717614    }
    718615
    719616    //出力ファイル名が与えられなかったとき
    720     if(OutputFileName[0]=='\0'){
    721         _splitpath(SourceFileName,OutputFileName,temporary,temp2,0);
    722         lstrcat(OutputFileName,temporary);
    723         lstrcat(OutputFileName,temp2);
     617    if( program.GetOutputFilePath().size() == 0 )
     618    {
     619        char tempOutputFileName[MAX_PATH];
     620        _splitpath( program.GetSourceFilePath().c_str(), tempOutputFileName,temporary,temp2,0);
     621        lstrcat(tempOutputFileName,temporary);
     622        lstrcat(tempOutputFileName,temp2);
    724623        if( compiler.IsStaticLibrary() )
    725624        {
    726             if( bDebugRun || compiler.IsDebug() )
     625            if( program.IsDebugRun() || compiler.IsDebug() )
    727626            {
    728                 lstrcat(OutputFileName,"_debug.abobj");
     627                lstrcat(tempOutputFileName,"_debug.abobj");
    729628            }
    730629            else
    731630            {
    732                 lstrcat(OutputFileName,".abobj");
     631                lstrcat(tempOutputFileName,".abobj");
    733632            }
    734633        }
    735634        else
    736635        {
    737             if( bDebugRun || compiler.IsDebug() )
     636            if( program.IsDebugRun() || compiler.IsDebug() )
    738637            {
    739                 lstrcat(OutputFileName,"_debug.exe");
     638                lstrcat(tempOutputFileName,"_debug.exe");
    740639            }
    741640            else
    742641            {
    743                 lstrcat(OutputFileName,".exe");
    744             }
    745         }
     642                lstrcat(tempOutputFileName,".exe");
     643            }
     644        }
     645
     646        program.SetOutputFilePath( tempOutputFileName );
    746647    }
    747648
     
    751652
    752653        // インクルードディレクトリが指定されなかったとき
    753         if(szIncludeDir[0]=='\0'){
    754             lstrcpy(szIncludeDir,".\\Include\\");
    755 
    756             // インクルードディレクトリを絶対パスに変更
    757             GetFullPath(szIncludeDir,baseDirPath.c_str());
     654        if( program.GetIncludeDir().size() == 0 )
     655        {
     656            program.SetIncludeDir( Jenga::Common::Path::MakeFullPath( ".\\Include\\", baseDirPath ) );
    758657        }
    759658        else
    760659        {
    761660            // インクルードディレクトリを絶対パスに変更
    762             GetFullPath(szIncludeDir,baseDirPath.c_str());
     661            program.SetIncludeDir( Jenga::Common::Path::MakeFullPath( program.GetIncludeDir(), baseDirPath ) );
    763662        }
    764663
    765664        // ソースファイル名を絶対パスに変換
    766         GetFullPath(SourceFileName,baseDirPath.c_str());
     665        program.SetSourceFilePath( Jenga::Common::Path::MakeFullPath( program.GetSourceFilePath(), baseDirPath ) );
    767666
    768667        // 出力ファイル名を絶対パスに変換
    769         GetFullPath(OutputFileName,baseDirPath.c_str());
     668        program.SetOutputFilePath( Jenga::Common::Path::MakeFullPath( program.GetOutputFilePath(), baseDirPath ) );
    770669
    771670        // モジュール名をセット
    772         compiler.SetModuleName( Jenga::Common::Path( OutputFileName ).GetFileName() );
    773     }
    774 
    775     if( compiler.IsDll() ){
     671        compiler.SetModuleName( Jenga::Common::Path( program.GetOutputFilePath() ).GetFileName() );
     672    }
     673
     674    if( compiler.IsDll() )
     675    {
    776676        //DLLファイル名を取得
    777         _splitpath(OutputFileName,NULL,NULL,szDllName,temporary);
     677        _splitpath( program.GetOutputFilePath().c_str(),NULL,NULL,szDllName,temporary);
    778678        lstrcat(szDllName,temporary);
    779679    }
    780680
    781     if(bDebugRun){
     681    if( program.IsDebugRun() )
     682    {
    782683        //コマンドライン、DLLの実行可能アプリケーションを取得
    783684        HANDLE hFile;
     
    805706    }
    806707
    807     _splitpath(SourceFileName,BasicCurDir,temporary,NULL,NULL);
     708    _splitpath( program.GetSourceFilePath().c_str(), BasicCurDir,temporary,NULL,NULL);
    808709    lstrcat(BasicCurDir,temporary);
    809710
    810     if(bClipCompileView){
     711    if( program.IsClipCompileView() ){
    811712        //ProjectEditor埋め込み型インターフェイス
    812713        hMainDlg=CreateDialog(hInst,MAKEINTRESOURCE(IDD_CLIPMAIN),hOwnerEditor,(DLGPROC)DlgCompile);
     
    840741    SetWindowLongPtr(GetDlgItem(hMainDlg,IDC_DEBUGLIST),GWLP_WNDPROC,(LONG_PTR)DebugListProc);
    841742
    842     if( isFromEditor )
     743    if( program.IsKickedFromEditor() )
    843744    {
    844745        SendMessage(hMainDlg,WM_COMMAND,IDOK,0);
     
    861762#endif
    862763
    863     if(bClipCompileView){
     764    if( program.IsClipCompileView() ){
    864765        SendMessage(hOwnerEditor,WM_DESTROYCOMPILEVIEW,0,0);
    865766    }
Note: See TracChangeset for help on using the changeset viewer.