diff options
Diffstat (limited to 'autodoc/source/exes')
-rw-r--r-- | autodoc/source/exes/adc_uni/adc_cl.cxx | 451 | ||||
-rw-r--r-- | autodoc/source/exes/adc_uni/adc_cmds.cxx | 578 | ||||
-rw-r--r-- | autodoc/source/exes/adc_uni/adc_cmds.hxx | 433 | ||||
-rw-r--r-- | autodoc/source/exes/adc_uni/cmd_run.cxx | 492 | ||||
-rw-r--r-- | autodoc/source/exes/adc_uni/cmd_run.hxx | 164 | ||||
-rw-r--r-- | autodoc/source/exes/adc_uni/main.cxx | 93 | ||||
-rw-r--r-- | autodoc/source/exes/adc_uni/makefile.mk | 146 |
7 files changed, 2357 insertions, 0 deletions
diff --git a/autodoc/source/exes/adc_uni/adc_cl.cxx b/autodoc/source/exes/adc_uni/adc_cl.cxx new file mode 100644 index 000000000000..226dee45ed8a --- /dev/null +++ b/autodoc/source/exes/adc_uni/adc_cl.cxx @@ -0,0 +1,451 @@ +/************************************************************************* + * + * $RCSfile: adc_cl.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: np $ $Date: 2002-03-08 14:45:26 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + + +#include <precomp.h> +#include <adc_cl.hxx> + + +// NOT FULLY DEFINED SERVICES +#include "adc_cmds.hxx" + + +namespace autodoc +{ + +CommandLine * CommandLine::pTheInstance_ = 0; + + +const char * const C_sUserGuide = + +"\n\n\n" +" Use of Autodoc\n" +" --------------\n" +"\n" +" Example for C++:\n" +"\n" +" -html <OutputDirectory> -name \"UDK 3.x anything\" -lg c++\n" +" -p <ProjName> <ProjectRootDirectory>\n" +" -t <SourceDir_relativeToProjectRoot>\n" +"\n" +" There may be several Projects specified by -p.\n" +"\n" +"\n" +" Example for IDL:\n" +"\n" +" -html <OutputDirectory> -name \"UDK 3.x anything\" -lg idl\n" +" -t <SourceDir1> <SourceDir2>\n" +"\n" +"\n" +" For both languages, instead of or in addition to -t may be\n" +" used -d (no subdirectories) or -f (just one file). There can\n" +" be multiple arguments after each of these options (-t -d -f).\n"; + + +#if 0 // FUTURE +"\n\n\n" +" Use of Autodoc\n" +" --------------\n" +"\n" +" Basics:\n" +"\n" +" Autodoc may perform different tasks.\n" +"\n" +" Possible tasks are\n" +" - parsing source code\n" +" - creating HTML-output.\n" +" On the command line each task starts with a specific\n" +" option:\n" +" '-parse' for parsing source code,\n" +" '-html' for creating HTML.\n" +" All command line options, related to one task, have to follow before\n" +" the starting option of the next task.\n" +"\n" +" Within the task '-parse', there may be defined different projects.\n" +" A project definition is started with '-p'.\n" +" All not project specific options within the task '-parse' have to\n" +" appear in front of the first '-p'.\n" +" There can be no project at all. Then all options, available for\n" +" projects, can be used like for one nameless default project, without using\n" +" '-p', but these options still have to appear behind all other\n" +" options of the task '-parse'.\n" +"\n" +"\n" +" Legend:\n" +"\n" +" <SomeText> Describes an argument.\n" +" 'SomeText' Within '...' is the literal value of an argument.\n" +" + There can be multiple arguments.\n" +" | Separator for alternative literal values of an argument.\n" +"\n" +"\n" +" Syntax:\n" +"\n" +" -parse\n" +" -name <RepositoryName>]\n" +" -lg 'c++'|'idl'\n" +" -extg <AdditonalExtensions>+\n" +" -docg 'usehtml'\n" +" -p <ProjectName> <ProjectRootDir>\n" +" -l 'c++'|'idl'\n" +" -ext <AdditonalExtensions>+\n" +" -doc 'usehtml'\n" +" -d <SourceDir_relative2ProjectRootDir_nosubdirs>+\n" +" -t <SourceTree_relative2ProjectRootDir>+\n" +" -f <SourceFile_relative2ProjectRootDir>+\n" +" -html <OutputDir>\n" +" -xlinks <Namespace> <ExternLinksRootDir>\n" +" -i <CommandFilePath>\n" +" -v <VerboseNr>\n" +"\n" +"\n" +" Detailed Options Description:\n" +"\n" +" Option Arguments\n" +" ----------------------------------------------------------\n" +"\n" +" -parse \n\n" +" Starts the task \"Parse source code\".\n" +" May be omitted, if it would be the first option on the\n" +" command line.\n" +"\n" +" -name <RepositoryName>\n\n" +" This name is used for naming the repository in\n" +" human readable output. In future it may be used also for\n" +" identifiing a repository in searches.\n" +"\n" +" -lg 'c++|'idl'\n\n" +" Identifies the programming language to be parsed.\n" +" 'c++': C++\n" +" Files with extensions '.h', '.hxx' are parsed.\n" +" 'idl': UNO-IDL\n" +" Files with extensions '.idl' are parsed.\n" +" Here the language is set globally for all projects.\n" +" A project can override this by using '-l'.\n" +"\n" +" -extg <.AdditionalExtension>+\n\n" +" Has to follow immediately behind '-lg'.\n" +" Specifies additional extensions, that will be recognised as\n" +" source code files of the previously specified programming\n" +" language. Each extension has to start with '.'.\n" +" It is possible to include extensionless files, too,\n" +" by the argument '.'\n" +" Here these extensions are set globally for all projects.\n" +" A project can override this by using '-l' and '-ext'.\n" +"\n" +" -docg 'html'|'nohtml'\n\n" +" Specifies the default for all comments in source code, so \n" +" that HTML-tags are interpreted as such or else treated as\n" +" regular text.\n" +" Without this option, the default is 'nohtml'.\n" +" Here the default is set globally for all projects.\n" +" A project can override this by using '-doc'.\n" +"\n" +" -p <ProjectName> <ProjectRootDirectory>\n\n" +" ProjectName is used in output as human readable identifier\n" +" for the project. ProjectRootDirectory is the path,\n" +" where the arguments of '-d', '-t' and '-f' are relative to.\n" +" This option can be omitted, then there is no project name\n" +" and all paths are relative to the current working directory.\n" +"\n" +" -l 'c++|'idl'\n\n" +" Overrides -lg and -extg for the current project, which is\n" +" specified by the last previous '-p'.\n" +" For details see at option '-lg'.\n" +"\n" +" -ext <.AdditionalExtension>+\n\n" +" Can be used only immediately behind '-l'.\n" +" Overrides -extg for the current project, which is\n" +" specified by the last previous '-p'.\n" +" For details see at option '-extg'.\n" +"\n" +" -doc 'html'|'nohtml'\n\n" +" Overrides -docg for the current project, which is\n" +" specified by the last previous '-p'.\n" +" For details see at option '-docg'.\n" +"\n" +" -d <SourceDir_relative2ProjectRootDir_nosubdirs>+\n\n" +" For the current project all files in the given\n" +" directories are parsed, which have valid extensions.\n" +" Subdirectories are NOT parsed.\n" +"\n" +" -t <SourceTree_relative2ProjectRootDir>+\n\n" +" For the current project all files in the given\n" +" directories AND its subdirectories are parsed, which\n" +" have valid extensions.\n" +"\n" +" -f <SourceFile_relative2ProjectRootDir>+\n\n" +" For the current project and language the given files\n" +" are parsed. It doesn't matter, if their extensions match\n" +" the valid extensions.\n" +"\n" +" -html <OutputRootDir>\n\n" +" Starts the task \"Create HTML output\".\n" +"\n" +" -xlinks <Namespace> <ExternLinksRootDir>\n\n" +" This option allows, to create links to external\n" +" HTML-documents.\n" +" For all source code objects (like classes or functions)\n" +" which belong in the given namespace, the given root\n" +" directory is used as a base for links to them.\n" +" Presently, this works only for C++-mappings of IDL-items.\n" +" The given namespace has to be absolute.\n" +"\n" +" -i <CommandFilePath>\n\n" +" This option is replaced by the contents of the given\n" +" file. The file has to be ASCII and each option\n" +" has to start in the first column of a new line.\n" +" So each valid line starts with a '-'.\n" +" Empty lines are allowed.\n" +" Comment lines have to start with '#'\n" +"\n" +" -v <VerboseNumber>\n\n" +" Show details during parsing:\n" +" 2 shows each parsed letter,\n" +" 4 shows stored objects.\n" +" 1 shows recognised tokens.\n" +" These bit-values can be combined.\n" +" This option suppresses errors, because of\n" +" missing output options (no '-html').\n"; +#endif // 0, FUTURE + + +CommandLine::CommandLine() + : nDebugStyle(0), + // pCmd_Parse, + // pCmd_Load, + // pCmd_CreateHtml, + // pCmd_CreateXml, + // pCmd_Save, + pCurProject(0), + bInitOk(false) +{ + csv_assert(pTheInstance_ == 0); + pTheInstance_ = this; +} + +CommandLine::~CommandLine() +{ + pTheInstance_ = 0; +} + +void +CommandLine::SetUpdate( const char * i_sRepositoryDir ) +{ + if ( pCmd_Load ) + { + if ( strcmp(pCmd_Load->ReposyDir(), i_sRepositoryDir) != 0 ) + { + StreamLock slMsg(200); + throw command::X_CommandLine( + slMsg() << "Different repository directories with options " + << command::C_opt_Load + << " and " + << command::C_opt_Update + << "." + << c_str ); + } + } + else + { + pCmd_Load = new command::Load(i_sRepositoryDir); + } +} + +void +CommandLine::SetCurProject( command::S_ProjectData & io_rProject ) +{ + pCurProject = &io_rProject; +} + +command::S_ProjectData & +CommandLine::CurProject() +{ + if (pCurProject == 0) + { + if ( NOT pCmd_Parse ) + { + pCmd_Parse = new command::Parse(*this); + } + pCurProject = &pCmd_Parse->CreateDefaultProject(); + } + + return *pCurProject; +} + +const CommandLine & +CommandLine::Get_() +{ + csv_assert(pTheInstance_ != 0); + return *pTheInstance_; +} + +void +CommandLine::do_Init( int argc, + char * argv[] ) +{ + bInitOk = false; + + try + { + + char * * itEnd = &argv[0] + argc; + for ( char * * it = &argv[1]; it != itEnd; ) + { + if ( strcmp(*it, command::C_opt_Verbose) == 0 ) + { + ++it; + if ( NOT(it != itEnd && **it >= '0' && **it <= '9') ) + { + StreamLock slMsg(200); + throw command::X_CommandLine( + slMsg() << "Missing number after " + << command::C_opt_Verbose + << "." + << c_str ); + } + + nDebugStyle = int(**it - '0'); + ++it; + } + else if ( strcmp(*it, command::C_opt_Load) == 0 ) + { + pCmd_Load = new command::Load; + it = pCmd_Load->Init(it, itEnd); + } + else if ( strcmp(*it, command::C_opt_CreateHtml) == 0 ) + { + pCmd_CreateHtml = new command::CreateHtml; + it = pCmd_CreateHtml->Init(it, itEnd); + } + else if ( strcmp(*it, command::C_opt_CreateXml) == 0 ) + { + pCmd_CreateXml = new command::CreateXml; + it = pCmd_CreateXml->Init(it, itEnd); + } + else if ( strcmp(*it, command::C_opt_Save) == 0 ) + { + pCmd_Save = new command::Save; + it = pCmd_Save->Init(it, itEnd); + } + else + { + pCmd_Parse = new command::Parse(*this); + char * * result = pCmd_Parse->Init(it, itEnd); + if (result == it) + { + StreamLock slMsg(200); + throw command::X_CommandLine( + slMsg() << "Unknown comand line option: '" + << *it + << "' ." + << c_str ); + } + else + it = result; + } + } // end for + + bInitOk = true; + + } // end try + catch ( command::X_CommandLine & xxx ) + { + xxx.Report( Cerr() ); + } + catch ( ... ) + { + Cerr() << "Unknown error during command line parsing." << Endl(); + } + +} + +void +CommandLine::do_PrintUse() const +{ + Cout() << C_sUserGuide << Endl(); +} + +bool +CommandLine::inq_CheckParameters() const +{ + if ( NOT pCmd_Parse AND NOT pCmd_Load) + return false; + if ( pCmd_Parse ) + { + if ( pCmd_Parse->GlobalLanguageInfo() == 0 ) + { + Cerr() << "Missing language option (" + << command::C_opt_LangAll + << ") in command line" + << Endl(); + return false; + } + } + if ( NOT pCmd_Save AND NOT pCmd_CreateHtml AND NOT pCmd_CreateXml + AND nDebugStyle == 0 ) + return false; + return bInitOk; +} + + +} // namespace autodoc + diff --git a/autodoc/source/exes/adc_uni/adc_cmds.cxx b/autodoc/source/exes/adc_uni/adc_cmds.cxx new file mode 100644 index 000000000000..785396783d15 --- /dev/null +++ b/autodoc/source/exes/adc_uni/adc_cmds.cxx @@ -0,0 +1,578 @@ +/************************************************************************* + * + * $RCSfile: adc_cmds.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: np $ $Date: 2002-03-08 14:45:26 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + + +#include <precomp.h> +#include "adc_cmds.hxx" + + +// NOT FULLY DEFINED SERVICES +#include <cosv/template/tpltools.hxx> +#include <cosv/ploc.hxx> +#include "adc_cl.hxx" + + + +namespace autodoc +{ +namespace command +{ + +Parse::InitMap Parse::aOptions_; + + + +inline bool +is( char * * pArgsIterator, const char * pOption ) +{ + return strcmp(*pArgsIterator, pOption) == 0; +} + +#define CHECK( cond, text ) \ + if ( NOT ( cond ) ) \ + throw X_CommandLine( text ) +#define CHECKOPT( cond, miss, opt ) \ + if ( NOT ( cond ) ) \ + { \ + StreamLock slMsg(100); \ + throw X_CommandLine( slMsg() << "Missing " << miss <<" after " << opt << "." << c_str ); \ + } + + +//************************** Parsing ***********************// + + +S_ProjectData::S_ProjectData( const char * i_sName, + const char * i_sRootDir ) + : sName(i_sName), + aRootDirectory(i_sRootDir,true), + // pLanguage, + bHtmlIsDefaultForDocs(false) + // aFiles +{ +} + +S_ProjectData::~S_ProjectData() +{ +} + +Parse::Parse( CommandLine & io_rCommandLine ) + : // sRepositoryName, + // sRepositoryDirectoryForUpdate + // pGlobal_Language + bGlobal_HtmlIsDefaultForDocs(false), + // aProjects, + pCommandLine(&io_rCommandLine) +{ +} + +Parse::~Parse() +{ + csv::erase_container_of_heap_ptrs(aProjects); +} + +S_ProjectData & +Parse::CreateDefaultProject() +{ + if ( aProjects.size() > 0 ) + throw new X_CommandLine("Unexpected default project in command line."); + + S_ProjectData * ret = new S_ProjectData("", "."); + aProjects.push_back(ret); + return *ret; +} + +char * * +Parse::do_Init( char * * i_nCurArgsBegin, + char * * i_nEndOfAllArgs ) +{ + for ( char * * it = i_nCurArgsBegin; + it != i_nEndOfAllArgs; + ) + { + F_Init fi = FindFI(*it); + if (fi != 0) + it = (this->*fi)(it, i_nEndOfAllArgs); + } + + return it; +} + + +const Parse::InitMap & +Parse::Options() +{ + if ( aOptions_.size() > 0 ) + return aOptions_; + + aOptions_[udmstri(C_opt_Parse)] = &Parse::FI_Start_ParseOptions; + aOptions_[udmstri(C_opt_Name)] = &Parse::FI_SetName; + aOptions_[udmstri(C_opt_Update)] = &Parse::FI_SetUpdate; + aOptions_[udmstri(C_opt_LangAll)] = &Parse::FI_SetLanguage4All; + aOptions_[udmstri(C_opt_ExtensionsAll)] = &Parse::FI_SetExtensions4All; + aOptions_[udmstri(C_opt_DocAll)] = &Parse::FI_SetDocAttrs4All; + + aOptions_[udmstri(C_opt_Project)] = &Parse::FI_Start_ProjectOptions; + aOptions_[udmstri(C_opt_Lang)] = &Parse::FI_SetLanguage; + aOptions_[udmstri(C_opt_Extensions)] = &Parse::FI_SetExtensions; + aOptions_[udmstri(C_opt_Doc)] = &Parse::FI_SetDocAttrs; + aOptions_[udmstri(C_opt_SourceDir)] = &Parse::FI_SetSourceDirs; + aOptions_[udmstri(C_opt_SourceTree)] = &Parse::FI_SetSourceTrees; + aOptions_[udmstri(C_opt_SourceFile)] = &Parse::FI_SetSourceFiles; + + return aOptions_; +} + +Parse::F_Init +Parse::FindFI( const char * i_pArg ) const +{ + InitMap::const_iterator itFound = Options().find( udmstri(i_pArg) ); + if ( itFound == Options().end() ) + return 0; + + return (*itFound).second; +} + +char * * +Parse::FI_Start_ParseOptions( char * * i_nCurArgsBegin, + char * * i_nEndOfAllArgs ) +{ + return i_nCurArgsBegin + 1; +} + +char * * +Parse::FI_SetName( char * * i_nCurArgsBegin, + char * * i_nEndOfAllArgs ) +{ + char * * ret = i_nCurArgsBegin + 1; + CHECKOPT( **ret != '-' && ret != i_nEndOfAllArgs, + "name", C_opt_Name ); + + sRepositoryName = *ret; + return ++ret; +} + +char * * +Parse::FI_SetUpdate( char * * i_nCurArgsBegin, + char * * i_nEndOfAllArgs ) +{ + char * * ret = i_nCurArgsBegin + 1; + CHECKOPT( **ret != '-' && ret != i_nEndOfAllArgs, + "directory", C_opt_Update ); + + sRepositoryDirectoryForUpdate = *ret; + pCommandLine->SetUpdate(*ret); + return ++ret; +} + +char * * +Parse::FI_SetLanguage4All( char * * i_nCurArgsBegin, + char * * i_nEndOfAllArgs ) +{ + char * * ret = i_nCurArgsBegin + 1; + + if ( is(ret, C_arg_Cplusplus) ) + { + pGlobal_Language = new S_LanguageInfo(S_LanguageInfo::cpp); + pGlobal_Language->aExtensions.push_back(udmstri("*.hxx")); + pGlobal_Language->aExtensions.push_back(udmstri("*.h")); + } + else if (is(ret, C_arg_Idl) ) + { + pGlobal_Language = new S_LanguageInfo(S_LanguageInfo::idl); + pGlobal_Language->aExtensions.push_back(udmstri("*.idl")); + } + else if (is(ret, C_arg_Corba) ) + { + pGlobal_Language = new S_LanguageInfo(S_LanguageInfo::corba); + pGlobal_Language->aExtensions.push_back(udmstri("*.idl")); + } + else if (is(ret, C_arg_Java) ) + { + pGlobal_Language = new S_LanguageInfo(S_LanguageInfo::java); + pGlobal_Language->aExtensions.push_back(udmstri("*.java")); + } + else + { + StreamLock slMsg(100); + throw X_CommandLine( + slMsg() << "Missing language after " << C_opt_LangAll << "." << c_str ); + } + + return ++ret; +} + +char * * +Parse::FI_SetExtensions4All( char * * i_nCurArgsBegin, + char * * i_nEndOfAllArgs ) +{ + char * * ret = i_nCurArgsBegin + 1; + CHECKOPT( ret != i_nEndOfAllArgs && **ret == '.', + "extension(s)", C_opt_ExtensionsAll ); + StreamLock slCheck(150); + slCheck() << C_opt_ExtensionsAll + << " used without previous " + << C_opt_LangAll; + + CHECK( pGlobal_Language != 0, + slCheck().c_str() ); + + do { + pGlobal_Language->aExtensions.push_back(udmstri(*ret)); + ++ret; + } while ( ret != i_nEndOfAllArgs && **ret == '.' ); + + return ret; +} + +char * * +Parse::FI_SetDocAttrs4All( char * * i_nCurArgsBegin, + char * * i_nEndOfAllArgs ) +{ + char * * ret = i_nCurArgsBegin + 1; + CHECKOPT( ret != i_nEndOfAllArgs && **ret != '-', + "attribute", C_opt_DocAll ); + + if ( is(ret, C_arg_Usehtml) ) + { + bGlobal_HtmlIsDefaultForDocs = true; + ++ret; + } + else + { + throw X_CommandLine( + StreamLock(100)() << "Unknown attribute after " + << C_opt_DocAll + << "." + << c_str ); + } + + return ret; +} + +char * * +Parse::FI_Start_ProjectOptions( char * * i_nCurArgsBegin, + char * * i_nEndOfAllArgs ) +{ + if ( aProjects.size() == 1 ) + { + if ( aProjects[0]->sName.length() == 0 ) + throw X_CommandLine( "Both, named projects and a default project, cannot be used together." ); + } + + S_ProjectData * pProject = 0; + + char * * ret = i_nCurArgsBegin + 1; + CHECKOPT( ret != i_nEndOfAllArgs && **ret != '-', + "name", C_opt_Project ); + ++ret; + CHECKOPT( ret != i_nEndOfAllArgs && **ret != '-', + "root directory", C_opt_Project ); + ++ret; + + pProject = new S_ProjectData( i_nCurArgsBegin[1], i_nCurArgsBegin[2] ); + pCommandLine->SetCurProject(*pProject); + aProjects.push_back(pProject); + + return ret; +} + +char * * +Parse::FI_SetLanguage( char * * i_nCurArgsBegin, + char * * i_nEndOfAllArgs ) +{ + char * * ret = i_nCurArgsBegin + 1; + + if ( is(ret, C_arg_Cplusplus) ) + pCommandLine->CurProject().pLanguage + = new S_LanguageInfo(S_LanguageInfo::cpp); + else if (is(ret, C_arg_Idl) ) + pCommandLine->CurProject().pLanguage + = new S_LanguageInfo(S_LanguageInfo::idl); + else if (is(ret, C_arg_Corba) ) + pCommandLine->CurProject().pLanguage + = new S_LanguageInfo(S_LanguageInfo::corba); + else if (is(ret, C_arg_Java) ) + pCommandLine->CurProject().pLanguage + = new S_LanguageInfo(S_LanguageInfo::java); + else + throw X_CommandLine( + StreamLock(100)() << "Missing language after " + << C_opt_Lang + << "." + << c_str ); + + return ++ret; +} + +char * * +Parse::FI_SetExtensions( char * * i_nCurArgsBegin, + char * * i_nEndOfAllArgs ) +{ + char * * ret = i_nCurArgsBegin + 1; + + CHECKOPT( ret != i_nEndOfAllArgs && **ret == '.', + "extension(s)", C_opt_Extensions ); + CHECK( pCommandLine->CurProject().pLanguage != 0, + StreamLock(100)() << C_opt_Extensions + << " used without previous " + << C_opt_Lang + << c_str ); + + do { + pCommandLine->CurProject().pLanguage + ->aExtensions.push_back(udmstri(*ret)); + ++ret; + } while ( ret != i_nEndOfAllArgs && **ret == '.' ); + + return ret; +} + +char * * +Parse::FI_SetDocAttrs( char * * i_nCurArgsBegin, + char * * i_nEndOfAllArgs ) +{ + char * * ret = i_nCurArgsBegin + 1; + + CHECKOPT( ret != i_nEndOfAllArgs && **ret != '-', + "attribute", C_opt_Doc ); + + if ( is(ret, C_arg_Usehtml) ) + { + pCommandLine->CurProject().bHtmlIsDefaultForDocs = true; + ++ret; + } + else + { + throw X_CommandLine( + StreamLock(100)() << "Unknown attribute after " + << C_opt_Doc + << "." + << c_str ); + } + + return ret; +} + +char * * +Parse::FI_SetSourceDirs( char * * i_nCurArgsBegin, + char * * i_nEndOfAllArgs ) +{ + char * * ret = i_nCurArgsBegin + 1; + CHECKOPT( ret != i_nEndOfAllArgs && **ret != '-', + "directory", C_opt_SourceDir ); + do { + pCommandLine->CurProject().aFiles. + aDirectories.push_back( udmstri(*ret) ); + ++ret; + } while (ret != i_nEndOfAllArgs && **ret != '-'); + + return ret; +} + +char * * +Parse::FI_SetSourceTrees( char * * i_nCurArgsBegin, + char * * i_nEndOfAllArgs ) +{ + char * * ret = i_nCurArgsBegin + 1; + CHECKOPT( ret != i_nEndOfAllArgs && **ret != '-', + "directory", C_opt_SourceTree ); + do { + pCommandLine->CurProject().aFiles. + aTrees.push_back( udmstri(*ret) ); + ++ret; + } while (ret != i_nEndOfAllArgs && **ret != '-'); + + return ret; +} + +char * * +Parse::FI_SetSourceFiles( char * * i_nCurArgsBegin, + char * * i_nEndOfAllArgs ) +{ + char * * ret = i_nCurArgsBegin + 1; + CHECKOPT( ret != i_nEndOfAllArgs && **ret != '-', + "file", C_opt_SourceFile ); // KORR_FUTURE + // What about files, which start with '-'? + do { + pCommandLine->CurProject().aFiles. + aFiles.push_back( udmstri(*ret) ); + ++ret; + } while (ret != i_nEndOfAllArgs && **ret != '-'); // KORR_FUTURE + // What about files, which start with '-'? + return ret; +} + +//************************** Load ***********************// + +Load::Load( const char * i_sRepositoryDirectory ) + : sRepositoryDirectory(i_sRepositoryDirectory) +{ +} + +Load::~Load() +{ +} + +char * * +Load::do_Init( char * * i_nCurArgsBegin, + char * * i_nEndOfAllArgs ) +{ + char * * ret = i_nCurArgsBegin + 1; + CHECKOPT( ret != i_nEndOfAllArgs AND **ret != '-', + "directory", C_opt_Load ); + + sRepositoryDirectory = *ret; + return ++ret; +} + + + +//************************** CreateHTML ***********************// + +CreateHtml::CreateHtml() +// : // sOutputRootDirectory, + // aExtLinks +{ +} + +CreateHtml::~CreateHtml() +{ +} + +char * * +CreateHtml::do_Init( char * * i_nCurArgsBegin, + char * * i_nEndOfAllArgs ) +{ + char * * ret = i_nCurArgsBegin + 1; + CHECKOPT( ret != i_nEndOfAllArgs && **ret != '-', + "output directory", C_opt_CreateHtml ); + sOutputRootDirectory = *ret; + + if ( is(++ret, C_opt_ExternLinks) ) + { + CHECKOPT( ret+1 != i_nEndOfAllArgs && **(ret+1) != '-', + "namespace", C_opt_ExternLinks ); + CHECKOPT( ret+2 != i_nEndOfAllArgs && **(ret+2) != '-', + "linked root directory", C_opt_ExternLinks ); + do { + aExtLinks.push_back( S_ExternLinkage(*(ret+1), *(ret+2)) ); + ret += 3; + } while ( is(ret, C_opt_ExternLinks) ); + } + + return ret; +} + + +//************************** Out XML ***********************// + +CreateXml::CreateXml() +// : // sOutputRootDirectory +{ +} + +CreateXml::~CreateXml() +{ +} + +char * * +CreateXml::do_Init( char * * i_nCurArgsBegin, + char * * i_nEndOfAllArgs ) +{ + char * * ret = i_nCurArgsBegin + 1; + CHECKOPT( ret != i_nEndOfAllArgs && **ret != '-', + "output directory", C_opt_CreateXml ); + + sOutputRootDirectory = *ret; + return ++ret; +} + + +//************************** Save ***********************// + +Save::Save() +// : // sRepositoryDirectory, +{ +} + +Save::~Save() +{ +} + +char * * +Save::do_Init( char * * i_nCurArgsBegin, + char * * i_nEndOfAllArgs ) +{ + char * * ret = i_nCurArgsBegin + 1; + CHECKOPT( ret != i_nEndOfAllArgs AND **ret != '-', + "directory", C_opt_Save ); + + sRepositoryDirectory = *ret; + return ++ret; +} + + +} // namespace command +} // namespace autodoc + + + diff --git a/autodoc/source/exes/adc_uni/adc_cmds.hxx b/autodoc/source/exes/adc_uni/adc_cmds.hxx new file mode 100644 index 000000000000..210602ffeffd --- /dev/null +++ b/autodoc/source/exes/adc_uni/adc_cmds.hxx @@ -0,0 +1,433 @@ +/************************************************************************* + * + * $RCSfile: adc_cmds.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: np $ $Date: 2002-03-08 14:45:27 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef ADC_ADC_CMDS_HXX +#define ADC_ADC_CMDS_HXX + + + +// USED SERVICES + // BASE CLASSES +#include <cosv/comdline.hxx> + // COMPONENTS +#include <cosv/ploc.hxx> + // PARAMETERS + +namespace ary +{ + class Repository; +} + +namespace autodoc +{ + class CommandLine; + +namespace command +{ + + +class Command +{ + public: + virtual ~Command() {} + + /** @return The first not parsed argument. + If an error occured, 0 is returned. + */ + char * * Init( + char * * i_nCurArgsBegin, + char * * i_nEndOfAllArgs ); + private: + virtual char * * do_Init( + char * * i_nCurArgsBegin, + char * * i_nEndOfAllArgs ) = 0; +}; + +inline char * * +Command::Init( char * * i_nCurArgsBegin, + char * * i_nEndOfAllArgs ) + { return do_Init(i_nCurArgsBegin, i_nEndOfAllArgs); } + + +struct S_ProjectData; +struct S_LanguageInfo; +struct S_ExternLinkage; + +class Parse : public Command +{ + public: + typedef std::vector< DYN S_ProjectData * > ProjectList; + typedef ProjectList::const_iterator ProjectIterator; + + Parse( + CommandLine & io_rCommandLine ); + ~Parse(); + + // INQUIRY + const udmstri & ReposyName() const; + const S_LanguageInfo * + GlobalLanguageInfo() const; + bool GlobalIsHtmlDefaultForDocs() const; + ProjectIterator ProjectsBegin() const; + ProjectIterator ProjectsEnd() const; + + + // ACCESS + S_ProjectData & CreateDefaultProject(); + + private: + // Interface Command: + virtual char * * do_Init( + char * * i_nCurArgsBegin, + char * * i_nEndOfAllArgs ); + + typedef char * * (Parse::*F_Init)(char * *, char * *); + typedef std::map< udmstri , F_Init > InitMap; + + static const InitMap & + Options(); + F_Init FindFI( + const char * i_pArg ) const; + + char * * FI_Start_ParseOptions( + char * * i_nCurArgsBegin, + char * * i_nEndOfAllArgs ); + char * * FI_SetName( + char * * i_nCurArgsBegin, + char * * i_nEndOfAllArgs ); + char * * FI_SetUpdate( + char * * i_nCurArgsBegin, + char * * i_nEndOfAllArgs ); + char * * FI_SetLanguage4All( + char * * i_nCurArgsBegin, + char * * i_nEndOfAllArgs ); + char * * FI_SetExtensions4All( + char * * i_nCurArgsBegin, + char * * i_nEndOfAllArgs ); + char * * FI_SetDocAttrs4All( + char * * i_nCurArgsBegin, + char * * i_nEndOfAllArgs ); + + char * * FI_Start_ProjectOptions( + char * * i_nCurArgsBegin, + char * * i_nEndOfAllArgs ); + char * * FI_SetLanguage( + char * * i_nCurArgsBegin, + char * * i_nEndOfAllArgs ); + char * * FI_SetExtensions( + char * * i_nCurArgsBegin, + char * * i_nEndOfAllArgs ); + char * * FI_SetDocAttrs( + char * * i_nCurArgsBegin, + char * * i_nEndOfAllArgs ); + char * * FI_SetSourceDirs( + char * * i_nCurArgsBegin, + char * * i_nEndOfAllArgs ); + char * * FI_SetSourceTrees( + char * * i_nCurArgsBegin, + char * * i_nEndOfAllArgs ); + char * * FI_SetSourceFiles( + char * * i_nCurArgsBegin, + char * * i_nEndOfAllArgs ); + + // DATA + udmstri sRepositoryName; + udmstri sRepositoryDirectoryForUpdate; + + Dyn<S_LanguageInfo> pGlobal_Language; + bool bGlobal_HtmlIsDefaultForDocs; + + ProjectList aProjects; + + CommandLine * pCommandLine; + static InitMap aOptions_; +}; + +inline const udmstri & +Parse::ReposyName() const + { return sRepositoryName; } +inline const S_LanguageInfo * +Parse::GlobalLanguageInfo() const + { return pGlobal_Language ? pGlobal_Language.Ptr() : 0; } +inline bool +Parse::GlobalIsHtmlDefaultForDocs() const + { return bGlobal_HtmlIsDefaultForDocs; } +inline Parse::ProjectIterator +Parse::ProjectsBegin() const + { return aProjects.begin(); } +inline Parse::ProjectIterator +Parse::ProjectsEnd() const + { return aProjects.end(); } + +class Load : public Command +{ + public: + Load( + const char * i_sRepositoryDirectory = "" ); + ~Load(); + + const udmstri & ReposyDir() const; + + private: + // Interface Command: + virtual char * * do_Init( + char * * i_nCurArgsBegin, + char * * i_nEndOfAllArgs ); + // DATA + udmstri sRepositoryDirectory; +}; + +inline const udmstri & +Load::ReposyDir() const + { return sRepositoryDirectory; } + +struct S_ExternLinkage +{ + S_ExternLinkage( + const char * i_sNamespace, + const char * i_sLinkedRootDirectory ) + : sNamespace(i_sNamespace), + sLinkedRootDirectory(i_sLinkedRootDirectory) + { } + + udmstri sNamespace; + udmstri sLinkedRootDirectory; + +}; + +class CreateHtml : public Command +{ + public: + CreateHtml(); + ~CreateHtml(); + + const udmstri & OutputDir() const; + + private: + // Interface Command: + virtual char * * do_Init( + char * * i_nCurArgsBegin, + char * * i_nEndOfAllArgs ); + // DATA + udmstri sOutputRootDirectory; + + std::vector< S_ExternLinkage > + aExtLinks; +}; + +inline const udmstri & +CreateHtml::OutputDir() const + { return sOutputRootDirectory; } + + +class CreateXml : public Command +{ + public: + CreateXml(); + ~CreateXml(); + + const udmstri & OutputDir() const; + + private: + // Interface Command: + virtual char * * do_Init( + char * * i_nCurArgsBegin, + char * * i_nEndOfAllArgs ); + // DATA + udmstri sOutputRootDirectory; +}; + +inline const udmstri & +CreateXml::OutputDir() const + { return sOutputRootDirectory; } + + + +class Save : public Command +{ + public: + Save(); + ~Save(); + + const udmstri & ReposyDir() const; + + private: + // Interface Command: + virtual char * * do_Init( + char * * i_nCurArgsBegin, + char * * i_nEndOfAllArgs ); + // DATA + udmstri sRepositoryDirectory; +}; + +inline const udmstri & +Save::ReposyDir() const + { return sRepositoryDirectory; } + + +class X_CommandLine +{ + public: + X_CommandLine( + const char * i_sExplanation ) + : sExplanation(i_sExplanation) {} + + void Report( + ostream & o_rOut ) + { o_rOut << "Error in command line: " + << sExplanation << Endl(); } + + private: + udmstri sExplanation; +}; + +struct S_LanguageInfo +{ + enum E_ProgrammingLanguage + { + none, + cpp, + idl, + corba, + java + }; + S_LanguageInfo( + E_ProgrammingLanguage + i_eLang ); + StringVector + aExtensions; // An empty string is possible and means exactly that: files without extension. + E_ProgrammingLanguage + eLanguage; +}; + +inline +S_LanguageInfo::S_LanguageInfo( E_ProgrammingLanguage i_eLang ) +{ + eLanguage = i_eLang; +} + +struct S_Sources +{ + StringVector aDirectories; + StringVector aTrees; + StringVector aFiles; +}; + +struct S_ProjectData +{ + S_ProjectData( + const char * i_sName, + const char * i_sRootDir ); + ~S_ProjectData(); + + udmstri sName; + csv::ploc::Path aRootDirectory; + + Dyn<S_LanguageInfo> pLanguage; + bool bHtmlIsDefaultForDocs; + + S_Sources aFiles; +}; + + + + +const char * const C_opt_Verbose = "-v"; + +const char * const C_opt_Parse = "-parse"; +const char * const C_opt_Name = "-name"; +const char * const C_opt_Update = "-update"; +const char * const C_opt_LangAll = "-lg"; +const char * const C_opt_ExtensionsAll = "-extg"; +const char * const C_opt_DocAll = "-docg"; + +const char * const C_arg_Usehtml = "usehtml"; +const char * const C_arg_Cplusplus = "c++"; +const char * const C_arg_Idl = "idl"; +const char * const C_arg_Corba = "corba"; +const char * const C_arg_Java = "java"; + +const char * const C_opt_Project = "-p"; +const char * const C_opt_Lang = "-l"; +const char * const C_opt_Extensions = "-ext"; +const char * const C_opt_Doc = "-doc"; +const char * const C_opt_SourceDir = "-d"; +const char * const C_opt_SourceTree = "-t"; +const char * const C_opt_SourceFile = "-f"; + +const char * const C_opt_Load = "-load"; + +const char * const C_opt_CreateHtml = "-html"; +const char * const C_opt_ExternLinks = "-xlinks"; + +const char * const C_opt_CreateXml = "-xml"; +const char * const C_opt_Save = "-save"; + +// IMPLEMENTATION + + + +} // namespace command +} // namespace autodoc + + +#endif + diff --git a/autodoc/source/exes/adc_uni/cmd_run.cxx b/autodoc/source/exes/adc_uni/cmd_run.cxx new file mode 100644 index 000000000000..af55940f2679 --- /dev/null +++ b/autodoc/source/exes/adc_uni/cmd_run.cxx @@ -0,0 +1,492 @@ +/************************************************************************* + * + * $RCSfile: cmd_run.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: np $ $Date: 2002-03-08 14:45:27 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + + +#include <precomp.h> +#include "cmd_run.hxx" + + +// NOT FULLY DEFINED SERVICES +#include <cosv/x.hxx> +#include <ary/ary.hxx> +#include <ary/ary.hxx> +#include <ary/cpp/c_rwgate.hxx> +#include <ary_i/ce2.hxx> +#include <ary_i/uidl/cenamesp.hxx> +#include <ary_i/uidl/gate.hxx> +#include <autodoc/displaying.hxx> +#include <autodoc/dsp_html_std.hxx> +#include <autodoc/filecoli.hxx> +#include <autodoc/parsing.hxx> +#include <autodoc/prs_code.hxx> +#include <autodoc/prs_docu.hxx> +#include <display/uidldisp.hxx> +#include <parser/unoidl.hxx> +#include "adc_cl.hxx" +#include "adc_cmds.hxx" + + +ary::uidl::Gate * G_pGate = 0; + +ary::uidl::Gate & +GetAryGate() +{ + csv_assert(G_pGate != 0); + return *G_pGate; +} + + +namespace +{ + +void Recursive_PutOutNamespace( + csi::uidl::Display & o_rDisplay, + const ary::uidl::CeNamespace & + i_rNamespace, + const ary::uidl::Gate & i_rGate ); + +} // anonymous namespace + + +namespace autodoc +{ + + +inline const ParseToolsFactory_Ifc & +CommandRunner::ParseToolsFactory() + { return ParseToolsFactory_Ifc::GetIt_(); } + + +inline const command::S_LanguageInfo & +CommandRunner::Get_ProjectLanguage( const command::Parse & i_rCommand, + const command::S_ProjectData & i_rProject ) +{ + if ( i_rProject.pLanguage ) + return *i_rProject.pLanguage; + return *i_rCommand.GlobalLanguageInfo(); +} + +inline bool +CommandRunner::HasParsedCpp() const + { return pCppParser; } +inline bool +CommandRunner::HasParsedIdl() const + { return pIdlParser; } + + + + + +CommandRunner::CommandRunner() + : pCommandLine(0), + pReposy(0), + nResultCode(0) +{ +} + +CommandRunner::~CommandRunner() +{ + ary::Repository::Destroy_(); +} + +int +CommandRunner::Run( const CommandLine & i_rCL ) +{ + ary::Repository::Destroy_(); + pReposy = 0; + nResultCode = 0; + pCommandLine = &i_rCL; + + if ( nResultCode == 0 AND pCommandLine->Cmd_Load() ) + Load(); + + if ( nResultCode == 0 AND pCommandLine->Cmd_Parse() ) + Parse(); + + if ( nResultCode == 0 AND pCommandLine->Cmd_Save() ) + Save(); + + if ( nResultCode == 0 AND pCommandLine->Cmd_CreateHtml() ) + CreateHtml(); + + if ( nResultCode == 0 AND pCommandLine->Cmd_CreateXml() ) + CreateXml(); + + return nResultCode; +} + +void +CommandRunner::Parse() +{ + try + { + + csv_assert( pCommandLine->Cmd_Parse() != 0 ); + const command::Parse & + rCmd = *pCommandLine->Cmd_Parse(); + + Cout() << "Parsing the repository " + << rCmd.ReposyName() + << " ..." + << Endl(); + + if ( pReposy == 0 ) + pReposy = & ary::Repository::Create_( rCmd.ReposyName(), 0 ); + + Dyn< FileCollector_Ifc > pFiles; + pFiles = ParseToolsFactory().Create_FileCollector(6000); + + command::Parse::ProjectIterator itEnd = rCmd.ProjectsEnd(); + for ( command::Parse::ProjectIterator it = rCmd.ProjectsBegin(); + it != itEnd; + ++it ) + { + + uintt nCount = GatherFiles( *pFiles, rCmd, *(*it) ); + Cout() << nCount + << " files found to parse in project " + << (*it)->sName + << "." + << Endl(); + + + switch ( Get_ProjectLanguage(rCmd, *(*it)).eLanguage ) + { + case command::S_LanguageInfo::cpp: + { + Get_CppParser().Run( (*it)->sName, + (*it)->aRootDirectory, + *pFiles ); +// pReposy->RwGate_Cpp().Connect_AllTypes_2_TheirRelated_CodeEntites(); + } break; + case command::S_LanguageInfo::idl: + { + Get_IdlParser().Run(*pFiles); + } break; + default: + Cerr() << "Project in yet unimplemented language skipped." + << Endl(); + } + } + + pReposy->RwGate_Cpp().Connect_AllTypes_2_TheirRelated_CodeEntites(); + + } // end try + catch (csv::Exception & xx) + { + xx.GetInfo(Cerr()); + Cerr() << " program will exit." << Endl(); + nResultCode = 1; + } + catch (...) + { + Cerr() << "Unknown exception - program will exit." << Endl(); + nResultCode = 1; + } +} + +void +CommandRunner::Load() +{ + Cout() << "This would load the repository from the directory " + << pCommandLine->Cmd_Load()->ReposyDir() + << "." + << Endl(); +} + + +void +CommandRunner::Save() +{ + Cout() << "This would save the repository into the directory " + << pCommandLine->Cmd_Save()->ReposyDir() + << "." + << Endl(); +} + + +void +CommandRunner::CreateHtml() +{ + Cout() << "Creating HTML-output into the directory " + << pCommandLine->Cmd_CreateHtml()->OutputDir() + << "." + << Endl(); + + if ( HasParsedCpp() ) + CreateHtml_NewStyle(); + if ( HasParsedIdl() ) + CreateHtml_OldIdlStyle(); +} + + + +void +CommandRunner::CreateXml() +{ + Cout() << "This would create the XML-output into the directory " + << pCommandLine->Cmd_CreateXml()->OutputDir() + << "." + << Endl(); +} + +CodeParser_Ifc & +CommandRunner::Get_CppParser() +{ + if ( NOT pCppParser ) + Create_CppParser(); + return *pCppParser; +} + +IdlParser & +CommandRunner::Get_IdlParser() +{ + if ( NOT pIdlParser ) + Create_IdlParser(); + return *pIdlParser; +} + +void +CommandRunner::Create_CppParser() +{ + pCppParser = ParseToolsFactory().Create_Parser_Cplusplus(); + pCppDocuInterpreter = ParseToolsFactory().Create_DocuParser_AutodocStyle(); + + pCppParser->Setup( *pReposy, + *pCppDocuInterpreter ); +} + +void +CommandRunner::Create_IdlParser() +{ + pIdlParser = new IdlParser(*pReposy); +} + +uintt +CommandRunner::GatherFiles( FileCollector_Ifc & o_rFiles, + const command::Parse & i_rCommand, + const command::S_ProjectData & i_rProject ) +{ + uintt ret = 0; + o_rFiles.EraseAll(); + + typedef StringVector StrVector; + typedef StrVector::const_iterator StrIterator; + const command::S_Sources & + rSources = i_rProject.aFiles; + const StrVector & + rExtensions = Get_ProjectLanguage(i_rCommand,i_rProject).aExtensions; + + StrIterator it; + StrIterator itDirsEnd = rSources.aDirectories.end(); + StrIterator itTreesEnd = i_rProject.aFiles.aTrees.end(); + StrIterator itFilesEnd = i_rProject.aFiles.aFiles.end(); + StrIterator itExt; + StrIterator itExtEnd = rExtensions.end(); + + csv::StreamStr aDir(500); + i_rProject.aRootDirectory.Get( aDir ); + + uintt nProjectDir_AddPosition = + (strcmp(aDir.c_str(),".\\") == 0) + ? 0 + : uintt( aDir.tellp() ); + + for ( it = rSources.aDirectories.begin(); + it != itDirsEnd; + ++it ) + { + aDir.seekp( nProjectDir_AddPosition ); + aDir << *it; + + for ( itExt = rExtensions.begin(); + itExt != itExtEnd; + ++itExt ) + { + ret += o_rFiles.AddFilesFrom( aDir.c_str(), + *itExt, + FileCollector_Ifc::flat ); + } // end for itExt + } // end for it + for ( it = rSources.aTrees.begin(); + it != itTreesEnd; + ++it ) + { + aDir.seekp( nProjectDir_AddPosition ); + aDir << *it; + + for ( itExt = rExtensions.begin(); + itExt != itExtEnd; + ++itExt ) + { + ret += o_rFiles.AddFilesFrom( aDir.c_str(), + *itExt, + FileCollector_Ifc::recursive ); + } // end for itExt + } // end for it + for ( it = rSources.aFiles.begin(); + it != itFilesEnd; + ++it ) + { + aDir.seekp( nProjectDir_AddPosition ); + aDir << *it; + + o_rFiles.AddFile( aDir.c_str() ); + } // end for it + ret += rSources.aFiles.size(); + + return ret; +} + +void +CommandRunner::CreateHtml_NewStyle() +{ + const ary::cpp::DisplayGate & + rGate = pReposy->DisplayGate_Cpp(); + + Dyn< autodoc::HtmlDisplay_UdkStd > pHtmlDisplay; + pHtmlDisplay = DisplayToolsFactory_Ifc::GetIt_(). + Create_HtmlDisplay_UdkStd(); + + pHtmlDisplay->Run( pCommandLine->Cmd_CreateHtml()->OutputDir(), + rGate, + DisplayToolsFactory_Ifc::GetIt_().Create_StdFrame() ); +} + +void +CommandRunner::CreateHtml_OldIdlStyle() +{ + ary::uidl::Gate & + rAryGate = pReposy->RwGate_Idl(); + G_pGate = &rAryGate; + ary::uidl::CeNamespace & + rGlobalNamespace = rAryGate.GlobalNamespace(); + + Dyn<csi::uidl::Display> pDisplay; + pDisplay = csi::uidl::Create_HtmlDisplay_( + pCommandLine->Cmd_CreateHtml()->OutputDir(), + DisplayToolsFactory_Ifc::GetIt_() + .Create_StdFrame() ); + + Recursive_PutOutNamespace( *pDisplay, + rGlobalNamespace, + rAryGate ); + pDisplay->WriteGlobalIndices(); +} + + +} // namespace autodoc + +namespace +{ + +typedef std::vector< ary::uidl::CeNamespace * > LocalSNList; + +inline void +DisplayCe( csi::uidl::Display & o_rDisplay, + ary::Cei i_nID, + const ary::uidl::Gate & i_rGate ) +{ + ary::CodeEntity2 * pEntity = i_rGate.FindCe(i_nID); + if (pEntity != 0) + pEntity->DisplayAt(o_rDisplay); +} + +void +Recursive_PutOutNamespace( csi::uidl::Display & o_rDisplay, + const ary::uidl::CeNamespace & i_rNamespace, + const ary::uidl::Gate & i_rGate ) +{ + static StreamStr sPath(512); + sPath.seekp(0); + i_rNamespace.GetFullName( sPath, "\\"); + o_rDisplay.InitModule( i_rNamespace.Name(), + sPath.c_str(), + i_rNamespace.Depth() ); + + DisplayCe(o_rDisplay, i_rNamespace.Id(), i_rGate); + + const ary::uidl::CeNamespace::NameMap & rMap = i_rNamespace.LocalNames(); + + for ( ary::uidl::CeNamespace::NameMap::const_iterator iter = rMap.begin(); + iter != rMap.end(); + ++iter ) + { + if ( uintt((*iter).second.second) > uintt(ary::uidl::CeNamespace::nok_predeclaration) ) + DisplayCe(o_rDisplay, (*iter).second.first, i_rGate); + } // for + + LocalSNList aSubNamespaces; + i_rNamespace.GetSubNamespaces(aSubNamespaces); + + for ( LocalSNList::iterator iter2 = aSubNamespaces.begin(); + iter2 != aSubNamespaces.end(); + ++iter2 ) + { + csv_assert(*iter2 != 0); + Recursive_PutOutNamespace(o_rDisplay, *(*iter2), i_rGate); + } // for +} + +} // anonymous namespace + + + diff --git a/autodoc/source/exes/adc_uni/cmd_run.hxx b/autodoc/source/exes/adc_uni/cmd_run.hxx new file mode 100644 index 000000000000..2f1655b6f58b --- /dev/null +++ b/autodoc/source/exes/adc_uni/cmd_run.hxx @@ -0,0 +1,164 @@ +/************************************************************************* + * + * $RCSfile: cmd_run.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: np $ $Date: 2002-03-08 14:45:27 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef ADC_CMD_RUN_HXX +#define ADC_CMD_RUN_HXX + + + +// USED SERVICES + // BASE CLASSES +#include <cosv/comdline.hxx> + // COMPONENTS + // PARAMETERS + +namespace ary +{ + class Repository; +} + +namespace csi +{ + namespace uidl + { + class Uidl_Parser; + } +} + +namespace autodoc +{ + namespace command + { + class Parse; + struct S_ProjectData; + struct S_LanguageInfo; + } + + class CommandLine; + class FileCollector_Ifc; + class ParseToolsFactory_Ifc; + class CodeParser_Ifc; + class DocumentationParser_Ifc; + typedef csi::uidl::Uidl_Parser IdlParser; + + +class CommandRunner +{ + public: + CommandRunner(); + ~CommandRunner(); + + + int Run( + const CommandLine & i_rCL ); + private: + // Locals + void Parse(); + void Load(); + void Save(); + void CreateHtml(); + void CreateXml(); + + CodeParser_Ifc & Get_CppParser(); + IdlParser & Get_IdlParser(); + void Create_CppParser(); + void Create_IdlParser(); + + inline const ParseToolsFactory_Ifc & + ParseToolsFactory(); + inline const command::S_LanguageInfo & + Get_ProjectLanguage( + const command::Parse & + i_rCommand, + const command::S_ProjectData & + i_rProject ); + uintt GatherFiles( + FileCollector_Ifc & o_rFiles, + const command::Parse & + i_rCommand, + const command::S_ProjectData & + i_rProject ); + void CreateHtml_NewStyle(); + void CreateHtml_OldIdlStyle(); + + bool HasParsedCpp() const; + bool HasParsedIdl() const; + + // DATA + const CommandLine * pCommandLine; + ary::Repository * pReposy; + int nResultCode; + + Dyn<CodeParser_Ifc> pCppParser; + Dyn<DocumentationParser_Ifc> + pCppDocuInterpreter; + Dyn<IdlParser> pIdlParser; +}; + + + +// IMPLEMENTATION + + +} // namespace autodoc + +#endif + diff --git a/autodoc/source/exes/adc_uni/main.cxx b/autodoc/source/exes/adc_uni/main.cxx new file mode 100644 index 000000000000..f9480ebea688 --- /dev/null +++ b/autodoc/source/exes/adc_uni/main.cxx @@ -0,0 +1,93 @@ +/************************************************************************* + * + * $RCSfile: main.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: np $ $Date: 2002-03-08 14:45:27 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include <precomp.h> + + +// NOT FULLY DECLARED SERVICES + +#include <adc_cl.hxx> +#include "cmd_run.hxx" + + + + +int +#ifdef WNT + _cdecl +#endif +main( int argc, + char * argv[] ) +{ + autodoc::CommandLine aCL; + autodoc::CommandRunner aRunner; + + aCL.Init(argc, argv); + if (NOT aCL.CheckParameters() ) + return 1; + + int ret = aRunner.Run(aCL); + + return ret; +} + + + diff --git a/autodoc/source/exes/adc_uni/makefile.mk b/autodoc/source/exes/adc_uni/makefile.mk new file mode 100644 index 000000000000..e3c314071b6a --- /dev/null +++ b/autodoc/source/exes/adc_uni/makefile.mk @@ -0,0 +1,146 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: np $ $Date: 2002-03-08 14:45:27 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (the "License"); You may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at http://www.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRUNTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +PRJ=..$/..$/.. + +PRJNAME=autodoc +TARGET=autodoc +TARGETTYPE=CUI + +# --- Settings ----------------------------------------------------- + +ENABLE_EXCEPTIONS=true +PRJINC=$(PRJ)$/source + +.INCLUDE : settings.mk +.INCLUDE : $(PRJ)$/source$/mkinc$/fullcpp.mk + +.INCLUDE : static.mk + + + + +# --- Files -------------------------------------------------------- + +OBJFILES= \ + $(OBJ)$/adc_cl.obj \ + $(OBJ)$/adc_cmds.obj \ + $(OBJ)$/cmd_run.obj + + +# --- Targets ------------------------------------------------------ + +LIB1TARGET=$(LB)$/atdoc.lib +LIB1FILES= \ + $(LB)$/$(TARGET).lib $(LB)$/autodoc_tools.lib \ + $(LB)$/ary_kernel.lib $(LB)$/ary_cpp.lib $(LB)$/ary_info.lib \ + $(LB)$/ary_loc.lib $(LB)$/ary_store.lib \ + $(LB)$/parser_kernel.lib $(LB)$/parser_tokens.lib $(LB)$/parser_semantic.lib \ + $(LB)$/parser_cpp.lib $(LB)$/parser_adoc.lib \ + $(LB)$/csi_html.lib \ + $(LB)$/display_kernel.lib $(LB)$/display_html.lib \ + $(LB)$/ary2_kernel.lib $(LB)$/ary2_uidl.lib \ + $(LB)$/csi2_uidl.lib $(LB)$/csi2_dsapi.lib $(LB)$/csi2_html.lib \ + $(LB)$/parser2_tokens.lib \ + $(LB)$/parser2_s2_luidl.lib $(LB)$/parser2_s2_dsapi.lib \ + $(LB)$/display2_dsapi.lib \ + $(LB)$/comphelp.lib + +# $(LB)$/display_funclist.lib + + + +APP1TARGET= $(TARGET) +APP1STACK= 1000000 +APP1OBJS= $(OBJ)$/main.obj + +.IF "$(GUI)"=="WNT" +APP1STDLIBS= $(LIBSTLPORT) msvcirt.lib cosv.lib udm.lib +.ELSE +APP1STDLIBS= $(L)$/acosv.a $(L)$/audm.a +.ENDIF + +APP1LIBS=$(LB)$/atdoc.lib + +DEPOBJFILES += $(APP1OBJS) + +APP1DEPN= $(L)$/cosv.lib \ + $(LB)$/$(TARGET).lib $(LB)$/autodoc_tools.lib \ + $(LB)$/ary_kernel.lib $(LB)$/ary_cpp.lib $(LB)$/ary_info.lib \ + $(LB)$/ary_loc.lib $(LB)$/ary_store.lib \ + $(LB)$/parser_kernel.lib $(LB)$/parser_tokens.lib $(LB)$/parser_semantic.lib \ + $(LB)$/parser_cpp.lib $(LB)$/parser_adoc.lib \ + $(LB)$/csi_html.lib \ + $(LB)$/display_kernel.lib $(LB)$/display_html.lib \ + $(LB)$/ary2_kernel.lib $(LB)$/ary2_uidl.lib \ + $(LB)$/csi2_uidl.lib $(LB)$/csi2_dsapi.lib $(LB)$/csi2_html.lib \ + $(LB)$/parser2_tokens.lib \ + $(LB)$/parser2_s2_luidl.lib $(LB)$/parser2_s2_dsapi.lib \ + $(LB)$/display2_dsapi.lib \ + $(LB)$/comphelp.lib + +# $(LB)$/display_funclist.lib + + +.INCLUDE : target.mk + + |