gnomemm r2156 - in gstreamermm/trunk: . gstreamer/src tools/extra_defs_gen tools/m4



Author: jaalburqu
Date: Mon Apr 13 21:33:47 2009
New Revision: 2156
URL: http://svn.gnome.org/viewvc/gnomemm?rev=2156&view=rev

Log:
2009-04-13  Josà Alburquerque  <jaalburqu svn gnome org>

	* tools/m4/convert_gst.m4: Reviewed conversions to make sure that only
	conversions to the C type (gobj() conversions) and conversions to
	types that are returned exist so that conversions to "const
	Glib::RefPtr<>&" are required in the .hg file (safer for signals and
	vfuncs).
	* gstreamer/src/event.hg:
	* gstreamer/src/index.hg:
	* gstreamer/src/index.ccg:
	* gstreamer/src/message.hg:
	* gstreamer/src/query.hg:
	* gstreamer/src/tagsetter.hg: Placed boxed type conversions specific
	to certain methods in the .hg files and removed them from the convert
	file.  Ensured that copies are made so that originals are not
	destroyed where appropriate.

	* tools/m4/ctocpp_base.m4: Modified the _CCONVERT() macro so that the
	conversion types it accepts are: type, param and return.
	* tools/extra_defs_gen/generate_plugin_gmmproc_file.cc: Added lines in
	signal generation to insert "#m4 _CONVERSION()" for parameters of type
	GstTagList because GstTagList has a different Glib::wrap() to
	distinguish it from GstStructure's Glib::wrap() (GstTagList is a
	GstStructure which makes the two different Glib::wrap() methods
	necessary).

	* gstreamer/src/basesrc.ccg:
	* gstreamer/src/preset.ccg: Typos.

Modified:
   gstreamermm/trunk/ChangeLog
   gstreamermm/trunk/gstreamer/src/basesrc.ccg
   gstreamermm/trunk/gstreamer/src/event.hg
   gstreamermm/trunk/gstreamer/src/index.ccg
   gstreamermm/trunk/gstreamer/src/index.hg
   gstreamermm/trunk/gstreamer/src/message.hg
   gstreamermm/trunk/gstreamer/src/preset.ccg
   gstreamermm/trunk/gstreamer/src/query.hg
   gstreamermm/trunk/gstreamer/src/tagsetter.hg
   gstreamermm/trunk/tools/extra_defs_gen/generate_plugin_gmmproc_file.cc
   gstreamermm/trunk/tools/m4/convert_gst.m4
   gstreamermm/trunk/tools/m4/ctocpp_base.m4

Modified: gstreamermm/trunk/gstreamer/src/basesrc.ccg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/basesrc.ccg	(original)
+++ gstreamermm/trunk/gstreamer/src/basesrc.ccg	Mon Apr 13 21:33:47 2009
@@ -45,9 +45,9 @@
       try // Trap C++ exceptions which would normally be lost because this is a C callback.
       {
       #endif //GLIBMM_EXCEPTIONS_ENABLED
-      Gst::Segment gstmm_segment(segment, true);
+      Gst::Segment cpp_segment(segment, true);
         // Call the virtual member method, which derived classes might override.
-        return static_cast<int>(obj->do_seek_vfunc(gstmm_segment));
+        return static_cast<int>(obj->do_seek_vfunc(cpp_segment));
       #ifdef GLIBMM_EXCEPTIONS_ENABLED
       }
       catch(...)
@@ -102,8 +102,8 @@
       {
       #endif //GLIBMM_EXCEPTIONS_ENABLED
         // Call the virtual member method, which derived classes might override.
-        Gst::Segment gstmm_segment(segment, true);
-        return static_cast<int>(obj->prepare_seek_segment_vfunc(Gst::wrap(seek, true) , gstmm_segment));
+        Gst::Segment cpp_segment(segment, true);
+        return static_cast<int>(obj->prepare_seek_segment_vfunc(Gst::wrap(seek, true) , cpp_segment));
       #ifdef GLIBMM_EXCEPTIONS_ENABLED
       }
       catch(...)

