Start with Perl introspection from C API

Hi, I would love to add more C API functions to HTTP::Soup Perl module.

Currently, the decoding and encoding functions are missing. I need them for a CGI script.

As looking at the perl module, I can’t find any .gir files:

Just recognized does something using gir in the meson build file.

I am missing the link between libsoup and HTTP::Soup, how is it organized? Where is the typelib provided and where are the gir files?

by Joël

Update, found the XS tutorial:

… and the XS documentation:

HTTP::Soup seems to use it.

The HTTP::Soup bindings are statically generated, and fairly out of date.

You should use Glib::Object::Introspection instead, and generate them dynamically from the introspection data. For instance, Glib::IO and Gtk3 use introspection and pure Perl to paper over the less Perl-y bits of the C API.

Using introspection has the added benefit that you can extract the documentation from the introspection data; Glib::Object::Introspection installs a small documentation viewer for that.

Just recognized, all I need is to apt-get install libsoup2.4-dev gir1.2-soup-2.4 and create a file with the content:

package HTTP::Soup;

use Glib::Object::Introspection;

sub import {
  Glib::Object::Introspection->setup(basename => $BASENAME,
                                     version => $VERSION,
                                     package => $PACKAGE);

$BASENAME = 'Soup'; $VERSION = '2.4'; $PACKAGE = 'HTTP::Soup';

The HTTP::Soup bindings are statically generated, and fairly out of date.

The HTTP::Soup bindings are generated with Glib::Object::Introspection [1]. At the time the gir definition files were far from being complete so the bindings had to resort to XS in order to provide the missing pieces.

I haven’t checked if the gir files are now providing the missing functions and methods.


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