[Vala] How to refer current class in class method like "this" in instance method?



In vala, before you can invoke a class method, you need an instance. Valac
generated C code will get class from instance and pass it in class method
as first argument.

For example,
class Foo
{
    public class void bar() { }
}

If we invoke bar() like vala code below
var foo = new Foo();
foo.bar();

Generated C code will look like
Foo * foo = foo_new();
foo_bar(FOO_GET_CLASS(foo));

So, if we invoke bar with difference instance of subclass of Foo, the
actual class pass in bar() varying.

The question is, if I want access the class argument (say get GType of that
class) just like "this" in instance method, how can I do it? Thanks!

Derek Dai


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