Modified: gstreamermm/trunk/gstreamer/src/event.hg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/event.hg	(original)
+++ gstreamermm/trunk/gstreamer/src/event.hg	Mon Apr 13 21:33:47 2009
@@ -132,7 +132,10 @@
    */
   Glib::RefPtr<Gst::Event> copy() const;
 
+// A copy is taken so that the original is not freed by the wrapper.
+#m4 _CONVERSION(`const GstStructure*',`const Gst::Structure',`Glib::wrap(const_cast<GstStructure*>($3), true)')
   _WRAP_METHOD(const Gst::Structure get_structure() const, gst_event_get_structure)
+
   _WRAP_METHOD(bool has_name(const Glib::ustring& name) const, gst_event_has_name)
 
   _WRAP_METHOD(guint32 get_seqnum() const, gst_event_get_seqnum)

Modified: gstreamermm/trunk/gstreamer/src/index.ccg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/index.ccg	(original)
+++ gstreamermm/trunk/gstreamer/src/index.ccg	Mon Apr 13 21:33:47 2009
@@ -114,7 +114,8 @@
     (GstIndexLookupMethod) method, (GstAssocFlags) flags, (GstFormat) format,
     value);
 
-  return Glib::wrap(gst_entry);
+  // Return a copy so that the original is not freed by wrapper.
+  return Glib::wrap(gst_entry, true);
 }
 
 void Index::set_filter(const SlotFilter& slot)

Modified: gstreamermm/trunk/gstreamer/src/index.hg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/index.hg	(original)
+++ gstreamermm/trunk/gstreamer/src/index.hg	Mon Apr 13 21:33:47 2009
@@ -109,6 +109,12 @@
   _WRAP_METHOD(void set_certainty(IndexCertainty certainty), gst_index_set_certainty)
   _WRAP_METHOD(IndexCertainty get_certainty() const, gst_index_get_certainty)
   _WRAP_METHOD(bool get_writer_id(const Glib::RefPtr<Gst::Object>& writer, int& id) const, gst_index_get_writer_id)
+
+// This conversion is used for next few add* methods (add_format,
+// add_association, etc.).  A copy is taken so the original is not freed by the
+// wrapper.
+#m4 _CONVERSION(`GstIndexEntry*',`Gst::IndexEntry',`Glib::wrap($3, true)')
+
   _WRAP_METHOD(Gst::IndexEntry add_format(int id, Format format), gst_index_add_format)
 
 #m4 _CONVERSION(`const Glib::ArrayHandle<const Gst::IndexAssociation>&', `const GstIndexAssociation*', `(const GstIndexAssociation*)(($3).data())')

Modified: gstreamermm/trunk/gstreamer/src/message.hg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/message.hg	(original)
+++ gstreamermm/trunk/gstreamer/src/message.hg	Mon Apr 13 21:33:47 2009
@@ -83,6 +83,8 @@
    */
    Glib::RefPtr<Gst::Message> copy() const;
 
