[vala/wip/attributes: 76/119] Drop has_type_id
- From: Luca Bruno <lucabru src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/attributes: 76/119] Drop has_type_id
- Date: Mon, 4 Jul 2011 10:28:28 +0000 (UTC)
commit 936718888ff9f5957205f1a0244845fbefc81af7
Author: Luca Bruno <lucabru src gnome org>
Date: Thu Jun 30 09:25:36 2011 +0200
Drop has_type_id
codegen/valaccodebasemodule.vala | 28 ++++++++++++++++++----------
codegen/valaccodestructmodule.vala | 2 +-
codegen/valagobjectmodule.vala | 2 +-
codegen/valagtypemodule.vala | 10 +++++-----
vala/valaenum.vala | 8 --------
vala/valastruct.vala | 8 --------
vapigen/valagidlparser.vala | 4 ++--
7 files changed, 27 insertions(+), 35 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 9359efc..4f09419 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -694,7 +694,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
decl_space.add_type_definition (cenum);
decl_space.add_type_definition (new CCodeNewline ());
- if (!en.has_type_id) {
+ if (!get_ccode_has_type_id (en)) {
return true;
}
@@ -5814,6 +5814,14 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
return p.get_attribute ("NoAccessorMethod") != null;
}
+ public static bool get_ccode_has_type_id (TypeSymbol sym) {
+ var a = st.get_attribute ("CCode");
+ if (a != null && a.has_argument ("has_type_id")) {
+ return a.get_bool ("has_type_id");
+ }
+ return true;
+ }
+
public override void visit_class (Class cl) {
}
@@ -6752,7 +6760,7 @@ public class Vala.CCodeAttribute : AttributeCache {
return "G_TYPE_ERROR";
} else if (sym is Struct) {
var st = (Struct) sym;
- if (!st.has_type_id) {
+ if (!get_ccode_has_type_id (st)) {
var base_struct = st.base_struct;
if (base_struct != null) {
return CCodeBaseModule.get_ccode_type_id (base_struct);
@@ -6804,7 +6812,7 @@ public class Vala.CCodeAttribute : AttributeCache {
}
} else if (sym is Enum) {
var en = (Enum) sym;
- if (en.has_type_id) {
+ if (get_ccode_has_type_id (en)) {
if (en.is_flags) {
return "FLAGS";
} else {
@@ -6833,7 +6841,7 @@ public class Vala.CCodeAttribute : AttributeCache {
}
if (st.is_simple_type ()) {
Report.error (st.source_reference, "The type `%s` doesn't declare a marshaller type name".printf (st.get_full_name ()));
- } else if (st.has_type_id) {
+ } else if (get_ccode_has_type_id (st)) {
return "BOXED";
} else {
return "POINTER";
@@ -6879,7 +6887,7 @@ public class Vala.CCodeAttribute : AttributeCache {
}
} else if (sym is Enum) {
var en = (Enum) sym;
- if (en.has_type_id) {
+ if (get_ccode_has_type_id (en)) {
if (en.is_flags) {
return "g_value_get_flags";
} else {
@@ -6908,7 +6916,7 @@ public class Vala.CCodeAttribute : AttributeCache {
}
if (st.is_simple_type ()) {
Report.error (st.source_reference, "The type `%s` doesn't declare a GValue get function".printf (st.get_full_name ()));
- } else if (st.has_type_id) {
+ } else if (get_ccode_has_type_id (st)) {
return "g_value_get_boxed";
} else {
return "g_value_get_pointer";
@@ -6933,7 +6941,7 @@ public class Vala.CCodeAttribute : AttributeCache {
}
} else if (sym is Enum) {
var en = (Enum) sym;
- if (en.has_type_id) {
+ if (get_ccode_has_type_id (en)) {
if (en.is_flags) {
return "g_value_set_flags";
} else {
@@ -6962,7 +6970,7 @@ public class Vala.CCodeAttribute : AttributeCache {
}
if (st.is_simple_type ()) {
Report.error (st.source_reference, "The type `%s` doesn't declare a GValue set function".printf (st.get_full_name ()));
- } else if (st.has_type_id) {
+ } else if (get_ccode_has_type_id (st)) {
return "g_value_set_boxed";
} else {
return "g_value_set_pointer";
@@ -6987,7 +6995,7 @@ public class Vala.CCodeAttribute : AttributeCache {
}
} else if (sym is Enum) {
var en = (Enum) sym;
- if (en.has_type_id) {
+ if (get_ccode_has_type_id (en)) {
if (en.is_flags) {
return "g_value_take_flags";
} else {
@@ -7016,7 +7024,7 @@ public class Vala.CCodeAttribute : AttributeCache {
}
if (st.is_simple_type ()) {
Report.error (st.source_reference, "The type `%s` doesn't declare a GValue take function".printf (st.get_full_name ()));
- } else if (st.has_type_id) {
+ } else if (get_ccode_has_type_id (st)) {
return "g_value_take_boxed";
} else {
return "g_value_set_pointer";
diff --git a/codegen/valaccodestructmodule.vala b/codegen/valaccodestructmodule.vala
index d7f312f..f141739 100644
--- a/codegen/valaccodestructmodule.vala
+++ b/codegen/valaccodestructmodule.vala
@@ -47,7 +47,7 @@ public abstract class Vala.CCodeStructModule : CCodeBaseModule {
}
if (context.profile == Profile.GOBJECT) {
- if (st.has_type_id) {
+ if (get_ccode_has_type_id (st)) {
decl_space.add_type_declaration (new CCodeNewline ());
var macro = "(%s_get_type ())".printf (get_ccode_lower_case_name (st, null));
decl_space.add_type_declaration (new CCodeMacroReplacement (get_ccode_type_id (st), macro));
diff --git a/codegen/valagobjectmodule.vala b/codegen/valagobjectmodule.vala
index 61bf851..394d378 100644
--- a/codegen/valagobjectmodule.vala
+++ b/codegen/valagobjectmodule.vala
@@ -683,7 +683,7 @@ public class Vala.GObjectModule : GTypeModule {
}
var st = prop.property_type.data_type as Struct;
- if (st != null && (!st.has_type_id || prop.property_type.nullable)) {
+ if (st != null && (!get_ccode_has_type_id (st) || prop.property_type.nullable)) {
return false;
}
diff --git a/codegen/valagtypemodule.vala b/codegen/valagtypemodule.vala
index 543a1c3..a2dff5f 100644
--- a/codegen/valagtypemodule.vala
+++ b/codegen/valagtypemodule.vala
@@ -1673,7 +1673,7 @@ public class Vala.GTypeModule : GErrorModule {
}
} else if (prop.property_type.data_type is Enum) {
var e = prop.property_type.data_type as Enum;
- if (e.has_type_id) {
+ if (get_ccode_has_type_id (e)) {
if (e.is_flags) {
cspec.call = new CCodeIdentifier ("g_param_spec_flags");
} else {
@@ -2056,7 +2056,7 @@ public class Vala.GTypeModule : GErrorModule {
public override void visit_struct (Struct st) {
base.visit_struct (st);
- if (st.has_type_id) {
+ if (get_ccode_has_type_id (st)) {
var type_fun = new StructRegisterFunction (st, context);
type_fun.init_from_type (false, false);
cfile.add_type_member_definition (type_fun.get_definition ());
@@ -2066,7 +2066,7 @@ public class Vala.GTypeModule : GErrorModule {
public override void visit_enum (Enum en) {
base.visit_enum (en);
- if (en.has_type_id) {
+ if (get_ccode_has_type_id (en)) {
var type_fun = new EnumRegisterFunction (en, context);
type_fun.init_from_type (false, false);
cfile.add_type_member_definition (type_fun.get_definition ());
@@ -2077,7 +2077,7 @@ public class Vala.GTypeModule : GErrorModule {
var ma = expr.call as MemberAccess;
var mtype = expr.call.value_type as MethodType;
if (mtype == null || ma == null || ma.inner == null ||
- !(ma.inner.value_type is EnumValueType) || !((Enum) ma.inner.value_type.data_type).has_type_id ||
+ !(ma.inner.value_type is EnumValueType) || !get_ccode_has_type_id (ma.inner.value_type.data_type) ||
mtype.method_symbol != ((EnumValueType) ma.inner.value_type).get_to_string_method ()) {
base.visit_method_call (expr);
return;
@@ -2101,7 +2101,7 @@ public class Vala.GTypeModule : GErrorModule {
public override void visit_property (Property prop) {
var cl = current_type_symbol as Class;
var st = current_type_symbol as Struct;
- if (prop.name == "type" && ((cl != null && !cl.is_compact) || (st != null && st.has_type_id))) {
+ if (prop.name == "type" && ((cl != null && !cl.is_compact) || (st != null && get_ccode_has_type_id (st)))) {
Report.error (prop.source_reference, "Property 'type' not allowed");
return;
}
diff --git a/vala/valaenum.vala b/vala/valaenum.vala
index 033a0e4..0876474 100644
--- a/vala/valaenum.vala
+++ b/vala/valaenum.vala
@@ -31,11 +31,6 @@ public class Vala.Enum : TypeSymbol {
*/
public bool is_flags { get; set; }
- /**
- * Specifies whether this enum has a registered GType.
- */
- public bool has_type_id { get; set; default = true; }
-
private List<EnumValue> values = new ArrayList<EnumValue> ();
private List<Method> methods = new ArrayList<Method> ();
private List<Constant> constants = new ArrayList<Constant> ();
@@ -228,9 +223,6 @@ public class Vala.Enum : TypeSymbol {
if (a.has_argument ("lower_case_csuffix")) {
lower_case_csuffix = a.get_string ("lower_case_csuffix");
}
- if (a.has_argument ("has_type_id")) {
- has_type_id = a.get_bool ("has_type_id");
- }
}
/**
diff --git a/vala/valastruct.vala b/vala/valastruct.vala
index 3a5eab6..c444d48 100644
--- a/vala/valastruct.vala
+++ b/vala/valastruct.vala
@@ -80,11 +80,6 @@ public class Vala.Struct : TypeSymbol {
*/
public bool is_immutable { get; set; }
- /**
- * Specifies whether this struct has a registered GType.
- */
- public bool has_type_id { get; set; default = true; }
-
public int width { get; set; default = 32; }
public bool signed { get; set; default = true; }
@@ -423,9 +418,6 @@ public class Vala.Struct : TypeSymbol {
if (a.has_argument ("cprefix")) {
lower_case_cprefix = a.get_string ("cprefix");
}
- if (a.has_argument ("has_type_id")) {
- has_type_id = a.get_bool ("has_type_id");
- }
}
private void process_boolean_type_attribute (Attribute a) {
diff --git a/vapigen/valagidlparser.vala b/vapigen/valagidlparser.vala
index fd16df9..0c6056c 100644
--- a/vapigen/valagidlparser.vala
+++ b/vapigen/valagidlparser.vala
@@ -760,7 +760,7 @@ public class Vala.GIdlParser : CodeVisitor {
}
} else if (nv[0] == "has_type_id") {
if (eval (nv[1]) == "0") {
- st.has_type_id = false;
+ st.set_attribute_bool ("CCode", "has_type_id", false);
}
} else if (nv[0] == "type_id") {
st.set_attribute_string ("CCode", "type_id", eval (nv[1]));
@@ -1281,7 +1281,7 @@ public class Vala.GIdlParser : CodeVisitor {
}
}
- en.has_type_id = (en_node.gtype_name != null && en_node.gtype_name != "");
+ en.set_attribute_bool ("CCode", "has_type_id", en_node.gtype_name != null && en_node.gtype_name != "");
string common_prefix = null;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]