[valadoc] Make PropertyAccessorType a flag to correctly handle its possible states



commit b2e2e4cfbb5272250f0f8095b872d3953c08d7e5
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Tue Mar 25 21:31:18 2014 +0100

    Make PropertyAccessorType a flag to correctly handle its possible states

 src/driver/0.16.x/treebuilder.vala           |    3 +++
 src/driver/0.18.x/treebuilder.vala           |    3 +++
 src/driver/0.20.x/treebuilder.vala           |    3 +++
 src/driver/0.22.x/treebuilder.vala           |    3 +++
 src/driver/0.24.x/treebuilder.vala           |    3 +++
 src/driver/0.26.x/treebuilder.vala           |    3 +++
 src/libvaladoc/api/propertyaccessor.vala     |    6 +++---
 src/libvaladoc/api/propertyaccessortype.vala |   18 +++++++++---------
 8 files changed, 30 insertions(+), 12 deletions(-)
---
diff --git a/src/driver/0.16.x/treebuilder.vala b/src/driver/0.16.x/treebuilder.vala
index b993a64..54458a1 100644
--- a/src/driver/0.16.x/treebuilder.vala
+++ b/src/driver/0.16.x/treebuilder.vala
@@ -579,6 +579,9 @@ public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor {
 
        private PropertyAccessorType get_property_accessor_type (Vala.PropertyAccessor element) {
                if (element.construction) {
+                       if (element.writable) {
+                               return (PropertyAccessorType.CONSTRUCT | PropertyAccessorType.SET);
+                       }
                        return PropertyAccessorType.CONSTRUCT;
                } else if (element.writable) {
                        return PropertyAccessorType.SET;
diff --git a/src/driver/0.18.x/treebuilder.vala b/src/driver/0.18.x/treebuilder.vala
index a7d7b44..43ec860 100644
--- a/src/driver/0.18.x/treebuilder.vala
+++ b/src/driver/0.18.x/treebuilder.vala
@@ -580,6 +580,9 @@ public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor {
 
        private PropertyAccessorType get_property_accessor_type (Vala.PropertyAccessor element) {
                if (element.construction) {
+                       if (element.writable) {
+                               return (PropertyAccessorType.CONSTRUCT | PropertyAccessorType.SET);
+                       }
                        return PropertyAccessorType.CONSTRUCT;
                } else if (element.writable) {
                        return PropertyAccessorType.SET;
diff --git a/src/driver/0.20.x/treebuilder.vala b/src/driver/0.20.x/treebuilder.vala
index 970f12c..06c5845 100644
--- a/src/driver/0.20.x/treebuilder.vala
+++ b/src/driver/0.20.x/treebuilder.vala
@@ -585,6 +585,9 @@ public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor {
 
        private PropertyAccessorType get_property_accessor_type (Vala.PropertyAccessor element) {
                if (element.construction) {
+                       if (element.writable) {
+                               return (PropertyAccessorType.CONSTRUCT | PropertyAccessorType.SET);
+                       }
                        return PropertyAccessorType.CONSTRUCT;
                } else if (element.writable) {
                        return PropertyAccessorType.SET;
diff --git a/src/driver/0.22.x/treebuilder.vala b/src/driver/0.22.x/treebuilder.vala
index cfc8c91..32f9b84 100644
--- a/src/driver/0.22.x/treebuilder.vala
+++ b/src/driver/0.22.x/treebuilder.vala
@@ -585,6 +585,9 @@ public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor {
 
        private PropertyAccessorType get_property_accessor_type (Vala.PropertyAccessor element) {
                if (element.construction) {
+                       if (element.writable) {
+                               return (PropertyAccessorType.CONSTRUCT | PropertyAccessorType.SET);
+                       }
                        return PropertyAccessorType.CONSTRUCT;
                } else if (element.writable) {
                        return PropertyAccessorType.SET;
diff --git a/src/driver/0.24.x/treebuilder.vala b/src/driver/0.24.x/treebuilder.vala
index 1b5d0dc..7210711 100644
--- a/src/driver/0.24.x/treebuilder.vala
+++ b/src/driver/0.24.x/treebuilder.vala
@@ -585,6 +585,9 @@ public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor {
 
        private PropertyAccessorType get_property_accessor_type (Vala.PropertyAccessor element) {
                if (element.construction) {
+                       if (element.writable) {
+                               return (PropertyAccessorType.CONSTRUCT | PropertyAccessorType.SET);
+                       }
                        return PropertyAccessorType.CONSTRUCT;
                } else if (element.writable) {
                        return PropertyAccessorType.SET;
diff --git a/src/driver/0.26.x/treebuilder.vala b/src/driver/0.26.x/treebuilder.vala
index 6dfae91..32197d5 100644
--- a/src/driver/0.26.x/treebuilder.vala
+++ b/src/driver/0.26.x/treebuilder.vala
@@ -585,6 +585,9 @@ public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor {
 
        private PropertyAccessorType get_property_accessor_type (Vala.PropertyAccessor element) {
                if (element.construction) {
+                       if (element.writable) {
+                               return (PropertyAccessorType.CONSTRUCT | PropertyAccessorType.SET);
+                       }
                        return PropertyAccessorType.CONSTRUCT;
                } else if (element.writable) {
                        return PropertyAccessorType.SET;
diff --git a/src/libvaladoc/api/propertyaccessor.vala b/src/libvaladoc/api/propertyaccessor.vala
index 8c28555..0a79dd3 100644
--- a/src/libvaladoc/api/propertyaccessor.vala
+++ b/src/libvaladoc/api/propertyaccessor.vala
@@ -67,7 +67,7 @@ public class Valadoc.Api.PropertyAccessor : Symbol {
         */
        public bool is_construct {
                get {
-                       return type == PropertyAccessorType.CONSTRUCT;
+                       return (type & PropertyAccessorType.CONSTRUCT) != 0;
                }
        }
 
@@ -76,7 +76,7 @@ public class Valadoc.Api.PropertyAccessor : Symbol {
         */
        public bool is_set {
                get {
-                       return type == PropertyAccessorType.SET;
+                       return (type & PropertyAccessorType.SET) != 0;
                }
        }
 
@@ -85,7 +85,7 @@ public class Valadoc.Api.PropertyAccessor : Symbol {
         */
        public bool is_get {
                get {
-                       return type == PropertyAccessorType.GET;
+                       return (type & PropertyAccessorType.GET) != 0;
                }
        }
 
diff --git a/src/libvaladoc/api/propertyaccessortype.vala b/src/libvaladoc/api/propertyaccessortype.vala
index 01529ca..609815a 100644
--- a/src/libvaladoc/api/propertyaccessortype.vala
+++ b/src/libvaladoc/api/propertyaccessortype.vala
@@ -21,19 +21,19 @@
  */
 
 public enum Valadoc.Api.PropertyAccessorType {
-       CONSTRUCT,
-       SET,
-       GET;
+       CONSTRUCT = 1 << 0,
+       SET = 1 << 1,
+       GET = 1 << 2;
 
        public string to_string () {
-               switch (this) {
-               case PropertyAccessorType.CONSTRUCT:
+               if ((this & PropertyAccessorType.CONSTRUCT) != 0) {
+                       if ((this & PropertyAccessorType.SET) != 0) {
+                               return "construct set";
+                       }
                        return "construct";
-
-               case PropertyAccessorType.SET:
+               } else if ((this & PropertyAccessorType.SET) != 0) {
                        return "set";
-
-               case PropertyAccessorType.GET:
+               } else if ((this & PropertyAccessorType.GET) != 0) {
                        return "get";
                }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]