Are GLibs functions somehow exposed in Perl?

I’d like to call Glib::shell_quote from Perl, but the Glib module seemingly doesn’t provide any of Glibs functions that aren’t part of some struct.

While it’s possible to import the GLib typelib via Glib::Object::Introspection and call the function via that, it causes assertion failures during the import that are printed.

Can you paste the assertion failures, so someone can take a look?

Also refer https://metacpan.org/pod/Glib::Object::Introspection.

That’s not really true: there are plenty of global functions in the Glib bindings.

The issue is that g_shell_quote() does not have a Perl trampoline because nobody bothered to add one. You’re welcome to open a merge request for the bindings, but they are in very low maintenance mode, these days.

It’s strongly discouraged to use GLib and GObject API via introspection with Perl; the Glib module exists for a reason, outside of historical legacy: a lot of the Glib::Object::Introspection functionality is implemented on top of the Glib Perl module itself, both in Perl and C.

  DB<4> Glib::Object::Introspection->setup(basename => 'GLib', version => '2.0', package => 'GlibGI');
GLib-GObject-CRITICAL **: g_boxed_type_register_static: assertion 'g_type_from_name (name) == 0' failed at /usr/lib/perl5/vendor_perl/5.40.0/x86_64-linux-thread-multi/Glib/Object/Introspection.pm line 110.
 at (eval 14)[/usr/lib/perl5/5.40.0/perl5db.pl:742] line 2.
	eval 'no strict; ($@, $!, $^E, $,, $/, $\\, $^W) = @DB::saved;package main; $^D = $^D | $DB::db_stop;
Glib::Object::Introspection->setup(basename => \'GLib\', version => \'2.0\', package => \'GlibGI\');;
' called at /usr/lib/perl5/5.40.0/perl5db.pl line 742
	DB::eval called at /usr/lib/perl5/5.40.0/perl5db.pl line 3449
	DB::DB called at -e line 1
GLib-CRITICAL **: g_once_init_leave_pointer: assertion 'result != 0' failed at /usr/lib/perl5/vendor_perl/5.40.0/x86_64-linux-thread-multi/Glib/Object/Introspection.pm line 110.
 at (eval 14)[/usr/lib/perl5/5.40.0/perl5db.pl:742] line 2.
	eval 'no strict; ($@, $!, $^E, $,, $/, $\\, $^W) = @DB::saved;package main; $^D = $^D | $DB::db_stop;
Glib::Object::Introspection->setup(basename => \'GLib\', version => \'2.0\', package => \'GlibGI\');;
' called at /usr/lib/perl5/5.40.0/perl5db.pl line 742
	DB::eval called at /usr/lib/perl5/5.40.0/perl5db.pl line 3449
	DB::DB called at -e line 1

Added support for them: Making sure you're not a bot!

A bit late for 48.0 tho :upside_down_face:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.