[opengtl-commits] [512] no more export to C

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


Revision: 512
Author:   cyrille
Date:     2008-12-01 23:39:52 +0100 (Mon, 01 Dec 2008)

Log Message:
-----------
no more export to C
parse curve parameters
parse metadata on top of kernels

Modified Paths:
--------------
    trunk/OpenGTL/OpenShiva/OpenShiva/CodeGenerator_p.cpp
    trunk/OpenGTL/OpenShiva/OpenShiva/Library.cpp
    trunk/OpenGTL/OpenShiva/OpenShiva/Library.h
    trunk/OpenGTL/OpenShiva/OpenShiva/Library_p.h
    trunk/OpenGTL/OpenShiva/OpenShiva/MetadataLexer_p.cpp
    trunk/OpenGTL/OpenShiva/OpenShiva/MetadataParser_p.cpp
    trunk/OpenGTL/OpenShiva/OpenShiva/MetadataParser_p.h
    trunk/OpenGTL/OpenShiva/OpenShiva/Parser_p.cpp
    trunk/OpenGTL/OpenShiva/doc/specification/ShivaSpec.tex
    trunk/OpenGTL/OpenShiva/tests/convolution/oilify.shiva
    trunk/OpenGTL/OpenShiva/tests/library/TestMetadataParser.h
    trunk/OpenGTL/OpenShiva/tests/parse/CMakeLists.txt
    trunk/OpenGTL/OpenShiva/tools/compiler/ShivaC.cpp

Added Paths:
-----------
    trunk/OpenGTL/OpenShiva/tests/parse/metadata.shiva


Modified: trunk/OpenGTL/OpenShiva/OpenShiva/CodeGenerator_p.cpp
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/CodeGenerator_p.cpp	2008-12-01 22:39:03 UTC (rev 511)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/CodeGenerator_p.cpp	2008-12-01 22:39:52 UTC (rev 512)
@@ -29,7 +29,6 @@
 #include <llvm/Instructions.h>
 #include <llvm/Module.h>
 #include <llvm/Value.h>
-#include <llvm/ParameterAttributes.h>
 
 #include "GTLCore/CodeGenerator_p.h"
 #include "GTLCore/ExpressionResult_p.h"

Modified: trunk/OpenGTL/OpenShiva/OpenShiva/Library.cpp
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/Library.cpp	2008-12-01 22:39:03 UTC (rev 511)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/Library.cpp	2008-12-01 22:39:52 UTC (rev 512)
@@ -32,10 +32,12 @@
 #include "GTLCore/PixelDescription.h"
 #include "GTLCore/Region.h"
 #include "GTLCore/Type.h"
+#include "GTLCore/Macros_p.h"
 #include "GTLCore/TypeManager.h"
 #include "GTLCore/Value.h"
 #include "GTLCore/VirtualMachine_p.h"
 #include "GTLCore/wrappers/Allocate.h"
+#include "GTLCore/Metadata/Factory_p.h"
 
 #include "Debug.h"
 #include "CodeGenerator_p.h"
@@ -43,11 +45,33 @@
 #include "Wrapper_p.h"
 #include "wrappers/ImageWrap_p.h"
 #include "wrappers/RegionWrap_p.h"
+#include "MetadataLexer_p.h"
+#include "MetadataParser_p.h"
+#include "KernelMetadata.h"
 
 #include "Kernel_p.h"
 
 using namespace OpenShiva;
 
