After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 562810 - Extending the extra defs generation tool to accept custom pointer determining function
Extending the extra defs generation tool to accept custom pointer determining...
Status: RESOLVED FIXED
Product: glibmm
Classification: Bindings
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkmm-forge
gtkmm-forge
Depends on:
Blocks:
 
 
Reported: 2008-11-30 22:10 UTC by José Alburquerque
Modified: 2008-12-16 18:08 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Custom is pointer function extension patch (5.65 KB, patch)
2008-11-30 22:11 UTC, José Alburquerque
committed Details | Review

Description José Alburquerque 2008-11-30 22:10:02 UTC
Would it be possible to modify the extra defs generation tool to accept a custom function to determine if a particular GType is a pointer?  The additional functionality can be used in modules to ensure that when the extra defs are generated, particular pointer types specific to the module can be generated correctly in the *.defs file as pointer types (e.g. GstMessage* instead of just GstMessage in gstreamermm).  It may also be useful when generating the extra defs (signals and properties) for additional GStreamer plugins like `filesrc' so that their sources are generated correctly.  The proposed patch (that follows) will not affect modules that use the extra defs generation tool already.  The change is not absolutely necessary, but it can make extra def generation more precise for modules such as gstreamermm.
Comment 1 José Alburquerque 2008-11-30 22:11:53 UTC
Created attachment 123713 [details] [review]
Custom is pointer function extension patch
Comment 2 Murray Cumming 2008-11-30 23:46:17 UTC
Could I see an example of how this would be used, please.
Comment 3 José Alburquerque 2008-12-01 00:18:54 UTC
It would be used from the extra defs generation utility of the module.  For example the genereate_defs_gst.cc would look partly like:

#include "glibmm_generate_extra_defs/generate_extra_defs.h"

#include <gst/gst.h>

bool gst_type_is_a_pointer(GType gtype)
{
  return (gtype_is_a_pointer(gtype) || g_type_is_a(gtype, GST_TYPE_MINI_OBJECT));
}

...

int main (int argc, char* argv[])
{
...
  std::cout << get_defs(GST_TYPE_BUFFER, gst_type_is_a_pointer)
            << get_defs(GST_TYPE_CAPS, gst_type_is_a_pointer)
...
}

However, I just looked and it is not necessary for what I'm trying to do (get the right types of properties and signals for plug-ins that are to be generated).  At first I sort of got somewhat confused and thought this was needed, but it really is not.  It still can be used as described above, but a local function for determining if a type is a function will work fine without the need for this patch.  Sorry for the confusion.
Comment 4 Murray Cumming 2008-12-01 08:14:32 UTC
> a local function for determining if a type is a function will work fine without
> the need for this patch.

I'd be interested to see that when you do it.

Thanks.
Comment 5 José Alburquerque 2008-12-15 22:48:46 UTC
Okay.  Plug-in generation is well underway so it can be said that it's pretty much functioning.  When generating plug-ins, however, we have two options when dealing with the plug-in defs:

1) Generate them prior to the build process (in the jhbuild environment) so that the defs are contained in the signal defs file (the extra defs) or:

2) Generate them as the plug-ins are generated in the build process and then use the generated defs when the generated plug-in sources are processed by gmmproc.

I think 2) is more advantageous because it allows the build process to deal correctly with possible differences in how plug-ins are defined in different versions.  One such example plug-in is audioresample[1].  In jhbuild its type is named GstSpeexResample while in version 0.10.20 its type is GstAudioResample.

When the defs are generated in jhbuild, the type name `GstSpeexResample' is used for the defs, but when the plug-in is generated outside of jhbuild, using version 0.10.20 of the GStreamer libraries, then the defs are not found for the type, GstAudioResample.

If the defs are generated during the build process, the defs will always be found for the available plug-ins on the build system.  However, this patch would be needed so that the pointer types are always correctly identified because defs generation would be done on the fly and not supervised so no patching could be done to the defs then.

In the audioresample example above the signals and properties are not modified, but the type name is different, which, as a side note, brings up any ABI issues that things like this may cause.

[1] http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-base-plugins/html/gst-plugins-base-plugins-audioresample.html
Comment 6 Murray Cumming 2008-12-16 08:39:47 UTC
(In reply to comment #3)
> bool gst_type_is_a_pointer(GType gtype)
> {
>   return (gtype_is_a_pointer(gtype) || g_type_is_a(gtype,
> GST_TYPE_MINI_OBJECT));
> }
> 
> ...
> 
> int main (int argc, char* argv[])
> {
> ...
>   std::cout << get_defs(GST_TYPE_BUFFER, gst_type_is_a_pointer)
>             << get_defs(GST_TYPE_CAPS, gst_type_is_a_pointer)
> ...
> }

Ah, so this is to detect GstMiniObjects, which don't use the normal GObject GType system. Sounds good. Feel free to commit that if you need it.

> However, I just looked and it is not necessary for what I'm trying to do 

Now I am a little confused. Do you need this or not?


> 2) Generate them as the plug-ins are generated in the build process and then
> use the generated defs when the generated plug-in sources are processed by
> gmmproc.

We generally generate .defs infrequently and by hand. That makes everything much less fragile - for instance the API doesn't change silently depending on what happenes to be on the PC of the person making the tarball. I'd like to keep it that way.
Comment 7 José Alburquerque 2008-12-16 17:47:39 UTC
(In reply to comment #6)
> Ah, so this is to detect GstMiniObjects, which don't use the normal GObject
> GType system. Sounds good. Feel free to commit that if you need it.
> 
> > However, I just looked and it is not necessary for what I'm trying to do 
> 
> Now I am a little confused. Do you need this or not?

Sorry.  I wasn't sure if it was needed when I first submitted the report.  After, I realized that I could do without it because I could just patch the defs files after manual generation.

> > 2) Generate them as the plug-ins are generated in the build process and then
> > use the generated defs when the generated plug-in sources are processed by
> > gmmproc.
> 
> We generally generate .defs infrequently and by hand. That makes everything
> much less fragile - for instance the API doesn't change silently depending on
> what happenes to be on the PC of the person making the tarball. I'd like to
> keep it that way.

For clarity, now I'm back to not needing it because the defs files can still be patched if the defs are generated by hand, but since it makes things easier (less patching necessary), with your permission, I think I'll apply it.
Comment 8 José Alburquerque 2008-12-16 18:08:15 UTC
Sorry once more for lack of clarity:

2008-12-16  José Alburquerque  <jaalburqu@svn.gnome.org>

	* tools/extra_defs_gen/generate_extra_defs.cc:
	* tools/extra_defs_gen/generate_extra_defs.h: Modify extra defs
	generation utility to accept custom defined function to determine if
	GType is a pointer.