Are GLibs functions somehow exposed in Perl? (original) (raw)

March 14, 2025, 10:28pm 1

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.

Sid (Sid) March 15, 2025, 2:00pm 2

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

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

ebassi (Emmanuele Bassi) March 15, 2025, 2:06pm 3

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.

sp1rit (Florian "sp1rit") March 16, 2025, 10:43pm 4

  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; ($@, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">!</mo><mo separator="true">,</mo></mrow><annotation encoding="application/x-tex">!, </annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mclose">!</span><span class="mpunct">,</span></span></span></span>^E, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo separator="true">,</mo><mo separator="true">,</mo></mrow><annotation encoding="application/x-tex">,, </annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3em;vertical-align:-0.1944em;"></span><span class="mpunct">,,</span></span></span></span>/, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mspace linebreak="newline"></mspace><mo separator="true">,</mo></mrow><annotation encoding="application/x-tex">\\, </annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="mspace newline"></span><span class="base"><span class="strut" style="height:0.3em;vertical-align:-0.1944em;"></span><span class="mpunct">,</span></span></span></span>^W) = @DB::saved;package main; <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mrow></mrow><mi>D</mi></msup><mo>=</mo></mrow><annotation encoding="application/x-tex">^D = </annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8413em;"></span><span class="mord"><span></span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8413em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.02778em;">D</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span></span></span></span>^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; ($@, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">!</mo><mo separator="true">,</mo></mrow><annotation encoding="application/x-tex">!, </annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mclose">!</span><span class="mpunct">,</span></span></span></span>^E, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo separator="true">,</mo><mo separator="true">,</mo></mrow><annotation encoding="application/x-tex">,, </annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.3em;vertical-align:-0.1944em;"></span><span class="mpunct">,,</span></span></span></span>/, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mspace linebreak="newline"></mspace><mo separator="true">,</mo></mrow><annotation encoding="application/x-tex">\\, </annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="mspace newline"></span><span class="base"><span class="strut" style="height:0.3em;vertical-align:-0.1944em;"></span><span class="mpunct">,</span></span></span></span>^W) = @DB::saved;package main; <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mrow></mrow><mi>D</mi></msup><mo>=</mo></mrow><annotation encoding="application/x-tex">^D = </annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8413em;"></span><span class="mord"><span></span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.8413em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.02778em;">D</span></span></span></span></span></span></span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span></span></span></span>^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

sp1rit (Florian "sp1rit") March 16, 2025, 11:27pm 5

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

A bit late for 48.0 tho 🙃

system (system) Closed March 30, 2025, 11:28pm 6

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