[vala] vapigen: Support type_id attribute for classes



commit c9f86ebb6c29323a9db5f8a570440a64bdc22b67
Author: Víctor Manuel Jáquez Leal <vjaquez igalia com>
Date:   Tue Apr 13 12:33:22 2010 +0200

    vapigen: Support type_id attribute for classes
    
    Fixes bug 615633.
    
    Signed-off-by: Víctor Manuel Jáquez Leal <vjaquez igalia com>

 vala/valaclass.vala         |   16 ++++++++++------
 vala/valacodewriter.vala    |    2 +-
 vapigen/valagidlparser.vala |    2 ++
 3 files changed, 13 insertions(+), 7 deletions(-)
---
diff --git a/vala/valaclass.vala b/vala/valaclass.vala
index b11b266..eef5075 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 8d5f1b3..f75691f 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 3547138..87bed68 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;



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