[vala/wip/girparser: 51/52] girparser: Improve instance method detection



commit 0a19ce969ef3205db3e36f91d00e7beffb8d53cc
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Mon Jun 30 09:39:59 2014 +0200

    girparser: Improve instance method detection
    
    Improve reparenting static namespace functions to their presumably parent
    structures. Only allow this if the first parameter is not defined as (out)
    or (inout)
    
    Unfortunately, while this patch fixes detection, nothing can be done about
    breaking API.
    
    Based on patch by Simon Werbeck <simon werbeck gmail com>
    
    https://bugzilla.gnome.org/show_bug.cgi?id=732460

 vala/valagirparser.vala |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/vala/valagirparser.vala b/vala/valagirparser.vala
index 73273f3..78a08fb 100644
--- a/vala/valagirparser.vala
+++ b/vala/valagirparser.vala
@@ -3827,10 +3827,10 @@ public class Vala.GirParser : CodeVisitor {
                var cname = node.get_cname ();
 
                Parameter first_param = null;
-               if (method.get_parameters ().size > 0) {
-                       first_param = method.get_parameters()[0];
+               if (node.parameters.size > 0) {
+                       first_param = node.parameters[0].param;
                }
-               if (first_param != null && first_param.variable_type is UnresolvedType) {
+               if (first_param != null && first_param.direction == ParameterDirection.IN && 
first_param.variable_type is UnresolvedType) {
                        // check if it's a missed instance method (often happens for structs)
                        var sym = ((UnresolvedType) first_param.variable_type).unresolved_symbol;
                        var parent = resolve_node (ns, sym);
@@ -3840,8 +3840,8 @@ public class Vala.GirParser : CodeVisitor {
                                if (parent.lookup (new_name) == null) {
                                        ns.remove_member (node);
                                        node.name = new_name;
+                                       node.parameters.remove_at (0);
                                        method.name = new_name;
-                                       method.get_parameters().remove_at (0);
                                        method.binding = MemberBinding.INSTANCE;
                                        parent.add_member (node);
                                }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]