]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
vapigen: Support type_id attribute for classes
authorVíctor Manuel Jáquez Leal <vjaquez@igalia.com>
Tue, 13 Apr 2010 10:33:22 +0000 (12:33 +0200)
committerJürg Billeter <j@bitron.ch>
Tue, 27 Apr 2010 10:36:49 +0000 (12:36 +0200)
Fixes bug 615633.

Signed-off-by: Víctor Manuel Jáquez Leal <vjaquez@igalia.com>
vala/valaclass.vala
vala/valacodewriter.vala
vapigen/valagidlparser.vala

index b11b266a516fa20e39e7277a1596267e1f137d75..eef5075b29ad0543bd669af47dd04524bb0897fb 100644 (file)
@@ -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;
        }
 
index 8d5f1b385ab2ef0650efc6fe4626466a36e1f7e2..f75691f036d3fba8e9822cef98ec0f88f66b1067 100644 (file)
@@ -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 ()));
                }
 
index 3547138131ec49ca53b5c9c58ce4b22ecfc5c537..87bed68f56b58019f0bce7a7ad33b8a571fe7bde 100644 (file)
@@ -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;