From: Luca Bruno Date: Sat, 4 Jun 2011 16:21:08 +0000 (+0200) Subject: Move custom_return_type_cname CCode attribute down to Method X-Git-Tag: 0.13.0~30 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c183c0992f9c6fbaff0f61431dd73ecc347c7e22;p=thirdparty%2Fvala.git Move custom_return_type_cname CCode attribute down to Method --- diff --git a/codegen/valaccodemethodmodule.vala b/codegen/valaccodemethodmodule.vala index 879fe329e..e2f098516 100644 --- a/codegen/valaccodemethodmodule.vala +++ b/codegen/valaccodemethodmodule.vala @@ -32,14 +32,7 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule { } public override string? get_custom_creturn_type (Method m) { - var attr = m.get_attribute ("CCode"); - if (attr != null) { - string type = attr.get_string ("type"); - if (type != null) { - return type; - } - } - return null; + return m.custom_return_type_cname; } string get_creturn_type (Method m, string default_value) { diff --git a/vala/valacodewriter.vala b/vala/valacodewriter.vala index 01cb8ef70..ff5b413a8 100644 --- a/vala/valacodewriter.vala +++ b/vala/valacodewriter.vala @@ -1138,12 +1138,13 @@ public class Vala.CodeWriter : CodeVisitor { ccode_params.append_printf ("%ssentinel = \"%s\"", separator, m.sentinel); separator = ", "; } + if (m.custom_return_type_cname != null) { + ccode_params.append_printf ("%stype = \"%s\"", separator, m.custom_return_type_cname); + separator = ", "; + } + var cm = m as CreationMethod; if (cm != null) { - if (cm.custom_return_type_cname != null) { - ccode_params.append_printf ("%stype = \"%s\"", separator, cm.custom_return_type_cname); - separator = ", "; - } if (!m.has_new_function) { ccode_params.append_printf ("%shas_new_function = false", separator); separator = ", "; diff --git a/vala/valacreationmethod.vala b/vala/valacreationmethod.vala index 7958ec65b..7ece293ca 100644 --- a/vala/valacreationmethod.vala +++ b/vala/valacreationmethod.vala @@ -33,14 +33,6 @@ public class Vala.CreationMethod : Method { */ public string class_name { get; set; } - /** - * Specifies a custom C return type for that creation method. - * Only the idl parser and the interface writer should use this. - * FIXME: remove this as soon the compiler has a decent attribute - * handling. - */ - public string? custom_return_type_cname { get; set; } - /** * Specifies whether this constructor chains up to a base * constructor or a different constructor of the same class. diff --git a/vala/valamethod.vala b/vala/valamethod.vala index cd935a20e..966407240 100644 --- a/vala/valamethod.vala +++ b/vala/valamethod.vala @@ -180,6 +180,11 @@ public class Vala.Method : Subroutine { */ public string? array_length_type { get; set; default = null; } + /** + * Specifies a custom C return type for this method. + */ + public string? custom_return_type_cname { get; set; } + /** * Specifies whether this method expects printf-style format arguments. */ @@ -471,6 +476,9 @@ public class Vala.Method : Subroutine { if (a.has_argument ("returns_floating_reference")) { returns_floating_reference = a.get_bool ("returns_floating_reference"); } + if (a.has_argument ("type")) { + custom_return_type_cname = a.get_string ("type"); + } } /** diff --git a/vapigen/valagidlparser.vala b/vapigen/valagidlparser.vala index 6fe0dc5d5..a1aa1ad51 100644 --- a/vapigen/valagidlparser.vala +++ b/vapigen/valagidlparser.vala @@ -2018,7 +2018,7 @@ public class Vala.GIdlParser : CodeVisitor { // return type. if (current_data_type is Class && res != null) { if ("%s*".printf (current_data_type.get_cname()) != res.type.unparsed) { - ((CreationMethod)m).custom_return_type_cname = res.type.unparsed; + m.custom_return_type_cname = res.type.unparsed; } } } else {