GVala added.

This commit is contained in:
Kolan Sh 2012-10-12 21:03:19 +04:00
parent 5fda726171
commit 859ba022f2
5 changed files with 61 additions and 64 deletions

14
vala/gvala/base.vala Normal file
View File

@ -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;
}
}

View File

@ -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;
}
}

17
vala/gvala/main.vala Normal file
View File

@ -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;
}
}

15
vala/gvala/sub.vala Normal file
View File

@ -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;
}
}

15
vala/gvala/subsub.vala Normal file
View File

@ -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;
}
}