[vala/wip/issue548: 32/34] vala: Collect implicit interface implementations
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/issue548: 32/34] vala: Collect implicit interface implementations
- Date: Tue, 18 Dec 2018 21:14:10 +0000 (UTC)
commit bad59656619fce0bbd9878ce2fb8a86a544914fa
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Sat Dec 1 22:10:34 2018 +0100
vala: Collect implicit interface implementations
codegen/valagtypemodule.vala | 40 +++++++++-------------------------------
vala/valaclass.vala | 8 ++++++++
2 files changed, 17 insertions(+), 31 deletions(-)
---
diff --git a/codegen/valagtypemodule.vala b/codegen/valagtypemodule.vala
index dda5e6fef..609a8fd6b 100644
--- a/codegen/valagtypemodule.vala
+++ b/codegen/valagtypemodule.vala
@@ -1472,39 +1472,17 @@ public class Vala.GTypeModule : GErrorModule {
}
// connect inherited implementations
- foreach (Method m in iface.get_methods ()) {
- if (m.is_abstract) {
- Method cl_method = null;
- var base_class = cl;
- while (base_class != null && cl_method == null) {
- foreach (var impl in base_class.get_methods ()) {
- if (impl.name == m.name && impl.base_interface_method == null
&& impl.base_interface_type == null
- && impl.compatible_no_error (m)) {
- cl_method = impl;
- break;
- }
- }
- base_class = base_class.base_class;
- }
- if (base_class != null && cl_method.parent_symbol != cl) {
- // method inherited from base class
-
- var base_method = cl_method;
- if (cl_method.base_interface_method != null) {
- base_method = cl_method.base_interface_method;
- } else if (cl_method.base_method != null) {
- //FIXME should this ever be possible here?
- base_method = cl_method.base_method;
- }
+ var it = cl.get_implicit_implementations ().map_iterator ();
+ while (it.next ()) {
+ Method m = it.get_key ();
+ Method base_method = it.get_value ();
- generate_method_declaration (base_method, cfile);
+ generate_method_declaration (base_method, cfile);
- CCodeExpression cfunc = new CCodeIdentifier (get_ccode_name
(base_method));
- cfunc = cast_method_pointer (base_method, cfunc, iface);
- var ciface = new CCodeIdentifier ("iface");
- ccode.add_assignment (new CCodeMemberAccess.pointer (ciface,
get_ccode_vfunc_name (m)), cfunc);
- }
- }
+ CCodeExpression cfunc = new CCodeIdentifier (get_ccode_name (base_method));
+ cfunc = cast_method_pointer (base_method, cfunc, iface);
+ var ciface = new CCodeIdentifier ("iface");
+ ccode.add_assignment (new CCodeMemberAccess.pointer (ciface, get_ccode_vfunc_name
(m)), cfunc);
}
foreach (Property prop in cl.get_properties ()) {
diff --git a/vala/valaclass.vala b/vala/valaclass.vala
index 2abbc7766..a07bc11e4 100644
--- a/vala/valaclass.vala
+++ b/vala/valaclass.vala
@@ -110,6 +110,7 @@ public class Vala.Class : ObjectTypeSymbol {
private bool? _is_singleton;
private List<DataType> base_types = new ArrayList<DataType> ();
+ private HashMap<Method,Method> implicit_implementations = new HashMap<Method,Method> ();
/**
* Specifies the default construction method.
@@ -305,6 +306,10 @@ public class Vala.Class : ObjectTypeSymbol {
}
}
+ public HashMap<Method,Method> get_implicit_implementations () {
+ return implicit_implementations;
+ }
+
/**
* Adds the specified property as a member to this class.
*
@@ -748,6 +753,9 @@ public class Vala.Class : ObjectTypeSymbol {
impl.version.check
(source_reference);
impl.used = true;
implemented = true;
+ if
(impl.base_interface_method == null) {
+
implicit_implementations.set (m, impl);
+ }
break;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]