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 385841 - Handle gchar** (GStrv) arguments
Handle gchar** (GStrv) arguments
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-python
0.10.x
Other Linux
: Normal enhancement
: 0.10.8
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2006-12-14 13:40 UTC by Lukáš Lalinský
Modified: 2007-07-09 19:49 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Add codegen support for gchar** return type (2.29 KB, patch)
2006-12-15 01:11 UTC, René Stadler
none Details | Review
Add codegen support for gchar*-array return type (1.07 KB, patch)
2006-12-17 19:14 UTC, René Stadler
none Details | Review
Add codegen support for gchar*-array return type (3.44 KB, patch)
2006-12-17 19:20 UTC, René Stadler
none Details | Review
Add codegen support for GStrv return type (3.49 KB, patch)
2007-02-10 13:40 UTC, René Stadler
committed Details | Review

Description Lukáš Lalinský 2006-12-14 13:40:42 UTC
Function gst_type_find_factory_get_extensions returns a list of strings as gchar**, so this definition:

(define-method get_extensions
  (of-object "GstTypeFindFactory")
  (c-name "gst_type_find_factory_get_extensions")
  (return-type "gchar**")
)

doesn't work:

Could not write method GstTypeFindFactory.get_extensions: No ArgType for 'gchar**'

I guess it will need a simple C function to build a Python list out of it, but I'm not familiar with the wrapper system pygst uses, so I can't implement it myself.
Comment 1 René Stadler 2006-12-15 01:11:59 UTC
Created attachment 78406 [details] [review]
Add codegen support for gchar** return type

With this patch, the code generator becomes capable of additionally binding gst.ElementFactory.get_uri_protocols and gst.TypeFindFactory.get_extensions.

List of changes:

        * gst/arg-types.py: (StringArrayArg, StringArrayArg.write_return):
        Add support for gchar** return type.
        * gst/gst.defs:
        Comment out definition for get_protocols virtual method of GstURIHandler
        objects.  The code generator now attempts to bind this method, which
        breaks compilation since the C function takes no arguments.
Comment 2 Edward Hervey 2006-12-16 14:54:57 UTC
Although the patch is nicely done (using the codegenerator and an argtype), the problem is that saying that 'gchar**' is always a string array is wrong, it could also be a pointer to a string (so that a method could return the location of a string at that adress).

I would prefer a patch with an override, please :)
Comment 3 René Stadler 2006-12-16 15:39:30 UTC
Sure, but are there functions that use it like this?  Obviously there are none in the .defs (that aren't overridden already).  If there are some that should be added, maybe we should consider to override _them_ instead.

Using overrides here is wrong in any case.  Instead, one might consider changing the ptype from gchar** to gchar-array or something.  The types used in the .defs do not have to match the C types, they already differ since the C definition does not communicate that the caller does not own the return value (seems like all the functions lack G_CONST_RETURN?).
Comment 4 Edward Hervey 2006-12-17 10:39:15 UTC
I'm more in favour of changing the type in .defs to gchar-array. Makes it more readable. If that is in the patch, it goes in :)
Comment 5 René Stadler 2006-12-17 19:14:57 UTC
Created attachment 78529 [details] [review]
Add codegen support for gchar*-array return type

Oops, gchar-array is just gchar*.  What we need is gchararray-array, gchar*-array, gcharpointer-array, str-array or strv or something.  Pick your favorite.  I picked gchar*-array for this updated patch, but feel free to object.

This patch is nicer: I found that we can get rid of an override.  This also returns tuples instead of lists, which is consistent with what pygtk does in its overrides.  Furthermore, I don't need to comment out the get_protocols virtual definition since we no longer claim to be able to handle gchar** returns.

Updated list of changes:

        * gst/arg-types.py: (StringArrayArg, StringArrayArg.write_return):
        Add support for gchar*-array return type (which occurs in the C API as
        gchar**).
        * gst/gst.defs:
        Change return type from gchar** to gchar*-array for
        GstElementFactory.get_uri_protocols, GstTypeFindFactory.get_extensions
        and GstURIHandler.get_protocols method definitions.
        * gst/gst.override: (_wrap_gst_uri_handler_get_protocols):
        Remove the now unneeded override for gst_uri_handler_get_protocols.
Comment 6 René Stadler 2006-12-17 19:20:18 UTC
Created attachment 78530 [details] [review]
Add codegen support for gchar*-array return type   	 

(attached correct file this time)
Comment 7 René Stadler 2007-02-10 13:40:00 UTC
Created attachment 82277 [details] [review]
Add codegen support for GStrv return type

Looks like GStrv is the correct type to use actually.

Updated list of changes:

        * gst/arg-types.py: (StringArrayArg, StringArrayArg.write_return):
        Add support for GStrv return type (which occurs in the C API as
        gchar**).
        * gst/gst.defs:
        Change return type from gchar** to GStrv for
        GstElementFactory.get_uri_protocols, GstTypeFindFactory.get_extensions
        and GstURIHandler.get_protocols method definitions.
        * gst/gst.override: (_wrap_gst_uri_handler_get_protocols):
        Remove the now unneeded override for gst_uri_handler_get_protocols.
Comment 8 Edward Hervey 2007-07-09 19:49:29 UTC
2007-07-05  Edward Hervey  <bilboed@bilboed.com>

        Patch by: Rene Stadler <mail@renestadler.de>
        * gst/arg-types.py:
        * gst/gst.defs:
        * gst/gst.override:
        Handle 'gchar**' (GStrv) arguments in a uniform way.
        Fixes #385841