adapt to ForStatement API changes make {get,set}_lower_case_csuffix
authorJürg Billeter <j@bitron.ch>
Sat, 8 Jul 2006 11:55:18 +0000 (11:55 +0000)
committerJürg Billeter <juergbi@src.gnome.org>
Sat, 8 Jul 2006 11:55:18 +0000 (11:55 +0000)
2006-07-08  Jürg Billeter  <j@bitron.ch>

* vala/parser.y, vala/valacodegenerator.vala: adapt to ForStatement API
  changes
* vala/valaclass.vala: make {get,set}_lower_case_csuffix methods private
* vala/valaenum.vala, vala/valaenumvalue.vala,
  vala/valaexpressionstatement.vala, vala/valafield.vala,
  vala/valaflags.vala, vala/valaflagsvalue.vala,
  vala/valaforeachstatement.vala, vala/valaforstatement.vala: add
  interface documentation, use implicit namespace specification

svn path=/trunk/; revision=72

12 files changed:
vala/ChangeLog
vala/vala/parser.y
vala/vala/valaclass.vala
vala/vala/valacodegenerator.vala
vala/vala/valaenum.vala
vala/vala/valaenumvalue.vala
vala/vala/valaexpressionstatement.vala
vala/vala/valafield.vala
vala/vala/valaflags.vala
vala/vala/valaflagsvalue.vala
vala/vala/valaforeachstatement.vala
vala/vala/valaforstatement.vala

index b79b6ed..2598ef5 100644 (file)
@@ -1,5 +1,16 @@
 2006-07-08  Jürg Billeter  <j@bitron.ch>
 
+       * vala/parser.y, vala/valacodegenerator.vala: adapt to ForStatement API
+         changes
+       * vala/valaclass.vala: make {get,set}_lower_case_csuffix methods private
+       * vala/valaenum.vala, vala/valaenumvalue.vala,
+         vala/valaexpressionstatement.vala, vala/valafield.vala,
+         vala/valaflags.vala, vala/valaflagsvalue.vala,
+         vala/valaforeachstatement.vala, vala/valaforstatement.vala: add
+         interface documentation, use implicit namespace specification
+
+2006-07-08  Jürg Billeter  <j@bitron.ch>
+
        * vala/parser.y: adapt to Method API changes
        * vala/valasemanticanalyzer.vala: support signals, mark private signal
          handlers as instance_last
index da436f0..068ea6e 100644 (file)
@@ -1215,12 +1215,28 @@ for_statement
        : FOR OPEN_PARENS opt_statement_expression_list SEMICOLON opt_expression SEMICOLON opt_statement_expression_list CLOSE_PARENS embedded_statement
          {
                ValaSourceReference *src = src(@1);
-               $$ = VALA_STATEMENT (vala_for_statement_new ($3, $5, $7, $9, src));
-               g_object_unref (src);
+               $$ = VALA_STATEMENT (vala_for_statement_new ($5, $9, src));
                if ($5 != NULL) {
                        g_object_unref ($5);
                }
+               g_object_unref (src);
                g_object_unref ($9);
+               
+               GList *l;
+               if ($3 != NULL) {
+                       for (l = $3; l != NULL; l = l->next) {
+                               vala_for_statement_add_initializer (VALA_FOR_STATEMENT ($$), l->data);
+                               g_object_unref (l->data);
+                       }
+                       g_list_free ($3);
+               }
+               if ($7 != NULL) {
+                       for (l = $7; l != NULL; l = l->next) {
+                               vala_for_statement_add_iterator (VALA_FOR_STATEMENT ($$), l->data);
+                               g_object_unref (l->data);
+                       }
+                       g_list_free ($7);
+               }
          }
        ;
 
@@ -1726,7 +1742,7 @@ field_declaration
                        $$->access = $3;
                }
                if (($4 & VALA_MODIFIER_STATIC) == VALA_MODIFIER_STATIC) {
-                       $$->instance = FALSE;
+                       vala_field_set_instance ($$, FALSE);
                }
                VALA_CODE_NODE($$)->attributes = $2;
                g_object_unref ($5);
index 2da1d19..0534769 100644 (file)
@@ -261,26 +261,14 @@ public class Vala.Class : DataType {
                this.cname = cname;
        }
        
