[opengtl-commits] [183] refactor function to hide Function::Data from the public API

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


Revision: 183
Author:   cyrille
Date:     2008-05-24 11:30:36 +0200 (Sat, 24 May 2008)

Log Message:
-----------
refactor function to hide Function::Data from the public API

Modified Paths:
--------------
    trunk/OpenGTL/OpenCTL/OpenCTL/compiler/Compiler.cpp
    trunk/OpenGTL/OpenGTL/GTLCore/AST/Expression.cpp
    trunk/OpenGTL/OpenGTL/GTLCore/AST/FunctionDeclaration.cpp
    trunk/OpenGTL/OpenGTL/GTLCore/Function.cpp
    trunk/OpenGTL/OpenGTL/GTLCore/Function.h
    trunk/OpenGTL/OpenGTL/GTLCore/Function_p.h
    trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.cpp


Modified: trunk/OpenGTL/OpenCTL/OpenCTL/compiler/Compiler.cpp
===================================================================
--- trunk/OpenGTL/OpenCTL/OpenCTL/compiler/Compiler.cpp	2008-05-21 21:56:42 UTC (rev 182)
+++ trunk/OpenGTL/OpenCTL/OpenCTL/compiler/Compiler.cpp	2008-05-24 09:30:36 UTC (rev 183)
@@ -292,8 +292,8 @@
     for(std::list<GTLCore::Function*>::iterator it = functions.begin();
         it != functions.end(); ++it)
     {
-      int min = (*it)->data()->minimumParameters();
-      int max = (*it)->data()->maximumParameters();
+      int min = (*it)->d->data->minimumParameters();
+      int max = (*it)->d->data->maximumParameters();
       std::vector<llvm::Function*> functions(max + 1);
       for(int i = min; i <= max; ++i)
       {

Modified: trunk/OpenGTL/OpenGTL/GTLCore/AST/Expression.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/AST/Expression.cpp	2008-05-21 21:56:42 UTC (rev 182)
+++ trunk/OpenGTL/OpenGTL/GTLCore/AST/Expression.cpp	2008-05-24 09:30:36 UTC (rev 183)
@@ -115,7 +115,7 @@
 {
   // Function Type
   GTL_ASSERT( m_function );
-  llvm::Function* llvmFunction = m_function->data()->function( m_arguments.size() );
+  llvm::Function* llvmFunction = m_function->d->data->function( m_arguments.size() );
     const llvm::FunctionType *FTy = llvm::cast<llvm::FunctionType>(llvm::cast<llvm::PointerType>( llvmFunction->getType())->getElementType());
     GTL_DEBUG( *FTy );
   GTL_ASSERT( llvmFunction );

Modified: trunk/OpenGTL/OpenGTL/GTLCore/AST/FunctionDeclaration.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/AST/FunctionDeclaration.cpp	2008-05-21 21:56:42 UTC (rev 182)
+++ trunk/OpenGTL/OpenGTL/GTLCore/AST/FunctionDeclaration.cpp	2008-05-24 09:30:36 UTC (rev 183)
@@ -109,7 +109,7 @@
   std::vector< Parameter > gtlParams = m_function->parameters(); // Use a copy of this to create the symbol name
   // Generates functions for default parameters
   llvm::Function* previousFunction = fullFunction;
-  for( unsigned int i = m_function->parameters().size(); i > m_function->data()->minimumParameters(); i--)
+  for( unsigned int i = m_function->parameters().size(); i > m_function->d->data->minimumParameters(); i--)
   {
     // Create the function type
     params.pop_back(); // remove the last parameter

Modified: trunk/OpenGTL/OpenGTL/GTLCore/Function.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Function.cpp	2008-05-21 21:56:42 UTC (rev 182)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Function.cpp	2008-05-24 09:30:36 UTC (rev 183)
@@ -29,14 +29,6 @@
 
 using namespace GTLCore;
 
-struct Function::Private
-{
-  GTLCore::ScopedName name;
-  const GTLCore::Type* returnType;
-  Function::Data* data;
-  std::vector<FunctionCaller*> functionsCaller;
-};
-
 Function::Function(const GTLCore::ScopedName& _name, const GTLCore::Type* _returnType, Data* _data) : d(new Private)
 {
   d->name = _name;
@@ -70,11 +62,6 @@
   return d->returnType;
 }
 
-const Function::Data* Function::data() const
-{
-  return d->data;
-}
-
 GTLCore::Value Function::call( const std::vector< GTLCore::Value>& _parameters) const
 {
   if(_parameters.size() > d->data->maximumParameters()) return GTLCore::Value();

Modified: trunk/OpenGTL/OpenGTL/GTLCore/Function.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Function.h	2008-05-21 21:56:42 UTC (rev 182)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Function.h	2008-05-24 09:30:36 UTC (rev 183)
@@ -23,18 +23,31 @@
 #include <vector>
 #include <GTLCore/String.h>
 
+namespace OpenCTL {
+  class Compiler;
+  class Program;
+}
+
 namespace GTLCore {
   class Type;
   class Value;
   class Parameter;
   class ScopedName;
+  namespace AST {
+    class FunctionCallExpression;
+    class FunctionDeclaration;
+  }
   /**
    * This class contains the information about a function, it also allow to
    * execute the function.
    * @ingroup GTLCore
    */
   class Function {
-    public:
+      friend class AST::FunctionCallExpression;
+      friend class AST::FunctionDeclaration;
+      friend class ParserBase;
+      friend class OpenCTL::Compiler;
+      friend class OpenCTL::Program;
       class Data;
     public:
       /**
@@ -62,11 +75,6 @@
        * @return the type of the function
        */
       const GTLCore::Type* returnType() const;
-      /**
-       * @internal
-       * @return the data of this function
-       */
-      const Data* data() const;
     private:
       struct Private;
       Private* const d;

Modified: trunk/OpenGTL/OpenGTL/GTLCore/Function_p.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Function_p.h	2008-05-21 21:56:42 UTC (rev 182)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Function_p.h	2008-05-24 09:30:36 UTC (rev 183)
@@ -23,6 +23,7 @@
 #include "Function.h"
 #include "Parameter.h"
 #include <vector>
+#include "GTLCore/ScopedName.h"
 
 namespace llvm {
   class Function;
@@ -30,13 +31,26 @@
 }
 
 namespace GTLCore {
+  class FunctionCaller;
   /**
+   * @internal
    * This class is not part of the public API of OpenCTL.
    * 
+   */
+  struct Function::Private
+  {
+    GTLCore::ScopedName name;
+    const GTLCore::Type* returnType;
+    Function::Data* data;
+    std::vector<FunctionCaller*> functionsCaller;
+  };
+  /**
+   * @internal
+   * This class is not part of the public API of OpenCTL.
+   * 
    * This class contains specific structure coming from LLVM,
    * like a pointer to llvm::Function.
    * 
-   * @internal
    */
   class Function::Data {
     public:

Modified: trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.cpp	2008-05-21 21:56:42 UTC (rev 182)
+++ trunk/OpenGTL/OpenGTL/GTLCore/ParserBase_p.cpp	2008-05-24 09:30:36 UTC (rev 183)
@@ -964,7 +964,7 @@
           }
           GTL_ASSERT( d->currentToken.type == GTLCore::Token::ENDBRACKET );
           getNextToken(); // eat the end bracket
-          if( arguments.size() >= function->data()->minimumParameters() and arguments.size() <= function->data()->maximumParameters() )
+          if( arguments.size() >= function->d->data->minimumParameters() and arguments.size() <= function->d->data->maximumParameters() )
           {
             return new AST::FunctionCallExpression( function, arguments ) ;
           } else {


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