[opengtl-commits] [602] use Source in Library

[ Thread Index | Date Index | More lists.tuxfamily.org/opengtl-commits Archives ]


Revision: 602
Author:   cyrille
Date:     2009-03-12 23:31:38 +0100 (Thu, 12 Mar 2009)

Log Message:
-----------
use Source in Library

Modified Paths:
--------------
    trunk/OpenGTL/OpenShiva/OpenShiva/Library.cpp
    trunk/OpenGTL/OpenShiva/OpenShiva/Library.h
    trunk/OpenGTL/OpenShiva/OpenShiva/Library_p.h
    trunk/OpenGTL/OpenShiva/OpenShiva/Source.cpp
    trunk/OpenGTL/OpenShiva/OpenShiva/Source.h


Modified: trunk/OpenGTL/OpenShiva/OpenShiva/Library.cpp
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/Library.cpp	2009-03-12 22:11:05 UTC (rev 601)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/Library.cpp	2009-03-12 22:31:38 UTC (rev 602)
@@ -62,7 +62,7 @@
   GTLCore::Metadata::Factory::deleteEntry( metadata );
   metadata = 0;
   compilationErrors.clear();
-  std::istringstream iss(source);
+  std::istringstream iss(source.source());
   MetadataLexer* lexer = new MetadataLexer(&iss);
   MetadataParser parser( lexer, "" );
   metadata = parser.parse();
@@ -139,14 +139,24 @@
 
 void Library::setSource(const GTLCore::String& _source )
 {
-  d->source = _source;
+  d->source.setSource(_source);
   d->compileMetaData();
 }
 
+void Library::setSource(const Source& source)
+{
+    d->source = source;
+}
+
+const Source& Library::source() const
+{
+    return d->source;
+}
+
 void Library::loadFromFile(const GTLCore::String& _fileName)
 {
   d->isStandardLibrary = _fileName.endWith( "shivastdlib.shiva" );
-  d->source = "";
+  GTLCore::String source = "";
   std::ifstream in;
   in.open(_fileName.c_str() );
   if(not in)
@@ -157,10 +167,11 @@
   GTLCore::String str;
   std::getline(in,str);
   while ( in ) {
-    d->source += str;
-    d->source += "\n";
+    source += str;
+    source += "\n";
     std::getline(in,str);
   }
+  d->source.setSource(source);
  d->compileMetaData();
 }
 
@@ -171,13 +182,13 @@
 void Library::compile()
 {
   if(d->metadataCompilationFailed ) return;
-  if(d->source.empty()) return;
+  if(d->source.source().empty()) return;
   cleanup();
   d->m_moduleData = new GTLCore::ModuleData(new llvm::Module(d->name));
   Compiler c( d->isKernel,  d->count_channels_generic );
   Wrapper::fillTypesManager( d->m_moduleData, d->m_moduleData->typesManager(), c.convertCenter() , d->count_channels_generic );
   GTLCore::String nameSpace;
-  bool result = c.compile( d->isStandardLibrary, d->source, d->name, d->m_moduleData, nameSpace, d->parameters );
+  bool result = c.compile( d->isStandardLibrary, d->source.source(), d->name, d->m_moduleData, nameSpace, d->parameters );
 
   if(result)
   {

Modified: trunk/OpenGTL/OpenShiva/OpenShiva/Library.h
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/Library.h	2009-03-12 22:11:05 UTC (rev 601)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/Library.h	2009-03-12 22:31:38 UTC (rev 602)
@@ -30,6 +30,7 @@
 }
 
 namespace OpenShiva {
+  class Source;
   class Metadata;
   /**
    * 
@@ -52,6 +53,8 @@
        * Set the code source of the module.
        */
       void setSource(const GTLCore::String& source);
+      void setSource(const Source& source);
+      const Source& source() const;
       /**
        * Load the module from the given file name.
        */

Modified: trunk/OpenGTL/OpenShiva/OpenShiva/Library_p.h
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/Library_p.h	2009-03-12 22:11:05 UTC (rev 601)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/Library_p.h	2009-03-12 22:31:38 UTC (rev 602)
@@ -25,6 +25,8 @@
 #include <GTLCore/String.h>
 #include <GTLCore/Value.h>
 
+#include "Source.h"
+
 #include <map>
 
 namespace llvm {
@@ -48,7 +50,7 @@
     void metadataToParameters( const GTLCore::Metadata::Group* );
     
     GTLCore::String name;
-    GTLCore::String source;
+    Source source;
     bool compiled;
     std::list<GTLCore::ErrorMessage> compilationErrors;
     llvm::ModuleProvider* moduleProvider;

Modified: trunk/OpenGTL/OpenShiva/OpenShiva/Source.cpp
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/Source.cpp	2009-03-12 22:11:05 UTC (rev 601)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/Source.cpp	2009-03-12 22:31:38 UTC (rev 602)
@@ -34,6 +34,17 @@
   
 }
 
+Source::Source(const Source& _rhs) : d(new Private(*_rhs.d))
+{
+    
+}
+
+Source& Source::operator=(const Source& _rhs)
+{
+    *d = *_rhs.d;
+    return *this;
+}
+
 Source::~Source()
 {
   delete d;

Modified: trunk/OpenGTL/OpenShiva/OpenShiva/Source.h
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/Source.h	2009-03-12 22:11:05 UTC (rev 601)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/Source.h	2009-03-12 22:31:38 UTC (rev 602)
@@ -34,6 +34,8 @@
   class Source {
     public:
       Source();
+      Source(const Source& );
+      Source& operator=(const Source& );
       ~Source();
       const GTLCore::String& name() const;
       const GTLCore::String& source() const;


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/