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 605778 - [PATCH] [scanner] Add an --add-init-function argument
[PATCH] [scanner] Add an --add-init-function argument
Status: RESOLVED FIXED
Product: gobject-introspection
Classification: Platform
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gobject-introspection Maintainer(s)
gobject-introspection Maintainer(s)
: 594209 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2009-12-31 01:32 UTC by Damien Lespiau
Modified: 2015-02-07 16:58 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Add an --add-init-function argument (3.59 KB, patch)
2009-12-31 01:32 UTC, Damien Lespiau
none Details | Review
take 2 (call the argument --add-init-section instead of --add-init-function) (3.61 KB, patch)
2010-01-05 17:45 UTC, Damien Lespiau
reviewed Details | Review
take 3 (don't add ';' at the end of each section) (3.54 KB, patch)
2010-01-05 18:23 UTC, Damien Lespiau
committed Details | Review

Description Damien Lespiau 2009-12-31 01:32:20 UTC
Created attachment 150597 [details] [review]
Add an --add-init-function argument

One might need to call some init functions before being able to call
get_type() to create the types of a library.

--add-init-function let the user insert some init functions in the
introspection program.

This is similar to the --type-init-func argument of gtk-doc's scangobj.

I needed this when introspecting a GstElement that needs to have GStreamer initialized before creating the element.
Comment 1 Colin Walters 2010-01-05 15:44:02 UTC
Review of attachment 150597 [details] [review]:

What do you think about --add-init-section="<arbitrary code block here>"?  This is really close it seems, all we're doing is appending ";".
Comment 2 Damien Lespiau 2010-01-05 17:45:47 UTC
Created attachment 150851 [details] [review]
take 2 (call the argument --add-init-section instead of --add-init-function)

That's absolutely fine with me and is more general indeed. Updated patch attached.
Comment 3 Colin Walters 2010-01-05 18:10:17 UTC
Review of attachment 150851 [details] [review]:

::: giscanner/dumper.py
@@ +99,3 @@
+                                              self._options.init_sections])
+	tpl_args['init_sections'] = ''.join([section + ";\n" for section in
+	tpl_args = {}

You're still suffixing the ';' here, which feels too magic.  It feels more natural to me like:

g-ir-scanner --add-init-section="foo_init(); bar_init(BAR_OPT_BAZ);"

i.e. we're just inserting your arbitrary C code exactly as is, rather than

g-ir-scanner --add-init-section="foo_init()" --add-init-section="bar_init(BAR_OPT_BAZ)"
Comment 4 Damien Lespiau 2010-01-05 18:23:09 UTC
Created attachment 150852 [details] [review]
take 3 (don't add ';' at the end of each section)

I noticed that the gtk-doc counterpart allowed not to put the ';' and it should not hurt to add random ';' at the end of each sections. That said it's not particularly useful nor beautiful.
Comment 5 Colin Walters 2010-01-05 18:31:32 UTC
Review of attachment 150852 [details] [review]:

Great, thank you!
Comment 6 Damien Lespiau 2010-01-05 18:38:09 UTC
Can you commit it? I don't have a GNOME account (yet! might ask for one soon :p)
Comment 7 Colin Walters 2010-01-05 18:53:40 UTC
*** Bug 594209 has been marked as a duplicate of this bug. ***
Comment 8 André Klapper 2015-02-07 16:58:45 UTC
[Mass-moving gobject-introspection tickets to its own Bugzilla product - see bug 708029. Mass-filter your bugmail for this message: introspection20150207 ]