summaryrefslogtreecommitdiff
path: root/vala/valaclass.vala
diff options
context:
space:
mode:
authorRico Tzschichholz <ricotz@ubuntu.com>2018-11-17 13:49:03 +0100
committerRico Tzschichholz <ricotz@ubuntu.com>2018-11-17 15:35:21 +0100
commitc280876a5d0bb26420d9b356150183d1e2964190 (patch)
treecca982a654e439632b4b707e529f12c5d69da4b8 /vala/valaclass.vala
parent7b434af7c65e8837f8205c83c47e429a085a4483 (diff)
downloadvala-c280876a5d0bb26420d9b356150183d1e2964190.tar.gz
vala: Clean up constructor/destructor API of Class/Struct
Diffstat (limited to 'vala/valaclass.vala')
-rw-r--r--vala/valaclass.vala50
1 files changed, 31 insertions, 19 deletions
diff --git a/vala/valaclass.vala b/vala/valaclass.vala
index def794f17..0a3d92b76 100644
--- a/vala/valaclass.vala
+++ b/vala/valaclass.vala
@@ -114,14 +114,14 @@ public class Vala.Class : ObjectTypeSymbol {
/**
* Specifies the default construction method.
*/
- public CreationMethod default_construction_method { get; set; }
+ public CreationMethod? default_construction_method { get; private set; }
/**
* Specifies the instance constructor.
*/
- public Constructor constructor {
+ public Constructor? constructor {
get { return _constructor; }
- set {
+ private set {
_constructor = value;
if (_constructor != null) {
_constructor.owner = scope;
@@ -132,9 +132,9 @@ public class Vala.Class : ObjectTypeSymbol {
/**
* Specifies the class constructor.
*/
- public Constructor class_constructor {
+ public Constructor? class_constructor {
get { return _class_constructor; }
- set {
+ private set {
_class_constructor = value;
if (_class_constructor != null) {
_class_constructor.owner = scope;
@@ -145,9 +145,9 @@ public class Vala.Class : ObjectTypeSymbol {
/**
* Specifies the static class constructor.
*/
- public Constructor static_constructor {
+ public Constructor? static_constructor {
get { return _static_constructor; }
- set {
+ private set {
_static_constructor = value;
if (_static_constructor != null) {
_static_constructor.owner = scope;
@@ -160,7 +160,7 @@ public class Vala.Class : ObjectTypeSymbol {
*/
public Destructor? destructor {
get { return _destructor; }
- set {
+ private set {
_destructor = value;
if (_destructor != null) {
_destructor.owner = scope;
@@ -178,7 +178,7 @@ public class Vala.Class : ObjectTypeSymbol {
*/
public Destructor? static_destructor {
get { return _static_destructor; }
- set {
+ private set {
_static_destructor = value;
if (_static_destructor != null) {
_static_destructor.owner = scope;
@@ -191,7 +191,7 @@ public class Vala.Class : ObjectTypeSymbol {
*/
public Destructor? class_destructor {
get { return _class_destructor; }
- set {
+ private set {
_class_destructor = value;
if (_class_destructor != null) {
_class_destructor.owner = scope;
@@ -208,9 +208,9 @@ public class Vala.Class : ObjectTypeSymbol {
}
}
- Constructor _constructor;
- Constructor _class_constructor;
- Constructor _static_constructor;
+ Constructor? _constructor;
+ Constructor? _class_constructor;
+ Constructor? _static_constructor;
Destructor? _destructor;
Destructor? _class_destructor;
Destructor? _static_destructor;
@@ -322,40 +322,52 @@ public class Vala.Class : ObjectTypeSymbol {
}
public override void add_constructor (Constructor c) {
- if (c.binding == MemberBinding.INSTANCE) {
+ switch (c.binding) {
+ case INSTANCE:
if (constructor != null) {
Report.error (c.source_reference, "class already contains a constructor");
}
constructor = c;
- } else if (c.binding == MemberBinding.CLASS) {
+ break;
+ case CLASS:
if (class_constructor != null) {
Report.error (c.source_reference, "class already contains a class constructor");
}
class_constructor = c;
- } else {
+ break;
+ case STATIC:
if (static_constructor != null) {
Report.error (c.source_reference, "class already contains a static constructor");
}
static_constructor = c;
+ break;
+ default:
+ assert_not_reached ();
}
}
public override void add_destructor (Destructor d) {
- if (d.binding == MemberBinding.INSTANCE) {
+ switch (d.binding) {
+ case INSTANCE:
if (destructor != null) {
Report.error (d.source_reference, "class already contains a destructor");
}
destructor = d;
- } else if (d.binding == MemberBinding.CLASS) {
+ break;
+ case CLASS:
if (class_destructor != null) {
Report.error (d.source_reference, "class already contains a class destructor");
}
class_destructor = d;
- } else {
+ break;
+ case STATIC:
if (static_destructor != null) {
Report.error (d.source_reference, "class already contains a static destructor");
}
static_destructor = d;
+ break;
+ default:
+ assert_not_reached ();
}
}