Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[Manta] r2106 - trunk/Core/Util


Chronological Thread 
  • From: "James Bigler" <bigler@cs.utah.edu>
  • To: manta@sci.utah.edu
  • Subject: [Manta] r2106 - trunk/Core/Util
  • Date: Thu, 21 Feb 2008 17:28:19 -0700 (MST)

Author: bigler
Date: Thu Feb 21 17:28:18 2008
New Revision: 2106

Added:
   trunk/Core/Util/genCallbacks.py
Modified:
   trunk/Core/Util/Callback.h
Log:
Core/Util/Callback.h

  Generated version of this file.

Core/Util/genCallbacks.py

  Start of script to generate the big mess of Callback functions.  Currently
  only handles Callback.h.


Modified: trunk/Core/Util/Callback.h
==============================================================================
--- trunk/Core/Util/Callback.h  (original)
+++ trunk/Core/Util/Callback.h  Thu Feb 21 17:28:18 2008
@@ -1,5 +1,6 @@
-
 /*
+  This file was automatically generated.  Don't modify by hand.
+
   For a detailed explaination of the Callback construct please see:
 
   doc/Callbacks.txt
@@ -11,9 +12,10 @@
   3.  Arg  is the callback creation time bound arguments.
   4.  Data parameters preceed the Arg parameters of the callback function.
   5.  If you don't find a create function that match the number of
-      Data and Arg parameters you need, add the create function and
-      corresponding Callback_XData_XArg class.
- */
+  Data and Arg parameters you need, add the create function and
+  corresponding Callback_XData_XArg class.
+
+*/
 
 #ifndef Manta_Interface_Callback_h
 #define Manta_Interface_Callback_h
