Re: G::O::I based bindings and problem passing char array ref

On 10.04.2016 20:48, Jeremy Volkening wrote:
A few months ago I updated the Poppler module to use
Glib::Object::Introspection to generate the bindings. I just realized
yesterday that this broke the "new_from_data()" constructor. I realized
this as I was wrapping librsvg 2.0 in a similar fashion
( and came across the
problem of passing in a Perl scalar when the underlying library wanted
a char array pointer.

Since new_from_data is currently not annotated to take an array of
bytes, a normal string should work fine in Perl.  This works for me:

use Glib::Object::Introspection;
  Glib::Object::Introspection->setup (
    basename => 'Poppler',
    version => '0.18',
    package => 'Poppler');

my $f = 'some PDF file';
open my $fh, '<:raw', $f or die "Could not open $f: $!";
my $data; { undef $/; $data = <$fh> };
close $fh;

warn my $d = Poppler::Document->new_from_data ($data, length $data);

Does it not work for you?

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