Passing a GType to a native function from Perl


Libsoup has functions that expect a GType as their argument [1].
Here's the prototype of one of them:
void soup_session_remove_feature_by_type (SoupSession *session, GType

WebKit registers some "features" that I would like to remove from a
Perl script. I couldn't find a direct way to pass a GType or to
retrieve one from Perl without using XS. Is that possible?

For now I added the following XS code to HTTP::Soup:

soup_session_remove_feature_by_type (SoupSession *session, const char *name)
                GType type;

                type = gperl_type_from_package(name);
                if (type) {
                        soup_session_remove_feature_by_type(session, type);

Which allows me to do:

    my $session = Gtk3::WebKit->get_default_session();

    # Provide my own login/password
    $session->signal_connect('authenticate' => sub {
        my ($session, $message, $auth) = @_;
        $auth->authenticate($login, $password);

Is there a better way to achieve this?

Emmanuel Rodriguez

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]