From: Jürg Billeter Date: Mon, 27 Oct 2008 08:12:26 +0000 (+0000) Subject: Use constructor chaining instead of helper method X-Git-Tag: VALA_0_5_1~37 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8ff16e2fc8a7fb97c4f578bba978f71cda54432d;p=thirdparty%2Fvala.git Use constructor chaining instead of helper method 2008-10-27 Jürg Billeter * vala/valaarraylengthfield.vala: * vala/valaarraymovemethod.vala: * vala/valaarrayresizemethod.vala: * vala/valablock.vala: * vala/valaclass.vala: * vala/valaconstant.vala: * vala/valaconstructor.vala: * vala/valacreationmethod.vala: * vala/valadelegate.vala: * vala/valadestructor.vala: * vala/valadynamicmethod.vala: * vala/valadynamicproperty.vala: * vala/valadynamicsignal.vala: * vala/valaenum.vala: * vala/valaenumvalue.vala: * vala/valaerrorcode.vala: * vala/valaerrordomain.vala: * vala/valafield.vala: * vala/valaforeachstatement.vala: * vala/valaformalparameter.vala: * vala/valainterface.vala: * vala/valalocalvariable.vala: * vala/valamember.vala: * vala/valamethod.vala: * vala/valanamespace.vala: * vala/valaobjecttypesymbol.vala: * vala/valaproperty.vala: * vala/valasignal.vala: * vala/valastruct.vala: * vala/valaswitchsection.vala: * vala/valasymbol.vala: * vala/valatypeparameter.vala: * vala/valatypesymbol.vala: Use constructor chaining instead of helper method svn path=/trunk/; revision=1934 --- diff --git a/ChangeLog b/ChangeLog index bfb17df06..4260e97bd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,41 @@ +2008-10-27 Jürg Billeter + + * vala/valaarraylengthfield.vala: + * vala/valaarraymovemethod.vala: + * vala/valaarrayresizemethod.vala: + * vala/valablock.vala: + * vala/valaclass.vala: + * vala/valaconstant.vala: + * vala/valaconstructor.vala: + * vala/valacreationmethod.vala: + * vala/valadelegate.vala: + * vala/valadestructor.vala: + * vala/valadynamicmethod.vala: + * vala/valadynamicproperty.vala: + * vala/valadynamicsignal.vala: + * vala/valaenum.vala: + * vala/valaenumvalue.vala: + * vala/valaerrorcode.vala: + * vala/valaerrordomain.vala: + * vala/valafield.vala: + * vala/valaforeachstatement.vala: + * vala/valaformalparameter.vala: + * vala/valainterface.vala: + * vala/valalocalvariable.vala: + * vala/valamember.vala: + * vala/valamethod.vala: + * vala/valanamespace.vala: + * vala/valaobjecttypesymbol.vala: + * vala/valaproperty.vala: + * vala/valasignal.vala: + * vala/valastruct.vala: + * vala/valaswitchsection.vala: + * vala/valasymbol.vala: + * vala/valatypeparameter.vala: + * vala/valatypesymbol.vala: + + Use constructor chaining instead of helper method + 2008-10-26 Jürg Billeter * vala/Makefile.am: diff --git a/vala/valaarraylengthfield.vala b/vala/valaarraylengthfield.vala index 87a8b52d5..220718000 100644 --- a/vala/valaarraylengthfield.vala +++ b/vala/valaarraylengthfield.vala @@ -32,9 +32,7 @@ public class Vala.ArrayLengthField : Field { * @return newly created field */ public ArrayLengthField (SourceReference source_reference) { - base.init (); - name = "length"; + base ("length", new InvalidType (), null, source_reference); external = true; - this.source_reference = source_reference; } } diff --git a/vala/valaarraymovemethod.vala b/vala/valaarraymovemethod.vala index 0f22c041d..916ae04f2 100644 --- a/vala/valaarraymovemethod.vala +++ b/vala/valaarraymovemethod.vala @@ -32,9 +32,7 @@ public class Vala.ArrayMoveMethod : Method { * @return newly created method */ public ArrayMoveMethod (SourceReference source_reference) { - base.init (); - name = "move"; + base ("move", new VoidType (), source_reference); external = true; - this.source_reference = source_reference; } } diff --git a/vala/valaarrayresizemethod.vala b/vala/valaarrayresizemethod.vala index f44a5bc01..ff9bc6173 100644 --- a/vala/valaarrayresizemethod.vala +++ b/vala/valaarrayresizemethod.vala @@ -32,10 +32,8 @@ public class Vala.ArrayResizeMethod : Method { * @return newly created method */ public ArrayResizeMethod (SourceReference source_reference) { - base.init (); - name = "resize"; + base ("resize", new VoidType (), source_reference); external = true; - this.source_reference = source_reference; cinstance_parameter_position = 0.1; } } diff --git a/vala/valablock.vala b/vala/valablock.vala index c8d19a8dc..9de484064 100644 --- a/vala/valablock.vala +++ b/vala/valablock.vala @@ -42,8 +42,7 @@ public class Vala.Block : Symbol, Statement { * @param source reference to source code */ public Block (SourceReference source_reference) { - base.init (); - this.source_reference = source_reference; + base (null, source_reference); } /** diff --git a/vala/valaclass.vala b/vala/valaclass.vala index 6c261c6af..8a066d331 100644 --- a/vala/valaclass.vala +++ b/vala/valaclass.vala @@ -209,9 +209,7 @@ public class Vala.Class : ObjectTypeSymbol { * @return newly created class */ public Class (string name, SourceReference? source_reference = null) { - base.init (); - this.source_reference = source_reference; - this.name = name; + base (name, source_reference); } /** diff --git a/vala/valaconstant.vala b/vala/valaconstant.vala index 8c6987fac..6d31c5787 100644 --- a/vala/valaconstant.vala +++ b/vala/valaconstant.vala @@ -68,11 +68,9 @@ public class Vala.Constant : Member, Lockable { * @return newly created constant */ public Constant (string name, DataType type_reference, Expression? initializer, SourceReference? source_reference) { - base.init (); - this.name = name; + base (name, source_reference); this.type_reference = type_reference; this.initializer = initializer; - this.source_reference = source_reference; } public override void accept (CodeVisitor visitor) { diff --git a/vala/valaconstructor.vala b/vala/valaconstructor.vala index 7ad4a554f..6e0c476c0 100644 --- a/vala/valaconstructor.vala +++ b/vala/valaconstructor.vala @@ -48,8 +48,7 @@ public class Vala.Constructor : Symbol { * @return newly created constructor */ public Constructor (SourceReference source) { - base.init (); - source_reference = source; + base (null, source); } public override void accept (CodeVisitor visitor) { diff --git a/vala/valacreationmethod.vala b/vala/valacreationmethod.vala index 9fcbc72a5..fccca87e8 100644 --- a/vala/valacreationmethod.vala +++ b/vala/valacreationmethod.vala @@ -59,11 +59,8 @@ public class Vala.CreationMethod : Method { * @return newly created method */ public CreationMethod (string? type_name, string? name, SourceReference? source_reference = null) { - base.init (); - this.name = name; - this.source_reference = source_reference; + base (name, new VoidType (), source_reference); this.type_name = type_name; - return_type = new VoidType (); carray_length_parameter_position = -3; cdelegate_target_parameter_position = -3; diff --git a/vala/valadelegate.vala b/vala/valadelegate.vala index fdf949f8a..0ad7ad62a 100644 --- a/vala/valadelegate.vala +++ b/vala/valadelegate.vala @@ -95,10 +95,8 @@ public class Vala.Delegate : TypeSymbol { * @return newly created delegate */ public Delegate (string? name, DataType return_type, SourceReference? source_reference = null) { - base.init (); - this.name = name; + base (name, source_reference); this.return_type = return_type; - this.source_reference = source_reference; // error is -1 (right of user_data) cinstance_parameter_position = -2; diff --git a/vala/valadestructor.vala b/vala/valadestructor.vala index df623c512..0d0da978e 100644 --- a/vala/valadestructor.vala +++ b/vala/valadestructor.vala @@ -48,8 +48,7 @@ public class Vala.Destructor : Symbol { * @return newly created destructor */ public Destructor (SourceReference? source_reference = null) { - base.init (); - this.source_reference = source_reference; + base (null, source_reference); } public override void accept (CodeVisitor visitor) { diff --git a/vala/valadynamicmethod.vala b/vala/valadynamicmethod.vala index 94ed2e31c..848911cbf 100644 --- a/vala/valadynamicmethod.vala +++ b/vala/valadynamicmethod.vala @@ -35,11 +35,8 @@ public class Vala.DynamicMethod : Method { static int dynamic_method_id; public DynamicMethod (DataType dynamic_type, string name, DataType return_type, SourceReference? source_reference = null) { - base.init (); + base (name, return_type, source_reference); this.dynamic_type = dynamic_type; - this.name = name; - this.return_type = return_type; - this.source_reference = source_reference; } public override Gee.List get_cheader_filenames () { diff --git a/vala/valadynamicproperty.vala b/vala/valadynamicproperty.vala index 17c6aae41..e18ebbe3c 100644 --- a/vala/valadynamicproperty.vala +++ b/vala/valadynamicproperty.vala @@ -32,10 +32,8 @@ public class Vala.DynamicProperty : Property { private string cname; public DynamicProperty (DataType dynamic_type, string name, SourceReference? source_reference = null) { - base.init (); + base (name, null, null, null, source_reference); this.dynamic_type = dynamic_type; - this.name = name; - this.source_reference = source_reference; } public override Gee.List get_cheader_filenames () { diff --git a/vala/valadynamicsignal.vala b/vala/valadynamicsignal.vala index 96e4216aa..a363aa994 100644 --- a/vala/valadynamicsignal.vala +++ b/vala/valadynamicsignal.vala @@ -31,10 +31,7 @@ public class Vala.DynamicSignal : Signal { public Expression handler { get; set; } public DynamicSignal (DataType dynamic_type, string name, DataType return_type, SourceReference? source_reference = null) { - base.init (); + base (name, return_type, source_reference); this.dynamic_type = dynamic_type; - this.name = name; - this.return_type = return_type; - this.source_reference = source_reference; } } diff --git a/vala/valaenum.vala b/vala/valaenum.vala index 60a63a3ce..132d1eb32 100644 --- a/vala/valaenum.vala +++ b/vala/valaenum.vala @@ -53,9 +53,7 @@ public class Vala.Enum : TypeSymbol { * @return newly created enum */ public Enum (string name, SourceReference? source_reference = null) { - base.init (); - this.source_reference = source_reference; - this.name = name; + base (name, source_reference); } /** diff --git a/vala/valaenumvalue.vala b/vala/valaenumvalue.vala index 53f014bd5..dba9513e6 100644 --- a/vala/valaenumvalue.vala +++ b/vala/valaenumvalue.vala @@ -40,9 +40,7 @@ public class Vala.EnumValue : Symbol { * @return newly created enum value */ public EnumValue (string name, SourceReference? source_reference = null) { - base.init (); - this.name = name; - this.source_reference = source_reference; + base (name, source_reference); } /** @@ -53,10 +51,8 @@ public class Vala.EnumValue : Symbol { * @return newly created enum value */ public EnumValue.with_value (string name, Expression value, SourceReference? source_reference = null) { - base.init (); - this.name = name; + this (name, source_reference); this.value = value; - this.source_reference = source_reference; } /** diff --git a/vala/valaerrorcode.vala b/vala/valaerrorcode.vala index dab552648..aeef7f584 100644 --- a/vala/valaerrorcode.vala +++ b/vala/valaerrorcode.vala @@ -40,9 +40,7 @@ public class Vala.ErrorCode : TypeSymbol { * @return newly created enum value */ public ErrorCode (string name, SourceReference? source_reference = null) { - base.init (); - this.name = name; - this.source_reference = source_reference; + base (name, source_reference); } /** @@ -53,10 +51,8 @@ public class Vala.ErrorCode : TypeSymbol { * @return newly created enum value */ public ErrorCode.with_value (string name, Expression value, SourceReference? source_reference = null) { - base.init (); - this.name = name; + this (name, source_reference); this.value = value; - this.source_reference = source_reference; } public override void accept (CodeVisitor visitor) { diff --git a/vala/valaerrordomain.vala b/vala/valaerrordomain.vala index 418f3a3ca..d302aed17 100644 --- a/vala/valaerrordomain.vala +++ b/vala/valaerrordomain.vala @@ -42,9 +42,7 @@ public class Vala.ErrorDomain : TypeSymbol { * @return newly created error domain */ public ErrorDomain (string name, SourceReference? source_reference = null) { - base.init (); - this.source_reference = source_reference; - this.name = name; + base (name, source_reference); } /** diff --git a/vala/valafield.vala b/vala/valafield.vala index 7625efa35..f9b4a954a 100644 --- a/vala/valafield.vala +++ b/vala/valafield.vala @@ -87,11 +87,9 @@ public class Vala.Field : Member, Lockable { * @return newly created field */ public Field (string name, DataType field_type, Expression? initializer, SourceReference? source_reference = null) { - base.init (); - this.name = name; + base (name, source_reference); this.field_type = field_type; this.initializer = initializer; - this.source_reference = source_reference; } public override void accept (CodeVisitor visitor) { diff --git a/vala/valaforeachstatement.vala b/vala/valaforeachstatement.vala index cf3fa611b..5133a286b 100644 --- a/vala/valaforeachstatement.vala +++ b/vala/valaforeachstatement.vala @@ -101,11 +101,10 @@ public class Vala.ForeachStatement : Block { * @return newly created foreach statement */ public ForeachStatement (DataType? type_reference, string variable_name, Expression collection, Block body, SourceReference source_reference) { - base.init (); + base (source_reference); this.variable_name = variable_name; this.collection = collection; this.body = body; - this.source_reference = source_reference; this.type_reference = type_reference; } diff --git a/vala/valaformalparameter.vala b/vala/valaformalparameter.vala index 014a5faed..d0693759a 100644 --- a/vala/valaformalparameter.vala +++ b/vala/valaformalparameter.vala @@ -98,10 +98,8 @@ public class Vala.FormalParameter : Symbol { * @return newly created formal parameter */ public FormalParameter (string name, DataType parameter_type, SourceReference? source_reference = null) { - base.init (); - this.name = name; + base (name, source_reference); this.parameter_type = parameter_type; - this.source_reference = source_reference; access = SymbolAccessibility.PUBLIC; } @@ -110,10 +108,9 @@ public class Vala.FormalParameter : Symbol { * Creates a new ellipsis parameter representing an indefinite number of * parameters. */ - public FormalParameter.with_ellipsis (SourceReference? source = null) { - base.init (); + public FormalParameter.with_ellipsis (SourceReference? source_reference = null) { + base (null, source_reference); ellipsis = true; - source_reference = source; access = SymbolAccessibility.PUBLIC; } diff --git a/vala/valainterface.vala b/vala/valainterface.vala index 224dd4919..a925f640b 100644 --- a/vala/valainterface.vala +++ b/vala/valainterface.vala @@ -97,9 +97,7 @@ public class Vala.Interface : ObjectTypeSymbol { * @return newly created interface */ public Interface (string name, SourceReference? source_reference = null) { - base.init (); - this.source_reference = source_reference; - this.name = name; + base (name, source_reference); } /** diff --git a/vala/valalocalvariable.vala b/vala/valalocalvariable.vala index e9a200920..f8767118b 100644 --- a/vala/valalocalvariable.vala +++ b/vala/valalocalvariable.vala @@ -66,11 +66,9 @@ public class Vala.LocalVariable : Symbol { * @return newly created variable declarator */ public LocalVariable (DataType? variable_type, string name, Expression? initializer = null, SourceReference? source_reference = null) { - base.init (); + base (name, source_reference); this.variable_type = variable_type; - this.name = name; this.initializer = initializer; - this.source_reference = source_reference; } public override void accept (CodeVisitor visitor) { diff --git a/vala/valamember.vala b/vala/valamember.vala index 954bcf522..ceb4ceeb2 100644 --- a/vala/valamember.vala +++ b/vala/valamember.vala @@ -28,7 +28,11 @@ using Gee; */ public abstract class Vala.Member : Symbol { private Gee.List cheader_filenames = new ArrayList (); - + + public Member (string? name, SourceReference? source_reference) { + base (name, source_reference); + } + public override void accept (CodeVisitor visitor) { visitor.visit_member (this); } diff --git a/vala/valamethod.vala b/vala/valamethod.vala index 6cebf4744..f18a5b3fd 100644 --- a/vala/valamethod.vala +++ b/vala/valamethod.vala @@ -222,11 +222,9 @@ public class Vala.Method : Member { * @param source reference to source code * @return newly created method */ - public Method (string name, DataType return_type, SourceReference? source_reference = null) { - base.init (); + public Method (string? name, DataType return_type, SourceReference? source_reference = null) { + base (name, source_reference); this.return_type = return_type; - this.source_reference = source_reference; - this.name = name; carray_length_parameter_position = -3; cdelegate_target_parameter_position = -3; diff --git a/vala/valanamespace.vala b/vala/valanamespace.vala index c6245c08d..e83793567 100644 --- a/vala/valanamespace.vala +++ b/vala/valanamespace.vala @@ -52,9 +52,7 @@ public class Vala.Namespace : Symbol { * @return newly created namespace */ public Namespace (string? name, SourceReference? source_reference = null) { - base.init (); - this.source_reference = source_reference; - this.name = name; + base (name, source_reference); access = SymbolAccessibility.PUBLIC; } diff --git a/vala/valaobjecttypesymbol.vala b/vala/valaobjecttypesymbol.vala index 4bc7e3294..069d18493 100644 --- a/vala/valaobjecttypesymbol.vala +++ b/vala/valaobjecttypesymbol.vala @@ -32,4 +32,8 @@ public abstract class Vala.ObjectTypeSymbol : TypeSymbol { public abstract Gee.List get_methods (); public abstract Gee.List get_signals (); public abstract Gee.List get_properties (); + + public ObjectTypeSymbol (string name, SourceReference? source_reference = null) { + base (name, source_reference); + } } diff --git a/vala/valaproperty.vala b/vala/valaproperty.vala index 2afe27b4a..fee4bd3dd 100644 --- a/vala/valaproperty.vala +++ b/vala/valaproperty.vala @@ -30,7 +30,7 @@ public class Vala.Property : Member, Lockable { /** * The property type. */ - public DataType property_type { + public DataType? property_type { get { return _data_type; } set { _data_type = value; @@ -175,13 +175,11 @@ public class Vala.Property : Member, Lockable { * @param source reference to source code * @return newly created property */ - public Property (string name, DataType property_type, PropertyAccessor? get_accessor, PropertyAccessor? set_accessor, SourceReference? source_reference = null) { - base.init (); - this.name = name; + public Property (string name, DataType? property_type, PropertyAccessor? get_accessor, PropertyAccessor? set_accessor, SourceReference? source_reference = null) { + base (name, source_reference); this.property_type = property_type; this.get_accessor = get_accessor; this.set_accessor = set_accessor; - this.source_reference = source_reference; } public override void accept (CodeVisitor visitor) { diff --git a/vala/valasignal.vala b/vala/valasignal.vala index 6fe63e41e..bb0a40894 100644 --- a/vala/valasignal.vala +++ b/vala/valasignal.vala @@ -66,10 +66,8 @@ public class Vala.Signal : Member, Lockable { * @return newly created signal */ public Signal (string name, DataType return_type, SourceReference? source_reference = null) { - base.init (); - this.name = name; + base (name, source_reference); this.return_type = return_type; - this.source_reference = source_reference; } /** diff --git a/vala/valastruct.vala b/vala/valastruct.vala index 9e3850591..8ec827feb 100644 --- a/vala/valastruct.vala +++ b/vala/valastruct.vala @@ -66,9 +66,7 @@ public class Vala.Struct : TypeSymbol { * @return newly created struct */ public Struct (string name, SourceReference? source_reference = null) { - base.init (); - this.source_reference = source_reference; - this.name = name; + base (name, source_reference); } /** diff --git a/vala/valaswitchsection.vala b/vala/valaswitchsection.vala index 958ecfff3..2212c47b9 100644 --- a/vala/valaswitchsection.vala +++ b/vala/valaswitchsection.vala @@ -36,8 +36,7 @@ public class Vala.SwitchSection : Block { * @return newly created switch section */ public SwitchSection (SourceReference source_reference) { - base.init (); - this.source_reference = source_reference; + base (source_reference); } /** diff --git a/vala/valasymbol.vala b/vala/valasymbol.vala index e3e95cfdc..b9ccd7e94 100644 --- a/vala/valasymbol.vala +++ b/vala/valasymbol.vala @@ -56,7 +56,7 @@ public abstract class Vala.Symbol : CodeNode { /** * The symbol name. */ - public string name { get; set; } + public string? name { get; set; } /** * Specifies whether this symbol is active. @@ -118,7 +118,9 @@ public abstract class Vala.Symbol : CodeNode { private weak Scope _owner; private Scope _scope; - public void init () { + public Symbol (string? name, SourceReference? source_reference) { + this.name = name; + this.source_reference = source_reference; _scope = new Scope (this); } diff --git a/vala/valatypeparameter.vala b/vala/valatypeparameter.vala index f25b10bf4..8985ea8a2 100644 --- a/vala/valatypeparameter.vala +++ b/vala/valatypeparameter.vala @@ -39,10 +39,8 @@ public class Vala.TypeParameter : Symbol { * @param source reference to source code * @return newly created generic type parameter */ - public TypeParameter (string _name, SourceReference source) { - base.init (); - name = _name; - source_reference = source; + public TypeParameter (string name, SourceReference source_reference) { + base (name, source_reference); } public override void accept (CodeVisitor visitor) { diff --git a/vala/valatypesymbol.vala b/vala/valatypesymbol.vala index a838017f7..ccb3820a2 100644 --- a/vala/valatypesymbol.vala +++ b/vala/valatypesymbol.vala @@ -31,6 +31,10 @@ using Gee; public abstract class Vala.TypeSymbol : Symbol { private Gee.List cheader_filenames = new ArrayList (); + public TypeSymbol (string? name, SourceReference? source_reference = null) { + base (name, source_reference); + } + /** * Returns the name of this data type as it is used in C code. *