[vala/wip/attributes: 82/100] Get rid of cname and cprefix information in code nodes
- From: Luca Bruno <lucabru src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/attributes: 82/100] Get rid of cname and cprefix information in code nodes
- Date: Sat, 2 Jul 2011 12:32:11 +0000 (UTC)
commit 94f3b8ed32a9c776c46fa228b22675bb8bd148e4
Author: Luca Bruno <lucabru src gnome org>
Date: Thu Jun 30 10:35:00 2011 +0200
Get rid of cname and cprefix information in code nodes
codegen/valaccodebasemodule.vala | 6 ++-
vala/valaarraytype.vala | 16 +-----
vala/valaclass.vala | 95 +-----------------------------
vala/valaclasstype.vala | 4 -
vala/valaconstant.vala | 43 +-------------
vala/valacreationmethod.vala | 26 --------
vala/valadatatype.vala | 47 ---------------
vala/valadelegate.vala | 27 ---------
vala/valadelegatetype.vala | 8 ---
vala/valadynamicmethod.vala | 11 ----
vala/valaenum.vala | 82 +-------------------------
vala/valaenumvalue.vala | 5 --
vala/valaerrorcode.vala | 41 -------------
vala/valaerrordomain.vala | 76 +-----------------------
vala/valaerrortype.vala | 18 ------
vala/valafield.vala | 46 +--------------
vala/valagenerictype.vala | 12 ----
vala/valagirparser.vala | 2 +-
vala/valainterface.vala | 121 +-------------------------------------
vala/valainterfacetype.vala | 4 -
vala/valamethod.vala | 43 -------------
vala/valamethodtype.vala | 4 -
vala/valanamespace.vala | 83 --------------------------
vala/valanulltype.vala | 8 ---
vala/valaobjecttype.vala | 10 ---
vala/valapointertype.vala | 8 ---
vala/valapropertyaccessor.vala | 37 ------------
vala/valasignal.vala | 18 ------
vala/valastruct.vala | 74 +-----------------------
vala/valasymbol.vala | 23 -------
vala/valatypesymbol.vala | 12 ----
vala/valavaluetype.vala | 8 ---
vala/valavoidtype.vala | 4 -
33 files changed, 15 insertions(+), 1007 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 49a3eb7..007bb91 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -307,6 +307,8 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
public static int ccode_attribute_hash = CodeNode.get_attribute_hash ();
+ public static int dynamic_method_id;
+
public CCodeBaseModule () {
predefined_marshal_set = new HashSet<string> (str_hash, str_equal);
predefined_marshal_set.add ("VOID:VOID");
@@ -6555,6 +6557,8 @@ public class Vala.CCodeAttribute : AttributeCache {
} else {
return "%s%s_%s".printf (CCodeBaseModule.get_ccode_lower_case_prefix (m.parent_symbol), infix, m.name);
}
+ } else if (sym is DynamicMethod) {
+ return "_dynamic_%s%d".printf (sym.name, dynamic_method_id++);
} else if (sym is Method) {
var m = (Method) sym;
if (m.is_async_callback) {
@@ -6921,7 +6925,7 @@ public class Vala.CCodeAttribute : AttributeCache {
if (sym is Class) {
var cl = (Class) sym;
if (cl.is_fundamental ()) {
- return CCodeBaseModule.get_ccode_lower_case_cname (cl, "value_get_");
+ return CCodeBaseModule.get_ccode_lower_case_name (cl, "value_get_");
} else if (cl.base_class != null) {
return CCodeBaseModule.get_ccode_get_value_function (cl.base_class);
} else if (type_id == "G_TYPE_POINTER") {
diff --git a/vala/valaarraytype.vala b/vala/valaarraytype.vala
index 3af7f30..6929aee 100644
--- a/vala/valaarraytype.vala
+++ b/vala/valaarraytype.vala
@@ -102,7 +102,7 @@ public class Vala.ArrayType : ReferenceType {
resize_method.return_type = new VoidType ();
resize_method.access = SymbolAccessibility.PUBLIC;
- resize_method.set_cname ("g_renew");
+ resize_method.set_attribute_string ("CCode", "cname", "g_renew");
var root_symbol = source_reference.file.context.root;
var int_type = new IntegerType ((Struct) root_symbol.scope.lookup ("int"));
@@ -121,7 +121,7 @@ public class Vala.ArrayType : ReferenceType {
move_method.return_type = new VoidType ();
move_method.access = SymbolAccessibility.PUBLIC;
- move_method.set_cname ("_vala_array_move");
+ move_method.set_attribute_string ("CCode", "cname", "_vala_array_move");
var root_symbol = source_reference.file.context.root;
var int_type = new IntegerType ((Struct) root_symbol.scope.lookup ("int"));
@@ -148,18 +148,6 @@ public class Vala.ArrayType : ReferenceType {
return result;
}
- public override string? get_cname () {
- if (inline_allocated) {
- return element_type.get_cname ();
- } else {
- if (CodeContext.get ().profile == Profile.DOVA) {
- return "DovaArray";
- } else {
- return element_type.get_cname () + "*";
- }
- }
- }
-
public override string get_cdeclarator_suffix () {
if (fixed_length) {
return "[%d]".printf (length);
diff --git a/vala/valaclass.vala b/vala/valaclass.vala
index e8a3e9b..dbeae26 100644
--- a/vala/valaclass.vala
+++ b/vala/valaclass.vala
@@ -79,10 +79,6 @@ public class Vala.Class : ObjectTypeSymbol {
*/
public bool has_class_private_fields { get; private set; }
- private string cname;
- public string const_cname { get; set; }
- private string lower_case_cprefix;
- private string lower_case_csuffix;
private bool _is_compact;
private bool _is_immutable;
@@ -539,81 +535,6 @@ public class Vala.Class : ObjectTypeSymbol {
}
}
- public override string get_cprefix () {
- return get_cname ();
- }
-
- public override string get_cname (bool const_type = false) {
- if (const_type) {
- if (const_cname != null) {
- return const_cname;
- } else if (is_immutable) {
- return "const " + get_cname (false);
- }
- }
-
- if (cname == null) {
- cname = get_attribute_string ("CCode", "cname");
- if (cname == null) {
- cname = get_default_cname ();
- }
- }
- return cname;
- }
-
- /**
- * Returns the default name of this class as it is used in C code.
- *
- * @return the name to be used in C code by default
- */
- public string get_default_cname () {
- return "%s%s".printf (parent_symbol.get_cprefix (), name);
- }
-
- /**
- * Sets the name of this class as it is used in C code.
- *
- * @param cname the name to be used in C code
- */
- public void set_cname (string cname) {
- this.cname = cname;
- }
-
- private string get_lower_case_csuffix () {
- if (lower_case_csuffix == null) {
- lower_case_csuffix = camel_case_to_lower_case (name);
-
- // remove underscores in some cases to avoid conflicts of type macros
- if (lower_case_csuffix.has_prefix ("type_")) {
- lower_case_csuffix = "type" + lower_case_csuffix.substring ("type_".length);
- } else if (lower_case_csuffix.has_prefix ("is_")) {
- lower_case_csuffix = "is" + lower_case_csuffix.substring ("is_".length);
- }
- if (lower_case_csuffix.has_suffix ("_class")) {
- lower_case_csuffix = lower_case_csuffix.substring (0, lower_case_csuffix.length - "_class".length) + "class";
- }
- }
- return lower_case_csuffix;
- }
-
- public override string? get_lower_case_cname (string? infix) {
- if (infix == null) {
- infix = "";
- }
- return "%s%s%s".printf (parent_symbol.get_lower_case_cprefix (), infix, get_lower_case_csuffix ());
- }
-
- public override string get_lower_case_cprefix () {
- if (lower_case_cprefix == null) {
- lower_case_cprefix = "%s_".printf (get_lower_case_cname (null));
- }
- return lower_case_cprefix;
- }
-
- public void set_lower_case_cprefix (string cprefix) {
- lower_case_cprefix = cprefix;
- }
-
public override bool is_reference_type () {
return true;
}
@@ -623,27 +544,13 @@ public class Vala.Class : ObjectTypeSymbol {
gir_name = a.get_string ("name");
}
}
-
- private void process_ccode_attribute (Attribute a) {
- if (a.has_argument ("const_cname")) {
- const_cname = a.get_string ("const_cname");
- }
- if (a.has_argument ("cprefix")) {
- lower_case_cprefix = a.get_string ("cprefix");
- }
- if (a.has_argument ("lower_case_csuffix")) {
- lower_case_csuffix = a.get_string ("lower_case_csuffix");
- }
- }
/**
* Process all associated attributes.
*/
public void process_attributes () {
foreach (Attribute a in attributes) {
- if (a.name == "CCode") {
- process_ccode_attribute (a);
- } else if (a.name == "Compact") {
+ if (a.name == "Compact") {
is_compact = true;
} else if (a.name == "Immutable") {
is_immutable = true;
diff --git a/vala/valaclasstype.vala b/vala/valaclasstype.vala
index aef62b7..a0430a1 100644
--- a/vala/valaclasstype.vala
+++ b/vala/valaclasstype.vala
@@ -49,8 +49,4 @@ public class Vala.ClassType : ReferenceType {
return result;
}
-
- public override string? get_cname () {
- return "%sClass*".printf (class_symbol.get_cname ());
- }
}
diff --git a/vala/valaconstant.vala b/vala/valaconstant.vala
index b6bb8e1..8a9e552 100644
--- a/vala/valaconstant.vala
+++ b/vala/valaconstant.vala
@@ -50,8 +50,6 @@ public class Vala.Constant : Symbol, Lockable {
}
}
- private string cname;
-
private bool lock_used = false;
private DataType _data_type;
@@ -87,37 +85,6 @@ public class Vala.Constant : Symbol, Lockable {
}
}
- /**
- * Returns the name of this constant as it is used in C code.
- *
- * @return the name to be used in C code
- */
- public string get_cname () {
- if (cname == null) {
- cname = get_default_cname ();
- }
- return cname;
- }
-
- /**
- * Returns the default name of this constant as it is used in C
- * code.
- *
- * @return the name to be used in C code by default
- */
- public virtual string get_default_cname () {
- if (parent_symbol == null) {
- // global constant
- return name;
- } else {
- return "%s%s".printf (parent_symbol.get_lower_case_cprefix ().up (), name);
- }
- }
-
- public void set_cname (string value) {
- this.cname = value;
- }
-
public bool get_lock_used () {
return lock_used;
}
@@ -138,20 +105,12 @@ public class Vala.Constant : Symbol, Lockable {
}
}
- private void process_ccode_attribute (Attribute a) {
- if (a.has_argument ("cname")) {
- cname = a.get_string ("cname");
- }
- }
-
/**
* Process all associated attributes.
*/
public void process_attributes () {
foreach (Attribute a in attributes) {
- if (a.name == "CCode") {
- process_ccode_attribute (a);
- } else if (a.name == "Deprecated") {
+ if (a.name == "Deprecated") {
process_deprecated_attribute (a);
} else if (a.name == "Experimental") {
process_experimental_attribute (a);
diff --git a/vala/valacreationmethod.vala b/vala/valacreationmethod.vala
index 3315228..88194c4 100644
--- a/vala/valacreationmethod.vala
+++ b/vala/valacreationmethod.vala
@@ -80,32 +80,6 @@ public class Vala.CreationMethod : Method {
}
}
- public override string get_default_cname () {
- var parent = parent_symbol as TypeSymbol;
-
- string infix = "new";
- var st = parent as Struct;
- if (st != null) {
- if (CodeContext.get ().profile == Profile.DOVA) {
- if (st.is_boolean_type () || st.is_integer_type () || st.is_floating_type ()) {
- // don't use any infix for basic types
- if (name == ".new") {
- return parent.get_lower_case_cname ();
- } else {
- return "%s%s".printf (parent.get_lower_case_cprefix (), name);
- }
- }
- }
- infix = "init";
- }
-
- if (name == ".new") {
- return "%s%s".printf (parent.get_lower_case_cprefix (), infix);
- } else {
- return "%s%s_%s".printf (parent.get_lower_case_cprefix (), infix, name);
- }
- }
-
public override bool check (CodeContext context) {
if (checked) {
return !error;
diff --git a/vala/valadatatype.vala b/vala/valadatatype.vala
index 84aa205..316a75a 100644
--- a/vala/valadatatype.vala
+++ b/vala/valadatatype.vala
@@ -117,57 +117,10 @@ public abstract class Vala.DataType : CodeNode {
}
}
- /**
- * Returns the name and qualifiers of this type as it is used in C code.
- *
- * @return the type string to be used in C code
- */
- public virtual string? get_cname () {
- // raise error
- Report.error (source_reference, "unresolved type reference");
- return null;
- }
-
public virtual string get_cdeclarator_suffix () {
return "";
}
- /**
- * Returns the name and qualifiers of this type as it is used in C code
- * in a const declaration.
- *
- * @return the type string to be used in C code const declarations
- */
- public string get_const_cname () {
- string ptr;
- TypeSymbol t;
- // FIXME: workaround to make constant arrays possible
- if (this is ArrayType) {
- t = ((ArrayType) this).element_type.data_type;
- } else {
- t = data_type;
- }
- if (!t.is_reference_type ()) {
- ptr = "";
- } else {
- ptr = "*";
- }
-
- return "const %s%s".printf (t.get_cname (), ptr);
- }
-
- /**
- * Returns the C name of this data type in lower case. Words are
- * separated by underscores.
- *
- * @param infix a string to be placed between namespace and data type
- * name or null
- * @return the lower case name to be used in C code
- */
- public virtual string? get_lower_case_cname (string? infix = null) {
- return data_type.get_lower_case_cname (infix);
- }
-
public override string to_string () {
return to_qualified_string (null);
}
diff --git a/vala/valadelegate.vala b/vala/valadelegate.vala
index d52fff3..d1270ab 100644
--- a/vala/valadelegate.vala
+++ b/vala/valadelegate.vala
@@ -88,7 +88,6 @@ public class Vala.Delegate : TypeSymbol {
private List<TypeParameter> type_parameters = new ArrayList<TypeParameter> ();
private List<Parameter> parameters = new ArrayList<Parameter> ();
- private string cname;
private DataType _return_type;
private bool? _has_target;
@@ -258,33 +257,7 @@ public class Vala.Delegate : TypeSymbol {
}
}
- public override string get_cname (bool const_type = false) {
- if (cname == null) {
- cname = "%s%s".printf (parent_symbol.get_cprefix (), name);
- }
- return cname;
- }
-
- /**
- * Sets the name of this callback as it is used in C code.
- *
- * @param cname the name to be used in C code
- */
- public void set_cname (string cname) {
- this.cname = cname;
- }
-
- public override string? get_lower_case_cname (string? infix) {
- if (infix == null) {
- infix = "";
- }
- return "%s%s%s".printf (parent_symbol.get_lower_case_cprefix (), infix, camel_case_to_lower_case (name));
- }
-
private void process_ccode_attribute (Attribute a) {
- if (a.has_argument ("cname")) {
- set_cname (a.get_string ("cname"));
- }
if (a.has_argument ("array_length")) {
no_array_length = !a.get_bool ("array_length");
}
diff --git a/vala/valadelegatetype.vala b/vala/valadelegatetype.vala
index 2c4c9e1..2cc6cf0 100644
--- a/vala/valadelegatetype.vala
+++ b/vala/valadelegatetype.vala
@@ -107,14 +107,6 @@ public class Vala.DelegateType : DataType {
return result;
}
- public override string? get_cname () {
- if (CodeContext.get ().profile == Profile.DOVA) {
- return "%s*".printf (delegate_symbol.get_cname ());
- } else {
- return delegate_symbol.get_cname ();
- }
- }
-
public override bool is_accessible (Symbol sym) {
return delegate_symbol.is_accessible (sym);
}
diff --git a/vala/valadynamicmethod.vala b/vala/valadynamicmethod.vala
index ff5f4e2..845c0af 100644
--- a/vala/valadynamicmethod.vala
+++ b/vala/valadynamicmethod.vala
@@ -30,22 +30,11 @@ public class Vala.DynamicMethod : Method {
public MethodCall invocation { get; set; }
- private string cname;
- static int dynamic_method_id;
-
public DynamicMethod (DataType dynamic_type, string name, DataType return_type, SourceReference? source_reference = null, Comment? comment = null) {
base (name, return_type, source_reference, comment);
this.dynamic_type = dynamic_type;
}
- public override string get_default_cname () {
- // return cname of wrapper method
- if (cname == null) {
- cname = "_dynamic_%s%d".printf (name, dynamic_method_id++);
- }
- return cname;
- }
-
public override bool check (CodeContext context) {
return true;
}
diff --git a/vala/valaenum.vala b/vala/valaenum.vala
index 0876474..a97c614 100644
--- a/vala/valaenum.vala
+++ b/vala/valaenum.vala
@@ -34,10 +34,6 @@ public class Vala.Enum : TypeSymbol {
private List<EnumValue> values = new ArrayList<EnumValue> ();
private List<Method> methods = new ArrayList<Method> ();
private List<Constant> constants = new ArrayList<Constant> ();
- private string cname;
- private string cprefix;
- private string lower_case_cprefix;
- private string lower_case_csuffix;
/**
* Creates a new enum.
@@ -147,92 +143,16 @@ public class Vala.Enum : TypeSymbol {
}
}
- public override string get_cname (bool const_type = false) {
- if (cname == null) {
- cname = get_attribute_string ("CCode", "cname");
- if (cname == null) {
- cname = get_default_cname ();
- }
- }
- return cname;
- }
-
- /**
- * Returns the default name of this enum as it is used in C code.
- *
- * @return the name to be used in C code by default
- */
- public string get_default_cname () {
- return "%s%s".printf (parent_symbol.get_cprefix (), name);
- }
-
- public void set_cname (string cname) {
- this.cname = cname;
- }
-
- public override string get_lower_case_cprefix () {
- if (lower_case_cprefix == null) {
- lower_case_cprefix = "%s_".printf (get_lower_case_cname (null));
- }
- return lower_case_cprefix;
- }
-
- private string get_lower_case_csuffix () {
- if (lower_case_csuffix == null) {
- lower_case_csuffix = camel_case_to_lower_case (name);
- }
- return lower_case_csuffix;
- }
-
- public override string? get_lower_case_cname (string? infix) {
- if (infix == null) {
- infix = "";
- }
- return "%s%s%s".printf (parent_symbol.get_lower_case_cprefix (), infix, get_lower_case_csuffix ());
- }
-
- public override string? get_upper_case_cname (string? infix = null) {
- return get_lower_case_cname (infix).up ();
- }
-
public override bool is_reference_type () {
return false;
}
- public override string get_cprefix () {
- if (cprefix == null) {
- cprefix = "%s_".printf (get_upper_case_cname ());
- }
- return cprefix;
- }
-
- /**
- * Sets the string to be prepended to the name of members of this enum
- * when used in C code.
- *
- * @param cprefix the prefix to be used in C code
- */
- public void set_cprefix (string? cprefix) {
- this.cprefix = cprefix;
- }
-
- private void process_ccode_attribute (Attribute a) {
- if (a.has_argument ("cprefix")) {
- set_cprefix (a.get_string ("cprefix"));
- }
- if (a.has_argument ("lower_case_csuffix")) {
- lower_case_csuffix = a.get_string ("lower_case_csuffix");
- }
- }
-
/**
* Process all associated attributes.
*/
public void process_attributes () {
foreach (Attribute a in attributes) {
- if (a.name == "CCode") {
- process_ccode_attribute (a);
- } else if (a.name == "Flags") {
+ if (a.name == "Flags") {
is_flags = true;
} else if (a.name == "Deprecated") {
process_deprecated_attribute (a);
diff --git a/vala/valaenumvalue.vala b/vala/valaenumvalue.vala
index 4a04b85..df2cec7 100644
--- a/vala/valaenumvalue.vala
+++ b/vala/valaenumvalue.vala
@@ -74,11 +74,6 @@ public class Vala.EnumValue : Constant {
}
}
- public override string get_default_cname () {
- var en = (Enum) parent_symbol;
- return "%s%s".printf (en.get_cprefix (), name);
- }
-
public override bool check (CodeContext context) {
if (checked) {
return !error;
diff --git a/vala/valaerrorcode.vala b/vala/valaerrorcode.vala
index eace48c..aa97641 100644
--- a/vala/valaerrorcode.vala
+++ b/vala/valaerrorcode.vala
@@ -31,8 +31,6 @@ public class Vala.ErrorCode : TypeSymbol {
*/
public Expression value { get; set; }
- private string cname;
-
/**
* Creates a new enum value.
*
@@ -65,43 +63,6 @@ public class Vala.ErrorCode : TypeSymbol {
}
}
- public override string get_cname (bool const_type = false) {
- if (cname == null) {
- cname = get_default_cname ();
- }
- return cname;
- }
-
- public string get_default_cname () {
- var edomain = (ErrorDomain) parent_symbol;
- return "%s%s".printf (edomain.get_cprefix (), name);
- }
-
- public void set_cname (string value) {
- this.cname = value;
- }
-
- public override string? get_lower_case_cname (string? infix) {
- return get_cname ().down ();
- }
-
- private void process_ccode_attribute (Attribute a) {
- if (a.has_argument ("cname")) {
- cname = a.get_string ("cname");
- }
- }
-
- /**
- * Process all associated attributes.
- */
- public void process_attributes () {
- foreach (Attribute a in attributes) {
- if (a.name == "CCode") {
- process_ccode_attribute (a);
- }
- }
- }
-
public override bool check (CodeContext context) {
if (checked) {
return !error;
@@ -109,8 +70,6 @@ public class Vala.ErrorCode : TypeSymbol {
checked = true;
- process_attributes ();
-
if (value != null) {
value.check (context);
}
diff --git a/vala/valaerrordomain.vala b/vala/valaerrordomain.vala
index 768768d..dac4508 100644
--- a/vala/valaerrordomain.vala
+++ b/vala/valaerrordomain.vala
@@ -28,7 +28,6 @@ using GLib;
public class Vala.ErrorDomain : TypeSymbol {
private List<ErrorCode> codes = new ArrayList<ErrorCode> ();
private List<Method> methods = new ArrayList<Method> ();
- private string cname;
private string cprefix;
private string lower_case_cprefix;
private string lower_case_csuffix;
@@ -107,89 +106,16 @@ public class Vala.ErrorDomain : TypeSymbol {
}
}
- public override string get_cname (bool const_type = false) {
- if (cname == null) {
- cname = "%s%s".printf (parent_symbol.get_cprefix (), name);
- }
- return cname;
- }
-
- public override string get_lower_case_cprefix () {
- if (lower_case_cprefix == null) {
- lower_case_cprefix = "%s_".printf (get_lower_case_cname (null));
- }
- return lower_case_cprefix;
- }
-
- private string get_lower_case_csuffix () {
- if (lower_case_csuffix == null) {
- lower_case_csuffix = camel_case_to_lower_case (name);
- }
- return lower_case_csuffix;
- }
-
- public override string? get_lower_case_cname (string? infix) {
- if (infix == null) {
- infix = "";
- }
-
- string cprefix = "";
- if (parent_symbol != null) {
- cprefix = parent_symbol.get_lower_case_cprefix ();
- }
-
- return "%s%s%s".printf (cprefix, infix, get_lower_case_csuffix ());
- }
-
- public override string? get_upper_case_cname (string? infix) {
- return get_lower_case_cname (infix).up ();
- }
-
public override bool is_reference_type () {
return false;
}
- public void set_cname (string cname) {
- this.cname = cname;
- }
-
- public override string get_cprefix () {
- if (cprefix == null) {
- cprefix = "%s_".printf (get_upper_case_cname (null));
- }
- return cprefix;
- }
-
- /**
- * Sets the string to be prepended to the name of members of this error
- * domain when used in C code.
- *
- * @param cprefix the prefix to be used in C code
- */
- public void set_cprefix (string cprefix) {
- this.cprefix = cprefix;
- }
-
- private void process_ccode_attribute (Attribute a) {
- if (a.has_argument ("cname")) {
- set_cname (a.get_string ("cname"));
- }
- if (a.has_argument ("cprefix")) {
- set_cprefix (a.get_string ("cprefix"));
- }
- if (a.has_argument ("lower_case_csuffix")) {
- lower_case_csuffix = a.get_string ("lower_case_csuffix");
- }
- }
-
/**
* Process all associated attributes.
*/
public void process_attributes () {
foreach (Attribute a in attributes) {
- if (a.name == "CCode") {
- process_ccode_attribute (a);
- } else if (a.name == "Deprecated") {
+ if (a.name == "Deprecated") {
process_deprecated_attribute (a);
} else if (a.name == "Experimental") {
process_experimental_attribute (a);
diff --git a/vala/valaerrortype.vala b/vala/valaerrortype.vala
index 3ce744f..c7c9f93 100644
--- a/vala/valaerrortype.vala
+++ b/vala/valaerrortype.vala
@@ -101,24 +101,6 @@ public class Vala.ErrorType : ReferenceType {
return result;
}
- public override string? get_cname () {
- return "GError*";
- }
-
- public override string? get_lower_case_cname (string? infix = null) {
- if (error_domain == null) {
- if (infix == null) {
- return "g_error";
- } else {
- return "g_%s_error".printf (infix);
- }
- } else if (error_code == null) {
- return error_domain.get_lower_case_cname (infix);
- } else {
- return error_code.get_lower_case_cname (infix);
- }
- }
-
public override bool equals (DataType type2) {
var et = type2 as ErrorType;
diff --git a/vala/valafield.vala b/vala/valafield.vala
index 5c0cfa7..803b9f9 100644
--- a/vala/valafield.vala
+++ b/vala/valafield.vala
@@ -38,8 +38,6 @@ public class Vala.Field : Variable, Lockable {
*/
public bool is_volatile { get; set; }
- private string cname;
-
private bool lock_used = false;
/**
@@ -68,55 +66,13 @@ public class Vala.Field : Variable, Lockable {
}
/**
- * Returns the name of this field as it is used in C code.
- *
- * @return the name to be used in C code
- */
- public string get_cname () {
- if (cname == null) {
- cname = get_default_cname ();
- }
- return cname;
- }
-
- /**
- * Sets the name of this field as it is used in C code.
- *
- * @param cname the name to be used in C code
- */
- public void set_cname (string cname) {
- this.cname = cname;
- }
-
- /**
- * Returns the default name of this field as it is used in C code.
- *
- * @return the name to be used in C code by default
- */
- public string get_default_cname () {
- if (binding == MemberBinding.STATIC) {
- return parent_symbol.get_lower_case_cprefix () + name;
- } else {
- return name;
- }
- }
-
- private void process_ccode_attribute (Attribute a) {
- if (a.has_argument ("cname")) {
- set_cname (a.get_string ("cname"));
- }
- }
-
- /**
* Process all associated attributes.
*/
public override void process_attributes () {
base.process_attributes ();
foreach (Attribute a in attributes) {
- if (a.name == "CCode") {
- process_ccode_attribute (a);
- } else if (a.name == "Deprecated") {
+ if (a.name == "Deprecated") {
process_deprecated_attribute (a);
} else if (a.name == "Experimental") {
process_experimental_attribute (a);
diff --git a/vala/valagenerictype.vala b/vala/valagenerictype.vala
index 15a2121..c7d7991 100644
--- a/vala/valagenerictype.vala
+++ b/vala/valagenerictype.vala
@@ -42,18 +42,6 @@ public class Vala.GenericType : DataType {
return result;
}
- public override string? get_cname () {
- if (CodeContext.get ().profile == Profile.GOBJECT) {
- if (value_owned) {
- return "gpointer";
- } else {
- return "gconstpointer";
- }
- } else {
- return "void *";
- }
- }
-
public override string to_qualified_string (Scope? scope = null) {
return type_parameter.name;
}
diff --git a/vala/valagirparser.vala b/vala/valagirparser.vala
index bddce1d..c79d29f 100644
--- a/vala/valagirparser.vala
+++ b/vala/valagirparser.vala
@@ -846,7 +846,7 @@ public class Vala.GirParser : CodeVisitor {
var iface = parser.resolve_symbol (parent, parser.parse_symbol_from_string (gtype_struct_for, source_reference)) as Interface;
if (iface != null) {
// set the interface struct name
- iface.set_type_cname (((Struct) symbol).get_cname ());
+ iface.set_attribute_string ("CCode", "type_cname", node.get_cname ());
}
merged = true;
}
diff --git a/vala/valainterface.vala b/vala/valainterface.vala
index 688bf31..a2eff42 100644
--- a/vala/valainterface.vala
+++ b/vala/valainterface.vala
@@ -40,10 +40,6 @@ public class Vala.Interface : ObjectTypeSymbol {
private List<Enum> enums = new ArrayList<Enum> ();
private List<Delegate> delegates = new ArrayList<Delegate> ();
- private string cname;
- private string lower_case_csuffix;
- private string type_cname;
-
/**
* Returns a copy of the list of classes.
*
@@ -275,89 +271,6 @@ public class Vala.Interface : ObjectTypeSymbol {
scope.add (d.name, d);
}
- public override string get_cprefix () {
- return get_cname ();
- }
-
- public override string get_cname (bool const_type = false) {
- if (cname == null) {
- cname = get_attribute_string ("CCode", "cname");
- if (cname == null) {
- cname = "%s%s".printf (parent_symbol.get_cprefix (), name);
- }
- }
- return cname;
- }
-
- public void set_cname (string cname) {
- this.cname = cname;
- }
-
- /**
- * Returns the string to be prepended to the name of members of this
- * interface when used in C code.
- *
- * @return the suffix to be used in C code
- */
- public string get_lower_case_csuffix () {
- if (lower_case_csuffix == null) {
- lower_case_csuffix = get_default_lower_case_csuffix ();
- }
- return lower_case_csuffix;
- }
-
- /**
- * Returns default string to be prepended to the name of members of this
- * interface when used in C code.
- *
- * @return the suffix to be used in C code
- */
- public string get_default_lower_case_csuffix () {
- string result = camel_case_to_lower_case (name);
-
- // remove underscores in some cases to avoid conflicts of type macros
- if (result.has_prefix ("type_")) {
- result = "type" + result.substring ("type_".length);
- } else if (result.has_prefix ("is_")) {
- result = "is" + result.substring ("is_".length);
- }
- if (result.has_suffix ("_class")) {
- result = result.substring (0, result.length - "_class".length) + "class";
- }
-
- return result;
- }
-
- /**
- * Returns default string for the type struct when used in C code.
- *
- * @return the type struct to be used in C code
- */
- public string get_default_type_cname () {
- return "%sIface".printf (get_cname ());
- }
-
- /**
- * Sets the string to be prepended to the name of members of this
- * interface when used in C code.
- *
- * @param csuffix the suffix to be used in C code
- */
- public void set_lower_case_csuffix (string csuffix) {
- this.lower_case_csuffix = csuffix;
- }
-
- public override string? get_lower_case_cname (string? infix) {
- if (infix == null) {
- infix = "";
- }
- return "%s%s%s".printf (parent_symbol.get_lower_case_cprefix (), infix, get_lower_case_csuffix ());
- }
-
- public override string get_lower_case_cprefix () {
- return "%s_".printf (get_lower_case_cname (null));
- }
-
public override void accept (CodeVisitor visitor) {
visitor.visit_interface (this);
}
@@ -427,23 +340,12 @@ public class Vala.Interface : ObjectTypeSymbol {
return false;
}
- private void process_ccode_attribute (Attribute a) {
- if (a.has_argument ("type_cname")) {
- set_type_cname (a.get_string ("type_cname"));
- }
- if (a.has_argument ("lower_case_csuffix")) {
- lower_case_csuffix = a.get_string ("lower_case_csuffix");
- }
- }
-
/**
* Process all associated attributes.
*/
public void process_attributes () {
foreach (Attribute a in attributes) {
- if (a.name == "CCode") {
- process_ccode_attribute (a);
- } else if (a.name == "Deprecated") {
+ if (a.name == "Deprecated") {
process_deprecated_attribute (a);
} else if (a.name == "Experimental") {
process_experimental_attribute (a);
@@ -451,27 +353,6 @@ public class Vala.Interface : ObjectTypeSymbol {
}
}
- /**
- * Returns the name of the type struct as it is used in C code.
- *
- * @return the type struct name to be used in C code
- */
- public string get_type_cname () {
- if (type_cname == null) {
- type_cname = get_default_type_cname ();
- }
- return type_cname;
- }
-
- /**
- * Sets the name of the type struct as it is used in C code.
- *
- * @param type_cname the type struct name to be used in C code
- */
- public void set_type_cname (string type_cname) {
- this.type_cname = type_cname;
- }
-
public override void replace_type (DataType old_type, DataType new_type) {
for (int i = 0; i < prerequisites.size; i++) {
if (prerequisites[i] == old_type) {
diff --git a/vala/valainterfacetype.vala b/vala/valainterfacetype.vala
index b767f14..3ca1a2c 100644
--- a/vala/valainterfacetype.vala
+++ b/vala/valainterfacetype.vala
@@ -49,8 +49,4 @@ public class Vala.InterfaceType : ReferenceType {
return result;
}
-
- public override string? get_cname () {
- return "%s*".printf (interface_symbol.get_type_cname ());
- }
}
diff --git a/vala/valamethod.vala b/vala/valamethod.vala
index 556c189..b13d9df 100644
--- a/vala/valamethod.vala
+++ b/vala/valamethod.vala
@@ -204,7 +204,6 @@ public class Vala.Method : Subroutine {
public int yield_count { get; set; }
private List<Parameter> parameters = new ArrayList<Parameter> ();
- private string cname;
private string _sentinel;
private List<Expression> preconditions;
private List<Expression> postconditions;
@@ -314,49 +313,7 @@ public class Vala.Method : Subroutine {
}
}
- /**
- * Returns the interface name of this method as it is used in C code.
- *
- * @return the name to be used in C code
- */
- public string get_cname () {
- if (cname == null) {
- cname = get_default_cname ();
- }
- return cname;
- }
-
-
- /**
- * Returns the default interface name of this method as it is used in C
- * code.
- *
- * @return the name to be used in C code by default
- */
- public virtual string get_default_cname () {
- if (name == "main" && parent_symbol.name == null) {
- // avoid conflict with generated main function
- return "_vala_main";
- } else if (name.has_prefix ("_")) {
- return "_%s%s".printf (parent_symbol.get_lower_case_cprefix (), name.substring (1));
- } else {
- return "%s%s".printf (parent_symbol.get_lower_case_cprefix (), name);
- }
- }
-
- /**
- * Sets the name of this method as it is used in C code.
- *
- * @param cname the name to be used in C code
- */
- public void set_cname (string cname) {
- this.cname = cname;
- }
-
private void process_ccode_attribute (Attribute a) {
- if (a.has_argument ("cname")) {
- set_cname (a.get_string ("cname"));
- }
if (a.has_argument ("sentinel")) {
this.sentinel = a.get_string ("sentinel");
}
diff --git a/vala/valamethodtype.vala b/vala/valamethodtype.vala
index 594aeb2..9a492fa 100644
--- a/vala/valamethodtype.vala
+++ b/vala/valamethodtype.vala
@@ -62,10 +62,6 @@ public class Vala.MethodType : DataType {
return method_symbol.get_full_name ();
}
- public override string? get_cname () {
- return "gpointer";
- }
-
public override Symbol? get_member (string member_name) {
if (method_symbol.coroutine && member_name == "begin") {
return method_symbol;
diff --git a/vala/valanamespace.vala b/vala/valanamespace.vala
index dc8614b..e4577ec 100644
--- a/vala/valanamespace.vala
+++ b/vala/valanamespace.vala
@@ -38,9 +38,6 @@ public class Vala.Namespace : Symbol {
private List<Comment> comments = new ArrayList<Comment> ();
- private List<string> cprefixes = new ArrayList<string> ();
- private string lower_case_cprefix;
-
private List<Namespace> namespaces = new ArrayList<Namespace> ();
private List<UsingDirective> using_directives = new ArrayList<UsingDirective> ();
@@ -499,88 +496,8 @@ public class Vala.Namespace : Symbol {
m.accept (visitor);
}
}
-
- public override string get_cprefix () {
- if (cprefixes.size > 0) {
- return cprefixes[0];
- } else if (null != name) {
- string parent_prefix;
- if (parent_symbol == null) {
- parent_prefix = "";
- } else {
- parent_prefix = parent_symbol.get_cprefix ();
- }
- return parent_prefix + name;
- } else {
- return "";
- }
- }
-
- public List<string> get_cprefixes () {
- if (0 == cprefixes.size && null != name)
- cprefixes.add (name);
-
- return cprefixes;
- }
-
- /**
- * Adds a camel case string to be prepended to the name of members of
- * this namespace when used in C code.
- *
- * @param cprefixes the camel case prefixes used in C code
- */
- public void add_cprefix (string cprefix) {
- cprefixes.add (cprefix);
- }
-
- /**
- * Returns the lower case string to be prepended to the name of members
- * of this namespace when used in C code.
- *
- * @return the lower case prefix to be used in C code
- */
- public override string get_lower_case_cprefix () {
- if (lower_case_cprefix == null) {
- if (name == null) {
- lower_case_cprefix = "";
- } else {
- string parent_prefix;
- if (parent_symbol == null) {
- parent_prefix = "";
- } else {
- parent_prefix = parent_symbol.get_lower_case_cprefix ();
- }
- lower_case_cprefix = "%s%s_".printf (parent_prefix, camel_case_to_lower_case (name));
- }
- }
- return lower_case_cprefix;
- }
-
- /**
- * Sets the lower case string to be prepended to the name of members of
- * this namespace when used in C code.
- *
- * @param cprefix the lower case prefix to be used in C code
- */
- public void set_lower_case_cprefix (string cprefix) {
- this.lower_case_cprefix = cprefix;
- }
private void process_ccode_attribute (Attribute a) {
- if (a.has_argument ("cprefix")) {
- string value = a.get_string ("cprefix");
- if (value == "") {
- // split of an empty string returns an empty array
- add_cprefix ("");
- } else {
- foreach (string name in value.split (",")) {
- add_cprefix (name);
- }
- }
- }
- if (a.has_argument ("lower_case_cprefix")) {
- set_lower_case_cprefix (a.get_string ("lower_case_cprefix"));
- }
if (a.has_argument ("gir_namespace")) {
source_reference.file.gir_namespace = a.get_string ("gir_namespace");
}
diff --git a/vala/valanulltype.vala b/vala/valanulltype.vala
index fdba4a7..19d1109 100644
--- a/vala/valanulltype.vala
+++ b/vala/valanulltype.vala
@@ -62,14 +62,6 @@ public class Vala.NullType : ReferenceType {
return new NullType (source_reference);
}
- public override string? get_cname () {
- if (CodeContext.get ().profile == Profile.GOBJECT) {
- return "gpointer";
- } else {
- return "void *";
- }
- }
-
public override bool is_disposable () {
return false;
}
diff --git a/vala/valaobjecttype.vala b/vala/valaobjecttype.vala
index 4218756..6d440b1 100644
--- a/vala/valaobjecttype.vala
+++ b/vala/valaobjecttype.vala
@@ -51,16 +51,6 @@ public class Vala.ObjectType : ReferenceType {
return result;
}
- public override string? get_cname () {
- if (CodeContext.get ().profile == Profile.DOVA) {
- if (type_symbol.get_full_name () == "string") {
- return "string_t";
- }
- }
-
- return "%s*".printf (type_symbol.get_cname (!value_owned));
- }
-
public override bool stricter (DataType target_type) {
var obj_target_type = target_type as ObjectType;
if (obj_target_type == null) {
diff --git a/vala/valapointertype.vala b/vala/valapointertype.vala
index 3294091..9600d0d 100644
--- a/vala/valapointertype.vala
+++ b/vala/valapointertype.vala
@@ -49,14 +49,6 @@ public class Vala.PointerType : DataType {
return base_type.to_qualified_string (scope) + "*";
}
- public override string? get_cname () {
- if (base_type.data_type != null && base_type.data_type.is_reference_type ()) {
- return base_type.get_cname ();
- } else {
- return base_type.get_cname () + "*";
- }
- }
-
public override DataType copy () {
return new PointerType (base_type.copy ());
}
diff --git a/vala/valapropertyaccessor.vala b/vala/valapropertyaccessor.vala
index 119ce51..47a1977 100644
--- a/vala/valapropertyaccessor.vala
+++ b/vala/valapropertyaccessor.vala
@@ -76,29 +76,7 @@ public class Vala.PropertyAccessor : Subroutine {
*/
public Parameter value_parameter { get; set; }
- public virtual string get_default_cname () {
- var t = (TypeSymbol) prop.parent_symbol;
-
- if (readable) {
- return "%sget_%s".printf (t.get_lower_case_cprefix (), prop.name);
- } else {
- return "%sset_%s".printf (t.get_lower_case_cprefix (), prop.name);
- }
- }
-
- /**
- * The publicly accessible name of the function that performs the
- * access in C code.
- */
- public string get_cname () {
- if (_cname != null) {
- return _cname;
- }
- return get_default_cname ();
- }
-
private DataType _value_type;
- private string? _cname;
/**
* Creates a new property accessor.
@@ -136,19 +114,6 @@ public class Vala.PropertyAccessor : Subroutine {
}
}
- /**
- * Process all associated attributes.
- */
- public void process_attributes () {
- foreach (Attribute a in attributes) {
- if (a.name == "CCode") {
- if (a.has_argument ("cname")) {
- _cname = a.get_string ("cname");
- }
- }
- }
- }
-
public override bool check (CodeContext context) {
if (checked) {
return !error;
@@ -156,8 +121,6 @@ public class Vala.PropertyAccessor : Subroutine {
checked = true;
- process_attributes ();
-
if (!value_type.check (context)) {
error = true;
return false;
diff --git a/vala/valasignal.vala b/vala/valasignal.vala
index bfff34e..4254131 100644
--- a/vala/valasignal.vala
+++ b/vala/valasignal.vala
@@ -75,8 +75,6 @@ public class Vala.Signal : Symbol, Lockable {
public bool no_hooks { get; set; }
- private string cname;
-
private bool lock_used = false;
private DataType _return_type;
@@ -168,22 +166,6 @@ public class Vala.Signal : Symbol, Lockable {
return generated_delegate;
}
-
- /**
- * Returns the name of this signal as it is used in C code.
- *
- * @return the name to be used in C code
- */
- public string get_cname () {
- if (cname == null) {
- cname = camel_case_to_lower_case (name);
- }
- return cname;
- }
-
- public void set_cname (string cname) {
- this.cname = cname;
- }
/**
* Returns the string literal of this signal to be used in C code.
diff --git a/vala/valastruct.vala b/vala/valastruct.vala
index c444d48..5c77270 100644
--- a/vala/valastruct.vala
+++ b/vala/valastruct.vala
@@ -33,10 +33,6 @@ public class Vala.Struct : TypeSymbol {
private List<Property> properties = new ArrayList<Property> ();
private DataType _base_type = null;
- private string cname;
- private string const_cname;
- private string lower_case_cprefix;
- private string lower_case_csuffix;
private bool? boolean_type;
private bool? integer_type;
private bool? floating_type;
@@ -255,63 +251,6 @@ public class Vala.Struct : TypeSymbol {
}
}
- public override string get_cname (bool const_type = false) {
- if (const_type && const_cname != null) {
- return const_cname;
- }
-
- if (cname == null) {
- cname = get_attribute_string ("CCode", "cname");
- if (cname == null) {
- cname = get_default_cname ();
- }
- }
- return cname;
- }
-
- public void set_cname (string cname) {
- this.cname = cname;
- }
-
- /**
- * Returns the default name of this struct as it is used in C code.
- *
- * @return the name to be used in C code by default
- */
- public string get_default_cname () {
- // parent_symbol may be null in GIR parser
- if (parent_symbol != null) {
- return "%s%s".printf (parent_symbol.get_cprefix (), name);
- } else {
- return name;
- }
- }
-
- private void set_const_cname (string cname) {
- this.const_cname = cname;
- }
-
- public override string get_lower_case_cprefix () {
- if (lower_case_cprefix == null) {
- lower_case_cprefix = "%s_".printf (get_lower_case_cname (null));
- }
- return lower_case_cprefix;
- }
-
- private string get_lower_case_csuffix () {
- if (lower_case_csuffix == null) {
- lower_case_csuffix = camel_case_to_lower_case (name);
- }
- return lower_case_csuffix;
- }
-
- public override string? get_lower_case_cname (string? infix) {
- if (infix == null) {
- infix = "";
- }
- return "%s%s%s".printf (parent_symbol.get_lower_case_cprefix (), infix, get_lower_case_csuffix ());
- }
-
/**
* Returns whether this is a boolean type.
*
@@ -411,15 +350,6 @@ public class Vala.Struct : TypeSymbol {
}
}
- private void process_ccode_attribute (Attribute a) {
- if (a.has_argument ("const_cname")) {
- set_const_cname (a.get_string ("const_cname"));
- }
- if (a.has_argument ("cprefix")) {
- lower_case_cprefix = a.get_string ("cprefix");
- }
- }
-
private void process_boolean_type_attribute (Attribute a) {
boolean_type = true;
}
@@ -447,9 +377,7 @@ public class Vala.Struct : TypeSymbol {
*/
public void process_attributes () {
foreach (Attribute a in attributes) {
- if (a.name == "CCode") {
- process_ccode_attribute (a);
- } else if (a.name == "IntegerType") {
+ if (a.name == "IntegerType") {
process_integer_type_attribute (a);
} else if (a.name == "FloatingType") {
process_floating_type_attribute (a);
diff --git a/vala/valasymbol.vala b/vala/valasymbol.vala
index 39a65c8..7b40b9c 100644
--- a/vala/valasymbol.vala
+++ b/vala/valasymbol.vala
@@ -268,29 +268,6 @@ public abstract class Vala.Symbol : CodeNode {
}
/**
- * Returns the C name of this symbol in lower case. Words are
- * separated by underscores. The lower case C name of the parent symbol
- * is prefix of the result, if there is one.
- *
- * @param infix a string to be placed between namespace and data type
- * name or null
- * @return the lower case name to be used in C code
- */
- public virtual string? get_lower_case_cname (string? infix = null) {
- return null;
- }
-
- /**
- * Returns the string to be prefixed to members of this symbol in
- * lower case when used in C code.
- *
- * @return the lower case prefix to be used in C code
- */
- public virtual string get_lower_case_cprefix () {
- return "";
- }
-
- /**
* Converts a string from CamelCase to lower_case.
*
* @param camel_case a string in camel case
diff --git a/vala/valatypesymbol.vala b/vala/valatypesymbol.vala
index bbb9688..8ba3aef 100644
--- a/vala/valatypesymbol.vala
+++ b/vala/valatypesymbol.vala
@@ -34,13 +34,6 @@ public abstract class Vala.TypeSymbol : Symbol {
}
/**
- * Returns the name of this data type as it is used in C code.
- *
- * @return the name to be used in C code
- */
- public abstract string get_cname (bool const_type = false);
-
- /**
* Checks whether this data type has value or reference type semantics.
*
* @return true if this data type has reference type semantics
@@ -48,11 +41,6 @@ public abstract class Vala.TypeSymbol : Symbol {
public virtual bool is_reference_type () {
return false;
}
-
-
- public virtual string? get_upper_case_cname (string? infix = null) {
- return null;
- }
/**
* Checks whether this data type is equal to or a subtype of the
diff --git a/vala/valavaluetype.vala b/vala/valavaluetype.vala
index baec19e..d78af99 100644
--- a/vala/valavaluetype.vala
+++ b/vala/valavaluetype.vala
@@ -36,14 +36,6 @@ public abstract class Vala.ValueType : DataType {
data_type = type_symbol;
}
- public override string? get_cname () {
- string ptr = "";
- if (nullable) {
- ptr = "*";
- }
- return type_symbol.get_cname () + ptr;
- }
-
public override bool is_disposable () {
if (!value_owned) {
return false;
diff --git a/vala/valavoidtype.vala b/vala/valavoidtype.vala
index 89771c5..9035c25 100644
--- a/vala/valavoidtype.vala
+++ b/vala/valavoidtype.vala
@@ -38,10 +38,6 @@ public class Vala.VoidType : DataType {
return "void";
}
- public override string? get_cname () {
- return "void";
- }
-
public override DataType copy () {
return new VoidType (source_reference);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]