+// A copy is taken so that the original is not freed by the wrapper.
+#m4 _CONVERSION(`const GstStructure*',`const Gst::Structure',`Glib::wrap(const_cast<GstStructure*>($3), true)')
   _WRAP_METHOD(const Gst::Structure get_structure() const, gst_message_get_structure)
 
   /** Checks if a message is writable. If not, a writable copy is made and

Modified: gstreamermm/trunk/gstreamer/src/preset.ccg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/preset.ccg	(original)
+++ gstreamermm/trunk/gstreamer/src/preset.ccg	Mon Apr 13 21:33:47 2009
@@ -140,13 +140,11 @@
       try // Trap C++ exceptions which would normally be lost because this is a C callback.
       {
       #endif //GLIBMM_EXCEPTIONS_ENABLED
-        Glib::ustring gstmm_value;
+        Glib::ustring cpp_value;
         // Call the virtual member method, which derived classes might override.
         const gboolean result = static_cast<int>(obj->get_meta_vfunc(Glib::convert_const_gchar_ptr_to_ustring(name)
-, Glib::convert_const_gchar_ptr_to_ustring(tag)
-, gstmm_value
-));
-        *value = g_strdup(gstmm_value.c_str());
+, Glib::convert_const_gchar_ptr_to_ustring(tag) , cpp_value));
+        *value = g_strdup(cpp_value.c_str());
         return result;
       #ifdef GLIBMM_EXCEPTIONS_ENABLED
       }

Modified: gstreamermm/trunk/gstreamer/src/query.hg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/query.hg	(original)
+++ gstreamermm/trunk/gstreamer/src/query.hg	Mon Apr 13 21:33:47 2009
@@ -131,6 +131,8 @@
     */
    Glib::RefPtr<Gst::Query> create_writable();
 
+// A copy is taken so that the original is not freed by the wrapper.
+#m4 _CONVERSION(`GstStructure*',`const Gst::Structure',`Glib::wrap(const_cast<GstStructure*>($3), true)')
   _WRAP_METHOD(const Gst::Structure get_structure() const, gst_query_get_structure)
 
   /** Get the Gst::QueryType of the query.

Modified: gstreamermm/trunk/gstreamer/src/tagsetter.hg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/tagsetter.hg	(original)
+++ gstreamermm/trunk/gstreamer/src/tagsetter.hg	Mon Apr 13 21:33:47 2009
@@ -56,8 +56,8 @@
    * @param value The value to set the tag to.
    * @param mode The mode to use.
    */
-   void add_tag(const Glib::ustring& tag, const Glib::ValueBase& value, TagMergeMode mode=TAG_MERGE_PREPEND);
-   _IGNORE(gst_tag_setter_add_tag_valist, gst_tag_setter_add_tag_valist_values)
+  void add_tag(const Glib::ustring& tag, const Glib::ValueBase& value, TagMergeMode mode=TAG_MERGE_PREPEND);
+  _IGNORE(gst_tag_setter_add_tag_valist, gst_tag_setter_add_tag_valist_values)
 
   /** Adds the given value on the setter using the given merge mode.
    *
@@ -66,8 +66,8 @@
    * type).
    * @param mode The mode to use.
    */
-   template <class DataType>
-   void add_tag(const Glib::ustring& tag, const DataType& data, TagMergeMode mode=TAG_MERGE_PREPEND);
+  template <class DataType>
+  void add_tag(const Glib::ustring& tag, const DataType& data, TagMergeMode mode=TAG_MERGE_PREPEND);
 
   /** Adds the given value on the setter using the given merge mode. 
    *
@@ -75,14 +75,17 @@
    * @param data The value to set the tag to.
    * @param mode The mode to use.
    */
-   void add_tag(const Glib::ustring& tag, const char* data, TagMergeMode mode=TAG_MERGE_PREPEND);
+  void add_tag(const Glib::ustring& tag, const char* data, TagMergeMode mode=TAG_MERGE_PREPEND);
 
-   _WRAP_METHOD(const Gst::TagList get_tag_list() const, gst_tag_setter_get_tag_list)
-   _WRAP_METHOD(void set_tag_merge_mode(TagMergeMode mode), gst_tag_setter_set_tag_merge_mode)
-   _WRAP_METHOD(TagMergeMode get_tag_merge_mode() const, gst_tag_setter_get_tag_merge_mode)
+// A copy is taken so that the original is not freed by the wrapper.
+#m4 _CONVERSION(`const GstTagList*',`const Gst::TagList',`Glib::wrap(const_cast<GstTagList*>($3), 0, true)')
+  _WRAP_METHOD(const Gst::TagList get_tag_list() const, gst_tag_setter_get_tag_list)
 
