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



Type t = typeof(Foo);

On Wed, Mar 14, 2012 at 10:47 AM, Derek Dai <daiderek gmail com> wrote:
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

_______________________________________________
vala-list mailing list
vala-list gnome org
http://mail.gnome.org/mailman/listinfo/vala-list




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