On Wed, May 25, 2016 at 6:20 PM, Brandon Allbery <allber...@gmail.com>
wrote:

> On Wed, May 25, 2016 at 11:50 AM, Fernando Santagata <
> nando.santag...@gmail.com> wrote:
>
>> When I write a C program I'm able to call that function and I receive the
>> strings, so I guess my problem is just a mapping one.
>
>
> It can also mean a preallocated array of strings, though; C is sloppy
> about the difference between pointer-to and array-of. In NativeCall, the
> former is Pointer[Str] and the latter is CArray[Str]. From your
> description, you want the former.
>

In this case I'm working on libnotify. The interface to all the core
functionality works fine and I can show notifications on screen.

Now I'm working on this function:

gboolean        notify_get_server_info (char **ret_name,
                                        char **ret_vendor,
                                        char **ret_version,
                                        char **ret_spec_version);

I think that the four arguments return the information about the system.
The problem here is that I'm not an expert on NativeCall, which I'm just
beginning to love, and I don't know how to map those char **.

What I concocted on the Perl6 side so far is this:

sub notify_get_server_info(Str $name is rw, Str $vendor is rw, Str $version
is rw, Str $spec_version is rw) returns Bool is native('notify', v4) is
export {};

The calling program goes like this:

my Str ($name, $vendor, $version, $spec_version);
if notify_get_server_info($name, $vendor, $version, $spec_version) {
  say $name, $vendor, $version, $spec_version;
}else{
  say 'No server info';
}

and it prints

(Str)(Str)(Str)(Str)

So, I get that the mapping is wrong.

-- 
Fernando Santagata

Reply via email to