[vala/staging: 5/9] codegen: Add type declarations required for generics as needed
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging: 5/9] codegen: Add type declarations required for generics as needed
- Date: Wed, 21 Nov 2018 16:17:35 +0000 (UTC)
commit 67c7468820eef0fa9142eac46271e2bb74d36664
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Wed Nov 21 13:03:31 2018 +0100
codegen: Add type declarations required for generics as needed
codegen/valaccodebasemodule.vala | 17 +++++++++++++++--
codegen/valaccodemethodmodule.vala | 2 ++
codegen/valagasyncmodule.vala | 2 ++
3 files changed, 19 insertions(+), 2 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index acadf940e..aabcd9b93 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -1478,9 +1478,17 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
if (type is ObjectType) {
var object_type = (ObjectType) type;
if (object_type.type_symbol is Class) {
- generate_class_declaration ((Class) object_type.type_symbol, decl_space);
+ var cl = (Class) object_type.type_symbol;
+ generate_class_declaration (cl, decl_space);
+ if (!cl.is_compact && cl.has_type_parameters ()) {
+ generate_struct_declaration ((Struct) gtype_type, decl_space);
+ }
} else if (object_type.type_symbol is Interface) {
- generate_interface_declaration ((Interface) object_type.type_symbol,
decl_space);
+ var iface = (Interface) object_type.type_symbol;
+ generate_interface_declaration (iface, decl_space);
+ if (iface.has_type_parameters ()) {
+ generate_struct_declaration ((Struct) gtype_type, decl_space);
+ }
}
} else if (type is DelegateType) {
var deleg_type = (DelegateType) type;
@@ -1509,6 +1517,11 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
} else if (type is PointerType) {
var pointer_type = (PointerType) type;
generate_type_declaration (pointer_type.base_type, decl_space);
+ } else if (type is MethodType) {
+ var method = ((MethodType) type).method_symbol;
+ if (method.has_type_parameters () && !get_ccode_simple_generics (method)) {
+ generate_struct_declaration ((Struct) gtype_type, decl_space);
+ }
}
foreach (DataType type_arg in type.get_type_arguments ()) {
diff --git a/codegen/valaccodemethodmodule.vala b/codegen/valaccodemethodmodule.vala
index 361fb0065..6bf75b3a9 100644
--- a/codegen/valaccodemethodmodule.vala
+++ b/codegen/valaccodemethodmodule.vala
@@ -177,6 +177,8 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule {
return;
}
+ generate_type_declaration (new MethodType (m), decl_space);
+
var function = new CCodeFunction (get_ccode_name (m));
if (m.is_private_symbol () && !m.external) {
diff --git a/codegen/valagasyncmodule.vala b/codegen/valagasyncmodule.vala
index 21f72dee1..a3022532a 100644
--- a/codegen/valagasyncmodule.vala
+++ b/codegen/valagasyncmodule.vala
@@ -394,6 +394,8 @@ public class Vala.GAsyncModule : GtkModule {
return;
}
+ generate_type_declaration (new MethodType (m), decl_space);
+
var cl = m.parent_symbol as Class;
var asyncfunc = new CCodeFunction (get_ccode_name (m), "void");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]