From f45e7f710a21db3c98e5f7066ee60300e0355ac8 Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Fri, 28 Jan 2011 23:29:58 +0100 Subject: ArrayHandle, ListHandle, SListHandle: Document these as almost-deprecated. * glib/glibmm/arrayhandle.h: * glib/glibmm/listhandle.h: * glib/glibmm/slisthandle.h: Mention that we try not to use these now, though we cannot actually deprecate them yet without forcing other libraries such as pangomm to deprecate the methods that use them, which they cannot really do because they cannot just add a method overload without introducing ambiguity. --- ChangeLog | 12 ++++++++++++ glib/glibmm/arrayhandle.h | 15 +++++++++++++-- glib/glibmm/listhandle.h | 12 ++++++++---- glib/glibmm/slisthandle.h | 10 +++++++--- 4 files changed, 40 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8e20a3ff..defc9328 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2011-01-28 Murray Cumming + + ArrayHandle, ListHandle, SListHandle: Document these as almost-deprecated. + + * glib/glibmm/arrayhandle.h: + * glib/glibmm/listhandle.h: + * glib/glibmm/slisthandle.h: Mention that we try not to use these now, + though we cannot actually deprecate them yet without forcing other libraries + such as pangomm to deprecate the methods that use them, which they cannot + really do because they cannot just add a method overload without introducing + ambiguity. + 2011-01-27 Chris Kühl Changed glib include to build cleanly with GLIB_DISABLE_SINGLE_INCLUDES. diff --git a/glib/glibmm/arrayhandle.h b/glib/glibmm/arrayhandle.h index 9048d5ce..c66c8716 100644 --- a/glib/glibmm/arrayhandle.h +++ b/glib/glibmm/arrayhandle.h @@ -178,8 +178,13 @@ private: } // namespace Container_Helpers -/** If a method takes this as an argument, or has this as a return type, then you can use a standard - * container such as std::list or std::vector. +/** This is an intermediate type. When a method takes this, or returns this, you + * should use a standard C++ container of your choice, such as std::list or + * std::vector. + * + * However, this is not used in new API. We now prefer to just use std::vector, + * which is less flexibile, but makes the API clearer. + * * @ingroup ContHandles */ template < class T, class Tr = Glib::Container_Helpers::TypeTraits > @@ -234,8 +239,14 @@ private: ArrayHandle& operator=(const ArrayHandle&); }; +//TODO: Remove this when we can break glibmm API. /** If a method takes this as an argument, or has this as a return type, then you can use a standard * container such as std::list or std::vector. + * + * + * However, this is not used in new API. We now prefer to just use std::vector, + * which is less flexibile, but makes the API clearer. + * * @ingroup ContHandles */ typedef ArrayHandle StringArrayHandle; diff --git a/glib/glibmm/listhandle.h b/glib/glibmm/listhandle.h index 13359b6f..4716064b 100644 --- a/glib/glibmm/listhandle.h +++ b/glib/glibmm/listhandle.h @@ -119,8 +119,6 @@ struct ListSourceTraits : ListSourceTraits /** * @ingroup ContHelpers - * If a method takes this as an argument, or has this as a return type, then you can use a standard - * container such as std::list or std::vector. */ template class ListHandleIterator @@ -150,8 +148,14 @@ private: } // namespace Container_Helpers - -/** +//TODO: Remove this when we can break glibmm API. +/** This is an intermediate type. When a method takes this, or returns this, you + * should use a standard C++ container of your choice, such as std::list or + * std::vector. + * + * However, this is not used in new API. We now prefer to just use std::vector, + * which is less flexibile, but makes the API clearer. + * * @ingroup ContHandles */ template < class T, class Tr = Glib::Container_Helpers::TypeTraits > diff --git a/glib/glibmm/slisthandle.h b/glib/glibmm/slisthandle.h index 70028c39..2885e944 100644 --- a/glib/glibmm/slisthandle.h +++ b/glib/glibmm/slisthandle.h @@ -119,8 +119,6 @@ struct SListSourceTraits : SListSourceTraits /** * @ingroup ContHelpers - * If a method takes this as an argument, or has this as a return type, then you can use a standard - * container such as std::list or std::vector. */ template class SListHandleIterator @@ -151,7 +149,13 @@ private: } // namespace Container_Helpers -/** +//TODO: Remove this when we can break glibmm API. +/** This is an intermediate type. When a method takes this, or returns this, you + * should use a standard C++ container of your choice, such as std::list or + * std::vector. + * + * However, this is not used in new API. We now prefer to just use std::vector, + * which is less flexibile, but makes the API clearer. * @ingroup ContHandles */ template < class T, class Tr = Glib::Container_Helpers::TypeTraits > -- cgit v1.2.1 From a57dde3d329ec0c96b04803940c9bc844667a7b1 Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Sun, 30 Jan 2011 13:55:06 +0100 Subject: Vector utils: Added simple documentation. * glib/glibmm/vectorutils.h: Some simple documentation about the *Handler utility classes, though I need to correct the example code and explain the memory mangement when that is clear to me. --- ChangeLog | 8 +++++++ glib/glibmm/vectorutils.h | 56 ++++++++++++++++++++++++++++++++++------------- 2 files changed, 49 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index defc9328..6f419902 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2011-01-30 Murray Cumming + + Vector utils: Added simple documentation. + + * glib/glibmm/vectorutils.h: Some simple documentation about the *Handler + utility classes, though I need to correct the example code and explain the + memory mangement when that is clear to me. + 2011-01-28 Murray Cumming ArrayHandle, ListHandle, SListHandle: Document these as almost-deprecated. diff --git a/glib/glibmm/vectorutils.h b/glib/glibmm/vectorutils.h index f6bafc67..b724d8fc 100644 --- a/glib/glibmm/vectorutils.h +++ b/glib/glibmm/vectorutils.h @@ -149,9 +149,6 @@ GSList* create_gslist(const typename std::vector::const_it #endif /* DOXYGEN_SHOULD_SKIP_THIS */ -/** - * @ingroup ContHelpers - */ template class ArrayIterator { @@ -193,11 +190,6 @@ private: const CType* pos_; }; -/** - * @ingroup ContHelpers - * If a method takes this as an argument, or has this as a return type, then you can use a standard - * container such as std::list or std::vector. - */ template class ListIterator { @@ -224,11 +216,6 @@ private: const GList* node_; }; -/** - * @ingroup ContHelpers - * If a method takes this as an argument, or has this as a return type, then you can use a standard - * container such as std::list or std::vector. - */ template class SListIterator { @@ -312,8 +299,21 @@ private: } // namespace Container_Helpers -// a struct instead of templated functions because standard template arguments -// for function templates is a C++0x feature... +// Note that this is a struct instead of templated functions because standard template arguments +// for function templates is a C++0x feature. +/** A utility for converting between std::vector and plain C arrays. + * This would normally only be used by glibmm or gtkmm itself, or similar + * libraries that wrap C APIs. + * + * For instance: + * @code + * std::vector vec = Glib::ArrayHandler::array_to_vector(array, array_size, Glib::OWNERSHIP_DEEP); + * @endcode + * or + * @code + * const char** array = Glib::ArrayHandler::vector_to_array(vec).data (); + * @endcode + */ template > class ArrayHandler { @@ -346,6 +346,19 @@ public: static ArrayKeeperType vector_to_array(const VectorType& vector); }; +/** A utility for converting between std::vector and GList. + * This would normally only be used by glibmm or gtkmm itself, or similar + * libraries that wrap C APIs. + * + * For instance: + * @code + * Glib::ListHandler< Glib::RefPtr >::list_to_vector(gdk_window_get_children(gobj()), Glib::OWNERSHIP_SHALLOW); + * @endcode + * or + * @code + * GList* glist = Glib::ListHandler >::vector_to_list(pixbufs).data(); + * @endcode + */ template > class ListHandler { @@ -361,6 +374,19 @@ public: static GListKeeperType vector_to_list(const VectorType& vector); }; +/** A utility for converting between std::vector and GSList. + * This would normally only be used by glibmm or gtkmm itself, or similar + * libraries that wrap C APIs. + * + * For instance: + * @code + * std::vector< Glib::RefPtr > vec = Glib::SListHandler >::slist_to_vector(gdk_display_manager_list_displays(gobj()), Glib::OWNERSHIP_SHALLOW); + * @endcode + * or + * @code + * GSList* gslist = Glib::SListHandler< Glib::RefPtr >::vector_to_slist(vec).data(); + * @endcode + */ template > class SListHandler { -- cgit v1.2.1 From ad59743628383374a590508d474ae81fbb74b6cd Mon Sep 17 00:00:00 2001 From: Krzesimir Nowak Date: Mon, 31 Jan 2011 20:32:21 +0100 Subject: Vector utils: Corrected documentation and extended it bit. * glib/glibmm/vectorutils.h: Documented important parts of *Keeper classes and corrected examples in *Handler classes. The documentation mostly tries to explain memory management. --- ChangeLog | 8 +++ glib/glibmm/vectorutils.h | 173 ++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 175 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6f419902..ad3edebb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2011-01-21 Krzesimir Nowak + + Vector utils: Corrected documentation and extended it bit. + + * glib/glibmm/vectorutils.h: Documented important parts of *Keeper classes + and corrected examples in *Handler classes. The documentation mostly tries + to explain memory management. + 2011-01-30 Murray Cumming Vector utils: Added simple documentation. diff --git a/glib/glibmm/vectorutils.h b/glib/glibmm/vectorutils.h index b724d8fc..87a91511 100644 --- a/glib/glibmm/vectorutils.h +++ b/glib/glibmm/vectorutils.h @@ -242,6 +242,28 @@ private: const GSList* node_; }; +/** A keeper class for C array. + * + * Primarily used by C++ wrappers like gtkmm. + * + * Its main purpose is to free its data when they are not needed. What will be + * destroyed depends on passed ownership upon construction. + * + * The most common usage of Glib::ArrayKeeper is getting its data when converting + * std::vector to a C array: + * @code + * void G::Temp::do_something(const std::vector& v) + * { + * g_temp_do_something(gobj(), Glib::ArrayHandler::vector_to_array(v).data()); + * } + * @endcode + * Variables of this class are seldom defined directly - it is mostly used as + * a temporary variable returned by Glib::ArrayHandler::vector_to_array(). + * + * Note that the usage above is correct with regards to C++ standard point 12.2.3. + * That means that data returned by data() method is valid through whole + * g_temp_do_something function and is destroyed, when this function returns. + */ template class ArrayKeeper { @@ -249,10 +271,28 @@ public: typedef typename Tr::CppType CppType; typedef typename Tr::CType CType; + /** Constructs an ArrayKeeper holding @a array of size @array_size. + * @a ownership tells what should be destroyed with keeper destruction: + *
    + *
  • Glib::OWNERSHIP_NONE - keeper won't destroy data it holds.
  • + *
  • Glib::OWNERSHIP_SHALLOW - keeper will destroy only container it holds.
  • + *
  • Glib::OWNERSHIP_DEEP - keeper will destroy data and container it holds.
  • + *
