]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Move handling of common attributes from Field and Parameter to Variable
authorJürg Billeter <j@bitron.ch>
Thu, 23 Dec 2010 19:05:19 +0000 (20:05 +0100)
committerJürg Billeter <j@bitron.ch>
Sun, 16 Jan 2011 09:54:38 +0000 (10:54 +0100)
vala/valafield.vala
vala/valaparameter.vala
vala/valavariable.vala

index 6bf48686a9443fba218e0a8847037ed0993e789b..28772d921ada59aa1a6725d0d623ac1403eab6d3 100644 (file)
@@ -38,46 +38,6 @@ public class Vala.Field : Variable, Lockable {
         */
        public bool is_volatile { get; set; }
 
-       /**
-        * Specifies whether an array length field should implicitly be created
-        * if the field type is an array.
-        */
-       public bool no_array_length { get; set; }
-
-       /**
-        * Specifies whether a delegate target field should implicitly be created
-        * if the field type is a delegate.
-        */
-       public bool no_delegate_target { get; set; }
-
-       /**
-        * Specifies whether the array is null terminated.
-        */
-       public bool array_null_terminated { get; set; }
-
-       /**
-        * Specifies whether the array length field uses a custom name in C.
-        */
-       public bool has_array_length_cname {
-               get { return (array_length_cname != null); }
-       }
-
-       /**
-        * Specifies whether the array uses a custom C expression as length.
-        */
-       public bool has_array_length_cexpr {
-               get { return (array_length_cexpr != null); }
-       }
-
-       /**
-        * Specifies a custom type for the array length.
-        */
-       public string? array_length_type { get; set; default = null; }
-
-       private string? array_length_cname;
-
-       private string? array_length_cexpr;
-
        private string cname;
        
        private bool lock_used = false;
@@ -141,45 +101,6 @@ public class Vala.Field : Variable, Lockable {
                }
        }
 