+// ---- Library::Private ---- //
+
+void Library::Private::compileMetaData()
+{
+  GTLCore::Metadata::Factory::deleteEntry( metadata );
+  metadata = 0;
+  compilationErrors.clear();
+  std::istringstream iss(source);
+  Metadata::Lexer* lexer = new Metadata::Lexer(&iss);
+  Metadata::Parser parser( lexer, "" );
+  metadata = parser.parse();
+  compilationErrors = parser.errorMessages();
+  metadataCompilationFailed = not compilationErrors.empty();
+  GTL_DEBUG( compilationErrors.size() );
+  GTL_DEBUG( parser.errorMessages().size() );
+}
+
+// -------- Library -------- //
+
 Library::Library( bool _isKernel , int _channelsNb) : d(new Private)
 {
   d->name = "";
@@ -62,6 +86,7 @@
 Library::~Library()
 {
   cleanup();
+  GTLCore::Metadata::Factory::deleteEntry( d->metadata );
   delete d;
 }
 
@@ -86,6 +111,7 @@
 void Library::setSource(const GTLCore::String& _source )
 {
   d->source = _source;
+  d->compileMetaData();
 }
 
 void Library::loadFromFile(const GTLCore::String& _fileName)
@@ -106,6 +132,7 @@
     d->source += "\n";
     std::getline(in,str);
   }
+ d->compileMetaData();
 }
 
 void Library::postCompilation()
@@ -114,6 +141,7 @@
 
 void Library::compile()
 {
+  if(d->metadataCompilationFailed ) return;
   if(d->source.empty()) return;
   cleanup();
   d->m_moduleData = new GTLCore::ModuleData(new llvm::Module(d->name));
@@ -168,11 +196,6 @@
   return os.str();
 }
 
-GTLCore::String Library::cSourceCode() const
-{
-  return d->m_moduleData->asCCode();
-}
-
 const GTLCore::ModuleData* Library::data() const
 {
   return d->m_moduleData;
@@ -182,3 +205,8 @@
 {
   return d->m_moduleData->functions();
 }
+
+const KernelMetadata* Library::metadata() const
+{
+  return d->metadata;
+}

Modified: trunk/OpenGTL/OpenShiva/OpenShiva/Library.h
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/Library.h	2008-12-01 22:39:03 UTC (rev 511)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/Library.h	2008-12-01 22:39:52 UTC (rev 512)
@@ -29,6 +29,7 @@
 }
 
 namespace OpenShiva {
+  class KernelMetadata;
   /**
    * 
    * @ingroup OpenShiva
@@ -75,10 +76,6 @@
        */
       GTLCore::String asmSourceCode() const;
       /**
-       * @return the C source code, it's mostly usefull for testing purpose
-       */
-      GTLCore::String cSourceCode() const;
-      /**
        * @return a pointer to the internal Data of this module (the class Module::Data
        *         is not part of the public API and therefor there is no reason for you
        *         to use that function).
@@ -88,6 +85,10 @@
        * @return the list of functions available in this module.
        */
       std::list<GTLCore::Function*> functions();
+      /**
+       * @return the metadata for this kernel.
+       */
+      const KernelMetadata* metadata() const;
     private:
       struct Private;
       Private* const d;

Modified: trunk/OpenGTL/OpenShiva/OpenShiva/Library_p.h
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/Library_p.h	2008-12-01 22:39:03 UTC (rev 511)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/Library_p.h	2008-12-01 22:39:52 UTC (rev 512)
@@ -33,9 +33,10 @@
 
 namespace OpenShiva {
   struct Library::Private {
-    Private() : m_moduleData(0)
+    Private() : m_moduleData(0), metadata(0), metadataCompilationFailed(true)
     {
     }
+    void compileMetaData();
     GTLCore::String name;
     GTLCore::String source;
     bool compiled;
@@ -45,6 +46,8 @@
     int count_channels_generic;
     bool isKernel;
     bool isStandardLibrary;
+    KernelMetadata* metadata;
+    bool metadataCompilationFailed;
   };
 }
 

Modified: trunk/OpenGTL/OpenShiva/OpenShiva/MetadataLexer_p.cpp
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/MetadataLexer_p.cpp	2008-12-01 22:39:03 UTC (rev 511)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/MetadataLexer_p.cpp	2008-12-01 22:39:52 UTC (rev 512)
@@ -39,6 +39,12 @@
   int initial_line = line() - 1;
   int initial_col = column() - 1;
   if( eof() ) return GTLCore::Token(GTLCore::Token::END_OF_FILE, line(), initial_col);
+  // Test for comment
+  GTLCore::Token commentToken;
+  if( ignoreComment( commentToken, lastChar ) )
+  {
+    return commentToken;
+  }
   if(isalpha(lastChar))
   {
     return GTLCore::Token(GTLCore::Token::IDENTIFIER, getIdentifier(lastChar),line(), initial_col);
@@ -52,9 +58,14 @@
     CHAR_IS_TOKEN(':', COLON );
     CHAR_IS_TOKEN('<', INFERIOR );
     CHAR_IS_TOKEN('>', SUPPERIOR );
+    CHAR_IS_TOKEN('{', STARTBRACE );
+    CHAR_IS_TOKEN('}', ENDBRACE );
+    CHAR_IS_TOKEN(',', COMA );
   }
   if( lastChar > 128 ) return nextToken();
-  GTL_ABORT("Unknown token : " << lastChar << " at " << initial_line << "," << initial_col);
+  GTLCore::String str;
+  str = lastChar;
+  GTL_DEBUG("Unknown token : " << lastChar << " " << str << " at " << initial_line << "," << initial_col);
   return GTLCore::Token(GTLCore::Token::UNKNOWN, initial_line, initial_col);
 }
 