@@ -23,257 +25,262 @@
 namespace Manta {
   class Callback {
   public:
+    //////////////////////////////
+    // Global functions or static class member functions
 
-    ////////////////////////////////////////////////////////////
-    // Global functin or static class member functions
-
-    // 0 Data
+    // 0 call time args --- 0 creating time args
     static
     CallbackBase_0Data*
     create(void (*pmf)()) {
       return new Callback_Static_0Data_0Arg(pmf);
     }
 
+    // 0 call time args --- 1 creating time args
     template<typename Arg1> static
     CallbackBase_0Data*
     create(void (*pmf)(Arg1), Arg1 arg1) {
       return new Callback_Static_0Data_1Arg<Arg1>(pmf, arg1);
     }
 
+    // 0 call time args --- 2 creating time args
     template<typename Arg1, typename Arg2> static
     CallbackBase_0Data*
     create(void (*pmf)(Arg1, Arg2), Arg1 arg1, Arg2 arg2) {
-      return new Callback_Static_0Data_2Arg<Arg1,Arg2>(pmf, arg1, arg2);
+      return new Callback_Static_0Data_2Arg<Arg1, Arg2>(pmf, arg1, arg2);
     }
 
+    // 0 call time args --- 5 creating time args
     template<typename Arg1, typename Arg2, typename Arg3, typename Arg4, 
typename Arg5> static
     CallbackBase_0Data*
-    create(void (*pmf)(Arg1, Arg2, Arg3, Arg4, Arg5), Arg1 arg1, Arg2 arg2, 
-        Arg3 arg3, Arg4 arg4, Arg5 arg5) {
-      return new Callback_Static_0Data_5Arg<Arg1,Arg2,Arg3,Arg4,Arg5>(
-          pmf, arg1, arg2, arg3, arg4, arg5);
+    create(void (*pmf)(Arg1, Arg2, Arg3, Arg4, Arg5), Arg1 arg1, Arg2 arg2, 
Arg3 arg3, Arg4 arg4, Arg5 arg5) {
+      return new Callback_Static_0Data_5Arg<Arg1, Arg2, Arg3, Arg4, 
Arg5>(pmf, arg1, arg2, arg3, arg4, arg5);
     }
 
-    // 1 Data
+    // 1 call time args --- 0 creating time args
     template<typename Data1> static
     CallbackBase_1Data<Data1>*
     create(void (*pmf)(Data1)) {
       return new Callback_Static_1Data_0Arg<Data1>(pmf);
     }
 
-    template<typename Data1,
-             typename Arg1> static
+    // 1 call time args --- 1 creating time args
+    template<typename Data1, typename Arg1> static
     CallbackBase_1Data<Data1>*
-    create(void (*pmf)(Data1, Arg1),
-           Arg1 arg1) {
+    create(void (*pmf)(Data1, Arg1), Arg1 arg1) {
       return new Callback_Static_1Data_1Arg<Data1, Arg1>(pmf, arg1);
     }
 
-    template<typename Data1,
-             typename Arg1, typename Arg2> static
+    // 1 call time args --- 2 creating time args
+    template<typename Data1, typename Arg1, typename Arg2> static
     CallbackBase_1Data<Data1>*
-    create(void (*pmf)(Data1, Arg1, Arg2),
-           Arg1 arg1, Arg2 arg2) {
+    create(void (*pmf)(Data1, Arg1, Arg2), Arg1 arg1, Arg2 arg2) {
       return new Callback_Static_1Data_2Arg<Data1, Arg1, Arg2>(pmf, arg1, 
arg2);
     }
 
-    // 2 Data
-    template<typename Data1, typename Data2,
-             typename Arg1, typename Arg2> static
-    CallbackBase_2Data<Data1, Data2>*
-    create(void (*pmf)(Data1, Data2, Arg1, Arg2),
-           Arg1 arg1, Arg2 arg2) {
-      return new Callback_Static_2Data_2Arg<Data1, Data2, Arg1, Arg2>(pmf, 
arg1, arg2);
-    }
-
+    // 2 call time args --- 0 creating time args
     template<typename Data1, typename Data2> static
     CallbackBase_2Data<Data1, Data2>*
     create(void (*pmf)(Data1, Data2)) {
       return new Callback_Static_2Data_0Arg<Data1, Data2>(pmf);
     }
 
-    // 3 Data
-    template<typename Data1, typename Data2, typename Data3,
-             typename Arg1> static
+    // 2 call time args --- 2 creating time args
+    template<typename Data1, typename Data2, typename Arg1, typename Arg2> 
static
+    CallbackBase_2Data<Data1, Data2>*
+    create(void (*pmf)(Data1, Data2, Arg1, Arg2), Arg1 arg1, Arg2 arg2) {
+      return new Callback_Static_2Data_2Arg<Data1, Data2, Arg1, Arg2>(pmf, 
arg1, arg2);
+    }
+
+    // 3 call time args --- 1 creating time args
+    template<typename Data1, typename Data2, typename Data3, typename Arg1> 
static
     CallbackBase_3Data<Data1, Data2, Data3>*
-    create(void (*pmf)(Data1, Data2, Data3, Arg1),
-           Arg1 arg1) {
+    create(void (*pmf)(Data1, Data2, Data3, Arg1), Arg1 arg1) {
       return new Callback_Static_3Data_1Arg<Data1, Data2, Data3, Arg1>(pmf, 
arg1);
     }
 
-    template<typename Data1, typename Data2, typename Data3,
-             typename Arg1, typename Arg2> static
+    // 3 call time args --- 2 creating time args
+    template<typename Data1, typename Data2, typename Data3, typename Arg1, 
typename Arg2> static
     CallbackBase_3Data<Data1, Data2, Data3>*
-    create(void (*pmf)(Data1, Data2, Data3, Arg1, Arg2),
-           Arg1 arg1, Arg2 arg2) {
+    create(void (*pmf)(Data1, Data2, Data3, Arg1, Arg2), Arg1 arg1, Arg2 
arg2) {
       return new Callback_Static_3Data_2Arg<Data1, Data2, Data3, Arg1, 
Arg2>(pmf, arg1, arg2);
     }
 
-    // 4 Data
-    template<typename Data1, typename Data2, typename Data3, typename Data4,
-             typename Arg1, typename Arg2> static
+    // 4 call time args --- 2 creating time args
+    template<typename Data1, typename Data2, typename Data3, typename Data4, 
typename Arg1, typename Arg2> static
     CallbackBase_4Data<Data1, Data2, Data3, Data4>*
-    create(void (*pmf)(Data1, Data2, Data3, Data4, Arg1, Arg2),
-           Arg1 arg1, Arg2 arg2) {
+    create(void (*pmf)(Data1, Data2, Data3, Data4, Arg1, Arg2), Arg1 arg1, 
Arg2 arg2) {
       return new Callback_Static_4Data_2Arg<Data1, Data2, Data3, Data4, 
Arg1, Arg2>(pmf, arg1, arg2);
     }
 
-
-    ///////////////////////////////////////////////////////////
+    //////////////////////////////
     // Class member functions
 
-    // 0 Data callbacks
+    // 0 call time args --- 0 creating time args
     template<class T> static
     CallbackBase_0Data*
     create(T* ptr, void (T::*pmf)()) {
       return new Callback_0Data_0Arg<T>(ptr, pmf);
     }
 
-#ifndef SWIG // For now these const versions won't compile in swig
-                template<class T> static
-    CallbackBase_0Data*
-    create(T* ptr, void (T::*pmf)() const) {
-      return new Callback_0Data_0Arg_const<T>(ptr, pmf);
-    }
-#endif
-
+    // 0 call time args --- 1 creating time args
     template<class T, typename Arg1> static
     CallbackBase_0Data*
     create(T* ptr, void (T::*pmf)(Arg1), Arg1 arg1) {
       return new Callback_0Data_1Arg<T, Arg1>(ptr, pmf, arg1);
     }
 
-#ifndef SWIG // For now these const versions won't compile in swig
-                template<class T, typename Arg1> static
-    CallbackBase_0Data*
-    create(T* ptr, void (T::*pmf)(Arg1) const, Arg1 arg1) {
-      return new Callback_0Data_1Arg_const<T, Arg1>(ptr, pmf, arg1);
-    }
-#endif
-
+    // 0 call time args --- 2 creating time args
     template<class T, typename Arg1, typename Arg2> static
     CallbackBase_0Data*
     create(T* ptr, void (T::*pmf)(Arg1, Arg2), Arg1 arg1, Arg2 arg2) {
       return new Callback_0Data_2Arg<T, Arg1, Arg2>(ptr, pmf, arg1, arg2);
     }
 
-#ifndef SWIG // For now these const versions won't compile in swig
-                template<class T, typename Arg1, typename Arg2> static
-    CallbackBase_0Data*
-    create(T* ptr, void (T::*pmf)(Arg1, Arg2) const, Arg1 arg1, Arg2 arg2) {
-      return new Callback_0Data_2Arg_const<T, Arg1, Arg2>(ptr, pmf, arg1, 
arg2);
-    }
-#endif
+    // 0 call time args --- 3 creating time args
     template<class T, typename Arg1, typename Arg2, typename Arg3> static
     CallbackBase_0Data*
     create(T* ptr, void (T::*pmf)(Arg1, Arg2, Arg3), Arg1 arg1, Arg2 arg2, 
Arg3 arg3) {
       return new Callback_0Data_3Arg<T, Arg1, Arg2, Arg3>(ptr, pmf, arg1, 
arg2, arg3);
     }
 
+    // 0 call time args --- 4 creating time args
     template<class T, typename Arg1, typename Arg2, typename Arg3, typename 
Arg4> static
     CallbackBase_0Data*
     create(T* ptr, void (T::*pmf)(Arg1, Arg2, Arg3, Arg4), Arg1 arg1, Arg2 
arg2, Arg3 arg3, Arg4 arg4) {
       return new Callback_0Data_4Arg<T, Arg1, Arg2, Arg3, Arg4>(ptr, pmf, 
arg1, arg2, arg3, arg4);
     }
 
+    // 1 call time args --- 0 creating time args
     template<class T, typename Data1> static
     CallbackBase_1Data<Data1>*
     create(T* ptr, void (T::*pmf)(Data1)) {
       return new Callback_1Data_0Arg<T, Data1>(ptr, pmf);
     }
 
+    // 1 call time args --- 1 creating time args
     template<class T, typename Data1, typename Arg1> static
     CallbackBase_1Data<Data1>*
     create(T* ptr, void (T::*pmf)(Data1, Arg1), Arg1 arg1) {
       return new Callback_1Data_1Arg<T, Data1, Arg1>(ptr, pmf, arg1);
     }
 
+    // 1 call time args --- 2 creating time args
     template<class T, typename Data1, typename Arg1, typename Arg2> static
     CallbackBase_1Data<Data1>*
     create(T* ptr, void (T::*pmf)(Data1, Arg1, Arg2), Arg1 arg1, Arg2 arg2) {
       return new Callback_1Data_2Arg<T, Data1, Arg1, Arg2>(ptr, pmf, arg1, 
arg2);
     }
 
-    // 2 Data elements
+    // 2 call time args --- 0 creating time args
     template<class T, typename Data1, typename Data2> static
     CallbackBase_2Data<Data1, Data2>*
     create(T* ptr, void (T::*pmf)(Data1, Data2)) {
       return new Callback_2Data_0Arg<T, Data1, Data2>(ptr, pmf);
     }
 
+    // 2 call time args --- 1 creating time args
     template<class T, typename Data1, typename Data2, typename Arg1> static
     CallbackBase_2Data<Data1, Data2>*
     create(T* ptr, void (T::*pmf)(Data1, Data2, Arg1), Arg1 arg1) {
       return new Callback_2Data_1Arg<T, Data1, Data2, Arg1>(ptr, pmf, arg1);
     }
 
-    template<class T, typename Data1, typename Data2,
-             typename Arg1, typename Arg2> static
+    // 2 call time args --- 2 creating time args
+    template<class T, typename Data1, typename Data2, typename Arg1, 
typename Arg2> static
     CallbackBase_2Data<Data1, Data2>*
-    create(T* ptr, void (T::*pmf)(Data1, Data2, Arg1, Arg2),
-           Arg1 arg1, Arg2 arg2) {
+    create(T* ptr, void (T::*pmf)(Data1, Data2, Arg1, Arg2), Arg1 arg1, Arg2 
arg2) {
       return new Callback_2Data_2Arg<T, Data1, Data2, Arg1, Arg2>(ptr, pmf, 
arg1, arg2);
     }
 
-    template<class T, typename Data1, typename Data2,
-             typename Arg1, typename Arg2, typename Arg3> static
+    // 2 call time args --- 3 creating time args
+    template<class T, typename Data1, typename Data2, typename Arg1, 
typename Arg2, typename Arg3> static
     CallbackBase_2Data<Data1, Data2>*
-    create(T* ptr, void (T::*pmf)(Data1, Data2, Arg1, Arg2, Arg3),
-           Arg1 arg1, Arg2 arg2, Arg3 arg3) {
+    create(T* ptr, void (T::*pmf)(Data1, Data2, Arg1, Arg2, Arg3), Arg1 
arg1, Arg2 arg2, Arg3 arg3) {
       return new Callback_2Data_3Arg<T, Data1, Data2, Arg1, Arg2, Arg3>(ptr, 
pmf, arg1, arg2, arg3);
     }
 
-    // 3 Data elements
+    // 3 call time args --- 0 creating time args
     template<class T, typename Data1, typename Data2, typename Data3> static
     CallbackBase_3Data<Data1, Data2, Data3>*
     create(T* ptr, void (T::*pmf)(Data1, Data2, Data3)) {
       return new Callback_3Data_0Arg<T, Data1, Data2, Data3>(ptr, pmf);
     }
 
+    // 3 call time args --- 1 creating time args
     template<class T, typename Data1, typename Data2, typename Data3, 
typename Arg1> static
     CallbackBase_3Data<Data1, Data2, Data3>*
     create(T* ptr, void (T::*pmf)(Data1, Data2, Data3, Arg1), Arg1 arg1) {
       return new Callback_3Data_1Arg<T, Data1, Data2, Data3, Arg1>(ptr, pmf, 
arg1);
     }
 
-    // 4 data elements
+    // 4 call time args --- 0 creating time args
     template<class T, typename Data1, typename Data2, typename Data3, 
typename Data4> static
     CallbackBase_4Data<Data1, Data2, Data3, Data4>*
     create(T* ptr, void (T::*pmf)(Data1, Data2, Data3, Data4)) {
       return new Callback_4Data_0Arg<T, Data1, Data2, Data3, Data4>(ptr, 
pmf);
     }
 
+    // 4 call time args --- 1 creating time args
     template<class T, typename Data1, typename Data2, typename Data3, 
typename Data4, typename Arg1> static
     CallbackBase_4Data<Data1, Data2, Data3, Data4>*
     create(T* ptr, void (T::*pmf)(Data1, Data2, Data3, Data4, Arg1), Arg1 
arg1) {
       return new Callback_4Data_1Arg<T, Data1, Data2, Data3, Data4, 
Arg1>(ptr, pmf, arg1);
     }
 
+    // 4 call time args --- 2 creating time args
     template<class T, typename Data1, typename Data2, typename Data3, 
typename Data4, typename Arg1, typename Arg2> static
     CallbackBase_4Data<Data1, Data2, Data3, Data4>*
     create(T* ptr, void (T::*pmf)(Data1, Data2, Data3, Data4, Arg1, Arg2), 
Arg1 arg1, Arg2 arg2) {
       return new Callback_4Data_2Arg<T, Data1, Data2, Data3, Data4, Arg1, 
Arg2>(ptr, pmf, arg1, arg2);
     }
 
-    // 5 data elements
+    // 5 call time args --- 0 creating time args
     template<class T, typename Data1, typename Data2, typename Data3, 
typename Data4, typename Data5> static
     CallbackBase_5Data<Data1, Data2, Data3, Data4, Data5>*
     create(T* ptr, void (T::*pmf)(Data1, Data2, Data3, Data4, Data5)) {
       return new Callback_5Data_0Arg<T, Data1, Data2, Data3, Data4, 
Data5>(ptr, pmf);
     }
 
-    // 6 data elements
+    // 6 call time args --- 0 creating time args
     template<class T, typename Data1, typename Data2, typename Data3, 
typename Data4, typename Data5, typename Data6> static
     CallbackBase_6Data<Data1, Data2, Data3, Data4, Data5, Data6>*
     create(T* ptr, void (T::*pmf)(Data1, Data2, Data3, Data4, Data5, Data6)) 
{
       return new Callback_6Data_0Arg<T, Data1, Data2, Data3, Data4, Data5, 
Data6>(ptr, pmf);
     }
-  private:
-    Callback(const Callback&);
-    Callback& operator=(const Callback&);
-  };
-}
 
-#endif
+    //////////////////////////////
+    // Class member functions
+
+#ifndef SWIG // For now these const versions won't compile in swig
+    // 0 call time args --- 0 creating time args
+    template<class T> static
+    CallbackBase_0Data*
+    create(T* ptr, void (T::*pmf)() const) {
+      return new Callback_0Data_0Arg_const<T>(ptr, pmf);
+    }
+#endif // #ifndef SWIG
+
+#ifndef SWIG // For now these const versions won't compile in swig
+    // 0 call time args --- 1 creating time args
+    template<class T, typename Arg1> static
+    CallbackBase_0Data*
+    create(T* ptr, void (T::*pmf)(Arg1) const, Arg1 arg1) {
+      return new Callback_0Data_1Arg_const<T, Arg1>(ptr, pmf, arg1);
+    }
+#endif // #ifndef SWIG
 
+#ifndef SWIG // For now these const versions won't compile in swig
+    // 0 call time args --- 2 creating time args
+    template<class T, typename Arg1, typename Arg2> static
+    CallbackBase_0Data*
+    create(T* ptr, void (T::*pmf)(Arg1, Arg2) const, Arg1 arg1, Arg2 arg2) {
+      return new Callback_0Data_2Arg_const<T, Arg1, Arg2>(ptr, pmf, arg1, 
arg2);
+    }
+#endif // #ifndef SWIG
 
+  private:
+    Callback(const Callback&);
+    Callback& operator=(const Callback&);
+  }; // end class Callback
+} // end namespace Manta
+#endif // #ifndef Manta_Interface_Callback_h

Added: trunk/Core/Util/genCallbacks.py
==============================================================================
--- (empty file)
+++ trunk/Core/Util/genCallbacks.py     Thu Feb 21 17:28:18 2008
@@ -0,0 +1,234 @@
+#!/usr/bin/python
+
+class Function:
+    def __init__(self, num_call_time_args = 0, num_creation_time_args = 0):
+        self.num_call_time_args = num_call_time_args
+        self.num_creation_time_args = num_creation_time_args
+
+    def templateParameter(self):
+        arg_list = self.typeList()
+        if (len(arg_list) == 0):
+            return ""
+        return "template<" + self.format(arg_list, prefix="typename") + "> "
+
+    def baseName(self):
+        base = "CallbackBase_%dData" % self.num_call_time_args
+        if (self.num_call_time_args > 0):
+            base+= "<" + self.format(self.dataList()) + ">"
+        return base
+
+    def staticClassName(self):
+        base = "Callback_Static_%dData_%dArg" % (self.num_call_time_args, 
self.num_creation_time_args)
+        type_list = self.typeList()
+        if (len(type_list) > 0):
+            base += "<" + self.format(type_list) + ">"
+        return base
+
+    def className(self, constant=False):
+        if (constant):
+            constant_text = "_const"
+        else:
+            constant_text = ""
+        base = "Callback_%dData_%dArg%s<T" % (self.num_call_time_args, 
self.num_creation_time_args, constant_text)
+        type_list = self.typeList()
+        if (len(type_list) > 0):
+            base += ", " + self.format(type_list)
+        base += ">"
+        return base
+
+    def typeList(self):
+        return self.dataList() + self.argList()
+
+    def dataList(self):
+        list = []
+        for arg in range(1, self.num_call_time_args+1):
+            list.append("Data%d" % arg)
+        return tuple(list)
+
+    def argList(self):
+        list = []
+        for arg in range(1, self.num_creation_time_args+1):
+            list.append("Arg%d" % arg)
+        return tuple(list)
+
+    def functionArgList(self):
+        result = ""
+        for arg in range(1, self.num_creation_time_args+1):
+            result += ", Arg%d arg%d" % (arg, arg)
+        return result
+
+    def functionCallCreateList(self):
+        result = ""
+        for arg in range(1, self.num_creation_time_args+1):
+            result += ", arg%d" % arg
+        return result
+
+    def format(self, args, begin_seperator = "", prefix = "", seperator = 
","):
+        result = ""
+        # if value is "" you get "", otherwise you get ("%s " % value)
+        begin_seperator_text = begin_seperator and "%s " % begin_seperator
+        #
+        prefix_text = prefix and "%s " % prefix
+        #
+        seperator_text = seperator and "%s " % seperator
+        #
+        for arg in args[:1]:
+            result += "%s%s%s" % (begin_seperator, prefix_text, arg)
+        for arg in args[1:]:
+            result += "%s%s%s" % (seperator_text, prefix_text, arg)
+        return result
+
+
+def addFunctions(functions, num_call_time_args, creation_time_arg_sizes):
+    for T in creation_time_arg_sizes:
+        functions.append(Function(num_call_time_args, T))
+
+class CallbackH:
+    def __init__(self, filename = "Callback.h"):
+        self.file = open(filename, "w")
+        self.indent_ammount = 0
+
+    def __del__(self):
+        if (not self.file.closed):
+            self.file.close()
+
+    def indent(self):
+        self.indent_ammount += 2;
+
+    def unindent(self):
+        self.indent_ammount -= 2;
+        if (self.indent_ammount < 0):
+            self.indent_ammount = 0
+
+    def write(self, string, indent_ammount = None):
+        if (indent_ammount == None):
+            indent_ammount = self.indent_ammount
+        if (string == ""):
+            self.file.write("\n")
+        else:
+            self.file.write(" " * indent_ammount + string + "\n")
+
+    def writeStart(self):
+        self.write("/*")
+        self.indent()
+        self.write("This file was automatically generated.  Don't modify by 
hand.")
+        self.write("")
+        self.write("For a detailed explaination of the Callback construct 
please see:")
+        self.write("")
+        self.write("doc/Callbacks.txt")
+        self.write("")
+        self.write("Briefly explained:")
+        self.write("")
+        self.write("1.  Only void return functions are supported.")
+        self.write("2.  Data is the call time bound arguments.")
+        self.write("3.  Arg  is the callback creation time bound arguments.")
+        self.write("4.  Data parameters preceed the Arg parameters of the 
callback function.")
+        self.write("5.  If you don't find a create function that match the 
number of")
+        self.write("Data and Arg parameters you need, add the create 
function and")
+        self.write("corresponding Callback_XData_XArg class.")
+        self.write("")
+        self.unindent()
+        self.write("*/")
+        self.write("")
+        self.write("#ifndef Manta_Interface_Callback_h")
+        self.write("#define Manta_Interface_Callback_h")
+        self.write("")
+        self.write("#include <Core/Util/CallbackHelpers.h>")
+        self.write("")
+        self.write("namespace Manta {")
+        self.indent()
+        self.write("class Callback {")
+        self.write("public:")
+        self.indent()
+
+    def writeEnd(self):
+        self.unindent()
+        self.write("private:")
+        self.indent()
+        self.write("Callback(const Callback&);")
+        self.write("Callback& operator=(const Callback&);")
+        self.unindent()
+        self.write("}; // end class Callback")
+        self.unindent()
+        self.write("} // end namespace Manta")
+        self.write("#endif // #ifndef Manta_Interface_Callback_h")
+        # Close the file
+        self.file.close()
+
+    def writeGlobalStaticFunctions(self, functions):
+        self.write("/" * 30)
+        self.write("// Global functions or static class member functions")
+        self.write("");
+        for function in functions:
+            num_call_time_args = function.num_call_time_args
+            num_creation_time_args = function.num_creation_time_args
+            self.write("// %d call time args --- %d creating time args" % 
(num_call_time_args, num_creation_time_args))
+            self.write(function.templateParameter() + "static")
+            self.write(function.baseName() + "*")
+            self.write("create(void (*pmf)(" + 
function.format(function.typeList()) + ")" + function.functionArgList() + ") 
{")
+            self.indent()
+            self.write("return new " + function.staticClassName() + "(pmf" + 
function.functionCallCreateList() + ");")
+            self.unindent()
+            self.write("}")
+            self.write("")
+
+    def writeClassMemberFunctions(self, functions, constant=False):
+        if (constant):
+            constant_text = " const"
+        else:
+            constant_text = ""
+        self.write("/" * 30)
+        self.write("// Class member functions")
+        self.write("");
+        for function in functions:
+            num_call_time_args = function.num_call_time_args
+            num_creation_time_args = function.num_creation_time_args
+            if (constant):
+                self.write("#ifndef SWIG // For now these const versions 
won't compile in swig", indent_ammount=0)
+            self.write("// %d call time args --- %d creating time args" % 
(num_call_time_args, num_creation_time_args))
+            self.write("template<class T" + 
function.format(function.typeList(), begin_seperator=", ", prefix="typename") 
+ "> static")
+            self.write(function.baseName() + "*")
+            self.write("create(T* ptr, void (T::*pmf)(" + 
function.format(function.typeList()) + ")" + constant_text + 
function.functionArgList() + ") {")
+            self.indent()
+            self.write("return new " + function.className(constant) + "(ptr, 
pmf" + function.functionCallCreateList() + ");")
+            self.unindent()
+            self.write("}")
+            if (constant):
+                self.write("#endif // #ifndef SWIG", indent_ammount=0)
+            self.write("")
+
+
+def main():
+    static_functions = []
+    const_member_functions = []
+    member_functions = []
+
+    addFunctions(static_functions, 0, (0,1,2,5))
+    addFunctions(static_functions, 1, (0,1,2))
+    addFunctions(static_functions, 2, (0,2))
+    addFunctions(static_functions, 3, (1,2))
+    addFunctions(static_functions, 4, (2,))
+
+    addFunctions(member_functions, 0, (0,1,2,3,4))
+    addFunctions(const_member_functions, 0, (0,1,2))
+
+    addFunctions(member_functions, 1, (0,1,2))
+    addFunctions(member_functions, 2, (0,1,2,3))
+    addFunctions(member_functions, 3, (0,1))
+    addFunctions(member_functions, 4, (0,1,2))
+
+    addFunctions(member_functions, 5, (0,))
+    addFunctions(member_functions, 6, (0,))
+
+    callbackH = CallbackH()
+    callbackH.writeStart()
+    callbackH.writeGlobalStaticFunctions(static_functions)
+    callbackH.writeClassMemberFunctions(member_functions)
+    callbackH.writeClassMemberFunctions(const_member_functions, 
constant=True)
+    callbackH.writeEnd()
+
+
+if __name__ == "__main__":
+    main()
+
+




  • [Manta] r2106 - trunk/Core/Util, James Bigler, 02/21/2008

Archive powered by MHonArc 2.6.16.

Top of page