-       /**
-        * Returns the name of the array length field as it is used in C code
-        *
-        * @return the name of the array length field to be used in C code
-        */
-       public string? get_array_length_cname () {
-               return this.array_length_cname;
-       }
-
-       /**
-        * Sets the name of the array length field as it is used in C code
-        *
-        * @param array_length_cname the name of the array length field to be
-        * used in C code
-        */
-       public void set_array_length_cname (string? array_length_cname) {
-               this.array_length_cname = array_length_cname;
-       }
-
-       /**
-        * Returns the array length expression as it is used in C code
-        *
-        * @return the array length expression to be used in C code
-        */
-       public string? get_array_length_cexpr () {
-               return this.array_length_cexpr;
-       }
-
-
-       /**
-        * Sets the array length expression as it is used in C code
-        *
-        * @param array_length_cexpr the array length expression to be used in C
-        * code
-        */
-       public void set_array_length_cexpr (string? array_length_cexpr) {
-               this.array_length_cexpr = array_length_cexpr;
-       }
-
        private void process_ccode_attribute (Attribute a) {
                if (a.has_argument ("cname")) {
                        set_cname (a.get_string ("cname"));
@@ -213,7 +134,9 @@ public class Vala.Field : Variable, Lockable {
        /**
         * Process all associated attributes.
         */
-       public void process_attributes () {
+       public override void process_attributes () {
+               base.process_attributes ();
+
                foreach (Attribute a in attributes) {
                        if (a.name == "CCode") {
                                process_ccode_attribute (a);
index 7c52e9c683587f90c4ce876b7dd92c86c93cc788..2091efcf6c5e4ca898b5024270e1b1028c0f63f4 100644 (file)
@@ -42,29 +42,6 @@ public class Vala.Parameter : Variable {
         */
        public bool params_array { get; set; }
        
-       /**
-        * Specifies whether the array length should be passed implicitly
-        * if the parameter type is an array.
-        */
-       public bool no_array_length { get; set; }
-
-       /**
-        * Specifies whether the array is null terminated.
-        */
-       public bool array_null_terminated { get; set; }
-
-       /**
-        * Specifies whether the array length parameter uses a custom name in C.
-        */
-       public bool has_array_length_cname {
-               get { return (array_length_cname != null); }
-       }
-
-       /**
-        * Specifies a custom type for the array length.
-        */
-       public string? array_length_type { get; set; default = null; }
-
        /**
         * Specifies the position of the parameter in the C function.
         */
@@ -91,8 +68,6 @@ public class Vala.Parameter : Variable {
 
        public bool captured { get; set; }
 
-       private string? array_length_cname;
-
        /**
         * Creates a new formal parameter.
         *
@@ -144,25 +119,6 @@ public class Vala.Parameter : Variable {
                }
        }
 
-       /**
-        * Returns the name of the array length parameter as it is used in C code
-        *
-        * @return the name of the array length parameter to be used in C code
-        */
-       public string? get_array_length_cname () {
-               return this.array_length_cname;
-       }
-
-       /**
-        * Sets the name of the array length parameter as it is used in C code
-        *
-        * @param array_length_cname the name of the array length parameter to be
-        * used in C code
-        */
-       public void set_array_length_cname (string? array_length_cname) {
-               this.array_length_cname = array_length_cname;
-       }
-
        private void process_ccode_attribute (Attribute a) {
                if (a.has_argument ("type")) {
                        ctype = a.get_string ("type");
@@ -170,21 +126,9 @@ public class Vala.Parameter : Variable {
                if (a.has_argument ("pos")) {
                        cparameter_position = a.get_double ("pos");
                }
-               if (a.has_argument ("array_length")) {
-                       no_array_length = !a.get_bool ("array_length");
-               }
-               if (a.has_argument ("array_length_type")) {
-                       array_length_type = a.get_string ("array_length_type");
-               }
-               if (a.has_argument ("array_null_terminated")) {
-                       array_null_terminated = a.get_bool ("array_null_terminated");
-               }
                if (a.has_argument ("array_length_pos")) {
                        carray_length_parameter_position = a.get_double ("array_length_pos");
                }
-               if (a.has_argument ("array_length_cname")) {
-                       set_array_length_cname (a.get_string ("array_length_cname"));
-               }
                if (a.has_argument ("delegate_target_pos")) {
                        cdelegate_target_parameter_position = a.get_double ("delegate_target_pos");
                }
@@ -196,7 +140,9 @@ public class Vala.Parameter : Variable {
        /**
         * Process all associated attributes.
         */
-       public void process_attributes () {
+       public override void process_attributes () {
+               base.process_attributes ();
+
                foreach (Attribute a in attributes) {
                        if (a.name == "CCode") {
                                process_ccode_attribute (a);
index 9337751e18df2ac5cc5f6859955dce0fcc58b5e3..56cb1aed4a4ee96d79ffbcbefae5e96fe7ffc256 100644 (file)
@@ -49,12 +49,123 @@ public class Vala.Variable : Symbol {
                }
        }
 
+       /**
+        * Specifies whether an array length field should implicitly be created
+        * if the field type is an array.
+        */
+       public bool no_array_length { get; set; }
+
+       /**
+        * Specifies whether a delegate target field should implicitly be created
+        * if the field type is a delegate.
+        */
+       public bool no_delegate_target { get; set; }
+
+       /**
+        * Specifies whether the array is null terminated.
+        */
+       public bool array_null_terminated { get; set; }
+
+       /**
+        * Specifies whether the array length field uses a custom name in C.
+        */
+       public bool has_array_length_cname {
+               get { return (array_length_cname != null); }
+       }
+
+       /**
+        * Specifies whether the array uses a custom C expression as length.
+        */
+       public bool has_array_length_cexpr {
+               get { return (array_length_cexpr != null); }
+       }
+
+       /**
+        * Specifies a custom type for the array length.
+        */
+       public string? array_length_type { get; set; default = null; }
+
        Expression? _initializer;
        DataType? _variable_type;
 
+       private string? array_length_cname;
+
+       private string? array_length_cexpr;
+
        public Variable (DataType? variable_type, string? name, Expression? initializer = null, SourceReference? source_reference = null, Comment? comment = null) {
                base (name, source_reference, comment);
                this.variable_type = variable_type;
                this.initializer = initializer;
        }
+
+       /**
+        * Returns the name of the array length variable as it is used in C code
+        *
+        * @return the name of the array length variable to be used in C code
+        */
+       public string? get_array_length_cname () {
+               return this.array_length_cname;
+       }
+
+       /**
+        * Sets the name of the array length variable as it is used in C code
+        *
+        * @param array_length_cname the name of the array length variable to be
+        * used in C code
+        */
+       public void set_array_length_cname (string? array_length_cname) {
+               this.array_length_cname = array_length_cname;
+       }
+
+       /**
+        * Returns the array length expression as it is used in C code
+        *
+        * @return the array length expression to be used in C code
+        */
+       public string? get_array_length_cexpr () {
+               return this.array_length_cexpr;
+       }
+
+
+       /**
+        * Sets the array length expression as it is used in C code
+        *
+        * @param array_length_cexpr the array length expression to be used in C
+        * code
+        */
+       public void set_array_length_cexpr (string? array_length_cexpr) {
+               this.array_length_cexpr = array_length_cexpr;
+       }
+
+       void process_ccode_attribute (Attribute a) {
+               if (a.has_argument ("array_length")) {
+                       no_array_length = !a.get_bool ("array_length");
+               }
+               if (a.has_argument ("array_null_terminated")) {
+                       array_null_terminated = a.get_bool ("array_null_terminated");
+               }
+               if (a.has_argument ("array_length_cname")) {
+                       set_array_length_cname (a.get_string ("array_length_cname"));
+               }
+               if (a.has_argument ("array_length_cexpr")) {
+                       set_array_length_cexpr (a.get_string ("array_length_cexpr"));
+               }
+               if (a.has_argument ("array_length_type")) {
+                       array_length_type = a.get_string ("array_length_type");
+               }
+               if (a.has_argument ("delegate_target")) {
+                       no_delegate_target = !a.get_bool ("delegate_target");
+               }
+       }
+
+       /**
+        * Process all associated attributes.
+        */
+       public virtual void process_attributes () {
+               foreach (Attribute a in attributes) {
+                       if (a.name == "CCode") {
+                               process_ccode_attribute (a);
+                       }
+               }
+       }
 }