[opengtl-commits] [742] don't create a new GenerationContext for local information

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


Revision: 742
Author:   cyrille
Date:     2009-05-26 15:16:30 +0200 (Tue, 26 May 2009)

Log Message:
-----------
don't create a new GenerationContext for local information

Modified Paths:
--------------
    trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/GenerationContext_p.cpp
    trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/GenerationContext_p.h
    trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/TemplateAST.cpp


Modified: trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/GenerationContext_p.cpp
===================================================================
--- trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/GenerationContext_p.cpp	2009-05-26 13:10:32 UTC (rev 741)
+++ trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/GenerationContext_p.cpp	2009-05-26 13:16:30 UTC (rev 742)
@@ -28,17 +28,18 @@
 // TemplateGenerationContext::TemplateGenerationContext() : m_isLocalContext(false) {
 // }
 
-TemplateGenerationContext* TemplateGenerationContext::createLocalContext(const GTLCore::String& suffix, int _currentChannel) {
-  TemplateGenerationContext* local = 0; // FIXME :)
-  local->m_isLocalContext = true;
-  local->m_suffix = suffix;
-  local->m_currentChannel = _currentChannel;
-  return local;
+void TemplateGenerationContext::startLocalContext(const GTLCore::String& suffix, int _currentChannel) {
+  GTL_ASSERT(not m_isLocalContext);
+  m_isLocalContext = true;
+  m_suffix = suffix;
+  m_currentChannel = _currentChannel;
 }
 
-void TemplateGenerationContext::mergeLocalContext(TemplateGenerationContext* _localContext) {
-  append(_localContext->code());
-  delete _localContext;
+void TemplateGenerationContext::endLocalContext() {
+  GTL_ASSERT(m_isLocalContext);
+  m_isLocalContext = false;
+  m_suffix = "";
+  m_currentChannel = -1;
 }
 
 void TemplateGenerationContext::append(const GTLCore::String& _c) {

Modified: trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/GenerationContext_p.h
===================================================================
--- trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/GenerationContext_p.h	2009-05-26 13:10:32 UTC (rev 741)
+++ trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/GenerationContext_p.h	2009-05-26 13:16:30 UTC (rev 742)
@@ -26,8 +26,8 @@
 namespace OpenCTL {
   class TemplateGenerationContext {
     public:
-      TemplateGenerationContext* createLocalContext(const GTLCore::String& suffix, int _currentChannel);
-      void mergeLocalContext(TemplateGenerationContext* );
+      void startLocalContext(const GTLCore::String& suffix, int _currentChannel);
+      void endLocalContext();
       void append(const GTLCore::String& _c);
       const GTLCore::String& code() const;
       const GTLCore::PixelDescription& pixelDescription() const;

Modified: trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/TemplateAST.cpp
===================================================================
--- trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/TemplateAST.cpp	2009-05-26 13:10:32 UTC (rev 741)
+++ trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/TemplateAST.cpp	2009-05-26 13:16:30 UTC (rev 742)
@@ -197,9 +197,9 @@
         or ( m_whichChannel == ColorChannel and i != pd.alphaPos() )
         or ( m_whichChannel == AlphaChannel and i == pd.alphaPos() ) )
     {
-      TemplateGenerationContext* localContext = _context->createLocalContext("_" + GTLCore::String::number(i), i);
-      m_nodesList->generate(localContext);
-      _context->mergeLocalContext(localContext);
+      _context->startLocalContext("_" + GTLCore::String::number(i), i);
+      m_nodesList->generate(_context);
+      _context->endLocalContext();
     }
   }
 }


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