Modified: trunk/OpenGTL/OpenShiva/OpenShiva/MetadataParser_p.cpp
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/MetadataParser_p.cpp	2008-12-01 22:39:03 UTC (rev 511)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/MetadataParser_p.cpp	2008-12-01 22:39:52 UTC (rev 512)
@@ -74,14 +74,26 @@
       {
         version = parseValueEntry("version");
       } else if( str == "info" ) {
-        infoList = parseGroup("info", false);
+        const GTLCore::Metadata::Entry* entry = parseGroupOrParameterEntry("info", false);
+        if( entry )
+        {
+          infoList = entry->asGroup();
+          GTL_ASSERT( infoList );
+        }
       } else if( str == "parameters" ) {
-        parametersList = parseGroup("parameters", true);
+        const GTLCore::Metadata::Entry* entry = parseGroupOrParameterEntry("parameters", true);
+        if( entry )
+        {
+          parametersList = entry->asGroup();
+          GTL_ASSERT( parametersList );
+        }
       } else {
+        GTL_DEBUG("Unexpected");
         reportUnexpected( currentToken() );
         getNextToken();
       }
     } else {
+      GTL_DEBUG("Unexpected");
       reportUnexpected( currentToken() );
       getNextToken();
     }
@@ -101,6 +113,7 @@
 
 void Parser::reportError( const GTLCore::String& errMsg, const GTLCore::Token& token )
 {
+  SHIVA_DEBUG( errMsg );
   d->errorMessages.push_back( GTLCore::ErrorMessage( errMsg, token.line, d->fileName ) );
 }
 
