Thread: [Compbench-devel] CompBenchmarks++/Compiler Compiler-Options.cpp, 1.1, 1.2 Compiler-Options.h, 1.1,
Brought to you by:
xfred
From: Frederic T. <xf...@us...> - 2007-01-18 18:43:45
|
Update of /cvsroot/compbench/CompBenchmarks++/Compiler In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv18689 Modified Files: Compiler-Options.cpp Compiler-Options.h Compiler.cpp Compiler.h Log Message: CBM namespace. Index: Compiler-Options.h =================================================================== RCS file: /cvsroot/compbench/CompBenchmarks++/Compiler/Compiler-Options.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Compiler-Options.h 1 Nov 2006 11:31:39 -0000 1.1 --- Compiler-Options.h 18 Jan 2007 18:43:40 -0000 1.2 *************** *** 12,57 **** #include <string> ! class CBMCompiler; ! /** \brief Abstraction layer for handling compilers' options. ! * ! * This class defines the base object for all options to supported compilers. ! * It only stores options (std::string, or char*) into an object and allows ! * querying them. ! */ ! class CBMCompilerOptions ! { ! private: ! /** Stores options. Initialised by constructor. ! * \sa Options() */ ! std::string options; ! /** Stores compiler using options. Initialised by constructor. ! * \sa Compiler() ! */ ! class CBMCompiler *compiler; ! protected: ! public: ! /** Constructor ! \param _compiler Compiler object related to given options ! \param _options Options to manage in current object. ! */ ! CBMCompilerOptions(class CBMCompiler *_compiler, ! char *_options); ! /** Retrives compiler ! \return Compiler instance declared in constructor */ ! virtual class CBMCompiler *Compiler(void); ! /** Retrives options ! \return Options (to compiler instance) declared in constructor */ ! virtual std::string Options(void); ! virtual ~CBMCompilerOptions(); ! }; #endif --- 12,59 ---- #include <string> ! namespace CBM { ! class CBMCompiler; ! /** \brief Abstraction layer for handling compilers' options. ! * ! * This class defines the base object for all options to supported compilers. ! * It only stores options (std::string, or char*) into an object and allows ! * querying them. */ + class CompilerOptions + { + private: + /** Stores options. Initialised by constructor. + * \sa Options() + */ ! std::string options; ! /** Stores compiler using options. Initialised by constructor. ! * \sa Compiler() ! */ ! class Compiler *compiler; ! protected: ! public: ! /** Constructor ! \param _compiler Compiler object related to given options ! \param _options Options to manage in current object. ! */ ! CompilerOptions(class Compiler *_compiler, ! char *_options); ! /** Retrives compiler ! \return Compiler instance declared in constructor */ ! virtual class Compiler *Compiler(void); ! /** Retrives options ! \return Options (to compiler instance) declared in constructor */ ! virtual std::string Options(void); ! virtual ~CompilerOptions(); ! }; ! } #endif Index: Compiler.h =================================================================== RCS file: /cvsroot/compbench/CompBenchmarks++/Compiler/Compiler.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Compiler.h 1 Nov 2006 11:31:39 -0000 1.1 --- Compiler.h 18 Jan 2007 18:43:40 -0000 1.2 *************** *** 12,113 **** #include <string> ! class CBMSystem; ! /** \brief Abstraction layer for handling compilers. ! * ! * This class defines the base abstract (pure) object for all supported compilers. ! */ ! class CBMCompiler ! { ! private: ! /** Internal usage ! * Speeds up compilerName(). */ ! std::string cacheCompilerName; ! /** Internal usage ! * Speeds up compilerVersion(). ! */ ! std::string cacheCompilerVersion; ! protected: ! /** Used internally to get information on compiler's binary */ ! class CBMSystem *system; ! /** Initialised by constructor. ! \sa CBMCompiler() ! */ ! char *compilerBinary; ! /** Constructor ! \param _system the CBMSystem to use internaly. ! \param _compilerBinary absolute or relative path to the compiler program */ ! CBMCompiler(class CBMSystem *_system, ! char *_compilerBinary); ! /** Gets compiler's name ! * \return std::string containing the name of the compiler ! * \sa getCompilerName() */ ! virtual std::string getCompilerName(void) = 0; ! /** Gets compiler's version ! * \return std::string containing the version of the compiler ! * \sa getCompilerVersion() */ ! virtual std::string getCompilerVersion(void) = 0; ! public: ! /** Display compiler's information. ! * Format is strict. This output is used by compbenchmark-config. ! */ ! virtual void display(void); ! /** Internal compiler id. ! \return std::string like 'gcc' or 'g++'. ! */ ! virtual std::string compiler(void) = 0; ! /** Gets compiler's name. Do not overload. ! \sa getCompilerName() ! \return The compiler name. */ ! virtual std::string compilerName(void); ! /** Gets compiler's version. Do not overload. ! \sa getCompilerVersion() ! \return The compiler version. */ ! virtual std::string compilerVersion(void); ! /** Gets compiler's program (as specified in constructor). ! \return The compiler program (absolute or relative, depending on method used in instanciation). */ ! virtual std::string Binary(void); ! /** Gets compiler's language. ! \return C or C++. */ ! virtual char *language(void) = 0; ! /** Virtual destructor */ ! virtual ~CBMCompiler(); ! }; ! /** \brief Gives a compiler object according to a binary (or executable) program. ! * ! * This class creates CBMCompiler objects. It is only instancied once, and I currently see no need to derivate it. ! */ ! class CBMCompilerSelector ! { ! private: ! protected: ! class CBMSystem *system; ! public: ! /** Constructor */ ! CBMCompilerSelector(class CBMSystem *_system); ! ! /** Main method. ! * Returns a CBMCompiler object. ! * \param compilerBinary Absolute or relative name of the compiler program */ ! CBMCompiler *select(char *compilerBinary); ! /** Virtual destructor */ ! ~CBMCompilerSelector(); ! }; #endif --- 12,116 ---- #include <string> ! namespace CBM { ! // class CBM::System; ! /** \brief Abstraction layer for handling compilers. ! * ! * This class defines the base abstract (pure) object for all supported compilers. */ ! class Compiler ! { ! private: ! /** Internal usage ! * Speeds up compilerName(). ! */ ! std::string cacheCompilerName; ! /** Internal usage ! * Speeds up compilerVersion(). ! */ ! std::string cacheCompilerVersion; ! protected: ! /** Used internally to get information on compiler's binary */ ! class System *system; ! /** Initialised by constructor. ! \sa Compiler() ! */ ! char *compilerBinary; ! /** Constructor ! \param _system the System to use internaly. ! \param _compilerBinary absolute or relative path to the compiler program */ ! Compiler(class System *_system, ! char *_compilerBinary); ! /** Gets compiler's name ! * \return std::string containing the name of the compiler ! * \sa getCompilerName() */ ! virtual std::string getCompilerName(void) = 0; ! /** Gets compiler's version ! * \return std::string containing the version of the compiler ! * \sa getCompilerVersion() */ ! virtual std::string getCompilerVersion(void) = 0; ! public: ! /** Display compiler's information. ! * Format is strict. This output is used by compbenchmark-config. ! */ ! virtual void display(void); ! /** Internal compiler id. ! \return std::string like 'gcc' or 'g++'. ! */ ! virtual std::string compiler(void) = 0; ! /** Gets compiler's name. Do not overload. ! \sa getCompilerName() ! \return The compiler name. */ ! virtual std::string compilerName(void); ! /** Gets compiler's version. Do not overload. ! \sa getCompilerVersion() ! \return The compiler version. */ ! virtual std::string compilerVersion(void); ! /** Gets compiler's program (as specified in constructor). ! \return The compiler program (absolute or relative, depending on method used in instanciation). */ ! virtual std::string Binary(void); ! /** Gets compiler's language. ! \return C or C++. */ ! virtual char *language(void) = 0; ! /** Virtual destructor */ ! virtual ~Compiler(); ! }; ! /** \brief Gives a compiler object according to a binary (or executable) program. ! * ! * This class creates Compiler objects. It is only instancied once, and I currently see no need to derivate it. */ ! class CompilerSelector ! { ! private: ! protected: ! class System *system; ! public: ! /** Constructor */ ! CompilerSelector(class System *_system); ! ! /** Main method. ! * Returns a Compiler object. ! * \param compilerBinary Absolute or relative name of the compiler program ! */ ! Compiler *select(char *compilerBinary); ! /** Virtual destructor */ ! ~CompilerSelector(); ! ! }; ! } #endif Index: Compiler.cpp =================================================================== RCS file: /cvsroot/compbench/CompBenchmarks++/Compiler/Compiler.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Compiler.cpp 1 Nov 2006 11:31:39 -0000 1.1 --- Compiler.cpp 18 Jan 2007 18:43:40 -0000 1.2 *************** *** 14,19 **** #include <iostream> ! CBMCompiler::CBMCompiler(CBMSystem *_system, ! char *_compilerBinary) { system=_system; --- 14,21 ---- #include <iostream> ! using namespace CBM; ! ! Compiler::Compiler(System *_system, ! char *_compilerBinary) { system=_system; *************** *** 21,25 **** } ! std::string CBMCompiler::compilerName(void) { if (cacheCompilerName!="") --- 23,27 ---- } ! std::string Compiler::compilerName(void) { if (cacheCompilerName!="") *************** *** 31,35 **** } ! std::string CBMCompiler::compilerVersion(void) { if (cacheCompilerVersion!="") --- 33,37 ---- } ! std::string Compiler::compilerVersion(void) { if (cacheCompilerVersion!="") *************** *** 41,50 **** } ! std::string CBMCompiler::Binary(void) { return(compilerBinary); } ! void CBMCompiler::display(void) { std::cout << "compiler::id=" << compiler() << std::endl --- 43,52 ---- } ! std::string Compiler::Binary(void) { return(compilerBinary); } ! void Compiler::display(void) { std::cout << "compiler::id=" << compiler() << std::endl *************** *** 55,68 **** } ! CBMCompiler::~CBMCompiler() { } ! CBMCompilerSelector::CBMCompilerSelector(CBMSystem *_system) { system=_system; } ! CBMCompiler *CBMCompilerSelector::select(char *compilerBinary) { std::string cmd; --- 57,70 ---- } ! Compiler::~Compiler() { } ! CompilerSelector::CompilerSelector(CBM::System *_system) { system=_system; } ! Compiler *CompilerSelector::select(char *compilerBinary) { std::string cmd; *************** *** 78,94 **** ((int) raw.find("Free Software Foundation")>0)) { if ((int) raw.find("g++")>=0) { ! return(new CBMCompilerGCC_cpp(system, compilerBinary)); } else ! return(new CBMCompilerGCC(system, compilerBinary)); } raw=compilerBinary; if (((int) raw.find("g++")>0) || (raw=="g++")) { ! return(new CBMCompilerGCC_cpp(system, compilerBinary)); } if (((int) raw.find("gcc")>0) || (raw=="gcc")) { ! return(new CBMCompilerGCC(system, compilerBinary)); } --- 80,96 ---- ((int) raw.find("Free Software Foundation")>0)) { if ((int) raw.find("g++")>=0) { ! return(new CompilerGCC_cpp(system, compilerBinary)); } else ! return(new CompilerGCC(system, compilerBinary)); } raw=compilerBinary; if (((int) raw.find("g++")>0) || (raw=="g++")) { ! return(new CompilerGCC_cpp(system, compilerBinary)); } if (((int) raw.find("gcc")>0) || (raw=="gcc")) { ! return(new CompilerGCC(system, compilerBinary)); } *************** *** 99,106 **** cmd+=" -h) 2> /dev/null"; ! system->exec(cmd, raw); /* !!! */ if (raw!="") { if ((int) raw.find("Tiny C Compiler">0)) { ! return(new CBMCompilerTCC(system, compilerBinary)); } --- 101,108 ---- cmd+=" -h) 2> /dev/null"; ! system->exec(cmd, raw); /* !!! */ if (raw!="") { if ((int) raw.find("Tiny C Compiler">0)) { ! return(new CompilerTCC(system, compilerBinary)); } *************** *** 110,114 **** } ! CBMCompilerSelector::~CBMCompilerSelector() { } --- 112,117 ---- } ! ! CompilerSelector::~CompilerSelector() { } Index: Compiler-Options.cpp =================================================================== RCS file: /cvsroot/compbench/CompBenchmarks++/Compiler/Compiler-Options.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Compiler-Options.cpp 1 Nov 2006 11:31:39 -0000 1.1 --- Compiler-Options.cpp 18 Jan 2007 18:43:40 -0000 1.2 *************** *** 10,16 **** #include <Compiler/Compiler.h> ! CBMCompilerOptions::CBMCompilerOptions(CBMCompiler *_compiler, ! char *_options) { compiler=_compiler; --- 10,17 ---- #include <Compiler/Compiler.h> + using namespace CBM; ! CompilerOptions::CompilerOptions(CBM::Compiler *_compiler, ! char *_options) { compiler=_compiler; *************** *** 18,32 **** } ! CBMCompiler *CBMCompilerOptions::Compiler(void) { return(compiler); } ! std::string CBMCompilerOptions::Options(void) { return(options); } ! CBMCompilerOptions::~CBMCompilerOptions() { } --- 19,33 ---- } ! Compiler *CompilerOptions::Compiler(void) { return(compiler); } ! std::string CompilerOptions::Options(void) { return(options); } ! CompilerOptions::~CompilerOptions() { } |