-   //Variable argument functions are ignored.
-   _IGNORE(gst_tag_setter_add_tags, gst_tag_setter_add_tag_values)
+  _WRAP_METHOD(void set_tag_merge_mode(TagMergeMode mode), gst_tag_setter_set_tag_merge_mode)
+  _WRAP_METHOD(TagMergeMode get_tag_merge_mode() const, gst_tag_setter_get_tag_merge_mode)
+
+  //Variable argument functions are ignored.
+  _IGNORE(gst_tag_setter_add_tags, gst_tag_setter_add_tag_values)
 };
 
 #ifndef DOXYGEN_SHOULD_SKIP_THIS

Modified: gstreamermm/trunk/tools/extra_defs_gen/generate_plugin_gmmproc_file.cc
==============================================================================
--- gstreamermm/trunk/tools/extra_defs_gen/generate_plugin_gmmproc_file.cc	(original)
+++ gstreamermm/trunk/tools/extra_defs_gen/generate_plugin_gmmproc_file.cc	Mon Apr 13 21:33:47 2009
@@ -257,7 +257,7 @@
         }
 
         wrapStatements += "  _WRAP_PROPERTY(\"" + propertyName + "\", " +
-          "_CCONVERT(" + propertyCType + ", `ret'))\n";
+          "_CCONVERT(" + propertyCType + ", `return'))\n";
 
         if (!G_TYPE_IS_ENUM(propertyGType) || enumIsWrapped)
           includeMacroCalls += "_CCONVERSION_INCLUDE(" + propertyCType + ")dnl\n";
@@ -328,7 +328,7 @@
       includeMacroCalls += "_CCONVERSION_INCLUDE(" + returnCType + ")dnl\n";
 
       wrapStatement = "  _WRAP_SIGNAL(_CCONVERT("  + returnCType +
-        ", `ret') " + signalMethodName + "(";
+        ", `return') " + signalMethodName + "(";
 
       cClassSignalDeclarations += "  " + returnCType + " (*" +
         signalMethodName + ") (" + cTypeName + "* element";
@@ -355,10 +355,22 @@
 
           if (gst_type_is_a_pointer(paramGType))
           {
-            convertMacros += "#m4 _CONVERSION(``" + paramCType +
-              "'', _LQ()_CCONVERT(" + paramCType + ",`param')_RQ(), ";
-            convertMacros += g_type_is_a(paramGType, GST_TYPE_MINI_OBJECT) ?
-              "``Gst::wrap($3, true)'')\n" : "``Glib::wrap($3, true)'')\n";
+            if (paramGType == GST_TYPE_TAG_LIST)
+            // dealing with a GstTagList* which has a special Glib::wrap()
+            // because of the conflict with the Glib::wrap() for GstStructure*
+            // (GstTagList is infact a GstStructure).
+            {
+              convertMacros += "#m4 _CONVERSION(``" + paramCType +
+                "'', _LQ()_CCONVERT(" + paramCType + ",`param')_RQ(), ";
+              convertMacros +=  "``Glib::wrap($3, 0, true)'')\n";
+            }
+            else
+            {
+              convertMacros += "#m4 _CONVERSION(``" + paramCType +
+                "'', _LQ()_CCONVERT(" + paramCType + ",`param')_RQ(), ";
+              convertMacros += g_type_is_a(paramGType, GST_TYPE_MINI_OBJECT) ?
+                "``Gst::wrap($3, true)'')\n" : "``Glib::wrap($3, true)'')\n";
+            }
           }
 
           wrapStatement += "_CCONVERT(" + paramCType + ", `param') " +

Modified: gstreamermm/trunk/tools/m4/convert_gst.m4
==============================================================================
--- gstreamermm/trunk/tools/m4/convert_gst.m4	(original)
+++ gstreamermm/trunk/tools/m4/convert_gst.m4	Mon Apr 13 21:33:47 2009
@@ -93,12 +93,11 @@
 _CONVERSION(`Glib::RefPtr<Gst::Index>',`GstIndex*',`Glib::unwrap($3)')
 
 #IndexEntry