-       /**
-        * Returns the string to be prepended to the name of members of this
-        * class when used in C code.
-        *
-        * @return the suffix to be used in C code
-        */
-       public string get_lower_case_csuffix () {
+       private string get_lower_case_csuffix () {
                if (lower_case_csuffix == null) {
                        lower_case_csuffix = Namespace.camel_case_to_lower_case (name);
                }
                return lower_case_csuffix;
        }
        
-       /**
-        * Sets the string to be prepended to the name of members of this class
-        * when used in C code.
-        *
-        * @param csuffix the suffix to be used in C code
-        */
-       public void set_lower_case_csuffix (string! csuffix) {
+       private void set_lower_case_csuffix (string! csuffix) {
                this.lower_case_csuffix = csuffix;
        }
        
index 86b94bb..4db3a66 100644 (file)
@@ -1400,11 +1400,11 @@ public class Vala.CodeGenerator : CodeVisitor {
        public override void visit_for_statement (ForStatement! stmt) {
                var cfor = new CCodeForStatement (condition = (CCodeExpression) stmt.condition.ccodenode, body = (CCodeStatement) stmt.body.ccodenode);
                
-               foreach (Expression init_expr in stmt.initializer) {
+               foreach (Expression init_expr in stmt.get_initializer ()) {
                        cfor.add_initializer ((CCodeExpression) init_expr.ccodenode);
                }
                
-               foreach (Expression it_expr in stmt.iterator) {
+               foreach (Expression it_expr in stmt.get_iterator ()) {
                        cfor.add_iterator ((CCodeExpression) it_expr.ccodenode);
                }
                
index 9331d32..dbf8391 100644 (file)
 
 using GLib;
 
-namespace Vala {
-       public class Enum : DataType {
-               List<EnumValue> values;
+/**
+ * Represents an enum declaration in the source code.
+ */
+public class Vala.Enum : DataType {
+       private List<EnumValue> values;
+       private string cname;
+       private string cprefix;
 
-               public static ref Enum new (string name, SourceReference source) {
-                       return (new Enum (name = name, source_reference = source));
-               }
+       /**
+        * Creates a new enum.
+        *
+        * @param name   type name
+        * @param source reference to source code
+        * @return       newly created enum
+        */
+       public static ref Enum! new (string! name, SourceReference source) {
+               return (new Enum (name = name, source_reference = source));
+       }
+       
+       /**
+        * Appends the specified enum value to the list of values.
+        *
+        * @param value an enum value
+        */
+       public void add_value (EnumValue! value) {
+               values.append (value);
+       }
+       
+       public override void accept (CodeVisitor visitor) {
+               visitor.visit_begin_enum (this);
                
-               public void add_value (EnumValue value) {
-                       values.append (value);
+               foreach (EnumValue value in values) {
+                       value.accept (visitor);
                }
-               
-               public override void accept (CodeVisitor visitor) {
-                       visitor.visit_begin_enum (this);
-                       
-                       foreach (EnumValue value in values) {
-                               value.accept (visitor);
-                       }
 
-                       visitor.visit_end_enum (this);
-               }
+               visitor.visit_end_enum (this);
+       }
 
-               string cname;
-               public override string get_cname () {
-                       if (cname == null) {
-                               cname = "%s%s".printf (@namespace.get_cprefix (), name);
-                       }
-                       return cname;
-               }
-               
-               public override ref string get_upper_case_cname (string infix) {
-                       return "%s%s".printf (@namespace.get_lower_case_cprefix (), Namespace.camel_case_to_lower_case (name)).up ();
+       public override string get_cname () {
+               if (cname == null) {
+                       cname = "%s%s".printf (@namespace.get_cprefix (), name);
                }
+               return cname;
+       }
+       
+       public override ref string get_upper_case_cname (string infix) {
+               return "%s%s".printf (@namespace.get_lower_case_cprefix (), Namespace.camel_case_to_lower_case (name)).up ();
+       }
 
-               public override bool is_reference_type () {
-                       return false;
-               }
-               
-               public void set_cname (string! cname) {
-                       this.cname = cname;
-               }
-               
-               string cprefix;
-               public string get_cprefix () {
-                       if (cprefix == null) {
-                               cprefix = "%s_".printf (get_upper_case_cname (null));
-                       }
-                       return cprefix;
-               }
-               
-               public void set_cprefix (string! cprefix) {
-                       this.cprefix = cprefix;
+       public override bool is_reference_type () {
+               return false;
+       }
+       
+       private void set_cname (string! cname) {
+               this.cname = cname;
+       }
+       
+       /**
+        * Returns the string to be prepended to the name of members of this
+        * enum when used in C code.
+        *
+        * @return the prefix to be used in C code
+        */
+       public string! get_cprefix () {
+               if (cprefix == null) {
+                       cprefix = "%s_".printf (get_upper_case_cname (null));
                }
-               
-               void process_ccode_attribute (Attribute! a) {
-                       foreach (NamedArgument arg in a.args) {
-                               if (arg.name == "cname") {
-                                       /* this will already be checked during semantic analysis */
-                                       if (arg.argument is LiteralExpression) {
-                                               var lit = ((LiteralExpression) arg.argument).literal;
-                                               if (lit is StringLiteral) {
-                                                       set_cname (((StringLiteral) lit).eval ());
-                                               }
+               return cprefix;
+       }
+       
+       private void set_cprefix (string! cprefix) {
+               this.cprefix = cprefix;
+       }
+       
+       private void process_ccode_attribute (Attribute! a) {
+               foreach (NamedArgument arg in a.args) {
+                       if (arg.name == "cname") {
+                               /* this will already be checked during semantic analysis */
+                               if (arg.argument is LiteralExpression) {
+                                       var lit = ((LiteralExpression) arg.argument).literal;
+                                       if (lit is StringLiteral) {
+                                               set_cname (((StringLiteral) lit).eval ());
                                        }
-                               } else if (arg.name == "cprefix") {
-                                       /* this will already be checked during semantic analysis */
-                                       if (arg.argument is LiteralExpression) {
-                                               var lit = ((LiteralExpression) arg.argument).literal;
-                                               if (lit is StringLiteral) {
-                                                       set_cprefix (((StringLiteral) lit).eval ());
-                                               }
+                               }
+                       } else if (arg.name == "cprefix") {
+                               /* this will already be checked during semantic analysis */
+                               if (arg.argument is LiteralExpression) {
+                                       var lit = ((LiteralExpression) arg.argument).literal;
+                                       if (lit is StringLiteral) {
+                                               set_cprefix (((StringLiteral) lit).eval ());
                                        }
-                               } else if (arg.name == "cheader_filename") {
-                                       /* this will already be checked during semantic analysis */
-                                       if (arg.argument is LiteralExpression) {
-                                               var lit = ((LiteralExpression) arg.argument).literal;
-                                               if (lit is StringLiteral) {
-                                                       var val = ((StringLiteral) lit).eval ();
-                                                       foreach (string filename in val.split (",", 0)) {
-                                                               add_cheader_filename (filename);
-                                                       }
+                               }
+                       } else if (arg.name == "cheader_filename") {
+                               /* this will already be checked during semantic analysis */
+                               if (arg.argument is LiteralExpression) {
+                                       var lit = ((LiteralExpression) arg.argument).literal;
+                                       if (lit is StringLiteral) {
+                                               var val = ((StringLiteral) lit).eval ();
+                                               foreach (string filename in val.split (",", 0)) {
+                                                       add_cheader_filename (filename);
                                                }
                                        }
                                }
                        }
                }
-               
-               public void process_attributes () {
-                       foreach (Attribute a in attributes) {
-                               if (a.name == "CCode") {
-                                       process_ccode_attribute (a);
-                               }
+       }
+       
+       /**
+        * Process all associated attributes.
+        */
+       public void process_attributes () {
+               foreach (Attribute a in attributes) {
+                       if (a.name == "CCode") {
+                               process_ccode_attribute (a);
                        }
                }
        }
index 1073b1c..156e468 100644 (file)
 
 using GLib;
 
-namespace Vala {
-       public class EnumValue : CodeNode {
-               public string name { get; construct; }
-               public IntegerLiteral value { get; construct; }
+/**
+ * Represents an enum member in the source code.
+ */
+public class Vala.EnumValue : CodeNode {
+       /**
+        * The symbol name of this enum value.
+        */
+       public string! name { get; set construct; }
 
-               public static ref EnumValue new (string name) {
-                       return (new EnumValue (name = name));
-               }
+       /**
+        * Specifies the numerical representation of this enum value.
+        */
+       public Expression value { get; set; }
 
-               public static ref EnumValue new_with_value (string name, int value) {
-                       return (new EnumValue (name = name, value = value));
-               }
-               
-               public override void accept (CodeVisitor visitor) {
-                       visitor.visit_enum_value (this);
-               }
-               
-               string cname;
-               public string get_cname () {
-                       if (cname == null) {
-                               var en = (Enum) symbol.parent_symbol.node;
-                               cname = "%s%s".printf (en.get_cprefix (), name);
-                       }
-                       return cname;
+       private string cname;
+
+       /**
+        * Creates a new enum value.
+        *
+        * @param name enum value name
+        * @return     newly created enum value
+        */
+       public static ref EnumValue! new (string! name) {
+               return (new EnumValue (name = name));
+       }
+
+       /**
+        * Creates a new enum value with the specified numerical representation.
+        *
+        * @param name  enum value name
+        * @param value numerical representation
+        * @return      newly created enum value
+        */
+       public static ref EnumValue! new_with_value (string! name, Expression value) {
+               return (new EnumValue (name = name, value = value));
+       }
+       
+       public override void accept (CodeVisitor! visitor) {
+               visitor.visit_enum_value (this);
+       }
+       
+       /**
+        * Returns the name of this enum value as it is used in C code.
+        *
+        * @return the name to be used in C code
+        */
+       public string! get_cname () {
+               if (cname == null) {
+                       var en = (Enum) symbol.parent_symbol.node;
+                       cname = "%s%s".printf (en.get_cprefix (), name);
                }
+               return cname;
        }
 }
index 8ccb9b8..8234970 100644 (file)
 
 using GLib;
 
-namespace Vala {
-       public class ExpressionStatement : Statement {
-               public Expression expression { get; construct; }
+/**
+ * A code statement that evaluates a given expression. The value computed by the
+ * expression, if any, is discarded.
+ */
+public class Vala.ExpressionStatement : Statement {
+       /**
+        * Specifies the expression to evaluate.
+        */
+       public Expression! expression { get; set construct; }
 
-               public static ref ExpressionStatement new (Expression expr, SourceReference source) {
-                       return (new ExpressionStatement (expression = expr, source_reference = source));
-               }
-               
-               public override void accept (CodeVisitor visitor) {
-                       expression.accept (visitor);
+       /**
+        * Creates a new expression statement.
+        *
+        * @param expr   expression to evaluate
+        * @param source reference to source code
+        * @return       newly created expression statement
+        */
+       public static ref ExpressionStatement! new (Expression! expr, SourceReference source) {
+               return (new ExpressionStatement (expression = expr, source_reference = source));
+       }
+       
+       public override void accept (CodeVisitor! visitor) {
+               expression.accept (visitor);
 
-                       visitor.visit_expression_statement (this);
-               }
+               visitor.visit_expression_statement (this);
        }
 }
index 24123c2..8f03029 100644 (file)
 
 using GLib;
 
-namespace Vala {
-       public class Field : CodeNode {
-               public string name { get; construct; }
-               public TypeReference type_reference { get; construct; }
-               public Expression initializer { get; construct; }
-               public MemberAccessibility access;
-               public bool instance = true;
-               public string cname;
-               
-               public static ref Field new (string name, TypeReference type, Expression init, SourceReference source) {
-                       return (new Field (name = name, type_reference = type, initializer = init, source_reference = source));
-               }
-               
-               public override void accept (CodeVisitor visitor) {
-                       type_reference.accept (visitor);
-                       
-                       if (initializer != null) {
-                               initializer.accept (visitor);
-                       }
+/**
+ * Represents a type or namespace field.
+ */
+public class Vala.Field : CodeNode {
+       /**
+        * The symbol name of this field.
+        */
+       public string! name { get; set construct; }
 
-                       visitor.visit_field (this);
-               }
+       /**
+        * The data type of this field.
+        */
+       public TypeReference! type_reference { get; set construct; }
 
-               public string get_cname () {
-                       if (cname == null) {
-                               cname = name;
-                       }
-                       return cname;
+       /**
+        * Specifies the expression to be used to initialize this field.
+        */
+       public Expression initializer { get; set; }
+       
+       /**
+        * Specifies the accessibility of this field. Public accessibility
+        * doesn't limit access. Default accessibility limits access to this
+        * program or library. Private accessibility limits access to instances
+        * of the contained type.
+        */
+       public MemberAccessibility access;
+
+       /**
+        * Specifies whether this field may only be accessed with an instance of
+        * the contained type.
+        */
+       public bool instance {
+               get {
+                       return _instance;
                }
-               
-               public void set_cname (string cname) {
-                       this.cname = cname;
+               set {
+                       _instance = value;
                }
+       }
+
+       private string cname;
+       private bool _instance = true;
+       
+       /**
+        * Creates a new field.
+        *
+        * @param name   field name
+        * @param type   field type
+        * @param init   initializer expression
+        * @param source reference to source code
+        * @return       newly created field
+        */
+       public static ref Field! new (string! name, TypeReference! type, Expression init, SourceReference source) {
+               return (new Field (name = name, type_reference = type, initializer = init, source_reference = source));
+       }
+       
+       public override void accept (CodeVisitor! visitor) {
+               type_reference.accept (visitor);
                
-               void process_ccode_attribute (Attribute a) {
-                       foreach (NamedArgument arg in a.args) {
-                               if (arg.name == "cname") {
-                                       /* this will already be checked during semantic analysis */
-                                       if (arg.argument is LiteralExpression) {
-                                               var lit = ((LiteralExpression) arg.argument).literal;
-                                               if (lit is StringLiteral) {
-                                                       set_cname (((StringLiteral) lit).eval ());
-                                               }
+               if (initializer != null) {
+                       initializer.accept (visitor);
+               }
+
+               visitor.visit_field (this);
+       }
+
+       /**
+        * Returns the name of this field as it is used in C code.
+        *
+        * @return the name to be used in C code
+        */
+       public string! get_cname () {
+               if (cname == null) {
+                       cname = name;
+               }
+               return cname;
+       }
+       
+       private void set_cname (string! cname) {
+               this.cname = cname;
+       }
+       
+       private void process_ccode_attribute (Attribute! a) {
+               foreach (NamedArgument arg in a.args) {
+                       if (arg.name == "cname") {
+                               /* this will already be checked during semantic analysis */
+                               if (arg.argument is LiteralExpression) {
+                                       var lit = ((LiteralExpression) arg.argument).literal;
+                                       if (lit is StringLiteral) {
+                                               set_cname (((StringLiteral) lit).eval ());
                                        }
                                }
                        }
                }
-               
-               public void process_attributes () {
-                       foreach (Attribute a in attributes) {
-                               if (a.name == "CCode") {
-                                       process_ccode_attribute (a);
-                               }
+       }
+       
+       /**
+        * Process all associated attributes.
+        */
+       public void process_attributes () {
+               foreach (Attribute a in attributes) {
+                       if (a.name == "CCode") {
+                               process_ccode_attribute (a);
                        }
                }
        }
index e01b0b9..19427a9 100644 (file)
 
 using GLib;
 
-namespace Vala {
-       public class Flags : DataType {
-               List<FlagsValue> values;
+/**
+ * Represents a flags declaration in the source code.
+ */
+public class Vala.Flags : DataType {
+       List<FlagsValue> values;
+       string cname;
 
-               public static ref Flags new (string name, SourceReference source) {
-                       return (new Flags (name = name, source_reference = source));
-               }
-               
-               public void add_value (FlagsValue value) {
-                       values.append (value);
-               }
+       /**
+        * Creates a new flags.
+        *
+        * @param name   type name
+        * @param source reference to source code
+        * @return       newly created flags
+        */
+       public static ref Flags! new (string! name, SourceReference source) {
+               return (new Flags (name = name, source_reference = source));
+       }
+       
+       /**
+        * Appends the specified flags value to the list of values.
+        *
+        * @param value a flags value
+        */
+       public void add_value (FlagsValue! value) {
+               values.append (value);
+       }
+       
+       public override void accept (CodeVisitor! visitor) {
+               visitor.visit_begin_flags (this);
                
-               public override void accept (CodeVisitor visitor) {
-                       visitor.visit_begin_flags (this);
-                       
-                       foreach (FlagsValue value in values) {
-                               value.accept (visitor);
-                       }
-
-                       visitor.visit_end_flags (this);
+               foreach (FlagsValue value in values) {
+                       value.accept (visitor);
                }
 
-               string cname;
-               public override string get_cname () {
-                       if (cname == null) {
-                               cname = "%s%s".printf (@namespace.get_cprefix (), name);
-                       }
-                       return cname;
-               }
-               
-               public override string get_upper_case_cname (string infix) {
-                       return "%s%s".printf (@namespace.get_lower_case_cprefix (), Namespace.camel_case_to_lower_case (name)).up ();
-               }
+               visitor.visit_end_flags (this);
+       }
 
-               public override bool is_reference_type () {
-                       return false;
+       public override string! get_cname () {
+               if (cname == null) {
+                       cname = "%s%s".printf (@namespace.get_cprefix (), name);
                }
+               return cname;
+       }
+       
+       public override string! get_upper_case_cname (string infix) {
+               return "%s%s".printf (@namespace.get_lower_case_cprefix (), Namespace.camel_case_to_lower_case (name)).up ();
+       }
+
+       public override bool is_reference_type () {
+               return false;
        }
 }
index 4f6cbab..cb3fcfa 100644 (file)
 
 using GLib;
 
-namespace Vala {
-       public class FlagsValue : CodeNode {
-               public string name { get; construct; }
-               public IntegerLiteral value { get; construct; }
+/**
+ * Represents a flags member in the source code.
+ */
+public class Vala.FlagsValue : CodeNode {
+       /**
+        * The symbol name of this flags value.
+        */
+       public string! name { get; set construct; }
+       
+       /**
+        * Specifies the numerical representation of this flags value.
+        */
+       public Expression value { get; set; }
 
-               public static ref FlagsValue new (string name) {
-                       return (new FlagsValue (name = name));
-               }
+       private string cname;
 
-               public static ref FlagsValue new_with_value (string name, int value) {
-                       return (new FlagsValue (name = name, value = value));
-               }
-               
-               public override void accept (CodeVisitor visitor) {
-                       visitor.visit_flags_value (this);
-               }
-               
-               string cname;
-               public string get_cname () {
-                       if (cname == null) {
-                               var fl = (Flags) symbol.parent_symbol.node;
-                               cname = "%s_%s".printf (fl.get_upper_case_cname (null), name);
-                       }
-                       return cname;
+       /**
+        * Creates a new flags value.
+        *
+        * @param name  flags value name
+        * @return      newly created flags value
+        */
+       public static ref FlagsValue! new (string! name) {
+               return (new FlagsValue (name = name));
+       }
+
+       /**
+        * Creates a new flags value with the specified numerical
+        * representation.
+        *
+        * @param name  flags value name
+        * @param value numerical representation
+        * @return      newly created flags value
+        */
+       public static ref FlagsValue! new_with_value (string! name, Expression value) {
+               return (new FlagsValue (name = name, value = value));
+       }
+       
+       public override void accept (CodeVisitor! visitor) {
+               visitor.visit_flags_value (this);
+       }
+       
+       /**
+        * Returns the name of this flags value as it is used in C code.
+        *
+        * @return the name to be used in C code
+        */
+       public string! get_cname () {
+               if (cname == null) {
+                       var fl = (Flags) symbol.parent_symbol.node;
+                       cname = "%s_%s".printf (fl.get_upper_case_cname (null), name);
                }
+               return cname;
        }
 }
index 01ec16c..e0a4d3c 100644 (file)
 
 using GLib;
 
-namespace Vala {
-       public class ForeachStatement : Statement {
-               public TypeReference type_reference { get; construct; }
-               public string variable_name { get; construct; }
-               public Expression collection { get; construct; }
-               public Statement body { get; construct; }
-               public VariableDeclarator variable_declarator;
+/**
+ * Represents a foreach statement in the source code. Foreach statements iterate
+ * over the elements of a collection.
+ */
+public class Vala.ForeachStatement : Statement {
+       /**
+        * Specifies the element type.
+        */
+       public TypeReference! type_reference { get; set construct; }
+       
+       /**
+        * Specifies the element variable name.
+        */
+       public string! variable_name { get; set construct; }
+       
+       /**
+        * Specifies the container.
+        */
+       public Expression! collection { get; set construct; }
+       
+       /**
+        * Specifies the loop body.
+        */
+       public Statement body { get; set; }
+       
+       /**
+        * Specifies the declarator for the generated element variable.
+        */
+       public VariableDeclarator variable_declarator { get; set; }
 
-               public static ref ForeachStatement new (TypeReference type, string id, Expression col, Statement body, SourceReference source) {
-                       return (new ForeachStatement (type_reference = type, variable_name = id, collection = col, body = body, source_reference = source));
-               }
-               
-               public override void accept (CodeVisitor visitor) {
-                       visitor.visit_begin_foreach_statement (this);
+       /**
+        * Creates a new foreach statement.
+        *
+        * @param type   element type
+        * @param id     element variable name
+        * @param col    loop body
+        * @param source reference to source code
+        * @return       newly created foreach statement
+        */
+       public static ref ForeachStatement! new (TypeReference! type, string! id, Expression! col, Statement body, SourceReference source) {
+               return (new ForeachStatement (type_reference = type, variable_name = id, collection = col, body = body, source_reference = source));
+       }
+       
+       public override void accept (CodeVisitor! visitor) {
+               visitor.visit_begin_foreach_statement (this);
 
-                       type_reference.accept (visitor);
-                       collection.accept (visitor);
-                       body.accept (visitor);
+               type_reference.accept (visitor);
+               collection.accept (visitor);
+               body.accept (visitor);
 
-                       visitor.visit_end_foreach_statement (this);
-               }
+               visitor.visit_end_foreach_statement (this);
        }
 }
index 5a4a553..54bab51 100644 (file)
 
 using GLib;
 
-namespace Vala {
-       public class ForStatement : Statement {
-               public List<Expression> initializer { get; construct; }
-               public Expression condition { get; construct; }
-               public List<Expression> iterator { get; construct; }
-               public Statement body { get; construct; }
-
-               public static ref ForStatement new (List<Expression> init, Expression cond, List<Expression> iter, Statement body, SourceReference source) {
-                       return (new ForStatement (initializer = init, condition = cond, iterator = iter, body = body, source_reference = source));
-               }
-               
-               public override void accept (CodeVisitor visitor) {
-                       foreach (Expression init_expr in initializer) {
-                               init_expr.accept (visitor);
-                       }
+/**
+ * Represents a for iteration statement in the source code.
+ */
+public class Vala.ForStatement : Statement {
+       /**
+        * Specifies the loop condition.
+        */
+       public Expression condition { get; set; }
+       
+       /**
+        * Specifies the loop body.
+        */
+       public Statement body { get; set; }
 
-                       condition.accept (visitor);
-                       
-                       visitor.visit_end_full_expression (condition);
+       private List<Expression> initializer;
+       private List<Expression> iterator;
 
-                       foreach (Expression it_expr in iterator) {
-                               it_expr.accept (visitor);
-                       }
-                       body.accept (visitor);
+       /**
+        * Creates a new for statement.
+        *
+        * @param cond   loop condition
+        * @param body   loop body
+        * @param source reference to source code
+        * @return       newly created for statement
+        */
+       public static ref ForStatement! new (Expression cond, Statement body, SourceReference source) {
+               return (new ForStatement (condition = cond, body = body, source_reference = source));
+       }
+       
+       /**
+        * Appends the specified expression to the list of initializers.
+        *
+        * @param init an initializer expression
+        */
+       public void add_initializer (Expression! init) {
+               initializer.append (init);
+       }
+       
+       /**
+        * Returns a copy of the list of initializers.
+        *
+        * @return initializer list
+        */
+       public ref List<Expression> get_initializer () {
+               return initializer.copy ();
+       }
+       
+       /**
+        * Appends the specified expression to the iterator.
+        *
+        * @param iter an iterator expression
+        */
+       public void add_iterator (Expression! iter) {
+               iterator.append (iter);
+       }
+       
+       /**
+        * Returns a copy of the iterator.
+        *
+        * @return iterator
+        */
+       public ref List<Expression> get_iterator () {
+               return iterator.copy ();
+       }
+       
+       public override void accept (CodeVisitor! visitor) {
+               foreach (Expression init_expr in initializer) {
+                       init_expr.accept (visitor);
+               }
+
+               condition.accept (visitor);
+               
+               visitor.visit_end_full_expression (condition);
 
-                       visitor.visit_for_statement (this);
+               foreach (Expression it_expr in iterator) {
+                       it_expr.accept (visitor);
                }
+               
+               body.accept (visitor);
+
+               visitor.visit_for_statement (this);
        }
 }