[opengtl-commits] [743] add named variable

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


Revision: 743
Author:   cyrille
Date:     2009-05-26 15:41:59 +0200 (Tue, 26 May 2009)

Log Message:
-----------
add named variable

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
    trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/TemplateAST_p.h


Modified: trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/GenerationContext_p.cpp
===================================================================
--- trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/GenerationContext_p.cpp	2009-05-26 13:16:30 UTC (rev 742)
+++ trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/GenerationContext_p.cpp	2009-05-26 13:41:59 UTC (rev 743)
@@ -67,3 +67,13 @@
 const GTLCore::Type* TemplateGenerationContext::currentChannelType() const {
   return pixelDescription().channelTypes()[currentChannel()];
 }
+
+const GTLCore::Type* TemplateGenerationContext::namedType(const GTLCore::String& _name) const {
+  std::map< GTLCore::String, const GTLCore::Type* >::const_iterator cit = m_namedTypes.find(_name);
+  if(cit == m_namedTypes.end())
+  {
+    return 0;
+  } else {
+    return cit->second;
+  }
+}

Modified: trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/GenerationContext_p.h
===================================================================
--- trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/GenerationContext_p.h	2009-05-26 13:16:30 UTC (rev 742)
+++ trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/GenerationContext_p.h	2009-05-26 13:41:59 UTC (rev 743)
@@ -20,6 +20,8 @@
 #ifndef _GENERATION_CONTEXT_P_H_
 #define _GENERATION_CONTEXT_P_H_
 
+#include <map>
+
 #include <GTLCore/PixelDescription.h>
 #include <GTLCore/String.h>
 
@@ -34,12 +36,14 @@
       const GTLCore::String& suffix() const;
       int currentChannel() const;
       const GTLCore::Type* currentChannelType() const;
+      const GTLCore::Type* namedType(const GTLCore::String&) const;
     private:
       GTLCore::String m_code;
       bool m_isLocalContext;
       GTLCore::String m_suffix;
       int m_currentChannel;
       GTLCore::PixelDescription m_pixelDescription;
+      std::map< GTLCore::String, const GTLCore::Type* > m_namedTypes;
   };
 }
 

Modified: trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/TemplateAST.cpp
===================================================================
--- trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/TemplateAST.cpp	2009-05-26 13:16:30 UTC (rev 742)
+++ trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/TemplateAST.cpp	2009-05-26 13:41:59 UTC (rev 743)
@@ -239,3 +239,35 @@
 void ChannelUnitNode::generate(TemplateGenerationContext* _context) {
   _context->append(typeUnit(_context->currentChannelType()));
 }
+
+void ChannelTypeNode::generate(TemplateGenerationContext* _context) {
+  _context->append(typeToString(_context->currentChannelType()));
+}
+
+NamedMaxNode::NamedMaxNode(const GTLCore::String& _name) : m_name(_name) {
+}
+
+void NamedMaxNode::generate(TemplateGenerationContext* _context) {
+  _context->append(typeMax(_context->namedType(m_name)));
+}
+
+NamedMinNode::NamedMinNode(const GTLCore::String& _name) : m_name(_name) {
+}
+
+void NamedMinNode::generate(TemplateGenerationContext* _context) {
+  _context->append(typeMin(_context->namedType(m_name)));
+}
+
+NamedUnitNode::NamedUnitNode(const GTLCore::String& _name) : m_name(_name) {
+}
+
+void NamedUnitNode::generate(TemplateGenerationContext* _context) {
+  _context->append(typeUnit(_context->namedType(m_name)));
+}
+
+NamedTypeNode::NamedTypeNode(const GTLCore::String& _name) : m_name(_name) {
+}
+
+void NamedTypeNode::generate(TemplateGenerationContext* _context) {
+  _context->append(typeToString(_context->namedType(m_name)));
+}

Modified: trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/TemplateAST_p.h
===================================================================
--- trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/TemplateAST_p.h	2009-05-26 13:16:30 UTC (rev 742)
+++ trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/TemplateAST_p.h	2009-05-26 13:41:59 UTC (rev 743)
@@ -117,10 +117,39 @@
       public:
         virtual void generate(TemplateGenerationContext* _context);
     };
-    class TypeNode : public Node {
+    class ChannelTypeNode : public Node {
       public:
         virtual void generate(TemplateGenerationContext* _context);
     };
+    class NamedMaxNode : public Node {
+      public:
+        NamedMaxNode(const GTLCore::String& _name);
+        virtual void generate(TemplateGenerationContext* _context);
+      private:
+        GTLCore::String m_name;
+    };
+    class NamedMinNode : public Node {
+      public:
+        NamedMinNode(const GTLCore::String& _name);
+        virtual void generate(TemplateGenerationContext* _context);
+      private:
+        GTLCore::String m_name;
+    };
+    class NamedUnitNode : public Node {
+      public:
+        NamedUnitNode(const GTLCore::String& _name);
+        virtual void generate(TemplateGenerationContext* _context);
+      private:
+        GTLCore::String m_name;
+    };
+    class NamedTypeNode : public Node {
+      public:
+        NamedTypeNode(const GTLCore::String& _name);
+        virtual void generate(TemplateGenerationContext* _context);
+      private:
+        GTLCore::String m_name;
+    };
+    
   }
 }
 


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