[glibmm] _CLASS_GOBJECT: Allow classes to have custom wrap() functions.



commit 7aa56b64d313241495b3f45a853f784036718426
Author: Josà Alburquerque <jaalburqu svn gnome org>
Date:   Mon Sep 17 14:48:51 2012 -0400

    _CLASS_GOBJECT: Allow classes to have custom wrap() functions.
    
    	* tools/m4/class_gobject.m4 (_CUSTOM_WRAP_FUNCTION): Add this new
    	macro which can be used in _CLASS_GOBJECT classes so that if they want
    	they can write their own implementation of their Glib::wrap()
    	function.  This is useful for modules such as gstreamermm that want to
    	keep certain classes (like the plug-ins) from being registered on
    	startup but then do a one time registration of the wrap_new() function
    	in the Glib::wrap() function before calling Glib::wrap_auto() which
    	can then find the wrap_new() function if necessary.
    
    	Bug #684006.

 ChangeLog                 |   15 +++++++++++++++
 tools/m4/class_gobject.m4 |   14 +++++++++++++-
 2 files changed, 28 insertions(+), 1 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index ae39a7c..fda7e2b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,20 @@
 2012-09-14  Josà Alburquerque  <jaalburquerque gmail com>
 
+	_CLASS_GOBJECT: Allow classes to have custom wrap() functions.
+
+	* tools/m4/class_gobject.m4 (_CUSTOM_WRAP_FUNCTION): Add this new
+	macro which can be used in _CLASS_GOBJECT classes so that if they want
+	they can write their own implementation of their Glib::wrap()
+	function.  This is useful for modules such as gstreamermm that want to
+	keep certain classes (like the plug-ins) from being registered on
+	startup but then do a one time registration of the wrap_new() function
+	in the Glib::wrap() function before calling Glib::wrap_auto() which
+	can then find the wrap_new() function if necessary.
+
+	Bug #684006.
+
+2012-09-14  Josà Alburquerque  <jaalburquerque gmail com>
+
 	generate_wrap_init.pl: Allow classes in files to not be registered.
 
 	* tools/m4/class_shared.m4: Add a new _NO_WRAP_INIT_REGISTRATION macro
diff --git a/tools/m4/class_gobject.m4 b/tools/m4/class_gobject.m4
index b73069e..f097f18 100644
--- a/tools/m4/class_gobject.m4
+++ b/tools/m4/class_gobject.m4
@@ -68,6 +68,16 @@ dnl define(`__BOOL_NO_WRAP_FUNCTION__',`$1')
 dnl _POP()
 dnl ')
 
+dnl In case a class needs to write its own implementation of its Glib::wrap()
+dnl function.  The function will be declared in the header, but the body is not
+dnl generated.
+define(`_CUSTOM_WRAP_FUNCTION',`dnl
+_PUSH()
+dnl Define this macro to be tested for later.
+define(`__BOOL_CUSTOM_WRAP_FUNCTION__',`$1')
+_POP()
+')
+
 dnl Some gobjects actually derive from GInitiallyUnowned, which does some odd reference-counting that is useful to C coders.
 dnl We don't want to expose that base class in our API, 
 dnl but we do want to reverse what it does:
@@ -139,6 +149,8 @@ __NAMESPACE_END__
 
 _SECTION(SECTION_SRC_GENERATED)
 
+ifdef(`__BOOL_CUSTOM_WRAP_FUNCTION__',`dnl
+',`dnl else
 ifdef(`__BOOL_NO_WRAP_FUNCTION__',`dnl
 ',`dnl else
 namespace Glib
@@ -152,6 +164,7 @@ Glib::RefPtr<__NAMESPACE__::__CPPNAME__> wrap(__REAL_CNAME__`'* object, bool tak
 
 } /* namespace Glib */
 ')dnl endif
+')dnl endif
 
 
 
@@ -275,4 +288,3 @@ public:
 _H_VFUNCS_AND_SIGNALS()
 
 ')
-



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