@@ -134,8 +147,8 @@
 
 const GTLCore::Metadata::TextEntry* Parser::parseTextEntry( const GTLCore::String& name)
 {
-  getNextToken();
-  if( isOfType( currentToken(), GTLCore::Token::STRING_CONSTANT ) )
+  GTL_DEBUG( "parseTextEntry" );
+  if( currentToken().type == GTLCore::Token::STRING_CONSTANT or currentToken().type == GTLCore::Token::IDENTIFIER )
   {
     GTLCore::String v = currentToken().string;
     getNextToken();
@@ -144,12 +157,15 @@
       getNextToken();
       return GTLCore::Metadata::Factory::createTextEntry( name, v );
     }
+  } else {
+    reportUnexpected( currentToken() );
   }
   return 0;
 }
 
 const GTLCore::Metadata::ValueEntry* Parser::parseValueEntry(const GTLCore::String& name)
 {
+  GTL_DEBUG( "parseValueEntry" );
   GTLCore::Value val;
   if( currentToken().type == GTLCore::Token::FLOAT_CONSTANT )
   {
@@ -157,7 +173,57 @@
   } else if( currentToken().type == GTLCore::Token::INTEGER_CONSTANT )
   {
     val.setInt32( currentToken().i );
+  } else if( currentToken().type == GTLCore::Token::STARTBRACE )
+  {
+    getNextToken();
+    std::vector< GTLCore::Value > values;
+    while( currentToken().type != GTLCore::Token::ENDBRACE )
+    {
+      if( isOfType( currentToken(), GTLCore::Token::STARTBRACE ) )
+      {
+        getNextToken();
+        std::vector< GTLCore::Value > valuesEntry(2);
+        if( currentToken().type == GTLCore::Token::FLOAT_CONSTANT )
+        {
+          valuesEntry[0].setFloat( currentToken().f );
+        } else if( currentToken().type == GTLCore::Token::INTEGER_CONSTANT )
+        {
+          valuesEntry[0].setFloat( currentToken().i );
+        } else {
+          GTL_DEBUG("Unexpected");
+          reportUnexpected( currentToken() );
+        }
+        getNextToken();
+        if( isOfType( currentToken(), GTLCore::Token::COMA ) )
+        {
+          getNextToken();
+          if( currentToken().type == GTLCore::Token::FLOAT_CONSTANT )
+          {
+            valuesEntry[1].setFloat( currentToken().f );
+          } else if( currentToken().type == GTLCore::Token::INTEGER_CONSTANT )
+          {
+            valuesEntry[1].setFloat( currentToken().i );
+          } else {
+            GTL_DEBUG("Unexpected");
+            reportUnexpected( currentToken() );
+          }
+          getNextToken();
+          isOfType( currentToken(), GTLCore::Token::ENDBRACE );
+          getNextToken();
+          values.push_back( valuesEntry );
+        }
+      } else {
+        return 0;
+      }
+      if( currentToken().type == GTLCore::Token::COMA )
+      {
+        getNextToken();
+        isOfType( currentToken(), GTLCore::Token::STARTBRACE );
+      }
+    }
+    val = GTLCore::Value( values );
   } else {
+    GTL_DEBUG("Unexpected");
     reportUnexpected( currentToken() );
     getNextToken();
     return 0;
@@ -172,8 +238,10 @@
   return 0;
 }
 
-const GTLCore::Metadata::Group* Parser::parseGroup(const GTLCore::String& _name, bool _parameter)
+const GTLCore::Metadata::Entry* Parser::parseGroupOrParameterEntry( const GTLCore::String& _name, bool _parameter)
 {
+  bool isAParameter = false;
+  GTL_DEBUG( "parseListEntry" );
   std::list< const GTLCore::Metadata::Entry*> entries;
   if( isOfType( currentToken(), GTLCore::Token::INFERIOR ) )
   {
@@ -189,27 +257,49 @@
           getNextToken();
           if( currentToken().type == GTLCore::Token::INFERIOR )
           {
-            entries.push_back( parseGroup( str, _parameter ) );
+            entries.push_back( parseGroupOrParameterEntry( str, _parameter ) );
           } else if( not _parameter or str == "description" ) {
             GTL_DEBUG("t: " << str);
             entries.push_back( parseTextEntry( str ) );
           } else {
-            GTL_DEBUG("p: " << str);
-            entries.push_back( parseParameterEntry( str ) );
+            GTL_DEBUG("t: " << str);
+            if( str == "type" )
+            {
+              isAParameter = true;
+              entries.push_back( parseTextEntry( str ) );
+            } else if( str == "minValue" or str == "maxValue" or str == "defaultValue" )
+            {
+              isAParameter = true;
+              entries.push_back( parseValueEntry( str ) );
+            } else {
+              GTL_DEBUG("Unexpected");
+              reportUnexpected( currentToken() );
+            }
           }
+        } else {
+          break;
         }
+      } else {
+        break;
       }
-      getNextToken();
     }
