[Compbench-devel] CompBenchmarks++/libcompbenchmarks/Compiler Compiler.cpp, 1.14, 1.15 Compiler.h,
Brought to you by:
xfred
From: Frederic T. <xf...@us...> - 2007-05-17 14:31:18
|
Update of /cvsroot/compbench/CompBenchmarks++/libcompbenchmarks/Compiler In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv8472 Modified Files: Compiler.cpp Compiler.h Compiler-Options.cpp Compiler-Options.h Log Message: Option handling modified. Index: Compiler-Options.h =================================================================== RCS file: /cvsroot/compbench/CompBenchmarks++/libcompbenchmarks/Compiler/Compiler-Options.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Compiler-Options.h 25 Jan 2007 20:38:15 -0000 1.2 --- Compiler-Options.h 17 May 2007 14:31:13 -0000 1.3 *************** *** 10,14 **** #define H_CBMCOMPILER_OPTIONS ! #include <string> namespace CBM { --- 10,15 ---- #define H_CBMCOMPILER_OPTIONS ! #include <Compiler/Compiler-Option.h> ! #include <Base/XML.h> namespace CBM { *************** *** 25,32 **** * \sa Options() */ ! ! std::string options; protected: public: --- 26,34 ---- * \sa Options() */ ! std::vector<CBM::CompilerOption*> options; protected: + virtual void add(CBM::CompilerOption *_option); + virtual void remove(CBM::CompilerOption *_option); public: *************** *** 34,38 **** \param _options Options to manage in current object. */ ! CompilerOptions(std::string _options); /** Retrives options --- 36,48 ---- \param _options Options to manage in current object. */ ! CompilerOptions(std::string _options = ""); ! ! virtual CompilerOption *Option(std::string _id); ! virtual CompilerOption *Option(int i); ! ! virtual int optionNumber(void); ! ! virtual void add(std::string _option); ! virtual void remove(std::string _option); /** Retrives options *************** *** 40,43 **** --- 50,56 ---- virtual std::string Options(void); + virtual XMLNode *XML(void); + virtual void restore(XMLNode *_from); + virtual ~CompilerOptions(); }; Index: Compiler.h =================================================================== RCS file: /cvsroot/compbench/CompBenchmarks++/libcompbenchmarks/Compiler/Compiler.h,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** Compiler.h 16 Apr 2007 20:15:44 -0000 1.12 --- Compiler.h 17 May 2007 14:31:12 -0000 1.13 *************** *** 14,28 **** #ifdef SWIG ! /* !!! If in SWIG parser, we need to define CBM::Plan so that all methods get * correctly wrapped. Hope there's a better solution... */ %module CBM %{ - #include <Plan/Plan.h> #include <Compiler/Compiler-Option-Description.h> %} - #define CBM_PLAN CBM::Plan #define CBM_COD CBM::CompilerOptionDescriptions #else - # define CBM_PLAN class Plan # define CBM_COD class CompilerOptionDescriptions #endif --- 14,25 ---- #ifdef SWIG ! /* !!! If in SWIG parser, we need to define some classes so that all methods get * correctly wrapped. Hope there's a better solution... */ %module CBM %{ #include <Compiler/Compiler-Option-Description.h> %} #define CBM_COD CBM::CompilerOptionDescriptions #else # define CBM_COD class CompilerOptionDescriptions #endif *************** *** 77,82 **** class System *system; - CBM_PLAN *plan; - /** Initialised by constructor. \sa Compiler() --- 74,77 ---- *************** *** 122,127 **** public: - virtual void setPlan(CBM_PLAN *_plan, int modifyPlanObject); - /** Internal compiler id. \return std::string like 'gcc' or 'g++'. --- 117,120 ---- Index: Compiler.cpp =================================================================== RCS file: /cvsroot/compbench/CompBenchmarks++/libcompbenchmarks/Compiler/Compiler.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** Compiler.cpp 19 Apr 2007 20:50:11 -0000 1.14 --- Compiler.cpp 17 May 2007 14:31:12 -0000 1.15 *************** *** 13,18 **** #include <Compiler/Compiler-Version.h> - #include <Plan/Plan.h> - /* #include <CEL/CEL-Include.h> #include <CEL/CEL-Version.h> --- 13,16 ---- *************** *** 34,38 **** system=_system; compilerBinary=_compilerBinary; - plan=0; cacheOptionDescriptions=0; } --- 32,35 ---- *************** *** 73,84 **** } - void Compiler::setPlan(CBM::Plan *_plan, int modifyPlanObject) - { - if ((modifyPlanObject) && (plan)) - plan->remove(this); - - plan=_plan; - } - std::string Compiler::Name(void) { --- 70,73 ---- *************** *** 402,406 **** Compiler::~Compiler() { - setPlan(0, 1); if (cacheOptionDescriptions) delete(cacheOptionDescriptions); --- 391,394 ---- Index: Compiler-Options.cpp =================================================================== RCS file: /cvsroot/compbench/CompBenchmarks++/libcompbenchmarks/Compiler/Compiler-Options.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Compiler-Options.cpp 25 Jan 2007 20:38:15 -0000 1.2 --- Compiler-Options.cpp 17 May 2007 14:31:13 -0000 1.3 *************** *** 8,11 **** --- 8,12 ---- #include <Compiler/Compiler-Options.h> + #include <System/System.h> using namespace CBM; *************** *** 13,25 **** CompilerOptions::CompilerOptions(std::string _options) { ! options=_options; } std::string CompilerOptions::Options(void) { ! return(options); } CompilerOptions::~CompilerOptions() { } --- 14,145 ---- CompilerOptions::CompilerOptions(std::string _options) { ! std::string o = "!"; ! int i = 0; ! ! if (_options=="") ! return; ! ! while (o!="") { ! o=cbmSystem->Split(_options, " ", i++); ! if (o=="") { ! add(o); ! } ! } ! } ! ! void CompilerOptions::add(CBM::CompilerOption *_option) ! { ! options.push_back(_option); ! } ! ! void CompilerOptions::remove(CBM::CompilerOption *_option) ! { ! int i, n = optionNumber(); ! CompilerOption *O; ! ! std::vector<CBM::CompilerOption*> noptions; ! ! for(i=0;i<n;i++) { ! O=Option(i); ! if (O!=_option) ! noptions.push_back(O); ! else { ! delete(O); ! } ! } ! options=noptions; ! } ! ! CompilerOption *CompilerOptions::Option(std::string _id) ! { ! int i, n = optionNumber(); ! CompilerOption *O; ! ! for(i=0;i<n;i++) { ! O=Option(i); ! if (O->Option()==_id) ! return(O); ! } ! ! return(0); ! } ! ! CompilerOption *CompilerOptions::Option(int i) ! { ! if (i<optionNumber()) ! return(options[i]); ! else ! return(0); ! } ! ! int CompilerOptions::optionNumber(void) ! { ! return(options.size()); ! } ! ! void CompilerOptions::add(std::string _option) ! { ! if (!Option(_option)) ! add(new CompilerOption(_option)); ! } ! ! void CompilerOptions::remove(std::string _option) ! { ! CBM::CompilerOption *O = Option(_option); ! ! if (O) ! remove(O); } std::string CompilerOptions::Options(void) { ! int i, n = optionNumber(); ! CompilerOption *O; ! std::string r; ! ! for(i=0;i<n;i++) { ! O=Option(i); ! r+=O->Option(); ! if (i!=(n-1)) ! r+=" "; ! } ! ! return(r); ! } ! ! XMLNode *CompilerOptions::XML(void) ! { ! XMLNode *root; ! int i, n = optionNumber(); ! ! root=new XMLNode("options"); ! for(i=0; i<n; i++) ! root->add(Option(i)->XML()); ! ! return(root); ! } ! ! void CompilerOptions::restore(XMLNode *_from) ! { ! int i; ! int n = _from->nodeNumber(); ! XMLNode *N; ! CompilerOption *O; ! ! for(i=0; i<n; i++) { ! N=_from->getNode(i); ! if (N->Name()=="option") { ! O=new CompilerOption; ! O->restore(N); ! add(O); ! } ! } } CompilerOptions::~CompilerOptions() { + CompilerOption *O; + + while ( (O=Option(0)) ) + delete(O); } |