Re: [Vala] Writing VAPI: How to call struct member?



This is a virtual function: it is held by the struct.

Either you use a virtual member:

    public struct JavaVM {
        public virtual int get_env (...);
    }

Or a delegate:

public delegate GetEnvFunc (...);

    public struct JavaVM {
        GetEnvFunc get_env;
    }

I did not test the first option and it's likely to only work with
classes, so you might have to use a compact class.

Le lundi 08 août 2016 à 14:49 +0200, marcin saepia net a écrit :
Hello,

I am writing VAPI to the Java Native Interface.

I have there JavaVM struct.

In my function I get pointer to one.

I would like to call its member function, like this:

(*vm)->GetEnv(...)

When I define my VAPI in such way

  [CCode (cname = "JavaVM")]
  public struct JavaVM {
    [CCode (cname = "GetEnv")]
    public int get_env(out unowned Env env, Version version);
  }

I am getting C Code

GetEnv(vm, param1, param2)

instead of

(*vm)->GetEnv(param1, param2)

How can I write VAPI to achieve the second result in the C code?

Marcin
_______________________________________________
vala-list mailing list
vala-list gnome org
https://mail.gnome.org/mailman/listinfo/vala-list
-- 
Guillaume Poirier-Morency <guillaumepoiriermorency gmail com>

Étudiant au baccalauréat en Informatique à l'Université de Montréal
Chercheur boursier à l'IRIC

Mon blog: https://arteymix.github.io/
Clé PGP: B1AD6EA5

Attachment: signature.asc
Description: This is a digitally signed message part



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