sqlite3: Assorted memory management fixes for strings and blobs.
[vala-lang.git] / tests / objects / classes.vala
bloba89f475e66e627043991a11a8a7dc44e0dd1d5d9
1 using GLib;
3 [Compact]
4 class CompactClass {
5 public int field;
8 [Compact]
9 class CompactClassWithDestructor {
10 ~CompactClassWithDestructor () {
11 stdout.printf ("~CompactClassWithDestructor\n");
14 /* FIXME bug 533977 */
15 public char dummy;
18 class DerivedClass : CompactClass {
21 [Compact]
22 public class PublicClass {
23 public int field;
26 [Compact]
27 abstract class AbstractClass {
28 public int field;
31 [Compact]
32 class ClassWithCreationMethod {
33 public ClassWithCreationMethod () {
34 stdout.printf ("ClassWithCreationMethod\n");
37 public int field;
40 [Compact]
41 class ClassWithNamedCreationMethod {
42 public ClassWithNamedCreationMethod.named () {
43 stdout.printf ("ClassWithNamedCreationMethod\n");
46 public int field;
49 class SimpleGTypeInstanceClass {
52 class DerivedGTypeInstanceClass : SimpleGTypeInstanceClass {
55 public class PublicGTypeInstanceClass {
58 class GTypeInstanceClassWithCreationMethod {
59 public GTypeInstanceClassWithCreationMethod () {
60 stdout.printf ("GTypeInstanceClassWithCreationMethod\n");
64 class GTypeInstanceClassWithNamedCreationMethod {
65 public GTypeInstanceClassWithNamedCreationMethod.named () {
66 stdout.printf ("GTypeInstanceClassWithNamedCreationMethod\n");
70 class SimpleGObjectClass : Object {
73 class DerivedGObjectClass : SimpleGObjectClass {
76 public class PublicGObjectClass : Object {
79 abstract class AbstractGObjectClass : Object {
82 class GObjectClassWithCreationMethod : Object {
83 public GObjectClassWithCreationMethod () {
87 class GObjectClassWithNamedCreationMethod : Object {
88 public GObjectClassWithNamedCreationMethod.named () {
92 void main () {
93 stdout.printf ("Classes Test:\n");
95 stdout.printf ("new CompactClass ()\n");
96 var compact_class = new CompactClass ();
97 stdout.printf ("new DerivedClass ()\n");
98 var derived_class = new DerivedClass ();
99 stdout.printf ("new PublicClass ()\n");
100 var public_class = new PublicClass ();
101 stdout.printf ("new ClassWithCreationMethod ()\n");
102 var class_with_creation_method = new ClassWithCreationMethod ();
103 stdout.printf ("new ClassWithNamedCreationMethod ()\n");
104 var class_with_named_creation_method = new ClassWithNamedCreationMethod.named ();
105 stdout.printf ("new CompactClassWithDestructor ()\n");
106 var compact_class_with_destructor = new CompactClassWithDestructor ();
107 compact_class_with_destructor = null;
109 stdout.printf ("new SimpleGTypeInstanceClass ()\n");
110 var simple_gtypeinstance_class = new SimpleGTypeInstanceClass ();
111 stdout.printf ("new DerivedGTypeInstanceClass ()\n");
112 var derived_gtypeinstance_class = new DerivedGTypeInstanceClass ();
113 stdout.printf ("new PublicGTypeInstanceClass ()\n");
114 var public_gtypeinstance_class = new PublicGTypeInstanceClass ();
115 stdout.printf ("new GTypeInstanceClassWithCreationMethod ()\n");
116 var gtypeinstance_class_with_creation_method = new GTypeInstanceClassWithCreationMethod ();
117 stdout.printf ("new GTypeInstanceClassWithNamedCreationMethod ()\n");
118 var gtypeinstance_class_with_named_creation_method = new GTypeInstanceClassWithNamedCreationMethod.named ();
120 stdout.printf ("new SimpleGObjectClass ()\n");
121 var simple_gobject_class = new SimpleGObjectClass ();
122 stdout.printf ("new DerivedGObjectClass ()\n");
123 var derived_gobject_class = new DerivedGObjectClass ();
124 stdout.printf ("new PublicGObjectClass ()\n");
125 var public_gobject_class = new PublicGObjectClass ();
126 stdout.printf ("new GObjectClassWithCreationMethod ()\n");
127 var gobject_class_with_creation_method = new GObjectClassWithCreationMethod ();
128 stdout.printf ("new GObjectClassWithNamedCreationMethod ()\n");
129 var gobject_class_with_named_creation_method = new GObjectClassWithNamedCreationMethod.named ();
131 stdout.printf ("new CompactClass () { field = 1 }\n");
132 compact_class = new CompactClass () { field = 1 };
133 stdout.printf ("compact_class.field = %d\n", compact_class.field);
135 stdout.printf (".\n");