-    if( isOfType( currentToken(), GTLCore::Token::COLON ) )
+    getNextToken();
+    if( isOfType( currentToken(), GTLCore::Token::SEMI ) )
     {
       getNextToken();
-      return GTLCore::Metadata::Factory::createGroup( _name, entries );
+      if( isAParameter )
+      {
+        GTL_ASSERT( _parameter );
+        return GTLCore::Metadata::Factory::createParameterEntry( _name, entries);
+      } else {
+        return GTLCore::Metadata::Factory::createGroup( _name, entries);
+      }
     } else {
       foreach( const GTLCore::Metadata::Entry* entry, entries)
       {
         GTLCore::Metadata::Factory::deleteEntry( entry );
       }
+      return 0;
     }
   }
   getNextToken();

Modified: trunk/OpenGTL/OpenShiva/OpenShiva/MetadataParser_p.h
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/MetadataParser_p.h	2008-12-01 22:39:03 UTC (rev 511)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/MetadataParser_p.h	2008-12-01 22:39:52 UTC (rev 512)
@@ -28,6 +28,7 @@
   class String;
   class Token;
   namespace Metadata {
+    class Entry;
     class ParameterEntry;
     class ValueEntry;
     class TextEntry;
@@ -53,7 +54,7 @@
         const GTLCore::Metadata::ValueEntry* parseValueEntry(const GTLCore::String& name);
         const GTLCore::Metadata::ParameterEntry* parseParameterEntry(const GTLCore::String& name);
         const GTLCore::Metadata::TextEntry* parseTextEntry(const GTLCore::String& name);
-        const GTLCore::Metadata::Group* parseGroup(const GTLCore::String& name, bool _parameter);
+        const GTLCore::Metadata::Entry* parseGroupOrParameterEntry(const GTLCore::String& name, bool _parameter);
       private:
         void getNextToken();
         const GTLCore::Token& currentToken();

Modified: trunk/OpenGTL/OpenShiva/OpenShiva/Parser_p.cpp
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/Parser_p.cpp	2008-12-01 22:39:03 UTC (rev 511)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/Parser_p.cpp	2008-12-01 22:39:52 UTC (rev 512)
@@ -60,7 +60,30 @@
   SHIVA_ASSERT( not d->tree );
   d->tree = new GTLCore::AST::Tree();
   variablesManager()->startContext();
+  
   getNextToken();
+  // Start by ingoring metadata if any
+  if( currentToken().type == GTLCore::Token::INFERIOR )
+  {
+    int count = 0;
+    do
+    {
+      switch( currentToken().type )
+      {
+        case GTLCore::Token::INFERIOR:
+          ++count;
+          break;
+        case GTLCore::Token::SUPPERIOR:
+          --count;
+          break;
+        default:
+          break;
+      }
+      getNextToken();
+    } while( count > 0 and currentToken().type != GTLCore::Token::END_OF_FILE  );
+  }
+  
+  // Parse "import"
   while( currentToken().type == GTLCore::Token::IMPORT )
   {
     getNextToken();
@@ -71,6 +94,7 @@
     checkNextTokenIsSemi();
     getNextToken();
   }
+  // Parse "kernel" or "library"
   if( (d->compiler->isKernel() and isOfType( currentToken(), GTLCore::Token::KERNEL ) )
       or isOfType( currentToken(), GTLCore::Token::LIBRARY ) )
   {

Modified: trunk/OpenGTL/OpenShiva/doc/specification/ShivaSpec.tex
===================================================================
--- trunk/OpenGTL/OpenShiva/doc/specification/ShivaSpec.tex	2008-12-01 22:39:03 UTC (rev 511)
+++ trunk/OpenGTL/OpenShiva/doc/specification/ShivaSpec.tex	2008-12-01 22:39:52 UTC (rev 512)
@@ -193,7 +193,7 @@
       vendor: <
         name: "DoeGraphics";
         address: "1242 Main Street";
-      >
+      >;
       license: "LGPLv2+";
     >;
     parameters: <
@@ -210,6 +210,10 @@
           type: curve;
           defaultValue: {{0,0},{1,1}};
         >;
+        param3: <
+          type: rgb;
+          defaultValue: {1,0,0};
+        >;
       >;
     >;
   >
@@ -228,6 +232,7 @@
 defaulted to $[ 0.0, 1.0 ] $
   \item \verb|curve| (mapped to \verb|float[][2]|) this allow to pass a curve to
 a \verb|kernel|, values are expected to between $ (0,0) $ and $ (1,1) $.
+  \item \verb|rgb| a three components vector of float representing a color
 \end{itemize}
 
 

Modified: trunk/OpenGTL/OpenShiva/tests/convolution/oilify.shiva
===================================================================
--- trunk/OpenGTL/OpenShiva/tests/convolution/oilify.shiva	2008-12-01 22:39:03 UTC (rev 511)
+++ trunk/OpenGTL/OpenShiva/tests/convolution/oilify.shiva	2008-12-01 22:39:52 UTC (rev 512)
@@ -16,7 +16,7 @@
     {
       histogram[i] = 0;
     }
-    float4 max_px;
+/*    float4 max_px;
     int max = 0;
     for( int y = yc - 4; y < yc + 4; ++y)
     {
@@ -31,7 +31,7 @@
           }
        }
     }
-    result = max_px;
+    result = max_px;*/
   }
   region changed(region changed_input_region, int input_index, region input_DOD[])
   {

Modified: trunk/OpenGTL/OpenShiva/tests/library/TestMetadataParser.h
===================================================================
--- trunk/OpenGTL/OpenShiva/tests/library/TestMetadataParser.h	2008-12-01 22:39:03 UTC (rev 511)
+++ trunk/OpenGTL/OpenShiva/tests/library/TestMetadataParser.h	2008-12-01 22:39:52 UTC (rev 512)
@@ -21,7 +21,22 @@
 #include "OpenShiva/KernelMetadata.h"
 
 #include "GTLCore/ErrorMessage.h"
+#include "GTLCore/Value.h"
+#include "GTLCore/Metadata/TextEntry.h"
+#include "GTLCore/Metadata/Group.h"
+#include "GTLCore/Metadata/ValueEntry.h"
+#include "GTLCore/Metadata/ParameterEntry.h"
 
+#define TESTMEDATAPARSER_TEST_TEXT_ENTRY( entry, txt ) \
+  GTLTEST_CHECK_NOT_EQUAL( entry, 0 ) \
+  GTLTEST_CHECK_EQUAL( entry->asTextEntry(), entry ) \
+  GTLTEST_CHECK_EQUAL( entry->asTextEntry()->text(), txt )
+
+#define TESTMEDATAPARSER_TEST_VALUE_ENTRY( entry, val ) \
+  GTLTEST_CHECK_NOT_EQUAL( entry, 0 ) \
+  GTLTEST_CHECK_EQUAL( entry->asValueEntry(), entry ) \
+  GTLTEST_CHECK_EQUAL( entry->asValueEntry()->value(), GTLCore::Value( val ) )
+
 class TestMetadataParser : public GTLTest::Case {
   public:
     TestMetadataParser() : GTLTest::Case("MetadataParser") {}
@@ -35,7 +50,7 @@
     vendor: < \
       name: \"DoeGraphics\"; \
       address: \"1242 Main Street\"; \
-    > \
+    >; \
     license: \"LGPLv2+\"; \
   >; \
   parameters: < \
@@ -50,16 +65,57 @@
       description: \"This is a categorie of parameters\"; \
       param2: < \
         type: curve; \
-        defaultValue: {{0,0},{1,1}}; \
+        defaultValue: {{0.25,0},{1,0.5}}; \
       >; \
-    >; \
+      param3: < \
+          type: rgb; \
+          defaultValue: {1,0,0}; \
+        >; \
+     >; \
   >; \
 >");
       OpenShiva::Metadata::Lexer* lng = new OpenShiva::Metadata::Lexer(&iss);
       OpenShiva::Metadata::Parser parser( lng, "");
       OpenShiva::KernelMetadata* km = parser.parse();
       GTLTEST_CHECK_EQUAL( parser.errorMessages().size(), 0 );
-      std::cout << parser.errorMessages().begin()->errorMessage() << " " << parser.errorMessages().begin()->line() << std::endl;
-      km->name();
+      GTLTEST_CHECK_EQUAL( km->version(), 0 );
+      // Test info
+      TESTMEDATAPARSER_TEST_TEXT_ENTRY( km->infos()->entry( "author" ), "Joe Doe; Joe Doe Jr");
+      TESTMEDATAPARSER_TEST_TEXT_ENTRY( km->infos()->entry( "license" ), "LGPLv2+");
+      GTLTEST_CHECK_NOT_EQUAL( km->infos()->entry( "vendor" ), 0 );
+      const GTLCore::Metadata::Group* vendorGroup = km->infos()->entry( "vendor" )->asGroup();
+      GTLTEST_CHECK_NOT_EQUAL( vendorGroup, 0 );
+      TESTMEDATAPARSER_TEST_TEXT_ENTRY( vendorGroup->entry( "name" ), "DoeGraphics");
+      TESTMEDATAPARSER_TEST_TEXT_ENTRY( vendorGroup->entry( "address" ), "1242 Main Street");
+      // Test parameters
+      GTLTEST_CHECK_NOT_EQUAL( km->parameters()->entry( "param1" ), 0 );
+      const GTLCore::Metadata::ParameterEntry* param1 = km->parameters()->entry( "param1" )->asParameterEntry();
+      GTLTEST_CHECK_NOT_EQUAL( param1, 0 );
+      TESTMEDATAPARSER_TEST_TEXT_ENTRY( param1->entry( "type" ), "int");
+      TESTMEDATAPARSER_TEST_TEXT_ENTRY( param1->entry( "description" ), "This is the first parameter");
+      GTLTEST_CHECK_EQUAL( param1->description(), "This is the first parameter");
+      TESTMEDATAPARSER_TEST_VALUE_ENTRY( param1->entry( "minValue" ), 0);
+      GTLTEST_CHECK_EQUAL( param1->minimumValue(), 0);
+      TESTMEDATAPARSER_TEST_VALUE_ENTRY( param1->entry( "defaultValue" ), 50);
+      GTLTEST_CHECK_EQUAL( param1->defaultValue(), 50);
+      TESTMEDATAPARSER_TEST_VALUE_ENTRY( param1->entry( "maxValue" ), 100);
+      GTLTEST_CHECK_EQUAL( param1->maximumValue(), 100);
+      // Test categorie parameter
+      GTLTEST_CHECK_NOT_EQUAL( km->parameters()->entry( "categorie2" ), 0 );
+      const GTLCore::Metadata::Group* categorie2 = km->parameters()->entry( "categorie2" )->asGroup();
+      GTLTEST_CHECK_NOT_EQUAL( categorie2, 0 );
+      TESTMEDATAPARSER_TEST_TEXT_ENTRY( categorie2->entry( "description" ), "This is a categorie of parameters");
+      // Test parameter2
+      GTLTEST_CHECK_NOT_EQUAL( categorie2->entry("param2"), 0 );
+      const GTLCore::Metadata::ParameterEntry* param2 = categorie2->entry( "param2" )->asParameterEntry();
+      GTLTEST_CHECK_NOT_EQUAL( param2, 0 );
+      TESTMEDATAPARSER_TEST_TEXT_ENTRY( param2->entry( "type" ), "curve");
+      std::vector< GTLCore::Value > v1; v1.push_back( 0.25f ); v1.push_back( 0.0f );
+      std::vector< GTLCore::Value > v2; v2.push_back( 1.0f ); v2.push_back( 0.5f );
+      std::vector< GTLCore::Value > v3; v3.push_back( v1 ); v3.push_back( v2 );
+      TESTMEDATAPARSER_TEST_TEXT_ENTRY( param2->entry( "type" ), "curve");
+      TESTMEDATAPARSER_TEST_VALUE_ENTRY( param2->entry( "defaultValue" ), v3);
+      GTLTEST_CHECK_EQUAL( param2->defaultValue(), v3);
+      
     }
 };

