From fd13b54b6a3f66ed56c90a93e2cb23e27c06a11f Mon Sep 17 00:00:00 2001 From: Kolan Sh Date: Fri, 12 Oct 2012 20:44:31 +0400 Subject: [PATCH] GVala added. --- vala/gvala/gvala.vala | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/vala/gvala/gvala.vala b/vala/gvala/gvala.vala index 92a2fbe..9ced8a6 100644 --- a/vala/gvala/gvala.vala +++ b/vala/gvala/gvala.vala @@ -1,28 +1,45 @@ class Base : GLib.Object { - public virtual void copy () { - stdout.printf ("Base copy() called\n"); + public int b; + + public virtual void copy_from (Base b) { + stdout.printf ("Base copy_from() called\n"); + this.b = b.b; } } class Sub : Base { - public override void copy () { - stdout.printf ("Sub copy() called\n"); + public int s; + + public override void copy_from (Base b) { + stdout.printf ("Sub copy_from() called\n"); + this.s = ((Sub)b).s; } } class SubSub : Sub { - public override void copy () { - stdout.printf ("SubSub copy() called\n"); + public int ss; + public int s; + + public override void copy_from (Base b) { + stdout.printf ("SubSub copy_from() called\n"); + this.ss = ((SubSub)b).ss; + //((Sub)this).copy_from(b); } } class GVala : GLib.Object { public static int main (string[] args) { - // var base = new Base(); - // var sub = new Sub(); - Base b = new SubSub(); + var src = new SubSub(); + src.b = 1; + src.s = 2; + src.ss = 3; - b.copy(); + Base b = new SubSub(); + b.copy_from(src); + + var ss = (SubSub) b; + + stdout.printf ("b = %d, s = %d, ss = %d\n", ss.b, ss.s, ss.ss); return 0; }