[vala] Fix creation methods in abstract classes
- From: Jürg Billeter <juergbi src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [vala] Fix creation methods in abstract classes
- Date: Sun, 16 Aug 2009 19:05:29 +0000 (UTC)
commit 5b26bfd65422839b85d010bba6c1e9b126ee66f1
Author: Jürg Billeter <j bitron ch>
Date: Sun Aug 16 19:46:23 2009 +0200
Fix creation methods in abstract classes
Add default construction method to abstract classes to allow chain up.
Do not generate _new functions for construction methods in abstract
classes, only generate _construct functions.
codegen/valaccodemethodmodule.vala | 14 ++++++++++----
vala/valaparser.vala | 1 -
2 files changed, 10 insertions(+), 5 deletions(-)
---
diff --git a/codegen/valaccodemethodmodule.vala b/codegen/valaccodemethodmodule.vala
index b9cdc1c..f4bbc5e 100644
--- a/codegen/valaccodemethodmodule.vala
+++ b/codegen/valaccodemethodmodule.vala
@@ -163,11 +163,16 @@ internal class Vala.CCodeMethodModule : CCodeStructModule {
var cparam_map = new HashMap<int,CCodeFormalParameter> (direct_hash, direct_equal);
var carg_map = new HashMap<int,CCodeExpression> (direct_hash, direct_equal);
- generate_cparameters (m, decl_space, cparam_map, function, null, carg_map, new CCodeFunctionCall (new CCodeIdentifier ("fake")));
+ var cl = m.parent_symbol as Class;
+
+ // do not generate _new functions for creation methods of abstract classes
+ if (!(m is CreationMethod && cl != null && cl.is_abstract)) {
+ generate_cparameters (m, decl_space, cparam_map, function, null, carg_map, new CCodeFunctionCall (new CCodeIdentifier ("fake")));
- decl_space.add_type_member_declaration (function);
+ decl_space.add_type_member_declaration (function);
+ }
- if (m is CreationMethod && m.parent_symbol is Class) {
+ if (m is CreationMethod && cl != null) {
// _construct function
function = new CCodeFunction (m.get_real_cname ());
@@ -1010,7 +1015,8 @@ internal class Vala.CCodeMethodModule : CCodeStructModule {
creturn_type = new VoidType ();
}
- if (current_type_symbol is Class && !current_class.is_compact) {
+ // do not generate _new functions for creation methods of abstract classes
+ if (current_type_symbol is Class && !current_class.is_compact && !current_class.is_abstract) {
var vfunc = new CCodeFunction (m.get_cname ());
vfunc.line = function.line;
diff --git a/vala/valaparser.vala b/vala/valaparser.vala
index ebf63c5..d41d1b7 100644
--- a/vala/valaparser.vala
+++ b/vala/valaparser.vala
@@ -2038,7 +2038,6 @@ public class Vala.Parser : CodeVisitor {
// ensure there is always a default construction method
if (!scanner.source_file.external_package
- && !cl.is_abstract
&& cl.default_construction_method == null) {
var m = new CreationMethod (cl.name, null, cl.source_reference);
m.access = SymbolAccessibility.PUBLIC;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]