From: Víctor Manuel Jáquez Leal Date: Tue, 13 Apr 2010 10:33:22 +0000 (+0200) Subject: vapigen: Support type_id attribute for classes X-Git-Tag: 0.9.1~120 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c9f86ebb6c29323a9db5f8a570440a64bdc22b67;p=thirdparty%2Fvala.git vapigen: Support type_id attribute for classes Fixes bug 615633. Signed-off-by: Víctor Manuel Jáquez Leal --- diff --git a/vala/valaclass.vala b/vala/valaclass.vala index b11b266a5..eef5075b2 100644 --- a/vala/valaclass.vala +++ b/vala/valaclass.vala @@ -677,15 +677,19 @@ public class Vala.Class : ObjectTypeSymbol { } } + public string? get_default_type_id () { + if (is_compact) { + return "G_TYPE_POINTER"; + } + + return get_upper_case_cname ("TYPE_"); + } + public override string? get_type_id () { if (type_id == null) { - if (!is_compact) { - type_id = get_upper_case_cname ("TYPE_"); - } else { - type_id = "G_TYPE_POINTER"; - } + type_id = get_default_type_id (); } - + return type_id; } diff --git a/vala/valacodewriter.vala b/vala/valacodewriter.vala index 8d5f1b385..f75691f03 100644 --- a/vala/valacodewriter.vala +++ b/vala/valacodewriter.vala @@ -215,7 +215,7 @@ public class Vala.CodeWriter : CodeVisitor { write_string ("type_check_function = \"%s\", ".printf (cl.type_check_function )); } - if (cl.is_compact && cl.get_type_id () != "G_TYPE_POINTER") { + if (cl.get_type_id () != cl.get_default_type_id ()) { write_string ("type_id = \"%s\", ".printf (cl.get_type_id ())); } diff --git a/vapigen/valagidlparser.vala b/vapigen/valagidlparser.vala index 354713813..87bed68f5 100644 --- a/vapigen/valagidlparser.vala +++ b/vapigen/valagidlparser.vala @@ -1066,6 +1066,8 @@ public class Vala.GIdlParser : CodeVisitor { } } else if (nv[0] == "type_check_function") { cl.type_check_function = eval (nv[1]); + } else if (nv[0] == "type_id") { + cl.set_type_id (eval (nv[1])); } else if (nv[0] == "abstract") { if (eval (nv[1]) == "1") { cl.is_abstract = true;