[glibmm] gmmproc: Allow some classes to be in a sub-namespace.



commit ce84ddbd917364c61d50c3921c1f32fdde9f6698
Author: Murray Cumming <murrayc murrayc com>
Date:   Wed Feb 16 11:24:48 2011 +0100

    gmmproc: Allow some classes to be in a sub-namespace.
    
    	* tools/m4/class_shared.m4:
    	* tools/generate_wrap_init.pl.in: Add a _GMMPROC_EXTRA_NAMESPACE(thenamespace)
    	macro, so that wrap_init.cc will have the correct pre-declarations of the
    	wrap_new() and get_type() functions.
    	I am suprised that we have no other way to do this already, but I cannot
    	find one, and this hack works.
    	For instance, this lets use put some classes in a Gio::DBus namespace.

 ChangeLog                                     |   11 +++++++++++
 gio/src/{dbuserror.ccg => dbuserrorutils.ccg} |    0
 gio/src/{dbuserror.hg => dbuserrorutils.hg}   |    0
 tools/generate_wrap_init.pl.in                |    7 +++++--
 tools/m4/class_shared.m4                      |    5 +++++
 5 files changed, 21 insertions(+), 2 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 91a7913..9bdd8a2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2011-02-16  Murray Cumming  <murrayc murrayc com>
+
+	gmmproc: Allow some classes to be in a sub-namespace.
+	
+	* tools/m4/class_shared.m4:
+	* tools/generate_wrap_init.pl.in: Add a _GMMPROC_EXTRA_NAMESPACE(thenamespace) 
+	macro, so that wrap_init.cc will have the correct pre-declarations of the 
+	wrap_new() and get_type() functions.
+	I am suprised that we have no other way to do this already, but I cannot 
+	find one, and this hack works. 
+
 2011-02-15  Murray Cumming  <murrayc murrayc com>
 
 	OptionGroup: Minor code style changes.
diff --git a/gio/src/dbuserror.ccg b/gio/src/dbuserrorutils.ccg
similarity index 100%
rename from gio/src/dbuserror.ccg
rename to gio/src/dbuserrorutils.ccg
diff --git a/gio/src/dbuserror.hg b/gio/src/dbuserrorutils.hg
similarity index 100%
rename from gio/src/dbuserror.hg
rename to gio/src/dbuserrorutils.hg
diff --git a/tools/generate_wrap_init.pl.in b/tools/generate_wrap_init.pl.in
index 53c16d5..804dab2 100644
--- a/tools/generate_wrap_init.pl.in
+++ b/tools/generate_wrap_init.pl.in
@@ -71,9 +71,12 @@ while ($ARGV[0])
   my $ccast = "";
   while (<FILE>)
   {
-    if (/CLASS_START\((\w+)\)/) #We need a new way to get the namespace.
+    # This is useful when only some classes use a sub-namespace.
+    # Alternatively, we could parse the namespace start and end parentheses,
+    # but this hack is easier.
+    if (/_GMMPROC_EXTRA_NAMESPACE\((\w+)\)/)
     {
-      print "generate_wrap_init: namespace found: $1\n";
+      # debug: print "generate_wrap_init: namespace found: $1\n";
       push(@tmpnamespace, $1);
     }
     elsif (/_CLASS_GOBJECT\s*\(/) #TODO: There is duplication of code here.
diff --git a/tools/m4/class_shared.m4 b/tools/m4/class_shared.m4
index c9286da..a84d75b 100644
--- a/tools/m4/class_shared.m4
+++ b/tools/m4/class_shared.m4
@@ -1,5 +1,10 @@
 dnl $Id$
 
+
+dnl This is just a hint to generate_wrap_init.pl.
+dnl It does not generate any code in the actual .h and .cc file.
+m4_define(`_GMMPROC_EXTRA_NAMESPACE',`')
+
 define(`_CLASS_START',`dnl
 _PUSH(SECTION_CLASS1)
 ')



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]