Modified: trunk/OpenGTL/OpenShiva/tests/parse/CMakeLists.txt
===================================================================
--- trunk/OpenGTL/OpenShiva/tests/parse/CMakeLists.txt	2008-12-01 22:39:03 UTC (rev 511)
+++ trunk/OpenGTL/OpenShiva/tests/parse/CMakeLists.txt	2008-12-01 22:39:52 UTC (rev 512)
@@ -1,5 +1,6 @@
 
 set( TESTS_FILES
+  metadata.shiva
   kernel.shiva
   for.shiva
   region.shiva

Added: trunk/OpenGTL/OpenShiva/tests/parse/metadata.shiva
===================================================================
--- trunk/OpenGTL/OpenShiva/tests/parse/metadata.shiva	                        (rev 0)
+++ trunk/OpenGTL/OpenShiva/tests/parse/metadata.shiva	2008-12-01 22:39:52 UTC (rev 512)
@@ -0,0 +1,35 @@
+<
+  version: 0;
+  info: <
+    author: "Joe Doe; Joe Doe Jr";
+    vendor: <
+      name: "DoeGraphics";
+      address: "1242 Main Street";
+    >;
+    license: "LGPLv2+";
+  >;
+  parameters: <
+    param1: <
+      type: int;
+      minValue: 0;
+      maxValue: 100;
+      defaultValue: 50;
+      description: "This is the first parameter";
+    >;
+    categorie2: <
+      description: "This is a categorie of parameters";
+      param2: <
+        type: curve;
+        defaultValue: {{0.25,0},{1,0.5}};
+      >;
+    >;
+  >;
+>
+
+kernel Metadata {
+  void evaluatePixel(input image source1, output pixel result)
+  {
+    
+  }
+  
+}

Modified: trunk/OpenGTL/OpenShiva/tools/compiler/ShivaC.cpp
===================================================================
--- trunk/OpenGTL/OpenShiva/tools/compiler/ShivaC.cpp	2008-12-01 22:39:03 UTC (rev 511)
+++ trunk/OpenGTL/OpenShiva/tools/compiler/ShivaC.cpp	2008-12-01 22:39:52 UTC (rev 512)
@@ -53,7 +53,6 @@
   GTLCore::String fileName = "";
   GTLCore::String output = "";
   bool showAssembly = false;
-  bool showAsC = false;
   for(int ai = 1; ai < argc; ai++)
   {
     if(ARG_IS("-h","--help"))
@@ -66,8 +65,6 @@
       return EXIT_SUCCESS;
     } else if(ARG_IS("-S","--asm-source")) {
       showAssembly = true;
-    } else if(ARG_IS("-C","--c-source")) {
-      showAsC = true;
     } else if(ARG_IS("-o","--output")) {
       if( ai == argc )
       {
@@ -126,10 +123,6 @@
     {
       std::cout << p.asmSourceCode();
     }
-    if( showAsC )
-    {
-      std::cout << p.cSourceCode();
-    }
   }
   return EXIT_SUCCESS;
 }


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