[vala/wip/attributes: 23/119] codegen: Add get_ccode_param_spec_function
- From: Luca Bruno <lucabru src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/attributes: 23/119] codegen: Add get_ccode_param_spec_function
- Date: Mon, 4 Jul 2011 10:24:01 +0000 (UTC)
commit 0e592734ed56eb2f3376e0c682916b3568479ae0
Author: Luca Bruno <lucabru src gnome org>
Date: Tue Jun 28 14:54:59 2011 +0200
codegen: Add get_ccode_param_spec_function
codegen/valaccodebasemodule.vala | 39 ++++++++++++++++++++++++++++++++++++++
codegen/valagtypemodule.vala | 2 +-
2 files changed, 40 insertions(+), 1 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index e36e935..7b69ca2 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -5662,6 +5662,10 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
return get_ccode_attribute(sym).take_value_function;
}
+ public static string get_ccode_param_spec_function (CodeNode sym) {
+ return get_ccode_attribute(sym).param_spec_function;
+ }
+
public static string get_ccode_type_check_function (TypeSymbol sym) {
var cl = sym as Class;
var a = sym.get_attribute ("CCode");
@@ -6199,6 +6203,15 @@ public class Vala.CCodeAttribute : AttributeCache {
}
}
+ public string param_spec_function {
+ get {
+ if (_param_spec_function == null) {
+ _param_spec_function = get_default_param_spec_function ();
+ }
+ return _param_spec_function;
+ }
+ }
+
private string _name;
private string _const_name;
private string _type_name;
@@ -6217,6 +6230,7 @@ public class Vala.CCodeAttribute : AttributeCache {
private string _get_value_function;
private string _set_value_function;
private string _take_value_function;
+ private string _param_spec_function;
public CCodeAttribute (CodeNode node) {
this.node = node;
@@ -6253,6 +6267,7 @@ public class Vala.CCodeAttribute : AttributeCache {
_get_value_function = attr.get_string ("get_value_function");
_set_value_function = attr.get_string ("set_value_function");
_take_value_function = attr.get_string ("take_value_function");
+ _param_spec_function = attr.get_string ("param_spec_function");
}
}
@@ -6803,4 +6818,28 @@ public class Vala.CCodeAttribute : AttributeCache {
}
return "";
}
+
+ private string get_default_param_spec_function () {
+ if (sym is Class) {
+ var cl = (Class) sym;
+ if (cl.is_fundamental ()) {
+ return CCodeBaseModule.get_ccode_lower_case_cname (cl, "value_take_");
+ } else if (cl.base_class != null) {
+ return CCodeBaseModule.get_ccode_param_spec_function (cl.base_class);
+ } else if (type_id == "G_TYPE_POINTER") {
+ return "g_param_spec_pointer";
+ } else {
+ return "g_param_spec_boxed";
+ }
+ } else if (sym is Interface) {
+ foreach (var prereq in ((Interface) sym).get_prerequisites ()) {
+ var func = CCodeBaseModule.get_ccode_param_spec_function (prereq.data_type);
+ if (func != "") {
+ return func;
+ }
+ }
+ return "g_param_spec_pointer";
+ }
+ return "";
+ }
}
diff --git a/codegen/valagtypemodule.vala b/codegen/valagtypemodule.vala
index 1bdcca0..9c07e9f 100644
--- a/codegen/valagtypemodule.vala
+++ b/codegen/valagtypemodule.vala
@@ -1661,7 +1661,7 @@ public class Vala.GTypeModule : GErrorModule {
if (prop.property_type.data_type is Class || prop.property_type.data_type is Interface) {
- string param_spec_name = prop.property_type.data_type.get_param_spec_function ();
+ string param_spec_name = get_ccode_param_spec_function (prop.property_type.data_type);
cspec.call = new CCodeIdentifier (param_spec_name);
if (param_spec_name == "g_param_spec_string") {
cspec.add_argument (new CCodeConstant ("NULL"));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]