home *** CD-ROM | disk | FTP | other *** search
- // Parseraw.cpp : implementation file
- //
-
- #include "stdafx.h"
- #include "Parser.h"
- #include "Parseraw.h"
- #include "chooser.h"
- #include <comdef.h>
-
- #ifdef _PSEUDO_DEBUG
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
- IApplication *iapp = 0;
- // This is called immediately after the custom AppWizard is loaded. Initialize
- // the state of the custom AppWizard here.
- void CParserAppWiz::InitCustomAppWiz()
- {
- // Create a new dialog chooser; CDialogChooser's constructor initializes
- // its internal array with pointers to the steps.
- m_pChooser = new CDialogChooser;
-
- // Set the maximum number of steps.
- SetNumberOfSteps(LAST_DLG);
- // SetNumberOfSteps(0);
-
- // TODO: Add any other custom AppWizard-wide initialization here.
- }
-
- // This is called just before the custom AppWizard is unloaded.
- void CParserAppWiz::ExitCustomAppWiz()
- {
- // Deallocate memory used for the dialog chooser
- ASSERT(m_pChooser != NULL);
- delete m_pChooser;
- m_pChooser = NULL;
- // TODO: Add code here to deallocate resources used by the custom AppWizard
-
- CString s;
- CString c_only;
- m_Dictionary.Lookup(_T("root"),s);
- m_Dictionary.Lookup(_T("C_ONLY"),c_only);
-
- if (c_only.IsEmpty())
- {
- DeleteFile(s+".cpp");
- DeleteFile(s+".l.cpp");
- DeleteFile(s+".cpp.h");
- }
- else
- {
- DeleteFile(s+".tab.c");
- DeleteFile(s+".l.c");
- DeleteFile(s+".tab.h");
- }
- //CopyFile(s+"_tmp.dsp", s+".dsp", FALSE);
- //DeleteFile(s+"_tmp.dsp");
-
- if (iapp!=0)
- {
- //ReloadProject(iapp);
- iapp->Release();
- }
-
-
- }
-
- // This is called when the user clicks "Create..." on the New Project dialog
- // or "Next" on one of the custom AppWizard's steps.
- CAppWizStepDlg* CParserAppWiz::Next(CAppWizStepDlg* pDlg)
- {
- // Delegate to the dialog chooser
- return m_pChooser->Next(pDlg);
- }
-
- // This is called when the user clicks "Back" on one of the custom
- // AppWizard's steps.
- CAppWizStepDlg* CParserAppWiz::Back(CAppWizStepDlg* pDlg)
- {
- // Delegate to the dialog chooser
- return m_pChooser->Back(pDlg);
- }
-
- void CParserAppWiz::CustomizeProject(IBuildProject* pProject)
- {
- // TODO: Add code here to customize the project. If you don't wish
- // to customize project, you may remove this virtual override.
-
- // This is called immediately after the default Debug and Release
- // configurations have been created for each platform. You may customize
- // existing configurations on this project by using the methods
- // of IBuildProject and IConfiguration such as AddToolSettings,
- // RemoveToolSettings, and AddCustomBuildStep. These are documented in
- // the Developer Studio object model documentation.
-
- // WARNING!! IBuildProject and all interfaces you can get from it are OLE
- // COM interfaces. You must be careful to release all new interfaces
- // you acquire. In accordance with the standard rules of COM, you must
- // NOT release pProject, unless you explicitly AddRef it, since pProject
- // is passed as an "in" parameter to this function. See the documentation
- // on CCustomAppWiz::CustomizeProject for more information.
-
- CString root;
- CString c_only;
- m_Dictionary.Lookup(_T("root"),root);
- m_Dictionary.Lookup(_T("C_ONLY"),c_only);
-
-
- IConfigurations *iCfgs; //pointer to all configurations
- IConfiguration *iSingleCfg; //pointer to a individual configuration
- long lCount; //number of configurations
- long i;
-
- pProject->get_Application((IDispatch**)&iapp);
- pProject->get_Configurations(&iCfgs);
-
-
- iCfgs->get_Count(&lCount);
-
- for(i=0;i<lCount;i++) // walk through all configurations
- { COleVariant cv(i+1L); // one-based index!!!
- COleVariant cvReserved("");
-
- iCfgs->Item(cv,&iSingleCfg);
-
- /* BSTR bstr;
- iCfgs->get_Name(&bstr);
- _bstr_t bsLoc = bstr;
- char* lpStr = (char*)bsLoc;
- AfxMessageBox(lpStr);
- */
- // use wide-character strings...
- iSingleCfg->RemoveToolSettings(L"link.exe",L"/subsystem:windows",cvReserved);
- // iSingleCfg->AddCustomBuildStep(L"aaa",L"bb",L"CCC",cvReserved);
- iSingleCfg->AddToolSettings(L"link.exe",L"libflex.lib",cvReserved);
- iSingleCfg->AddToolSettings(L"cl.exe",L"/DYY_NEVER_INTERACTIVE",cvReserved);
-
- // _bstr_t lcommand("flex.exe " + s + ".l");
- // _bstr_t lout(s + "l.c");
- // iSingleCfg->AddCustomBuildStepToFile ( lfile, lcommand, lout, L"building lexer", cvReserved);
-
- _bstr_t lfile(root + ".l");
- _bstr_t yfile(root + ".y");
-
- if (c_only.IsEmpty())
- {
- _bstr_t lcommand("flex.exe -P" + root + " -t $(InputName).l > $(InputName).l.cpp");
- iSingleCfg->AddCustomBuildStepToFile (lfile, lcommand, L"$(InputName).l.cpp", L"Building Lexer", cvReserved);
- _bstr_t ycommand("bison.exe -p" + root + " -o " + root + ".cpp -d $(InputName).y");
- iSingleCfg->AddCustomBuildStepToFile (yfile, ycommand, L"$(InputName).cpp", L"Building Parser", cvReserved);
- }
- else
- {
- _bstr_t lcommand("flex.exe -P" + root + " -t $(InputName).l > $(InputName).l.c");
- iSingleCfg->AddCustomBuildStepToFile (lfile, lcommand, L"$(InputName).l.c", L"Building Lexer", cvReserved);
- _bstr_t ycommand("bison.exe -p" + root + " -d $(InputName).y");
- iSingleCfg->AddCustomBuildStepToFile (yfile, ycommand, L"$(InputName).tab.c", L"Building Parser", cvReserved);
- }
-
- iSingleCfg->Release();
- }
-
- iCfgs->Release();
- }
-
- void CParserAppWiz::ReloadProject(IApplication * app)
- {
- IDocuments *idocs;
- IGenericProject *iprj;
- app->get_ActiveProject((IDispatch**)&iprj);
- // iprj->AddRef();
- BSTR name;
- iprj->get_FullName(&name);
- _bstr_t bsLoc = name;
-
- char* lpStr = (char*)bsLoc;
- char *p = strstr(lpStr, "dsp");
- p[2] = 'w';
- DeleteFile(lpStr);
- // char aaa[100];
- // strcpy(aaa, lpStr);
- // BSTR name1 = (BSTR)(_bstr_t)aaa;
-
- /* _bstr_t bsLoc1 = name1;
- char* lpStr1 = (char*)bsLoc1;
- AfxMessageBox(lpStr1);
- */
- app->get_Documents((IDispatch**)&idocs);
- // idocs->AddRef();
- IGenericDocument *aa;
- COleVariant openas("Auto");
- COleVariant ro(0L);
- // idocs->CloseAll(ro,0);
- idocs->Open(name,openas,ro,(IDispatch**)&aa);
- // DsSaveStatus ss;
- // COleVariant ro1(0L);
- // aa->Close(ro1, 0);
- // aa->Release();
- // idocs->Open(name1,openas,ro,(IDispatch**)&aa);
- // aa->Release();
- idocs->Release();
- iprj->Release();
-
-
-
- }
-
- // Here we define one instance of the CParserAppWiz class. You can access
- // m_Dictionary and any other public members of this class through the
- // global Parseraw.
- CParserAppWiz Parseraw;
-
-