+ * + * @param array - C array to hold. + * @param array_size - length of @a array. + * @param ownership - ownership definition. + */ explicit inline ArrayKeeper(const CType* array, size_t array_size, Glib::OwnershipType ownership); inline ArrayKeeper(const ArrayKeeper& keeper); ~ArrayKeeper(); + /** Gets data the keeper holds. + * + * Note that this data is owned by the keeper, so there is no need to free it. + * + * @return C array owned by ArrayKeeper. + */ inline CType* data() const; private: @@ -261,6 +301,28 @@ private: mutable Glib::OwnershipType ownership_; }; +/** A keeper class for GList. + * + * Primarily used by C++ wrappers like gtkmm. + * + * Its main purpose is to free its data when they are not needed. What will be + * destroyed depends on passed ownership upon construction. + * + * The most common usage of Glib::GListKeeper is getting its data when converting + * std::vector to a GList*: + * @code + * void G::Temp::do_something(const std::vector& v) + * { + * g_temp_do_something(gobj(), Glib::ListHandler::vector_to_list(v).data()); + * } + * @endcode + * Variables of this class are seldom defined directly - it is mostly used as + * a temporary variable returned by Glib::ListHandler::vector_to_list(). + * + * Note that the usage above is correct with regards to C++ standard point 12.2.3. + * That means that data returned by data() method is valid through whole + * g_temp_do_something function and is destroyed, when this function returns. + */ template class GListKeeper { @@ -268,10 +330,27 @@ public: typedef typename Tr::CppType CppType; typedef typename Tr::CType CType; + /** Constructs an GListKeeper holding @a glist. + * @a ownership tells what should be destroyed with keeper destruction: + *
    + *
  • Glib::OWNERSHIP_NONE - keeper won't destroy data it holds.
  • + *
  • Glib::OWNERSHIP_SHALLOW - keeper will destroy only container it holds.
  • + *
  • Glib::OWNERSHIP_DEEP - keeper will destroy data and container it holds.
  • + *
+ * + * @param glist - GList* to hold. + * @param ownership - ownership definition. + */ explicit inline GListKeeper(const GList* glist, Glib::OwnershipType ownership); inline GListKeeper(const GListKeeper& keeper); ~GListKeeper(); + /** Gets data the keeper holds. + * + * Note that this data is owned by the keeper, so there is no need to free it. + * + * @return GList* owned by GListKeeper. + */ inline GList* data() const; private: @@ -279,6 +358,28 @@ private: mutable Glib::OwnershipType ownership_; }; +/** A keeper class for GSList. + * + * Primarily used by C++ wrappers like gtkmm. + * + * Its main purpose is to free its data when they are not needed. What will be + * destroyed depends on passed ownership upon construction. + * + * The most common usage of Glib::GSListKeeper is getting its data when converting + * std::vector to a GSList*: + * @code + * void G::Temp::do_something(const std::vector& v) + * { + * g_temp_do_something(gobj(), Glib::SListHandler::vector_to_slist(v).data()); + * } + * @endcode + * Variables of this class are seldom defined directly - it is mostly used as + * a temporary variable returned by Glib::SListHandler::vector_to_slist(). + * + * Note that the usage above is correct with regards to C++ standard point 12.2.3. + * That means that data returned by data() method is valid through whole + * g_temp_do_something function and is destroyed, when this function returns. + */ template class GSListKeeper { @@ -286,10 +387,27 @@ public: typedef typename Tr::CppType CppType; typedef typename Tr::CType CType; + /** Constructs an GSListKeeper holding @a gslist. + * @a ownership tells what should be destroyed with keeper destruction: + *
    + *
  • Glib::OWNERSHIP_NONE - keeper won't destroy data it holds.
  • + *
  • Glib::OWNERSHIP_SHALLOW - keeper will destroy only container it holds.
  • + *
  • Glib::OWNERSHIP_DEEP - keeper will destroy data and container it holds.
  • + *
+ * + * @param gslist - GList* to hold. + * @param ownership - ownership definition. + */ explicit inline GSListKeeper(const GSList* gslist, Glib::OwnershipType ownership); inline GSListKeeper(const GSListKeeper& keeper); ~GSListKeeper(); + /** Gets data the keeper holds. + * + * Note that this data is owned by the keeper, so there is no need to free it. + * + * @return GSList* owned by GSListKeeper. + */ inline GSList* data() const; private: @@ -302,15 +420,34 @@ private: // Note that this is a struct instead of templated functions because standard template arguments // for function templates is a C++0x feature. /** A utility for converting between std::vector and plain C arrays. - * This would normally only be used by glibmm or gtkmm itself, or similar + * This would normally only be used by glibmm or gtkmm itself, or similar * libraries that wrap C APIs. * * For instance: * @code - * std::vector vec = Glib::ArrayHandler::array_to_vector(array, array_size, Glib::OWNERSHIP_DEEP); + * std::vector PixbufFormat::get_mime_types() const + * { + * return Glib::ArrayHandler::array_to_vector(gdk_pixbuf_format_get_mime_types(const_cast(gobj())), Glib::OWNERSHIP_DEEP); + * } * @endcode * or * @code + * void Display::store_clipboard(const Glib::RefPtr& clipboard_window, guint32 time_, const std::vector& targets) + * { + * if (!targets.size ()) + * { + * gdk_display_store_clipboard(gobj(), + * Glib::unwrap (clipboard_window), + * time_, + * Glib::ArrayHandler::vector_to_array(targets).data (), + * targets.size ()); + * } + * } + * @endcode + * Note that usage below is wrong - data() returns a pointer to data owned by + * a temporary ArrayKeeper returned by vector_to_array(), which is destroyed at + * the end of this instruction. For details, see Glib::ArrayKeeper. + * @code * const char** array = Glib::ArrayHandler::vector_to_array(vec).data (); * @endcode */ @@ -347,15 +484,27 @@ public: }; /** A utility for converting between std::vector and GList. - * This would normally only be used by glibmm or gtkmm itself, or similar + * This would normally only be used by glibmm or gtkmm itself, or similar * libraries that wrap C APIs. * * For instance: * @code - * Glib::ListHandler< Glib::RefPtr >::list_to_vector(gdk_window_get_children(gobj()), Glib::OWNERSHIP_SHALLOW); + * std::vector< Glib::RefPtr > Window::get_children() + * { + * return Glib::ListHandler >::list_to_vector(gdk_window_get_children(gobj()), Glib::OWNERSHIP_SHALLOW); + * } * @endcode * or * @code + * void Window::set_icon_list(const std::vector< Glib::RefPtr >& pixbufs) + * { + * gdk_window_set_icon_list(gobj(), Glib::ListHandler >::vector_to_list(pixbufs).data ()); + * } + * @endcode + * Note that usage below is wrong - data() returns a pointer to data owned by + * a temporary ListKeeper returned by vector_to_list(), which is destroyed at + * the end of this instruction. For details, see Glib::ListKeeper. + * @code * GList* glist = Glib::ListHandler >::vector_to_list(pixbufs).data(); * @endcode */ @@ -375,15 +524,27 @@ public: }; /** A utility for converting between std::vector and GSList. - * This would normally only be used by glibmm or gtkmm itself, or similar + * This would normally only be used by glibmm or gtkmm itself, or similar * libraries that wrap C APIs. * * For instance: * @code - * std::vector< Glib::RefPtr > vec = Glib::SListHandler >::slist_to_vector(gdk_display_manager_list_displays(gobj()), Glib::OWNERSHIP_SHALLOW); + * std::vector< Glib::RefPtr > DisplayManager::list_displays() + * { + * return Glib::SListHandler >::slist_to_vector(gdk_display_manager_list_displays(gobj()), Glib::OWNERSHIP_SHALLOW); + * } * @endcode * or * @code + * void Stuff::set_slist(const std::vector& ints) + * { + * g_stuff_set_slist(gobj(), Glib::SListHandler::vector_to_slist(ints).data ()); + * } + * @endcode + * Note that usage below is wrong - data() returns a pointer to data owned by + * a temporary SListKeeper returned by vector_to_slist(), which is destroyed at + * the end of this instruction. For details, see Glib::SListKeeper. + * @code * GSList* gslist = Glib::SListHandler< Glib::RefPtr >::vector_to_slist(vec).data(); * @endcode */ -- cgit v1.2.1 From de5bdc0a8fb901330eff27aedd8950ca858e737c Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Tue, 1 Feb 2011 09:44:16 +0100 Subject: 2.27.93 --- ChangeLog | 4 ++++ NEWS | 16 ++++++++++++++++ configure.ac | 4 ++-- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index ad3edebb..5eadbf7e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,5 @@ +2.27.93: + 2011-01-21 Krzesimir Nowak Vector utils: Corrected documentation and extended it bit. @@ -68,6 +70,8 @@ make sure that glibmm and giomm are initialized when Gio::Application is instantiated, so it is then unnecssary to call them explicitly. +2.27.91.1: + 2011-01-17 Murray Cumming Fix the make check build. diff --git a/NEWS b/NEWS index 9a9627b2..3dc1cca3 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,19 @@ +2.27.93 (unstable): + +* Added ArrayHandler, ListHandler and SListHandler, to help with conversions + to/from std::vector. + These replace ArrayHandle, ListHandle, and SListHandle, which allowed the + use of any standard container. New APIs will use only std::vector, because + that is less confusing to developers, though less flexible. + (Krzesimir Nowak) +* Application: Initialize glibmm and giomm in the constructor, for + convenience. + (Murray Cumming) +* Resolver: lookup_service(), lookup_by_address(): Fix the reference counting. + (Murray Cumming) Bug #639575 (Michael Edwards) +* Fix the build (and of applications) with GLIB_DISABLE_SINGLE_INCLUDES. + (Chris Kühl) + 2.27.91.1 (unstable): * gmmproc: diff --git a/configure.ac b/configure.ac index 830651bf..5da218bf 100644 --- a/configure.ac +++ b/configure.ac @@ -15,7 +15,7 @@ ## You should have received a copy of the GNU Lesser General Public License ## along with this library. If not, see . -AC_INIT([glibmm], [2.27.91.1], +AC_INIT([glibmm], [2.27.93], [http://bugzilla.gnome.org/enter_bug.cgi?product=glibmm], [glibmm], [http://www.gtkmm.org/]) AC_PREREQ([2.59]) @@ -57,7 +57,7 @@ AS_IF([test "x$enable_static" = xyes], AC_DEFINE([GIOMM_STATIC_LIB], [1], [Define if giomm is built as a static library]) ]) -glibreq='2.0 >= 2.27.91' +glibreq='2.0 >= 2.27.93' GLIBMM_MODULES="sigc++-2.0 >= 2.0 glib-$glibreq gobject-$glibreq gmodule-$glibreq" GIOMM_MODULES="$GLIBMM_MODULES gio-$glibreq" test "x$glibmm_host_windows" = xyes || GIOMM_MODULES="$GIOMM_MODULES gio-unix-$glibreq" -- cgit v1.2.1 From abd2e2a991155d83e5eba620565b651a942d10f3 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Tue, 1 Feb 2011 18:40:42 +0100 Subject: gmmproc: Add optional arguments custom_vfunc[_callback] to _WRAP_VFUNC. * tools/pm/Output.pm: * tools/pm/WrapParser.pm: Add handling of optional arguments custom_vfunc[_callback] in _WRAP_VFUNC. Bug 641165. --- ChangeLog | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ChangeLog b/ChangeLog index 5eadbf7e..d11b0217 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2011-02-01 Kjell Ahlstedt + + gmmproc: Add optional arguments custom_vfunc[_callback] to _WRAP_VFUNC. + + * tools/pm/Output.pm: + * tools/pm/WrapParser.pm: Add handling of optional arguments + custom_vfunc[_callback] in _WRAP_VFUNC. Bug 641165. + 2.27.93: 2011-01-21 Krzesimir Nowak -- cgit v1.2.1 From f4d6bc29fcf364ddfb5cd714ccf41637f1e2c676 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Tue, 1 Feb 2011 18:40:42 +0100 Subject: gmmproc: Add optional arguments custom_vfunc[_callback] to _WRAP_VFUNC. * tools/pm/Output.pm: * tools/pm/WrapParser.pm: Add handling of optional arguments custom_vfunc[_callback] in _WRAP_VFUNC. Bug 641165. --- tools/pm/Output.pm | 67 ++++++++++++++++++++++++++++---------------------- tools/pm/WrapParser.pm | 53 +++++++++++++++++++++++++-------------- 2 files changed, 72 insertions(+), 48 deletions(-) diff --git a/tools/pm/Output.pm b/tools/pm/Output.pm index 511ea410..b08117dd 100644 --- a/tools/pm/Output.pm +++ b/tools/pm/Output.pm @@ -138,51 +138,58 @@ sub output_wrap_vfunc_h($$$$$$) # _VFUNC_CC(signame,gtkname,rettype,crettype,`',`') sub output_wrap_vfunc_cc($$$$$$$) { - my ($self, $filename, $line_num, $objCppfunc, $objDefsSignal, $ifdef) = @_; + my ($self, $filename, $line_num, $objCppfunc, $objCFunc, + $custom_vfunc, $custom_vfunc_callback, $ifdef) = @_; - my $cname = $$objDefsSignal{name}; + my $cname = $$objCFunc{name}; # e.g. Gtk::Button::draw_indicator: #Use a different macro for Interfaces, to generate an extra convenience method. - my $refreturn = ""; - $refreturn = "refreturn" if($$objCppfunc{rettype_needs_ref}); + if ($custom_vfunc eq 0) + { + my $refreturn = ""; + $refreturn = "refreturn" if($$objCppfunc{rettype_needs_ref}); - my $str = sprintf("_VFUNC_CC(%s,%s,%s,%s,\`%s\',\`%s\',%s,%s,%s)dnl\n", - $$objCppfunc{name}, - $cname, - $$objCppfunc{rettype}, - $$objDefsSignal{rettype}, - $objCppfunc->args_types_and_names(), - convert_args_cpp_to_c($objCppfunc, $objDefsSignal, 0, $line_num), #$objCppfunc->args_names_only(), - $objCppfunc->get_is_const(), - $refreturn, - $ifdef); + my $str = sprintf("_VFUNC_CC(%s,%s,%s,%s,\`%s\',\`%s\',%s,%s,%s)dnl\n", + $$objCppfunc{name}, + $cname, + $$objCppfunc{rettype}, + $$objCFunc{rettype}, + $objCppfunc->args_types_and_names(), + convert_args_cpp_to_c($objCppfunc, $objCFunc, 0, $line_num), #$objCppfunc->args_names_only(), + $objCppfunc->get_is_const(), + $refreturn, + $ifdef); - $self->append($str); + $self->append($str); + } # e.g. Gtk::ButtonClass::draw_indicator(): - my $refreturn_ctype = ""; - $refreturn_ctype = "refreturn_ctype" if($$objDefsSignal{rettype_needs_ref}); + if ($custom_vfunc_callback eq 0) + { + my $refreturn_ctype = ""; + $refreturn_ctype = "refreturn_ctype" if($$objCFunc{rettype_needs_ref}); - my $str = sprintf("_VFUNC_PCC(%s,%s,%s,%s,\`%s\',\`%s\',\`%s\',%s,%s,%s)dnl\n", - $$objCppfunc{name}, - $cname, - $$objCppfunc{rettype}, - $$objDefsSignal{rettype}, - $objDefsSignal->args_types_and_names(), - $objDefsSignal->args_names_only(), - convert_args_c_to_cpp($objDefsSignal, $objCppfunc, $line_num), - ${$objDefsSignal->get_param_names()}[0], - $refreturn_ctype, - $ifdef); + my $str = sprintf("_VFUNC_PCC(%s,%s,%s,%s,\`%s\',\`%s\',\`%s\',%s,%s,%s)dnl\n", + $$objCppfunc{name}, + $cname, + $$objCppfunc{rettype}, + $$objCFunc{rettype}, + $objCFunc->args_types_and_names(), + $objCFunc->args_names_only(), + convert_args_c_to_cpp($objCFunc, $objCppfunc, $line_num), + ${$objCFunc->get_param_names()}[0], + $refreturn_ctype, + $ifdef); - $self->append($str); + $self->append($str); + } } -### Convert _WRAP to a virtual +### Convert _WRAP to a signal # _SIGNAL_H(signame,rettype, ifdef, `') # _SIGNAL_PH(gtkname,crettype, ifdef, cargs and names) # void output_wrap_default_signal_handler_h($filename, $line_num, $objCppfunc, $objCDefsFunc, $ifdef. @args) diff --git a/tools/pm/WrapParser.pm b/tools/pm/WrapParser.pm index 05f82e15..b4a12c3e 100644 --- a/tools/pm/WrapParser.pm +++ b/tools/pm/WrapParser.pm @@ -1154,8 +1154,9 @@ sub on_wrap_signal($$) } } - - $self->output_wrap_signal( $argCppDecl, $argCName, $$self{filename}, $$self{line_num}, $bCustomDefaultHandler, $bNoDefaultHandler, $bCustomCCallback, $bRefreturn, $ifdef, $merge_doxycomment_with_previous); + $self->output_wrap_signal($argCppDecl, $argCName, $$self{filename}, $$self{line_num}, + $bCustomDefaultHandler, $bNoDefaultHandler, $bCustomCCallback, + $bRefreturn, $ifdef, $merge_doxycomment_with_previous); } # void on_wrap_vfunc() @@ -1179,25 +1180,40 @@ sub on_wrap_vfunc($) my $refreturn = 0; my $refreturn_ctype = 0; + my $custom_vfunc = 0; + my $custom_vfunc_callback = 0; my $ifdef = ""; - # Extra ref needed? - while($#args >= 2) # If the optional ref/err arguments are there. + while($#args >= 2) # If optional arguments are there. { my $argRef = string_trim(pop @args); + # Extra ref needed? if($argRef eq "refreturn") - { $refreturn = 1; } + { + $refreturn = 1; + } elsif($argRef eq "refreturn_ctype") - { $refreturn_ctype = 1; } - elsif($argRef =~ /^ifdef(.*)/) #If ifdef is at the start. + { + $refreturn_ctype = 1; + } + elsif($argRef eq "custom_vfunc") + { + $custom_vfunc = 1; + } + elsif($argRef eq "custom_vfunc_callback") + { + $custom_vfunc_callback = 1; + } + elsif($argRef =~ /^ifdef(.*)/) #If ifdef is at the start. { $ifdef = $1; } } - $self->output_wrap_vfunc($argCppDecl, $argCName, $refreturn, $refreturn_ctype, - $$self{filename}, $$self{line_num}, $ifdef); + $self->output_wrap_vfunc($argCppDecl, $argCName, $$self{filename}, $$self{line_num}, + $refreturn, $refreturn_ctype, $custom_vfunc, + $custom_vfunc_callback, $ifdef); } sub on_wrap_enum($) @@ -1291,7 +1307,6 @@ sub output_wrap_check($$$$$$) } # void output_wrap($CppDecl, $signal_name, $filename, $line_num, $bCustomDefaultHandler, $bNoDefaultHandler, $bCustomCCallback, $bRefreturn) -# Also used for vfunc. sub output_wrap_signal($$$$$$$$$) { my ($self, $CppDecl, $signal_name, $filename, $line_num, $bCustomDefaultHandler, $bNoDefaultHandler, $bCustomCCallback, $bRefreturn, $ifdef, $merge_doxycomment_with_previous) = @_; @@ -1301,7 +1316,7 @@ sub output_wrap_signal($$$$$$$$$) $filename, $line_num, "_WRAP_SIGNAL")); # handle first argument - #Parse the method decaration and build an object that holds the details: + #Parse the method declaration and build an object that holds the details: my $objCppSignal = &Function::new($CppDecl, $self); $$objCppSignal{class} = $$self{class}; #Remember the class name for use in Outputter::output_wrap_signal(). @@ -1338,18 +1353,19 @@ sub output_wrap_signal($$$$$$$$$) } } -# void output_wrap($CppDecl, $signal_name, $filename, $line_num) -# Also used for vfunc. +# void output_wrap($CppDecl, $vfunc_name, $filename, $line_num, $refreturn, $refreturn_ctype, +# $custom_vfunc, $custom_vfunc_callback, $ifdef) sub output_wrap_vfunc($$$$$$$$) { - my ($self, $CppDecl, $vfunc_name, $refreturn, $refreturn_ctype, $filename, $line_num, $ifdef) = @_; + my ($self, $CppDecl, $vfunc_name, $filename, $line_num, $refreturn, $refreturn_ctype, + $custom_vfunc, $custom_vfunc_callback, $ifdef) = @_; #Some checks: return if ($self->output_wrap_check($CppDecl, $vfunc_name, $filename, $line_num, '_WRAP_VFUNC')); # handle first argument - #Parse the method decaration and build an object that holds the details: + #Parse the method declaration and build an object that holds the details: my $objCppVfunc = &Function::new($CppDecl, $self); @@ -1373,12 +1389,13 @@ sub output_wrap_vfunc($$$$$$$$) # These macros are defined in vfunc.m4: $$objCppVfunc{rettype_needs_ref} = $refreturn; - $$objCppVfunc{name} .= "_vfunc"; #All vfuncs should have the "_vfunc" prefix, and a separate easily-named invoker method. + $$objCppVfunc{name} .= "_vfunc"; #All vfuncs should have the "_vfunc" suffix, and a separate easily-named invoker method. $$objCVfunc{rettype_needs_ref} = $refreturn_ctype; - $objOutputter->output_wrap_vfunc_h($filename, $line_num, $objCppVfunc, $objCVfunc,$ifdef); - $objOutputter->output_wrap_vfunc_cc($filename, $line_num, $objCppVfunc, $objCVfunc, $ifdef); + $objOutputter->output_wrap_vfunc_h($filename, $line_num, $objCppVfunc, $objCVfunc, $ifdef); + $objOutputter->output_wrap_vfunc_cc($filename, $line_num, $objCppVfunc, $objCVfunc, + $custom_vfunc, $custom_vfunc_callback, $ifdef); } # give some sort of weights to sorting attibutes -- cgit v1.2.1