diff --git a/vala/gvala/base.vala b/vala/gvala/base.vala new file mode 100644 index 0000000..fe16bd1 --- /dev/null +++ b/vala/gvala/base.vala @@ -0,0 +1,14 @@ +class Base : GLib.Object { + public int b; + + public new void copy_from (Base b) { + stdout.printf ("Base copy_from() called\n"); + this.b = b.b; + } + + public virtual Base clone () { + var b = new Base(); + b.copy_from (this); + return b; + } +} diff --git a/vala/gvala/gvala.vala b/vala/gvala/gvala.vala deleted file mode 100644 index 9f6a01f..0000000 --- a/vala/gvala/gvala.vala +++ /dev/null @@ -1,64 +0,0 @@ -class Base : GLib.Object { - public int b; - - public new void copy_from (Base b) { - stdout.printf ("Base copy_from() called\n"); - this.b = b.b; - } - - public virtual Base clone () { - var b = new Base(); - b.copy_from (this); - return b; - } -} - -class Sub : Base { - public int s; - - public new void copy_from (Base b) { - stdout.printf ("Sub copy_from() called\n"); - ((Base)this).copy_from(b); - this.s = ((Sub)b).s; - } - - public override Base clone () { - var b = new Sub(); - b.copy_from (this); - return b; - } -} - -class SubSub : Sub { - public int ss; - - public new void copy_from (Base b) { - stdout.printf ("SubSub copy_from() called\n"); - ((Sub)this).copy_from(b); - this.ss = ((SubSub)b).ss; - } - - public override Base clone () { - var b = new SubSub(); - b.copy_from (this); - return b; - } -} - -class GVala : GLib.Object { - public static int main (string[] args) { - var src = new SubSub(); - src.b = 1; - src.s = 2; - src.ss = 3; - - Base b = new SubSub(); - b = src.clone(); - - var ss = (SubSub) b; - - stdout.printf ("b = %d, s = %d, ss = %d\n", ss.b, ss.s, ss.ss); - - return 0; - } -} diff --git a/vala/gvala/main.vala b/vala/gvala/main.vala new file mode 100644 index 0000000..47b5cec --- /dev/null +++ b/vala/gvala/main.vala @@ -0,0 +1,17 @@ +class GVala : GLib.Object { + public static int main (string[] args) { + var src = new SubSub(); + src.b = 1; + src.s = 2; + src.ss = 3; + + Base b = new SubSub(); + b = src.clone(); + + var ss = (SubSub) b; + + stdout.printf ("b = %d, s = %d, ss = %d\n", ss.b, ss.s, ss.ss); + + return 0; + } +} diff --git a/vala/gvala/sub.vala b/vala/gvala/sub.vala new file mode 100644 index 0000000..dc04261 --- /dev/null +++ b/vala/gvala/sub.vala @@ -0,0 +1,15 @@ +class Sub : Base { + public int s; + + public new void copy_from (Base b) { + stdout.printf ("Sub copy_from() called\n"); + ((Base)this).copy_from(b); + this.s = ((Sub)b).s; + } + + public override Base clone () { + var b = new Sub(); + b.copy_from (this); + return b; + } +} diff --git a/vala/gvala/subsub.vala b/vala/gvala/subsub.vala new file mode 100644 index 0000000..0d29dc4 --- /dev/null +++ b/vala/gvala/subsub.vala @@ -0,0 +1,15 @@ +class SubSub : Sub { + public int ss; + + public new void copy_from (Base b) { + stdout.printf ("SubSub copy_from() called\n"); + ((Sub)this).copy_from(b); + this.ss = ((SubSub)b).ss; + } + + public override Base clone () { + var b = new SubSub(); + b.copy_from (this); + return b; + } +}