Commit 2a1a351c authored by Jürg Billeter's avatar Jürg Billeter Committed by Jürg Billeter

check method signatures of overriding methods support abstract classes add

2006-07-08  Jürg Billeter  <j@bitron.ch>

	* vala/valasemanticanalyzer.vala: check method signatures of overriding
	  methods
	* vala/parser.y, vala/valaclassregisterfunction.vala,
	  vala/valatyperegisterfunction.vala: support abstract classes
	* vala/valamethod.vala: add equals method
	* vala/valatypereference.vala: add equals method
	* corrects overriding methods to match signatures of overridden methods
	  to fix build with current compiler

svn path=/trunk/; revision=73
parent c8075c40
2006-07-08 Jürg Billeter <j@bitron.ch>
* vala/valasemanticanalyzer.vala: check method signatures of overriding
methods
* vala/parser.y, vala/valaclassregisterfunction.vala,
vala/valatyperegisterfunction.vala: support abstract classes
* vala/valamethod.vala: add equals method
* vala/valatypereference.vala: add equals method
* corrects overriding methods to match signatures of overridden methods
to fix build with current compiler
2006-07-08 Jürg Billeter <j@bitron.ch>
* vala/parser.y, vala/valacodegenerator.vala: adapt to ForStatement API
......
......@@ -41,7 +41,7 @@ public class Vala.CCodeAssignment : CCodeExpression {
*/
public CCodeExpression right { get; construct; }
public override void write (CCodeWriter writer) {
public override void write (CCodeWriter! writer) {
if (left != null) {
left.write (writer);
}
......
......@@ -28,7 +28,7 @@ namespace Vala {
public CCodeExpression left { get; construct; }
public CCodeExpression right { get; construct; }
public override void write (CCodeWriter writer) {
public override void write (CCodeWriter! writer) {
if (left != null) {
left.write (writer);
}
......
......@@ -36,7 +36,7 @@ namespace Vala {
statements.append (statement);
}
public override void write (CCodeWriter writer) {
public override void write (CCodeWriter! writer) {
writer.write_begin_block ();
foreach (CCodeNode statement in statements) {
statement.write (writer);
......
......@@ -24,7 +24,7 @@ using GLib;
namespace Vala {
public class CCodeBreakStatement : CCodeStatement {
public override void write (CCodeWriter writer) {
public override void write (CCodeWriter! writer) {
writer.write_indent ();
writer.write_string ("break;");
writer.write_newline ();
......
......@@ -27,11 +27,11 @@ namespace Vala {
public CCodeExpression expression { get; construct; }
List<CCodeStatement> statements;
public void add_statement (CCodeStatement stmt) {
public void add_statement (CCodeStatement! stmt) {
statements.append (stmt);
}
public override void write (CCodeWriter writer) {
public override void write (CCodeWriter! writer) {
writer.write_indent ();
writer.write_string ("case ");
expression.write (writer);
......
......@@ -26,7 +26,7 @@ namespace Vala {
public class CCodeCommaExpression : CCodeExpression {
public List<CCodeExpression> inner;
public override void write (CCodeWriter writer) {
public override void write (CCodeWriter! writer) {
bool first = true;
writer.write_string ("(");
......
......@@ -26,7 +26,7 @@ namespace Vala {
public class CCodeComment : CCodeNode {
public string text { get; construct; }
public override void write (CCodeWriter writer) {
public override void write (CCodeWriter! writer) {
writer.write_comment (text);
}
}
......
......@@ -28,7 +28,7 @@ namespace Vala {
public CCodeExpression true_expression { get; construct; }
public CCodeExpression false_expression { get; construct; }
public override void write (CCodeWriter writer) {
public override void write (CCodeWriter! writer) {
writer.write_string ("(");
condition.write (writer);
writer.write_string (" ? ");
......
......@@ -26,7 +26,7 @@ namespace Vala {
public class CCodeConstant : CCodeExpression {
public string name { get; construct; }
public override void write (CCodeWriter writer) {
public override void write (CCodeWriter! writer) {
writer.write_string (name);
}
}
......
......@@ -24,7 +24,7 @@ using GLib;
namespace Vala {
public class CCodeContinueStatement : CCodeStatement {
public override void write (CCodeWriter writer) {
public override void write (CCodeWriter! writer) {
writer.write_indent ();
writer.write_string ("continue;");
writer.write_newline ();
......
......@@ -28,11 +28,11 @@ namespace Vala {
public CCodeModifiers modifiers;
List<CCodeDeclarator> declarators;
public void add_declarator (CCodeDeclarator decl) {
public void add_declarator (CCodeDeclarator! decl) {
declarators.append (decl);
}
public override void write (CCodeWriter writer) {
public override void write (CCodeWriter! writer) {
writer.write_indent ();
if ((modifiers & CCodeModifiers.STATIC) == CCodeModifiers.STATIC) {
writer.write_string ("static ");
......
......@@ -24,7 +24,7 @@ using GLib;
namespace Vala {
public class CCodeEmptyStatement : CCodeStatement {
public override void write (CCodeWriter writer) {
public override void write (CCodeWriter! writer) {
writer.write_indent ();
writer.write_string (";");
writer.write_newline ();
......
......@@ -27,7 +27,7 @@ namespace Vala {
public string name { get; construct; }
List<string> values;
public void add_value (string name, string value) {
public void add_value (string! name, string value = null) {
if (value == null) {
values.append (name);
} else {
......@@ -35,7 +35,7 @@ namespace Vala {
}
}
public override void write (CCodeWriter writer) {
public override void write (CCodeWriter! writer) {
if (name != null) {
writer.write_string ("typedef ");
}
......
......@@ -26,7 +26,7 @@ namespace Vala {
public class CCodeExpressionStatement : CCodeStatement {
public CCodeExpression expression { get; construct; }
public override void write (CCodeWriter writer) {
public override void write (CCodeWriter! writer) {
writer.write_indent ();
if (expression != null) {
expression.write (writer);
......
......@@ -27,7 +27,7 @@ namespace Vala {
public string name { get; construct; }
public string type_name { get; construct; }
public override void write (CCodeWriter writer) {
public override void write (CCodeWriter! writer) {
writer.write_string (type_name);
writer.write_string (" ");
writer.write_string (name);
......
......@@ -30,15 +30,15 @@ namespace Vala {
List<CCodeExpression> initializer;
List<CCodeExpression> iterator;
public void add_initializer (CCodeExpression expr) {
public void add_initializer (CCodeExpression! expr) {
initializer.append (expr);
}
public void add_iterator (CCodeExpression expr) {
public void add_iterator (CCodeExpression! expr) {
iterator.append (expr);
}
public override void write (CCodeWriter writer) {
public override void write (CCodeWriter! writer) {
bool first;
writer.write_indent ();
......
......@@ -26,11 +26,11 @@ namespace Vala {
public class CCodeFragment : CCodeNode {
public GLib.List<CCodeNode> children { get; construct; }
public void append (CCodeNode node) {
public void append (CCodeNode! node) {
_children.append (node);
}
public override void write (CCodeWriter writer) {
public override void write (CCodeWriter! writer) {
foreach (CCodeNode node in children) {
node.write (writer);
}
......
......@@ -30,11 +30,11 @@ namespace Vala {
List<CCodeFormalParameter> parameters;
public CCodeBlock block;
public void add_parameter (CCodeFormalParameter param) {
public void add_parameter (CCodeFormalParameter!param) {
parameters.append (param);
}
public ref CCodeFunction copy () {
public ref CCodeFunction! copy () {
var func = new CCodeFunction (name = name, return_type = return_type);
func.modifiers = modifiers;
......@@ -49,7 +49,7 @@ namespace Vala {
return func;
}
public override void write (CCodeWriter writer) {
public override void write (CCodeWriter! writer) {
writer.write_indent ();
if ((modifiers & CCodeModifiers.STATIC) == CCodeModifiers.STATIC) {
writer.write_string ("static ");
......
......@@ -27,11 +27,11 @@ namespace Vala {
public string name { get; construct; }
List<CCodeFormalParameter> parameters;
public void add_parameter (CCodeFormalParameter param) {
public void add_parameter (CCodeFormalParameter! param) {
parameters.append (param);
}
public override void write (CCodeWriter writer) {
public override void write (CCodeWriter! writer) {
writer.write_string ("(*");
writer.write_string (name);
writer.write_string (") (");
......
......@@ -26,7 +26,7 @@ namespace Vala {
public class CCodeIdentifier : CCodeExpression {
public string name { get; construct; }
public override void write (CCodeWriter writer) {
public override void write (CCodeWriter! writer) {
writer.write_string (name);
}
}
......
......@@ -29,7 +29,7 @@ namespace Vala {
public CCodeStatement false_statement { get; construct; }
public bool else_if;
public override void write (CCodeWriter writer) {
public override void write (CCodeWriter! writer) {
if (!else_if) {
writer.write_indent ();
} else {
......
......@@ -26,7 +26,7 @@ namespace Vala {
public class CCodeIncludeDirective : CCodeNode {
public string filename { get; construct; }
public override void write (CCodeWriter writer) {
public override void write (CCodeWriter! writer) {
writer.write_indent ();
writer.write_string ("#include <");
writer.write_string (filename);
......
......@@ -26,11 +26,11 @@ namespace Vala {
public class CCodeInitializerList : CCodeExpression {
List<CCodeExpression> initializers;
public void append (CCodeExpression expr) {
public void append (CCodeExpression! expr) {
initializers.append (expr);
}
public override void write (CCodeWriter writer) {
public override void write (CCodeWriter! writer) {
writer.write_string ("{");
bool first = true;
......
......@@ -27,7 +27,7 @@ namespace Vala {
public string name { get; construct; }
public string replacement { get; construct; }
public override void write (CCodeWriter writer) {
public override void write (CCodeWriter! writer) {
writer.write_indent ();
writer.write_string ("#define ");
writer.write_string (name);
......
......@@ -28,7 +28,7 @@ namespace Vala {
public string member_name { get; construct; }
public bool is_pointer { get; construct; }
public override void write (CCodeWriter writer) {
public override void write (CCodeWriter! writer) {
inner.write (writer);
if (is_pointer) {
writer.write_string ("->");
......
......@@ -24,7 +24,7 @@ using GLib;
namespace Vala {
public class CCodeNewline : CCodeNode {
public override void write (CCodeWriter writer) {
public override void write (CCodeWriter! writer) {
writer.write_newline ();
}
}
......
......@@ -26,7 +26,7 @@ namespace Vala {
public class CCodeOnceSection : CCodeFragment {
public string define { get; construct; }
public override void write (CCodeWriter writer) {
public override void write (CCodeWriter! writer) {
writer.write_indent ();
writer.write_string ("#ifndef ");
writer.write_string (define);
......
......@@ -26,7 +26,7 @@ namespace Vala {
public class CCodeParenthesizedExpression : CCodeExpression {
public CCodeExpression inner { get; construct; }
public override void write (CCodeWriter writer) {
public override void write (CCodeWriter! writer) {
writer.write_string ("(");
inner.write (writer);
......
......@@ -26,7 +26,7 @@ namespace Vala {
public class CCodeReturnStatement : CCodeStatement {
public CCodeExpression return_expression { get; construct; }
public override void write (CCodeWriter writer) {
public override void write (CCodeWriter! writer) {
writer.write_indent ();
writer.write_string ("return ");
......
......@@ -27,17 +27,17 @@ namespace Vala {
public string name { get; construct; }
List<CCodeDeclaration> declarations;
public void add_declaration (CCodeDeclaration decl) {
public void add_declaration (CCodeDeclaration! decl) {
declarations.append (decl);
}
public void add_field (string type_name, string name) {
public void add_field (string! type_name, string! name) {
var decl = new CCodeDeclaration (type_name = type_name);
decl.add_declarator (new CCodeVariableDeclarator (name = name));
add_declaration (decl);
}
public override void write (CCodeWriter writer) {
public override void write (CCodeWriter! writer) {
writer.write_string ("struct ");
writer.write_string (name);
writer.write_begin_block ();
......
......@@ -27,11 +27,11 @@ namespace Vala {
public CCodeExpression expression { get; construct; }
List<CCodeCaseStatement> case_statements;
public void add_case (CCodeCaseStatement case_stmt) {
public void add_case (CCodeCaseStatement! case_stmt) {
case_statements.append (case_stmt);
}
public override void write (CCodeWriter writer) {
public override void write (CCodeWriter! writer) {
writer.write_indent ();
writer.write_string ("switch (");
expression.write (writer);
......
......@@ -36,7 +36,7 @@ public class Vala.CCodeTypeDefinition : CCodeNode {
*/
public CCodeDeclarator declarator { get; set; }
public override void write (CCodeWriter writer) {
public override void write (CCodeWriter! writer) {
writer.write_indent ();
writer.write_string ("typedef ");
......
......@@ -27,7 +27,7 @@ namespace Vala {
public CCodeUnaryOperator operator { get; construct; }
public CCodeExpression inner { get; construct; }
public override void write (CCodeWriter writer) {
public override void write (CCodeWriter! writer) {
if (operator == CCodeUnaryOperator.PLUS) {
writer.write_string ("+");
} else if (operator == CCodeUnaryOperator.MINUS) {
......
......@@ -27,7 +27,7 @@ namespace Vala {
public string name { get; construct; }
public CCodeExpression initializer { get; construct; }
public override void write (CCodeWriter writer) {
public override void write (CCodeWriter! writer) {
writer.write_string (name);
if (initializer != null) {
......
......@@ -27,7 +27,7 @@ namespace Vala {
public CCodeExpression condition { get; construct; }
public CCodeStatement body { get; construct; }
public override void write (CCodeWriter writer) {
public override void write (CCodeWriter! writer) {
writer.write_indent ();
writer.write_string ("while (");
......
......@@ -1525,6 +1525,9 @@ class_declaration
if ($3 != 0) {
VALA_DATA_TYPE(current_class)->access = $3;
}
if (($4 & VALA_MODIFIER_ABSTRACT) == VALA_MODIFIER_ABSTRACT) {
vala_class_set_is_abstract (current_class, TRUE);
}
for (l = $8; l != NULL; l = l->next) {
vala_class_add_type_parameter (current_class, l->data);
g_object_unref (l->data);
......
......@@ -119,7 +119,7 @@ public class Vala.Callback : DataType {
visitor.visit_end_callback (this);
}
public override string! get_cname () {
public override string get_cname () {
if (cname == null) {
cname = "%s%s".printf (@namespace.get_cprefix (), name);
}
......
......@@ -47,7 +47,7 @@ public class Vala.CastExpression : Expression {
return (new CastExpression (inner = inner, type_reference = type, source_reference = source));
}
public override void accept (CodeVisitor visitor) {
public override void accept (CodeVisitor! visitor) {
inner.accept (visitor);
type_reference.accept (visitor);
......
......@@ -279,7 +279,7 @@ public class Vala.Class : DataType {
return "%s%s%s".printf (@namespace.get_lower_case_cprefix (), infix, get_lower_case_csuffix ());
}
public override ref string get_upper_case_cname (string! infix) {
public override ref string get_upper_case_cname (string infix) {
return get_lower_case_cname (infix).up ();
}
......
......@@ -55,6 +55,14 @@ public class Vala.ClassRegisterFunction : TypeRegisterFunction {
return class_reference.base_class.get_upper_case_cname ("TYPE_");
}
public override string get_type_flags () {
if (class_reference.is_abstract) {
return "G_TYPE_FLAG_ABSTRACT";
} else {
return "0";
}
}
public override ref CCodeFragment! get_type_interface_init_statements () {
var frag = new CCodeFragment ();
......
......@@ -56,7 +56,7 @@ public class Vala.Constant : CodeNode {
return (new Constant (name = name, type_reference = type, initializer = init, source_reference = source));
}
public override void accept (CodeVisitor visitor) {
public override void accept (CodeVisitor! visitor) {
type_reference.accept (visitor);
initializer.accept (visitor);
......
......@@ -152,7 +152,7 @@ public abstract class Vala.DataType : CodeNode {
* name or null
* @return the upper case name to be used in C code
*/
public abstract ref string! get_upper_case_cname (string infix);
public abstract ref string get_upper_case_cname (string infix);
/**
* Returns the C name of this data type in lower case. Words are
......@@ -163,7 +163,7 @@ public abstract class Vala.DataType : CodeNode {
* name or null
* @return the lower case name to be used in C code
*/
public abstract ref string! get_lower_case_cname (string infix);
public abstract ref string get_lower_case_cname (string infix);
/**
* Returns a list of C header filenames users of this data type must
......
......@@ -50,7 +50,7 @@ public class Vala.Enum : DataType {
values.append (value);
}
public override void accept (CodeVisitor visitor) {
public override void accept (CodeVisitor! visitor) {
visitor.visit_begin_enum (this);
foreach (EnumValue value in values) {
......
......@@ -59,14 +59,14 @@ public class Vala.Flags : DataType {
visitor.visit_end_flags (this);
}
public override string! get_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) {
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 ();
}
......
......@@ -68,7 +68,7 @@ public class Vala.FormalParameter : CodeNode {
return (new FormalParameter (ellipsis = true, source_reference = source));
}
public override void accept (CodeVisitor visitor) {
public override void accept (CodeVisitor! visitor) {
if (!ellipsis) {
type_reference.accept (visitor);
}
......
......@@ -32,7 +32,7 @@ namespace Vala {
return (new IfStatement (condition = cond, true_statement = true_stmt, false_statement = false_stmt, source_reference = source));
}
public override void accept (CodeVisitor visitor) {
public override void accept (CodeVisitor! visitor) {
condition.accept (visitor);
visitor.visit_end_full_expression (condition);
......
......@@ -30,7 +30,7 @@ namespace Vala {
return (new InitializerList (initializers = initializers, source_reference = source));
}
public override void accept (CodeVisitor visitor) {
public override void accept (CodeVisitor! visitor) {
foreach (Expression expr in initializers) {
expr.accept (visitor);
}
......
......@@ -121,7 +121,7 @@ public class Vala.Interface : DataType {
private string cname;
private string lower_case_csuffix;
public override string! get_cname () {
public override string get_cname () {
if (cname == null) {
cname = "%s%s".printf (@namespace.get_cprefix (), name);
}
......@@ -151,14 +151,14 @@ public class Vala.Interface : DataType {
this.lower_case_csuffix = csuffix;
}
public override ref string! get_lower_case_cname (string infix) {
public override ref string get_lower_case_cname (string infix) {
if (infix == null) {
infix = "";
}
return "%s%s%s".printf (@namespace.get_lower_case_cprefix (), infix, get_lower_case_csuffix ());
}
public override ref string! get_upper_case_cname (string infix) {
public override ref string get_upper_case_cname (string infix) {
return get_lower_case_cname (infix).up ();
}
......
......@@ -31,27 +31,27 @@ public class Vala.InterfaceRegisterFunction : TypeRegisterFunction {
*/
public Interface interface_reference { get; construct; }
public override DataType get_type_declaration () {
public override DataType! get_type_declaration () {
return interface_reference;
}
public override ref string get_type_struct_name () {
public override ref string! get_type_struct_name () {
return "%sInterface".printf (interface_reference.get_cname ());
}
public override ref string get_class_init_func_name () {
public override ref string! get_class_init_func_name () {
return "NULL";
}
public override ref string get_instance_struct_size () {
public override ref string! get_instance_struct_size () {
return "0";
}
public override ref string get_instance_init_func_name () {
public override ref string! get_instance_init_func_name () {
return "NULL";
}
public override ref string get_parent_type_name () {
public override ref string! get_parent_type_name () {
return "G_TYPE_INTERFACE";
}
......
......@@ -56,11 +56,11 @@ public class Vala.InterfaceWriter : CodeVisitor {
stream = null;
}
public override void visit_begin_source_file (SourceFile source_file) {
public override void visit_begin_source_file (SourceFile! source_file) {
current_cheader_filename = source_file.get_cheader_filename ();
}
public override void visit_begin_namespace (Namespace ns) {
public override void visit_begin_namespace (Namespace! ns) {
if (ns.name == null) {
return;
}
......@@ -75,7 +75,7 @@ public class Vala.InterfaceWriter : CodeVisitor {
write_begin_block ();
}
public override void visit_end_namespace (Namespace ns) {
public override void visit_end_namespace (Namespace! ns) {
if (ns.name == null) {
return;
}
......@@ -84,7 +84,7 @@ public class Vala.InterfaceWriter : CodeVisitor {
write_newline ();
}
public override void visit_begin_class (Class cl) {
public override void visit_begin_class (Class! cl) {
if (cl.access != MemberAccessibility.PUBLIC) {
internal_scope = true;
return;
......@@ -115,7 +115,7 @@ public class Vala.InterfaceWriter : CodeVisitor {
write_begin_block ();
}
public override void visit_end_class (Class cl) {
public override void visit_end_class (Class! cl) {
if (cl.access != MemberAccessibility.PUBLIC) {
internal_scope = false;
return;
......@@ -125,7 +125,7 @@ public class Vala.InterfaceWriter : CodeVisitor {
write_newline ();
}
public override void visit_begin_struct (Struct st) {
public override void visit_begin_struct (Struct! st) {
if (st.access != MemberAccessibility.PUBLIC) {
internal_scope = true;
return;
......@@ -137,7 +137,7 @@ public class Vala.InterfaceWriter : CodeVisitor {
write_begin_block ();
}
public override void visit_end_struct (Struct st) {
public override void visit_end_struct (Struct! st) {
if (st.access != MemberAccessibility.PUBLIC) {
internal_scope = false;