From: Rico Tzschichholz Date: Mon, 30 Jun 2014 07:39:59 +0000 (+0200) Subject: girparser: Improve instance method detection X-Git-Tag: 0.39.5~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1fdaa354a9b8c911dd84ce559f2337aa75c029e8;p=thirdparty%2Fvala.git 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 https://bugzilla.gnome.org/show_bug.cgi?id=732460 --- diff --git a/vala/valagirparser.vala b/vala/valagirparser.vala index de5d7727c..7902e2d37 100644 --- a/vala/valagirparser.vala +++ b/vala/valagirparser.vala @@ -3942,10 +3942,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); @@ -3955,8 +3955,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); }