[opengtl-commits] [552] fix searching of funcion inside a namespace

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


Revision: 552
Author:   cyrille
Date:     2008-12-20 11:50:52 +0100 (Sat, 20 Dec 2008)

Log Message:
-----------
fix searching of funcion inside a namespace

Modified Paths:
--------------
    trunk/OpenGTL/OpenGTL/GTLCore/CompilerBase_p.cpp
    trunk/OpenGTL/OpenGTL/GTLCore/ModuleData_p.cpp
    trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.cpp


Modified: trunk/OpenGTL/OpenGTL/GTLCore/CompilerBase_p.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/CompilerBase_p.cpp	2008-12-18 21:41:03 UTC (rev 551)
+++ trunk/OpenGTL/OpenGTL/GTLCore/CompilerBase_p.cpp	2008-12-20 10:50:52 UTC (rev 552)
@@ -99,10 +99,21 @@
 
 GTLCore::Function* CompilerBase::function( const GTLCore::ScopedName&  name)
 {
+  GTL_DEBUG( "Look for function: " << name );
   std::map< GTLCore::ScopedName, GTLCore::Function* >::iterator it = d->functions.find( name );
   if( it == d->functions.end() )
   {
-    return 0;
+    if( name.nameSpace() == "" )
+    {
+      GTL_DEBUG(" Available functions");
+      for( std::map< GTLCore::ScopedName, GTLCore::Function* >::iterator it2 = d->functions.begin(); it2 != d->functions.end(); ++it2)
+      {
+        GTL_DEBUG( it2->first );
+      }
+      return 0;
+    }
+    GTLCore::ScopedName  globalName( "", name.name() );
+    return function( globalName );
   } else {
     return it->second;
   }

Modified: trunk/OpenGTL/OpenGTL/GTLCore/ModuleData_p.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/ModuleData_p.cpp	2008-12-18 21:41:03 UTC (rev 551)
+++ trunk/OpenGTL/OpenGTL/GTLCore/ModuleData_p.cpp	2008-12-20 10:50:52 UTC (rev 552)
@@ -68,12 +68,15 @@
 
 Function* ModuleData::function(const String& _currentNameSpace, const String& _name)
 {
+  GTL_DEBUG( _currentNameSpace << "::" << _name );
   for( std::map<ScopedName, Function*>::iterator it = m_functions.begin();
        it != m_functions.end(); ++it)
   {
+    GTL_DEBUG( it->first );
     if( (it->first.nameSpace() == "" or it->first.nameSpace() == _currentNameSpace )
         and it->first.name() == _name )
     {
+      GTL_DEBUG( it->second );
       return it->second;
     }
   }

Modified: trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.cpp	2008-12-18 21:41:03 UTC (rev 551)
+++ trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.cpp	2008-12-20 10:50:52 UTC (rev 552)
@@ -1319,7 +1319,10 @@
         }
         if( d->currentToken.type == Token::STARTBRACKET )
         { // It's a function call
-          Function* function = d->compiler->function( name );
+          GTL_DEBUG( name );
+          ScopedName fname( ( name.nameSpace() == "" ) ? d->nameSpace : name.nameSpace(),
+                              name.name() );
+          Function* function = d->compiler->function( fname );
           if( not function )
           {
             reportError("Unknown function: " + name.toString(), d->currentToken);


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