GVala added.

This commit is contained in:
Kolan Sh 2012-10-12 20:52:25 +04:00
parent fd13b54b6a
commit 5fda726171
1 changed files with 24 additions and 6 deletions

View File

@ -1,29 +1,47 @@
class Base : GLib.Object { class Base : GLib.Object {
public int b; public int b;
public virtual void copy_from (Base b) { public new void copy_from (Base b) {
stdout.printf ("Base copy_from() called\n"); stdout.printf ("Base copy_from() called\n");
this.b = b.b; this.b = b.b;
} }
public virtual Base clone () {
var b = new Base();
b.copy_from (this);
return b;
}
} }
class Sub : Base { class Sub : Base {
public int s; public int s;
public override void copy_from (Base b) { public new void copy_from (Base b) {
stdout.printf ("Sub copy_from() called\n"); stdout.printf ("Sub copy_from() called\n");
((Base)this).copy_from(b);
this.s = ((Sub)b).s; this.s = ((Sub)b).s;
} }
public override Base clone () {
var b = new Sub();
b.copy_from (this);
return b;
}
} }
class SubSub : Sub { class SubSub : Sub {
public int ss; public int ss;
public int s;
public override void copy_from (Base b) { public new void copy_from (Base b) {
stdout.printf ("SubSub copy_from() called\n"); stdout.printf ("SubSub copy_from() called\n");
((Sub)this).copy_from(b);
this.ss = ((SubSub)b).ss; this.ss = ((SubSub)b).ss;
//((Sub)this).copy_from(b); }
public override Base clone () {
var b = new SubSub();
b.copy_from (this);
return b;
} }
} }
@ -35,7 +53,7 @@ class GVala : GLib.Object {
src.ss = 3; src.ss = 3;
Base b = new SubSub(); Base b = new SubSub();
b.copy_from(src); b = src.clone();
var ss = (SubSub) b; var ss = (SubSub) b;