-_CONVERSION(`GstIndexEntry*',`Gst::IndexEntry',`Glib::wrap($3, true)')
 _CONVERSION(`const Gst::IndexEntry&',`GstIndexEntry*',`const_cast<GstIndexEntry*>(($3).gobj())')
 
 #IndexFactory
 _CONVERSION(`GstIndexFactory*',`Glib::RefPtr<Gst::IndexFactory>',`Glib::wrap($3)')
-#
+
 #Iterator
 _CONVERSION(`GstIterator*',`Gst::Iterator<Gst::Element>',`Gst::Iterator<Gst::Element>::Iterator($3)')
 _CONVERSION(`GstIterator*',`Gst::Iterator<const Gst::Element>',`Gst::Iterator<const Gst::Element>::Iterator($3)')
@@ -124,7 +123,6 @@
 _CONVERSION(`const Glib::RefPtr<const Gst::Pad>&',`GstPad*',`const_cast<GstPad*>(($3)->gobj())')
 
 #PadTemplate
-_CONVERSION(`const Glib::RefPtr<Gst::PadTemplate>&',`GstPadTemplate*', `Glib::unwrap($3)')
 _CONVERSION(`GstPadTemplate*',`Glib::RefPtr<Gst::PadTemplate>', `Glib::wrap($3)')
 _CONVERSION(`const Glib::RefPtr<const Gst::PadTemplate>&',`GstPadTemplate*',`const_cast<GstPadTemplate*>(($3)->gobj())')
 
@@ -143,15 +141,12 @@
 _CONVERSION(`GstRegistry*',`Glib::RefPtr<Gst::Registry>', `Glib::wrap($3)')
 
 #Structure
-_CONVERSION(`const GstStructure*',`const Gst::Structure',`Glib::wrap(const_cast<GstStructure*>($3), true)')
-_CONVERSION(`GstStructure*',`const Gst::Structure',`Glib::wrap(const_cast<GstStructure*>($3), true)')
 _CONVERSION(`Gst::Structure&',`GstStructure*',`($3).gobj()')
 
 #TagList
 _CONVERSION(`const Gst::TagList&',`const GstTagList*',`(($3).gobj())')
-_CONVERSION(`GstTagList*',`Gst::TagList',`Glib::wrap($3, 0, true)')
+_CONVERSION(`GstTagList*',`Gst::TagList',`Glib::wrap($3, 0)')
 _CONVERSION(`Gst::TagList&',`GstTagList*',`($3).gobj()')
-_CONVERSION(`const GstTagList*',`const Gst::TagList',`Glib::wrap(const_cast<GstTagList*>($3), 0, true)')
 _CONVERSION(`Gst::TagList',`GstTagList*',`($3).gobj()')
 
 #TypeFind

Modified: gstreamermm/trunk/tools/m4/ctocpp_base.m4
==============================================================================
--- gstreamermm/trunk/tools/m4/ctocpp_base.m4	(original)
+++ gstreamermm/trunk/tools/m4/ctocpp_base.m4	Mon Apr 13 21:33:47 2009
@@ -55,7 +55,7 @@
 dnl `conversion type' may be:
 dnl `type' - For a C to C++ type translation.
 dnl `param' - For a C to C++ parameter translation.
-dnl `ret' - For a C to C++ return translation.
+dnl `return' - For a C to C++ return translation.
 dnl
 define(`_CCONVERT',`dnl
 ifelse(dnl
@@ -71,7 +71,7 @@
 ')`'dnl
 m4exit(1)`'dnl
 ')',dnl
-`$2',`ret',`dnl
+`$2',`return',`dnl
 ifdef(`TFR'__HASH(`$1'), `indir(`TFR'__HASH(`$1'))',`dnl
 ifdef(`TFP'__HASH(`$1'), `indir(`TFP'__HASH(`$1'))',`dnl
 errprint(`No C++ return conversion from $1 defined.



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