Invoking "not introspectable" methods

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Invoking "not introspectable" methods

Ruslan Zakirov
Playing around with Glib-Object-Introspection and vips library. Things got wrong quickly: Vips::Image->new_from_file is not generated. In .gir file it's marked with introspectable="0" attribute: 2442 <constructor name="new_from_file" 2443 c:identifier="vips_image_new_from_file" 2444 introspectable="0"> Simple grep in typelib file shows that it's not there. In .h file it's marked with sentinel attribute: 437 VipsImage *vips_image_new_from_file( const char *name, ... ) 438 __attribute__((sentinel)); New to gobject world. Is something wrong with vips' gir file? with this module? Should I do some additional setup for such functions/methods?

--
Best regards, Ruslan.

_______________________________________________
gtk-perl-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-perl-list
Reply | Threaded
Open this post in threaded view
|

Re: Invoking "not introspectable" methods

"Torsten Schönfeld"
Here's a copy reply to your bug report which for some reason does not seem to make it through:

"Ruslan Zakirov via RT" <[hidden email]>:

> Playing around with the module and vips library. Things got wrong quickly: Vips::Image->new_from_file is not generated. In .gir file it's marked with introspectable="0" attribute:
>
> 2442 <constructor name="new_from_file"
> 2443 c:identifier="vips_image_new_from_file"
> 2444 introspectable="0">
>
> Simple grep in typelib file shows that it's not there.
>
> In .h file it's marked with sentinel attribute:
>
> 437 VipsImage *vips_image_new_from_file( const char *name, ... )
> 438 __attribute__((sentinel));
>
> New to gobject world. Is something wrong with vips' gir file? with this module? Should I do some additional setup for such functions/methods?

Looks like you've done everything correctly. Functions marked as introspectable=0 are simply not available from Perl (or any other language). In this case, the reason is that vips_image_new_from_file takes a variable number of arguments (indicated by the "..."), which is not supported by the introspection framework (mainly because the actual semantics of the implementation of "..." are complicated and platform-dependent). Most gobject-based libraries with varargs functions also offer alternative functions that take arrays, but that doesn't appear to be the case here.

The Python bindings seem to have a workaround: <https://github.com/jcupitt/libvips/blob/master/python/packages/gi/overrides/Vips.py#L448>.
_______________________________________________
gtk-perl-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-perl-list
Reply | Threaded
Open this post in threaded view
|

Re: Invoking "not introspectable" methods

Ruslan Zakirov


On Tue, May 23, 2017 at 3:09 PM, "Torsten Schönfeld" <[hidden email]> wrote:
Here's a copy reply to your bug report which for some reason does not seem to make it through:

It's not a bug report, but rather request for help. Duplicated it here manually. 

"Ruslan Zakirov via RT" <[hidden email]>:
> Playing around with the module and vips library. Things got wrong quickly: Vips::Image->new_from_file is not generated. In .gir file it's marked with introspectable="0" attribute:
>
> 2442 <constructor name="new_from_file"
> 2443 c:identifier="vips_image_new_from_file"
> 2444 introspectable="0">
>
> Simple grep in typelib file shows that it's not there.
>
> In .h file it's marked with sentinel attribute:
>
> 437 VipsImage *vips_image_new_from_file( const char *name, ... )
> 438 __attribute__((sentinel));
>
> New to gobject world. Is something wrong with vips' gir file? with this module? Should I do some additional setup for such functions/methods?

Looks like you've done everything correctly. Functions marked as introspectable=0 are simply not available from Perl (or any other language). In this case, the reason is that vips_image_new_from_file takes a variable number of arguments (indicated by the "..."), which is not supported by the introspection framework (mainly because the actual semantics of the implementation of "..." are complicated and platform-dependent). Most gobject-based libraries with varargs functions also offer alternative functions that take arrays, but that doesn't appear to be the case here.

The Python bindings seem to have a workaround: <https://github.com/jcupitt/libvips/blob/master/python/packages/gi/overrides/Vips.py#L448>.


Ok. Python re-implements logic of new_from_file on top of introspectable API. Can I use ->invoke to call such methods? Is it supported by FFI? vips has more of such functions.
 
_______________________________________________
gtk-perl-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-perl-list



--
Best regards, Ruslan.

_______________________________________________
gtk-perl-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-perl-list
Reply | Threaded
Open this post in threaded view
|

Re: Invoking "not introspectable" methods

"Torsten Schönfeld"
"Ruslan Zakirov" <[hidden email]>:

> Ok. Python re-implements logic of new_from_file on top of introspectable API. Can I use ->invoke to call such methods? Is it supported by > FFI? vips has more of such functions.

Please be more specific.  What do you mean by "such methods"?  What have you tried, which error messages did you get?
_______________________________________________
gtk-perl-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-perl-list
Reply | Threaded
Open this post in threaded view
|

Re: Invoking "not introspectable" methods

"Torsten Schönfeld"
"Torsten Schönfeld" <[hidden email]>:
> > Ok. Python re-implements logic of new_from_file on top of introspectable API. Can I use ->invoke to call such methods? Is it supported by > FFI? vips has more of such functions.
>
> Please be more specific.  What do you mean by "such methods"?  What have you tried, which error messages did you get?

And if you want to see examples for adding to or overriding introspection API, take a look at Gtk3: <https://git.gnome.org/browse/perl-Gtk3>.
_______________________________________________
gtk-perl-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-perl-list
Reply | Threaded
Open this post in threaded view
|

Re: Invoking "not introspectable" methods

Ruslan Zakirov
In reply to this post by "Torsten Schönfeld"


On Wed, May 24, 2017 at 10:32 AM, "Torsten Schönfeld" <[hidden email]> wrote:
"Ruslan Zakirov" <[hidden email]>:

> Ok. Python re-implements logic of new_from_file on top of introspectable API. Can I use ->invoke to call such methods? Is it supported by > FFI? vips has more of such functions.

Please be more specific.  What do you mean by "such methods"?  What have you tried, which error messages did you get?

Execute a function with varargs using ->invoke.


 
_______________________________________________
gtk-perl-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-perl-list



--
Best regards, Ruslan.

_______________________________________________
gtk-perl-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-perl-list
Reply | Threaded
Open this post in threaded view
|

Re: Invoking "not introspectable" methods

"Torsten Schönfeld"
On 25.05.2017 12:39, Ruslan Zakirov wrote:
> Execute a function with varargs using ->invoke.

No, that's not possible.
_______________________________________________
gtk-perl-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-perl-list