Commit 8ff16e2f authored by Jürg Billeter's avatar Jürg Billeter Committed by Jürg Billeter

Use constructor chaining instead of helper method

2008-10-27  Jürg Billeter  <j@bitron.ch>

	* 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
parent 8cec33e5
2008-10-27 Jürg Billeter <j@bitron.ch>
* 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 <j@bitron.ch>
* vala/Makefile.am:
......
......@@ -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;
}
}
......@@ -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;
}
}
......@@ -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;
}
}
......@@ -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);
}
/**
......
......@@ -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);
}
/**
......
......@@ -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) {
......
......@@ -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) {
......
......@@ -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;
......
......@@ -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;
......
......@@ -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) {
......
......@@ -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<string> get_cheader_filenames () {
......
......@@ -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<string> get_cheader_filenames () {
......
......@@ -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;
}
}
......@@ -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);
}
/**
......
......@@ -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;
}
/**
......
......@@ -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) {
......
......@@ -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);
}
/**
......
......@@ -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) {
......
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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);
}
/**
......
......@@ -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) {
......
......@@ -28,7 +28,11 @@ using Gee;
*/
public abstract class Vala.Member : Symbol {
private Gee.List<string> cheader_filenames = new ArrayList<string> ();
public Member (string? name, SourceReference? source_reference) {
base (name, source_reference);
}
public override void accept (CodeVisitor visitor) {
visitor.visit_member (this);
}
......
......@@ -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;
......
......@@ -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;
}
......
......@@ -32,4 +32,8 @@ public abstract class Vala.ObjectTypeSymbol : TypeSymbol {
public abstract Gee.List<Method> get_methods ();
public abstract Gee.List<Signal> get_signals ();
public abstract Gee.List<Property> get_properties ();
public ObjectTypeSymbol (string name, SourceReference? source_reference = null) {
base (name, source_reference);
}
}
......@@ -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) {
......
......@@ -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;
}
/**
......
......@@ -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);
}
/**
......
......@@ -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);
}
/**
......
......@@ -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);
}
......
......@@ -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) {
......
......@@ -31,6 +31,10 @@ using Gee;
public abstract class Vala.TypeSymbol : Symbol {
private Gee.List<string> cheader_filenames = new ArrayList<string> ();
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.
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment