summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--codegen/valaccodeattribute.vala12
-rw-r--r--vala/valaarrayresizemethod.vala2
-rw-r--r--vala/valaarraytype.vala40
-rw-r--r--vala/valaclass.vala406
-rw-r--r--vala/valaclasstype.vala4
-rw-r--r--vala/valaconstant.vala58
-rw-r--r--vala/valacreationmethod.vala60
-rw-r--r--vala/valadatatype.vala71
-rw-r--r--vala/valadelegate.vala131
-rw-r--r--vala/valadelegatetype.vala12
-rw-r--r--vala/valadynamicmethod.vala15
-rw-r--r--vala/valadynamicproperty.vala4
-rw-r--r--vala/valaenum.vala193
-rw-r--r--vala/valaenumvalue.vala7
-rw-r--r--vala/valaerrorcode.vala41
-rw-r--r--vala/valaerrordomain.vala110
-rw-r--r--vala/valaerrortype.vala26
-rw-r--r--vala/valafield.vala76
-rw-r--r--vala/valagenerictype.vala16
-rw-r--r--vala/valainterface.vala253
-rw-r--r--vala/valainterfacetype.vala4
-rw-r--r--vala/valalambdaexpression.vala4
-rw-r--r--vala/valamethod.vala286
-rw-r--r--vala/valamethodtype.vala4
-rw-r--r--vala/valanamespace.vala117
-rw-r--r--vala/valanulltype.vala8
-rw-r--r--vala/valaobjectcreationexpression.vala3
-rw-r--r--vala/valaobjecttype.vala10
-rw-r--r--vala/valaparameter.vala61
-rw-r--r--vala/valapointertype.vala14
-rw-r--r--vala/valaproperty.vala118
-rw-r--r--vala/valapropertyaccessor.vala41
-rw-r--r--vala/valasemanticanalyzer.vala2
-rw-r--r--vala/valasignal.vala115
-rw-r--r--vala/valastruct.vala371
-rw-r--r--vala/valasymbol.vala135
-rw-r--r--vala/valatypesymbol.vala180
-rw-r--r--vala/valavaluetype.vala8
-rw-r--r--vala/valavariable.vala111
-rw-r--r--vala/valavoidtype.vala8
40 files changed, 93 insertions, 3044 deletions
diff --git a/codegen/valaccodeattribute.vala b/codegen/valaccodeattribute.vala
index d8a3dd7ba..b28e96843 100644
--- a/codegen/valaccodeattribute.vala
+++ b/codegen/valaccodeattribute.vala
@@ -593,11 +593,15 @@ public class Vala.CCodeAttribute : AttributeCache {
} else if (node is ErrorType) {
return "GError*";
} else if (node is GenericType) {
- var type = (GenericType) node;
- if (type.value_owned) {
- return "gpointer";
+ if (CodeContext.get ().profile == Profile.GOBJECT) {
+ var type = (GenericType) node;
+ if (type.value_owned) {
+ return "gpointer";
+ } else {
+ return "gconstpointer";
+ }
} else {
- return "gconstpointer";
+ return "void *";
}
} else if (node is MethodType) {
return "gpointer";
diff --git a/vala/valaarrayresizemethod.vala b/vala/valaarrayresizemethod.vala
index ff9bc6173..c1008777e 100644
--- a/vala/valaarrayresizemethod.vala
+++ b/vala/valaarrayresizemethod.vala
@@ -34,6 +34,6 @@ public class Vala.ArrayResizeMethod : Method {
public ArrayResizeMethod (SourceReference source_reference) {
base ("resize", new VoidType (), source_reference);
external = true;
- cinstance_parameter_position = 0.1;
+ set_attribute_double ("CCode", "instance_pos", 0.1);
}
}
diff --git a/vala/valaarraytype.vala b/vala/valaarraytype.vala
index ed284105f..4bba50ec3 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);
@@ -179,14 +167,16 @@ public class Vala.ArrayType : ReferenceType {
}
public override bool compatible (DataType target_type) {
- if (target_type.get_type_id () == "G_TYPE_VALUE" && element_type.data_type == CodeContext.get ().root.scope.lookup ("string")) {
- // allow implicit conversion from string[] to GValue
- return true;
- }
+ if (CodeContext.get ().profile == Profile.GOBJECT && target_type.data_type != null) {
+ if (target_type.data_type.is_subtype_of (CodeContext.get ().analyzer.gvalue_type.data_type) && element_type.data_type == CodeContext.get ().root.scope.lookup ("string")) {
+ // allow implicit conversion from string[] to GValue
+ return true;
+ }
- if (target_type.get_type_id () == "G_TYPE_VARIANT") {
- // allow implicit conversion to GVariant
- return true;
+ if (target_type.data_type.is_subtype_of (CodeContext.get ().analyzer.gvariant_type.data_type)) {
+ // allow implicit conversion to GVariant
+ return true;
+ }
}
if (target_type is PointerType || (target_type.data_type != null && target_type.data_type.get_attribute ("PointerType") != null)) {
@@ -243,14 +233,6 @@ public class Vala.ArrayType : ReferenceType {
return element_type.check (context);
}
- public override string? get_type_id () {
- if (element_type.data_type == CodeContext.get ().root.scope.lookup ("string")) {
- return "G_TYPE_STRV";
- } else {
- return null;
- }
- }
-
public override DataType get_actual_type (DataType? derived_instance_type, MemberAccess? method_access, CodeNode node_reference) {
if (derived_instance_type == null && method_access == null) {
return this;
diff --git a/vala/valaclass.vala b/vala/valaclass.vala
index 038550e09..87a044187 100644
--- a/vala/valaclass.vala
+++ b/vala/valaclass.vala
@@ -44,8 +44,12 @@ public class Vala.Class : ObjectTypeSymbol {
*/
public bool is_compact {
get {
- if (base_class != null) {
- return base_class.is_compact;
+ if (_is_compact == null) {
+ if (base_class != null) {
+ _is_compact = base_class.is_compact;
+ } else {
+ _is_compact = get_attribute ("Compact") != null;
+ }
}
if (_is_compact == null) {
_is_compact = get_attribute ("Compact") != null;
@@ -63,8 +67,12 @@ public class Vala.Class : ObjectTypeSymbol {
*/
public bool is_immutable {
get {
- if (base_class != null) {
- return base_class.is_immutable;
+ if (_is_immutable == null) {
+ if (base_class != null) {
+ _is_immutable = base_class.is_immutable;
+ } else {
+ _is_immutable = get_attribute ("Immutable") != null;
+ }
}
if (_is_immutable == null) {
_is_immutable = get_attribute ("Immutable") != null;
@@ -78,29 +86,6 @@ public class Vala.Class : ObjectTypeSymbol {
}
/**
- * Specifies wheather the ref function returns void instead of the
- * object.
- */
- public bool ref_function_void {
- get {
- if (base_class != null) {
- return base_class.ref_function_void;
- }
- return _ref_function_void;
- }
- set {
- _ref_function_void = value;
- }
- }
-
- /**
- * The name of the function to use to check whether a value is an instance of
- * this class. If this is null then the default type check function should be
- * used instead.
- */
- public string? type_check_function { get; set; }
-
- /**
* Specifies whether this class has private fields.
*/
public bool has_private_fields { get; set; }
@@ -110,30 +95,6 @@ public class Vala.Class : ObjectTypeSymbol {
*/
public bool has_class_private_fields { get; private set; }
- /**
- * Specifies whether the free function requires the address of a
- * pointer instead of just the pointer.
- */
- public bool free_function_address_of { get; private set; }
-
- public bool is_gboxed { get { return (free_function == "g_boxed_free"); } }
-
- private string cname;
- public string const_cname { get; set; }
- private string lower_case_cprefix;
- private string lower_case_csuffix;
- private string type_id;
- private string ref_function;
- private string unref_function;
- private bool _ref_function_void;
- private string ref_sink_function;
- private string param_spec_function;
- private string copy_function;
- private string free_function;
- private string marshaller_type_name;
- private string get_value_function;
- private string set_value_function;
- private string take_value_function;
private bool? _is_compact;
private bool? _is_immutable;
@@ -592,281 +553,10 @@ 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) {
- var attr = get_attribute ("CCode");
- if (attr != null) {
- cname = attr.get_string ("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 string? get_upper_case_cname (string? infix) {
- return get_lower_case_cname (infix).up ();
- }
-
public override bool is_reference_type () {
return true;
}
- private void process_gir_attribute (Attribute a) {
- if (a.has_argument ("name")) {
- gir_name = a.get_string ("name");
- }
- }
-
- private void process_ccode_attribute (Attribute a) {
- if (a.has_argument ("ref_function")) {
- set_ref_function (a.get_string ("ref_function"));
- }
- if (a.has_argument ("ref_function_void")) {
- this.ref_function_void = a.get_bool ("ref_function_void");
- }
- if (a.has_argument ("unref_function")) {
- set_unref_function (a.get_string ("unref_function"));
- }
- if (a.has_argument ("ref_sink_function")) {
- set_ref_sink_function (a.get_string ("ref_sink_function"));
- }
- if (a.has_argument ("copy_function")) {
- set_dup_function (a.get_string ("copy_function"));
- }
- if (a.has_argument ("free_function")) {
- set_free_function (a.get_string ("free_function"));
- }
- if (a.has_argument ("free_function_address_of")) {
- free_function_address_of = a.get_bool ("free_function_address_of");
- }
- if (a.has_argument ("type_id")) {
- type_id = a.get_string ("type_id");
- }
- if (a.has_argument ("marshaller_type_name")) {
- marshaller_type_name = a.get_string ("marshaller_type_name");
- }
- if (a.has_argument ("get_value_function")) {
- get_value_function = a.get_string ("get_value_function");
- }
- if (a.has_argument ("set_value_function")) {
- set_value_function = a.get_string ("set_value_function");
- }
- if (a.has_argument ("take_value_function")) {
- take_value_function = a.get_string ("take_value_function");
- }
-
- 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");
- }
- if (a.has_argument ("cheader_filename")) {
- var val = a.get_string ("cheader_filename");
- foreach (string filename in val.split (",")) {
- add_cheader_filename (filename);
- }
- }
- if (a.has_argument ("type_check_function")) {
- type_check_function = a.get_string ("type_check_function");
- }
-
- if (a.has_argument ("param_spec_function")) {
- param_spec_function = a.get_string ("param_spec_function");
- }
- }
-
- /**
- * 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 == "GIR") {
- process_gir_attribute (a);
- }
- }
- }
-
- 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) {
- type_id = get_default_type_id ();
- }
-
- return type_id;
- }
-
- public void set_type_id (string type_id) {
- this.type_id = type_id;
- }
-
- public override string? get_marshaller_type_name () {
- if (marshaller_type_name == null) {
- if (base_class != null) {
- marshaller_type_name = base_class.get_marshaller_type_name ();
- } else if (!is_compact) {
- marshaller_type_name = get_upper_case_cname ();
- } else if (get_type_id () == "G_TYPE_POINTER") {
- marshaller_type_name = "POINTER";
- } else {
- marshaller_type_name = "BOXED";
- }
- }
-
- return marshaller_type_name;
- }
-
- public override string? get_param_spec_function () {
- if (param_spec_function == null) {
- param_spec_function = get_default_param_spec_function ();
- }
-
- return param_spec_function;
- }
-
- public string? get_default_param_spec_function () {
- if (is_fundamental ()) {
- return get_lower_case_cname ("param_spec_");
- } else if (base_class != null) {
- return base_class.get_param_spec_function ();
- } else if (get_type_id () == "G_TYPE_POINTER") {
- return "g_param_spec_pointer";
- } else {
- return "g_param_spec_boxed";
- }
- }
-
- public override string? get_get_value_function () {
- if (get_value_function == null) {
- if (is_fundamental ()) {
- get_value_function = get_lower_case_cname ("value_get_");
- } else if (base_class != null) {
- get_value_function = base_class.get_get_value_function ();
- } else if (get_type_id () == "G_TYPE_POINTER") {
- get_value_function = "g_value_get_pointer";
- } else {
- get_value_function = "g_value_get_boxed";
- }
- }
-
- return get_value_function;
- }
-
- public override string? get_set_value_function () {
- if (set_value_function == null) {
- if (is_fundamental ()) {
- set_value_function = get_lower_case_cname ("value_set_");
- } else if (base_class != null) {
- set_value_function = base_class.get_set_value_function ();
- } else if (get_type_id () == "G_TYPE_POINTER") {
- set_value_function = "g_value_set_pointer";
- } else {
- set_value_function = "g_value_set_boxed";
- }
- }
-
- return set_value_function;
- }
-
- public override string? get_take_value_function () {
- if (take_value_function == null) {
- if (is_fundamental ()) {
- take_value_function = get_lower_case_cname ("value_take_");
- } else if (base_class != null) {
- take_value_function = base_class.get_take_value_function ();
- } else if (get_type_id () == "G_TYPE_POINTER") {
- take_value_function = "g_value_set_pointer";
- } else {
- take_value_function = "g_value_take_boxed";
- }
- }
-
- return take_value_function;
- }
-
- public override bool is_reference_counting () {
- return get_ref_function () != null;
- }
-
public bool is_fundamental () {
if (!is_compact && base_class == null) {
return true;
@@ -876,76 +566,6 @@ public class Vala.Class : ObjectTypeSymbol {
return false;
}
- public override string? get_ref_function () {
- if (ref_function == null && is_fundamental ()) {
- ref_function = get_lower_case_cprefix () + "ref";
- }
-
- if (ref_function == null && base_class != null) {
- return base_class.get_ref_function ();
- } else {
- return ref_function;
- }
- }
-
- public void set_ref_function (string? name) {
- this.ref_function = name;
- }
-
- public override string? get_unref_function () {
- if (unref_function == null && is_fundamental ()) {
- unref_function = get_lower_case_cprefix () + "unref";
- }
-
- if (unref_function == null && base_class != null) {
- return base_class.get_unref_function ();
- } else {
- return unref_function;
- }
- }
-
- public void set_unref_function (string? name) {
- this.unref_function = name;
- }
-
- public override string? get_ref_sink_function () {
- if (ref_sink_function == null && base_class != null) {
- return base_class.get_ref_sink_function ();
- } else {
- return ref_sink_function;
- }
- }
-
- public void set_ref_sink_function (string? name) {
- this.ref_sink_function = name;
- }
-
- public override string? get_dup_function () {
- return copy_function;
- }
-
- public void set_dup_function (string? name) {
- this.copy_function = name;
- }
-
- public string get_default_free_function () {
- if (base_class != null) {
- return base_class.get_free_function ();
- }
- return get_lower_case_cprefix () + "free";
- }
-
- public override string? get_free_function () {
- if (free_function == null) {
- free_function = get_default_free_function ();
- }
- return free_function;
- }
-
- public void set_free_function (string name) {
- this.free_function = name;
- }
-
public override bool is_subtype_of (TypeSymbol t) {
if (this == t) {
return true;
@@ -1010,8 +630,6 @@ public class Vala.Class : ObjectTypeSymbol {
checked = true;
- process_attributes ();
-
var old_source_file = context.analyzer.current_source_file;
var old_symbol = context.analyzer.current_symbol;
diff --git a/vala/valaclasstype.vala b/vala/valaclasstype.vala
index aef62b71e..a0430a12c 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 0934ac07e..7361f9b06 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,29 +105,6 @@ public class Vala.Constant : Symbol, Lockable {
}
}
- private void process_ccode_attribute (Attribute a) {
- if (a.has_argument ("cname")) {
- cname = a.get_string ("cname");
- }
- if (a.has_argument ("cheader_filename")) {
- var val = a.get_string ("cheader_filename");
- foreach (string filename in val.split (",")) {
- add_cheader_filename (filename);
- }
- }
- }
-
- /**
- * 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;
@@ -168,8 +112,6 @@ public class Vala.Constant : Symbol, Lockable {
checked = true;
- process_attributes ();
-
var old_source_file = context.analyzer.current_source_file;
var old_symbol = context.analyzer.current_symbol;
diff --git a/vala/valacreationmethod.vala b/vala/valacreationmethod.vala
index 7ece293ca..826a0db90 100644
--- a/vala/valacreationmethod.vala
+++ b/vala/valacreationmethod.vala
@@ -49,9 +49,6 @@ public class Vala.CreationMethod : Method {
public CreationMethod (string? class_name, string? name, SourceReference? source_reference = null, Comment? comment = null) {
base (name, new VoidType (), source_reference, comment);
this.class_name = class_name;
-
- carray_length_parameter_position = -3;
- cdelegate_target_parameter_position = -3;
}
public override void accept (CodeVisitor visitor) {
@@ -80,61 +77,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 string get_real_cname () {
- var ccode_attribute = get_attribute ("CCode");
- if (ccode_attribute != null && ccode_attribute.has_argument ("construct_function")) {
- return ccode_attribute.get_string ("construct_function");
- }
-
- return get_default_construct_function ();
- }
-
- public string get_default_construct_function () {
- var parent = parent_symbol as Class;
-
- if (parent == null || parent.is_compact) {
- return get_cname ();
- }
-
- string infix = "construct";
-
- if (CodeContext.get ().profile == Profile.DOVA) {
- 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;
@@ -142,8 +84,6 @@ public class Vala.CreationMethod : Method {
checked = true;
- process_attributes ();
-
if (class_name != null && class_name != parent_symbol.name) {
// class_name is null for constructors generated by GIdlParser
Report.error (source_reference, "missing return type in method `%s.%s´".printf (context.analyzer.current_symbol.get_full_name (), class_name));
diff --git a/vala/valadatatype.vala b/vala/valadatatype.vala
index c53ce5c7c..0b2847cf1 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);
}
@@ -313,14 +266,16 @@ public abstract class Vala.DataType : CodeNode {
return false;
}
- if (target_type.get_type_id () == "G_TYPE_VALUE" && get_type_id () != null) {
- // allow implicit conversion to GValue
- return true;
- }
+ if (CodeContext.get ().profile == Profile.GOBJECT && target_type.data_type != null) {
+ if (target_type.data_type.is_subtype_of (CodeContext.get ().analyzer.gvalue_type.data_type)) {
+ // allow implicit conversion to GValue
+ return true;
+ }
- if (target_type.get_type_id () == "G_TYPE_VARIANT") {
- // allow implicit conversion to GVariant
- return true;
+ if (target_type.data_type.is_subtype_of (CodeContext.get ().analyzer.gvariant_type.data_type)) {
+ // allow implicit conversion to GVariant
+ return true;
+ }
}
if (this is ValueType && target_type.data_type != null && target_type.data_type.get_full_name () == "Dova.Value") {
@@ -474,14 +429,6 @@ public abstract class Vala.DataType : CodeNode {
return is_real_struct_type () && !nullable;
}
- public virtual string? get_type_id () {
- if (data_type != null) {
- return data_type.get_type_id ();
- } else {
- return null;
- }
- }
-
/**
* Returns whether the value needs to be disposed, i.e. whether
* allocated memory or other resources need to be released when
diff --git a/vala/valadelegate.vala b/vala/valadelegate.vala
index d4cfaa0b9..d949c611f 100644
--- a/vala/valadelegate.vala
+++ b/vala/valadelegate.vala
@@ -61,43 +61,9 @@ public class Vala.Delegate : TypeSymbol {
public DataType? sender_type { get; set; }
- /**
- * Specifies the position of the instance parameter in the C function.
- */
- public double cinstance_parameter_position { get; set; }
-
- /**
- * Specifies the position of the array length out parameter in the C
- * function.
- */
- public double carray_length_parameter_position { get; set; }
-
- /**
- * Specifies the position of the delegate target out parameter in the C
- * function.
- */
- public double cdelegate_target_parameter_position { get; set; }
-
- /**
- * Specifies whether the array length should be returned implicitly
- * if the return type is an array.
- */
- public bool no_array_length { get; set; }
-
- /**
- * Specifies whether the array is null terminated.
- */
- public bool array_null_terminated { get; set; }
-
- /**
- * Specifies a custom type for the array length parameter.
- */
- public string? array_length_type { get; set; default = null; }
-
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;
@@ -113,11 +79,6 @@ public class Vala.Delegate : TypeSymbol {
public Delegate (string? name, DataType return_type, SourceReference? source_reference = null, Comment? comment = null) {
base (name, source_reference, comment);
this.return_type = return_type;
-
- // error is -1 (right of user_data)
- cinstance_parameter_position = -2;
- carray_length_parameter_position = -3;
- cdelegate_target_parameter_position = -3;
}
/**
@@ -151,12 +112,6 @@ public class Vala.Delegate : TypeSymbol {
* @param param a formal parameter
*/
public void add_parameter (Parameter param) {
- // default C parameter position
- param.cparameter_position = parameters.size + 1;
- param.carray_length_parameter_position = param.cparameter_position + 0.1;
- param.cdelegate_target_parameter_position = param.cparameter_position + 0.1;
- param.cdestroy_notify_parameter_position = param.cparameter_position + 0.1;
-
parameters.add (param);
scope.add (param.name, param);
}
@@ -268,94 +223,10 @@ 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));
- }
-
- public override string? get_upper_case_cname (string? infix) {
- return get_lower_case_cname (infix).up ();
- }
-
- private void process_ccode_attribute (Attribute a) {
- if (a.has_argument ("cname")) {
- set_cname (a.get_string ("cname"));
- }
- if (a.has_argument ("instance_pos")) {
- cinstance_parameter_position = a.get_double ("instance_pos");
- }
- if (a.has_argument ("array_length")) {
- no_array_length = !a.get_bool ("array_length");
- }
- if (a.has_argument ("array_length_type")) {
- array_length_type = a.get_string ("array_length_type");
- }
- if (a.has_argument ("array_null_terminated")) {
- array_null_terminated = a.get_bool ("array_null_terminated");
- }
- if (a.has_argument ("array_length_pos")) {
- carray_length_parameter_position = a.get_double ("array_length_pos");
- }
- if (a.has_argument ("delegate_target_pos")) {
- cdelegate_target_parameter_position = a.get_double ("delegate_target_pos");
- }
- if (a.has_argument ("cheader_filename")) {
- var val = a.get_string ("cheader_filename");
- foreach (string filename in val.split (",")) {
- add_cheader_filename (filename);
- }
- }
- }
-
- /**
- * Process all associated attributes.
- */
- public void process_attributes () {
- foreach (Attribute a in attributes) {
- if (a.name == "CCode") {
- process_ccode_attribute (a);
- }
- }
- }
-
public override bool is_reference_type () {
return false;
}
- public override string? get_type_id () {
- return "G_TYPE_POINTER";
- }
-
- public override string? get_marshaller_type_name () {
- return "POINTER";
- }
-
- public override string? get_get_value_function () {
- return "g_value_get_pointer";
- }
-
- public override string? get_set_value_function () {
- return "g_value_set_pointer";
- }
-
public override void replace_type (DataType old_type, DataType new_type) {
if (return_type == old_type) {
return_type = new_type;
@@ -425,8 +296,6 @@ public class Vala.Delegate : TypeSymbol {
checked = true;
- process_attributes ();
-
var old_source_file = context.analyzer.current_source_file;
if (source_reference != null) {
diff --git a/vala/valadelegatetype.vala b/vala/valadelegatetype.vala
index 11648cad1..2cc6cf0db 100644
--- a/vala/valadelegatetype.vala
+++ b/vala/valadelegatetype.vala
@@ -107,22 +107,10 @@ 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);
}
- public override string? get_type_id () {
- return "G_TYPE_POINTER";
- }
-
public override bool check (CodeContext context) {
return delegate_symbol.check (context);
}
diff --git a/vala/valadynamicmethod.vala b/vala/valadynamicmethod.vala
index 3fc98f6f6..845c0af54 100644
--- a/vala/valadynamicmethod.vala
+++ b/vala/valadynamicmethod.vala
@@ -30,26 +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 List<string> get_cheader_filenames () {
- return new ArrayList<string> ();
- }
-
- 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/valadynamicproperty.vala b/vala/valadynamicproperty.vala
index dc9acb568..a15ff2f7d 100644
--- a/vala/valadynamicproperty.vala
+++ b/vala/valadynamicproperty.vala
@@ -33,10 +33,6 @@ public class Vala.DynamicProperty : Property {
this.dynamic_type = dynamic_type;
}
- public override List<string> get_cheader_filenames () {
- return new ArrayList<string> ();
- }
-
public override bool check (CodeContext context) {
return true;
}
diff --git a/vala/valaenum.vala b/vala/valaenum.vala
index 28d3151f8..eeabda917 100644
--- a/vala/valaenum.vala
+++ b/vala/valaenum.vala
@@ -29,21 +29,20 @@ public class Vala.Enum : TypeSymbol {
/**
* Specifies whether this is a flags enum.
*/
- public bool is_flags { get; set; }
-
- /**
- * Specifies whether this enum has a registered GType.
- */
- public bool has_type_id { get; set; default = true; }
+ public bool is_flags {
+ get {
+ if (_is_flags == null) {
+ _is_flags = get_attribute ("Flags") != null;
+ }
+ return _is_flags;
+ }
+ }
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;
- private string type_id;
+
+ private bool? _is_flags;
/**
* Creates a new enum.
@@ -153,180 +152,10 @@ public class Vala.Enum : TypeSymbol {
}
}
- public override string get_cname (bool const_type = false) {
- if (cname == null) {
- var attr = get_attribute ("CCode");
- if (attr != null) {
- cname = attr.get_string ("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");
- }
- if (a.has_argument ("cheader_filename")) {
- var val = a.get_string ("cheader_filename");
- foreach (string filename in val.split (",")) {
- add_cheader_filename (filename);
- }
- }
- if (a.has_argument ("has_type_id")) {
- has_type_id = a.get_bool ("has_type_id");
- }
- if (a.has_argument ("type_id")) {
- type_id = a.get_string ("type_id");
- }
- }
-
- /**
- * 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") {
- is_flags = true;
- }
- }
- }
-
- public void set_type_id (string? type_id) {
- this.type_id = type_id;
- }
-
- public override string? get_type_id () {
- if (type_id == null) {
- if (has_type_id) {
- type_id = get_upper_case_cname ("TYPE_");
- } else {
- type_id = is_flags ? "G_TYPE_UINT" : "G_TYPE_INT";
- }
- }
-
- return type_id;
- }
-
- public override string? get_marshaller_type_name () {
- if (has_type_id) {
- if (is_flags) {
- return "FLAGS";
- } else {
- return "ENUM";
- }
- } else {
- if (is_flags) {
- return "UINT";
- } else {
- return "INT";
- }
- }
- }
-
- public override string? get_get_value_function () {
- if (has_type_id) {
- if (is_flags) {
- return "g_value_get_flags";
- } else {
- return "g_value_get_enum";
- }
- } else {
- if (is_flags) {
- return "g_value_get_uint";
- } else {
- return "g_value_get_int";
- }
- }
- }
-
- public override string? get_set_value_function () {
- if (has_type_id) {
- if (is_flags) {
- return "g_value_set_flags";
- } else {
- return "g_value_set_enum";
- }
- } else {
- if (is_flags) {
- return "g_value_set_uint";
- } else {
- return "g_value_set_int";
- }
- }
- }
-
- public override string? get_default_value () {
- return "0";
- }
-
public override bool check (CodeContext context) {
if (checked) {
return !error;
@@ -334,8 +163,6 @@ public class Vala.Enum : TypeSymbol {
checked = true;
- process_attributes ();
-
var old_source_file = context.analyzer.current_source_file;
var old_symbol = context.analyzer.current_symbol;
diff --git a/vala/valaenumvalue.vala b/vala/valaenumvalue.vala
index 4a04b8569..05d4494c3 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;
@@ -86,8 +81,6 @@ public class Vala.EnumValue : Constant {
checked = true;
- process_attributes ();
-
if (value != null) {
value.check (context);
}
diff --git a/vala/valaerrorcode.vala b/vala/valaerrorcode.vala
index eace48cce..aa97641c5 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 2ac860c38..a73dcf84d 100644
--- a/vala/valaerrordomain.vala
+++ b/vala/valaerrordomain.vala
@@ -28,10 +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;
/**
* Creates a new error domain.
@@ -107,114 +103,10 @@ 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");
- }
- if (a.has_argument ("cheader_filename")) {
- var val = a.get_string ("cheader_filename");
- foreach (string filename in val.split (",")) {
- add_cheader_filename (filename);
- }
- }
- }
-
- /**
- * Process all associated attributes.
- */
- public void process_attributes () {
- foreach (Attribute a in attributes) {
- if (a.name == "CCode") {
- process_ccode_attribute (a);
- }
- }
- }
-
- public override string? get_type_id () {
- return "G_TYPE_POINTER";
- }
-
- public override string? get_marshaller_type_name () {
- return "POINTER";
- }
-
- public override string? get_get_value_function () {
- return "g_value_get_pointer";
- }
-
- public override string? get_set_value_function () {
- return "g_value_set_pointer";
- }
-
public override bool check (CodeContext context) {
if (checked) {
return !error;
@@ -222,8 +114,6 @@ public class Vala.ErrorDomain : TypeSymbol {
checked = true;
- process_attributes ();
-
foreach (ErrorCode ecode in codes) {
ecode.check (context);
}
diff --git a/vala/valaerrortype.vala b/vala/valaerrortype.vala
index 33f5e41fe..c7c9f9348 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;
@@ -135,14 +117,6 @@ public class Vala.ErrorType : ReferenceType {
return gerror_symbol.scope.lookup (member_name);
}
- public override string? get_type_id () {
- if (source_reference != null && source_reference.file.context.require_glib_version (2, 26)) {
- return "G_TYPE_ERROR";
- } else {
- return "G_TYPE_POINTER";
- }
- }
-
public override bool is_reference_type_or_type_parameter () {
return true;
}
diff --git a/vala/valafield.vala b/vala/valafield.vala
index 5926a3179..8b932a5df 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;
/**
@@ -67,65 +65,6 @@ 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"));
- }
- if (a.has_argument ("cheader_filename")) {
- var val = a.get_string ("cheader_filename");
- foreach (string filename in val.split (",")) {
- add_cheader_filename (filename);
- }
- }
- }
-
- /**
- * 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);
- }
- }
- }
-
public bool get_lock_used () {
return lock_used;
}
@@ -147,20 +86,11 @@ public class Vala.Field : Variable, Lockable {
}
public string? get_ctype () {
- var attr = get_attribute ("CCode");
- if (attr == null) {
- return null;
- }
- return attr.get_string ("type");
+ return get_attribute_string ("CCode", "type");
}
public void set_ctype (string ctype) {
- var attr = get_attribute ("CCode");
- if (attr == null) {
- attr = new Attribute ("CCode");
- attributes.append (attr);
- }
- attr.add_argument ("type", "\"%s\"".printf (ctype));
+ set_attribute_string ("CCode", "type", ctype);
}
public override bool check (CodeContext context) {
@@ -193,8 +123,6 @@ public class Vala.Field : Variable, Lockable {
return false;
}
- process_attributes ();
-
if (initializer != null) {
initializer.target_type = variable_type;
diff --git a/vala/valagenerictype.vala b/vala/valagenerictype.vala
index 3e881e518..c7d7991c6 100644
--- a/vala/valagenerictype.vala
+++ b/vala/valagenerictype.vala
@@ -42,22 +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? get_type_id () {
- return "G_TYPE_POINTER";
- }
-
public override string to_qualified_string (Scope? scope = null) {
return type_parameter.name;
}
diff --git a/vala/valainterface.vala b/vala/valainterface.vala
index e738e79fa..548304f07 100644
--- a/vala/valainterface.vala
+++ b/vala/valainterface.vala
@@ -40,11 +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;
- private string type_id;
-
/**
* Returns a copy of the list of classes.
*
@@ -276,96 +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) {
- var attr = get_attribute ("CCode");
- if (attr != null) {
- cname = attr.get_string ("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 string? get_upper_case_cname (string? infix) {
- return get_lower_case_cname (infix).up ();
- }
-
public override void accept (CodeVisitor visitor) {
visitor.visit_interface (this);
}
@@ -420,41 +325,7 @@ public class Vala.Interface : ObjectTypeSymbol {
public override bool is_reference_type () {
return true;
}
-
- public override bool is_reference_counting () {
- return true;
- }
- public override string? get_ref_function () {
- foreach (DataType prerequisite in prerequisites) {
- string ref_func = prerequisite.data_type.get_ref_function ();
- if (ref_func != null) {
- return ref_func;
- }
- }
- return null;
- }
-
- public override string? get_unref_function () {
- foreach (DataType prerequisite in prerequisites) {
- string unref_func = prerequisite.data_type.get_unref_function ();
- if (unref_func != null) {
- return unref_func;
- }
- }
- return null;
- }
-
- public override string? get_ref_sink_function () {
- foreach (DataType prerequisite in prerequisites) {
- string ref_sink_func = prerequisite.data_type.get_ref_sink_function ();
- if (ref_sink_func != null) {
- return ref_sink_func;
- }
- }
- return null;
- }
-
public override bool is_subtype_of (TypeSymbol t) {
if (this == t) {
return true;
@@ -469,109 +340,6 @@ 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 ("cheader_filename")) {
- var val = a.get_string ("cheader_filename");
- foreach (string filename in val.split (",")) {
- add_cheader_filename (filename);
- }
- }
- 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);
- }
- }
- }
-
- /**
- * 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 string? get_marshaller_type_name () {
- foreach (DataType prerequisite in prerequisites) {
- string type_name = prerequisite.data_type.get_marshaller_type_name ();
- if (type_name != null) {
- return type_name;
- }
- }
- return "POINTER";
- }
-
- public override string? get_get_value_function () {
- foreach (DataType prerequisite in prerequisites) {
- string get_value_func = prerequisite.data_type.get_get_value_function ();
- if (get_value_func != null) {
- return get_value_func;
- }
- }
- return "g_value_get_pointer";
- }
-
- public override string? get_set_value_function () {
- foreach (DataType prerequisite in prerequisites) {
- string set_value_func = prerequisite.data_type.get_set_value_function ();
- if (set_value_func != null) {
- return set_value_func;
- }
- }
- return "g_value_set_pointer";
- }
-
- public override string? get_take_value_function () {
- foreach (DataType prerequisite in prerequisites) {
- string take_value_func = prerequisite.data_type.get_take_value_function ();
- if (take_value_func != null) {
- return take_value_func;
- }
- }
- return "g_value_set_pointer";
- }
-
- public string? get_default_type_id () {
- return get_upper_case_cname ("TYPE_");
- }
-
- public override string? get_type_id () {
- if (type_id == null) {
- type_id = get_default_type_id ();
- }
-
- return type_id;
- }
-
- public void set_type_id (string type_id) {
- this.type_id = type_id;
- }
-
public override void replace_type (DataType old_type, DataType new_type) {
for (int i = 0; i < prerequisites.size; i++) {
if (prerequisites[i] == old_type) {
@@ -581,25 +349,6 @@ public class Vala.Interface : ObjectTypeSymbol {
}
}
- public override string? get_param_spec_function () {
- foreach (DataType prerequisite in prerequisites) {
- var prereq = prerequisite as ObjectType;
- var cl = prereq.type_symbol as Class;
- if (cl != null) {
- return cl.get_param_spec_function ();
- }
- var interf = prereq.type_symbol as Interface;
- if (interf != null) {
- var param_spec_function = interf.get_param_spec_function ();
- if (param_spec_function != null) {
- return param_spec_function;
- }
- }
- }
-
- return "g_param_spec_pointer";
- }
-
public override bool check (CodeContext context) {
if (checked) {
return !error;
@@ -607,8 +356,6 @@ public class Vala.Interface : ObjectTypeSymbol {
checked = true;
- process_attributes ();
-
var old_source_file = context.analyzer.current_source_file;
var old_symbol = context.analyzer.current_symbol;
diff --git a/vala/valainterfacetype.vala b/vala/valainterfacetype.vala
index b767f14b5..3ca1a2c85 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/valalambdaexpression.vala b/vala/valalambdaexpression.vala
index 1d791af32..8ad3a0834 100644
--- a/vala/valalambdaexpression.vala
+++ b/vala/valalambdaexpression.vala
@@ -135,9 +135,7 @@ public class Vala.LambdaExpression : Expression {
var cb = (Delegate) ((DelegateType) target_type).delegate_symbol;
var return_type = cb.return_type.get_actual_type (target_type, null, this);
method = new Method (get_lambda_name (context), return_type, source_reference);
- method.no_array_length = cb.no_array_length;
- method.array_null_terminated = cb.array_null_terminated;
- method.array_length_type = cb.array_length_type;
+ method.attributes = cb.attributes.copy ();
// track usage for flow analyzer
method.used = true;
method.check_deprecated (source_reference);
diff --git a/vala/valamethod.vala b/vala/valamethod.vala
index b2ac9aae6..c2de41d21 100644
--- a/vala/valamethod.vala
+++ b/vala/valamethod.vala
@@ -30,8 +30,6 @@ using GLib;
public class Vala.Method : Subroutine {
List<TypeParameter> type_parameters;
- public const string DEFAULT_SENTINEL = "NULL";
-
/**
* The return type of this method.
*/
@@ -52,38 +50,6 @@ public class Vala.Method : Subroutine {
* the contained type.
*/
public MemberBinding binding { get; set; default = MemberBinding.INSTANCE; }
-
- /**
- * The name of the vfunc of this method as it is used in C code.
- */
- public string vfunc_name {
- get {
- if (_vfunc_name == null) {
- _vfunc_name = this.name;
- }
- return _vfunc_name;
- }
- set {
- _vfunc_name = value;
- }
- }
-
- /**
- * The sentinel to use for terminating variable length argument lists.
- */
- public string sentinel {
- get {
- if (_sentinel == null) {
- return DEFAULT_SENTINEL;
- }
-
- return _sentinel;
- }
-
- set {
- _sentinel = value;
- }
- }
/**
* Specifies whether this method is abstract. Abstract methods have no
@@ -118,12 +84,19 @@ public class Vala.Method : Subroutine {
}
}
- /**
+ /*
* Specifies whether the C method returns a new instance pointer which
* may be different from the previous instance pointer. Only valid for
* imported methods.
*/
- public bool returns_modified_pointer { get; set; }
+ public bool returns_modified_pointer {
+ get {
+ return get_attribute ("ReturnsModifiedPointer") != null;
+ }
+ set {
+ set_attribute ("ReturnsModifiedPointer", value);
+ }
+ }
/**
* Specifies the virtual or abstract method this method overrides.
@@ -155,44 +128,6 @@ public class Vala.Method : Subroutine {
public Parameter this_parameter { get; set; }
/**
- * Specifies the position of the instance parameter in the C function.
- */
- public double cinstance_parameter_position { get; set; }
-
- /**
- * Specifies the position of the array length out parameter in the C
- * function.
- */
- public double carray_length_parameter_position { get; set; }
-
- /**
- * Specifies the position of the delegate target out parameter in the C
- * function.
- */
- public double cdelegate_target_parameter_position { get; set; }
-
- /**
- * Specifies whether the array length should be returned implicitly
- * if the return type is an array.
- */
- public bool no_array_length { get; set; }
-
- /**
- * Specifies whether the array is null terminated.
- */
- public bool array_null_terminated { get; set; }
-
- /**
- * Specifies a custom type for the array length parameter.
- */
- public string? array_length_type { get; set; default = null; }
-
- /**
- * Specifies a custom C return type for this method.
- */
- public string? custom_return_type_cname { get; set; }
-
- /**
* Specifies whether this method expects printf-style format arguments.
*/
public bool printf_format {
@@ -217,12 +152,6 @@ public class Vala.Method : Subroutine {
}
/**
- * Specifies whether a new function without a GType parameter is
- * available. This is only applicable to creation methods.
- */
- public bool has_new_function { get; set; default = true; }
-
- /**
* Specifies whether a construct function with a GType parameter is
* available. This is only applicable to creation methods.
*/
@@ -235,12 +164,6 @@ public class Vala.Method : Subroutine {
}
}
- public bool has_generic_type_parameter { get; set; }
-
- public double generic_type_parameter_position { get; set; }
-
- public bool simple_generics { get; set; }
-
public weak Signal signal_reference { get; set; }
public bool closure { get; set; }
@@ -252,10 +175,6 @@ public class Vala.Method : Subroutine {
public int yield_count { get; set; }
private List<Parameter> parameters = new ArrayList<Parameter> ();
- private string cname;
- private string finish_name;
- private string _vfunc_name;
- private string _sentinel;
private List<Expression> preconditions;
private List<Expression> postconditions;
private DataType _return_type;
@@ -283,9 +202,6 @@ public class Vala.Method : Subroutine {
public Method (string? name, DataType return_type, SourceReference? source_reference = null, Comment? comment = null) {
base (name, source_reference, comment);
this.return_type = return_type;
-
- carray_length_parameter_position = -3;
- cdelegate_target_parameter_position = -3;
}
/**
@@ -295,15 +211,8 @@ public class Vala.Method : Subroutine {
*/
public void add_parameter (Parameter param) {
// default C parameter position
- param.cparameter_position = parameters.size + 1;
- param.carray_length_parameter_position = param.cparameter_position + 0.1;
- param.cdelegate_target_parameter_position = param.cparameter_position + 0.1;
- param.cdestroy_notify_parameter_position = param.cparameter_position + 0.1;
-
parameters.add (param);
- if (!param.ellipsis) {
- scope.add (param.name, param);
- }
+ scope.add (param.name, param);
}
public List<Parameter> get_parameters () {
@@ -365,167 +274,6 @@ 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;
- }
-
- public string get_finish_cname () {
- assert (coroutine);
- if (finish_name == null) {
- finish_name = get_default_finish_cname ();
- }
- return finish_name;
- }
-
- public void set_finish_cname (string name) {
- finish_name = name;
- }
-
- /**
- * 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);
- }
- }
-
- /**
- * Returns the implementation name of this data type as it is used in C
- * code.
- *
- * @return the name to be used in C code
- */
- public virtual string get_real_cname () {
- if (base_method != null || base_interface_method != null) {
- return "%sreal_%s".printf (parent_symbol.get_lower_case_cprefix (), name);
- } else {
- return get_cname ();
- }
- }
-
- protected string get_finish_name_for_basename (string basename) {
- string result = basename;
- if (result.has_suffix ("_async")) {
- result = result.substring (0, result.length - "_async".length);
- }
- result += "_finish";
- return result;
- }
-
- public string get_finish_real_cname () {
- assert (coroutine);
- return get_finish_name_for_basename (get_real_cname ());
- }
-
- public string get_finish_vfunc_name () {
- assert (coroutine);
- return get_finish_name_for_basename (vfunc_name);
- }
-
- public string get_default_finish_cname () {
- return get_finish_name_for_basename (get_cname ());
- }
-
- /**
- * 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 ("cheader_filename")) {
- var val = a.get_string ("cheader_filename");
- foreach (string filename in val.split (",")) {
- add_cheader_filename (filename);
- }
- }
- if (a.has_argument ("vfunc_name")) {
- this.vfunc_name = a.get_string ("vfunc_name");
- }
- if (a.has_argument ("finish_name")) {
- this.finish_name = a.get_string ("finish_name");
- }
- if (a.has_argument ("sentinel")) {
- this.sentinel = a.get_string ("sentinel");
- }
- if (a.has_argument ("instance_pos")) {
- cinstance_parameter_position = a.get_double ("instance_pos");
- }
- if (a.has_argument ("array_length")) {
- no_array_length = !a.get_bool ("array_length");
- }
- if (a.has_argument ("array_length_type")) {
- array_length_type = a.get_string ("array_length_type");
- }
- if (a.has_argument ("array_null_terminated")) {
- array_null_terminated = a.get_bool ("array_null_terminated");
- }
- if (a.has_argument ("array_length_pos")) {
- carray_length_parameter_position = a.get_double ("array_length_pos");
- }
- if (a.has_argument ("delegate_target_pos")) {
- cdelegate_target_parameter_position = a.get_double ("delegate_target_pos");
- }
- if (a.has_argument ("has_new_function")) {
- has_new_function = a.get_bool ("has_new_function");
- }
- if (a.has_argument ("generic_type_pos")) {
- has_generic_type_parameter = true;
- generic_type_parameter_position = a.get_double ("generic_type_pos");
- }
- if (a.has_argument ("simple_generics")) {
- simple_generics = a.get_bool ("simple_generics");
- }
- if (a.has_argument ("type")) {
- custom_return_type_cname = a.get_string ("type");
- }
- }
-
- /**
- * 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 == "ReturnsModifiedPointer") {
- returns_modified_pointer = true;
- } else if (a.name == "FloatingReference") {
- return_type.floating_reference = true;
- } else if (a.name == "NoArrayLength") {
- Report.warning (source_reference, "NoArrayLength attribute is deprecated, use [CCode (array_length = false)] instead.");
- no_array_length = true;
- } else if (a.name == "NoThrow") {
- get_error_types ().clear ();
- } else if (a.name == "DestroysInstance") {
- this_parameter.variable_type.value_owned = true;
- }
- }
- }
-
- /**
* Checks whether the parameters and return type of this method are
* compatible with the specified method
*
@@ -809,7 +557,12 @@ public class Vala.Method : Subroutine {
checked = true;
- process_attributes ();
+ if (get_attribute ("DestroysInstance") != null) {
+ this_parameter.variable_type.value_owned = true;
+ }
+ if (get_attribute ("NoThrow") != null) {
+ get_error_types ().clear ();
+ }
if (is_abstract) {
if (parent_symbol is Class) {
@@ -1108,7 +861,6 @@ public class Vala.Method : Subroutine {
callback_method.binding = MemberBinding.INSTANCE;
callback_method.owner = scope;
callback_method.is_async_callback = true;
- callback_method.set_cname (get_real_cname () + "_co");
}
return callback_method;
}
@@ -1132,8 +884,8 @@ public class Vala.Method : Subroutine {
var callback_param = new Parameter ("_callback_", callback_type);
callback_param.initializer = new NullLiteral (source_reference);
callback_param.initializer.target_type = callback_type.copy ();
- callback_param.cparameter_position = -1;
- callback_param.cdelegate_target_parameter_position = -0.9;
+ callback_param.set_attribute_double ("CCode", "pos", -1);
+ callback_param.set_attribute_double ("CCode", "delegate_target_pos", -0.9);
params.add (callback_param);
@@ -1149,7 +901,7 @@ public class Vala.Method : Subroutine {
var result_type = new ObjectType ((ObjectTypeSymbol) glib_ns.scope.lookup ("AsyncResult"));
var result_param = new Parameter ("_res_", result_type);
- result_param.cparameter_position = 0.1;
+ result_param.set_attribute_double ("CCode", "pos", 0.1);
params.add (result_param);
foreach (var param in parameters) {
diff --git a/vala/valamethodtype.vala b/vala/valamethodtype.vala
index 594aeb2f4..9a492faeb 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 45abd68de..7506e25db 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,112 +496,6 @@ 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 ("cheader_filename")) {
- var val = a.get_string ("cheader_filename");
- foreach (string filename in val.split (",")) {
- add_cheader_filename (filename);
- }
- }
- if (a.has_argument ("gir_namespace")) {
- source_reference.file.gir_namespace = a.get_string ("gir_namespace");
- }
- if (a.has_argument ("gir_version")) {
- source_reference.file.gir_version = a.get_string ("gir_version");
- }
- }
-
- /**
- * 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) {
@@ -613,7 +504,13 @@ public class Vala.Namespace : Symbol {
checked = true;
- process_attributes ();
+ var a = get_attribute ("CCode");
+ if (a != null && a.has_argument ("gir_namespace")) {
+ source_reference.file.gir_namespace = a.get_string ("gir_namespace");
+ }
+ if (a != null && a.has_argument ("gir_version")) {
+ source_reference.file.gir_version = a.get_string ("gir_version");
+ }
foreach (Namespace ns in namespaces) {
ns.check (context);
diff --git a/vala/valanulltype.vala b/vala/valanulltype.vala
index fdba4a730..19d110984 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/valaobjectcreationexpression.vala b/vala/valaobjectcreationexpression.vala
index 1152b460f..a274de013 100644
--- a/vala/valaobjectcreationexpression.vala
+++ b/vala/valaobjectcreationexpression.vala
@@ -275,7 +275,8 @@ public class Vala.ObjectCreationExpression : Expression {
}
while (cl != null) {
- if (cl.get_ref_sink_function () != null) {
+ // FIXME: use target values in the codegen
+ if (cl.get_attribute_string ("CCode", "ref_sink_function") != null) {
value_type.floating_reference = true;
break;
}
diff --git a/vala/valaobjecttype.vala b/vala/valaobjecttype.vala
index 42187567e..6d440b181 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/valaparameter.vala b/vala/valaparameter.vala
index ab4d4a3b0..e34b773f2 100644
--- a/vala/valaparameter.vala
+++ b/vala/valaparameter.vala
@@ -42,30 +42,6 @@ public class Vala.Parameter : Variable {
*/
public bool params_array { get; set; }
- /**
- * Specifies the position of the parameter in the C function.
- */
- public double cparameter_position { get; set; }
-
- /**
- * Specifies the position of the array length parameter in the C
- * function.
- */
- public double carray_length_parameter_position { get; set; }
-
- /**
- * Specifies the position of the delegate target parameter in the C
- * function.
- */
- public double cdelegate_target_parameter_position { get; set; }
-
- public double cdestroy_notify_parameter_position { get; set; }
-
- /**
- * Specifies the type of the parameter in the C function.
- */
- public string? ctype { get; set; }
-
public bool captured { get; set; }
/**
@@ -119,46 +95,13 @@ public class Vala.Parameter : Variable {
}
}
- private void process_ccode_attribute (Attribute a) {
- if (a.has_argument ("type")) {
- ctype = a.get_string ("type");
- }
- if (a.has_argument ("pos")) {
- cparameter_position = a.get_double ("pos");
- }
- if (a.has_argument ("array_length_pos")) {
- carray_length_parameter_position = a.get_double ("array_length_pos");
- }
- if (a.has_argument ("delegate_target_pos")) {
- cdelegate_target_parameter_position = a.get_double ("delegate_target_pos");
- }
- if (a.has_argument ("destroy_notify_pos")) {
- cdestroy_notify_parameter_position = a.get_double ("destroy_notify_pos");
- }
- }
-
- /**
- * 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);
- }
- }
- }
-
public Parameter copy () {
if (!ellipsis) {
var result = new Parameter (name, variable_type, source_reference);
result.params_array = params_array;
result.direction = this.direction;
result.initializer = this.initializer;
- result.no_array_length = this.no_array_length;
- result.no_delegate_target = this.no_delegate_target;
- result.array_null_terminated = this.array_null_terminated;
+ result.attributes = this.attributes.copy ();
return result;
} else {
return new Parameter.with_ellipsis ();
@@ -172,8 +115,6 @@ public class Vala.Parameter : Variable {
checked = true;
- process_attributes ();
-
var old_source_file = context.analyzer.current_source_file;
var old_symbol = context.analyzer.current_symbol;
diff --git a/vala/valapointertype.vala b/vala/valapointertype.vala
index 92345874a..40016c342 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 ());
}
@@ -91,7 +83,7 @@ public class Vala.PointerType : DataType {
return base_type.compatible (target_type);
}
- if (target_type.get_type_id () == "G_TYPE_VALUE") {
+ if (CodeContext.get ().profile == Profile.GOBJECT && target_type.data_type != null && target_type.data_type.is_subtype_of (CodeContext.get ().analyzer.gvalue_type.data_type)) {
// allow implicit conversion to GValue
return true;
}
@@ -127,10 +119,6 @@ public class Vala.PointerType : DataType {
return base_type.is_accessible (sym);
}
- public override string? get_type_id () {
- return "G_TYPE_POINTER";
- }
-
public override void accept_children (CodeVisitor visitor) {
base_type.accept (visitor);
}
diff --git a/vala/valaproperty.vala b/vala/valaproperty.vala
index ea24086cc..7816020f7 100644
--- a/vala/valaproperty.vala
+++ b/vala/valaproperty.vala
@@ -72,18 +72,6 @@ public class Vala.Property : Symbol, Lockable {
public Parameter this_parameter { get; set; }
/**
- * Specifies whether a `notify` signal should be emitted on property
- * changes.
- */
- public bool notify { get; set; default = true; }
-
- /**
- * Specifies whether the implementation of this property does not
- * provide getter/setter methods.
- */
- public bool no_accessor_method { get; set; }
-
- /**
* Specifies whether automatic accessor code generation should be
* disabled.
*/
@@ -146,43 +134,10 @@ public class Vala.Property : Symbol, Lockable {
*/
public Expression initializer { get; set; }
- public bool no_array_length { get; set; }
-
- public bool array_null_terminated { get; set; }
-
- /**
- * Nickname of this property.
- */
- public string nick {
- get {
- if (_nick == null) {
- _nick = get_canonical_name ();
- }
- return _nick;
- }
- set { _nick = value; }
- }
-
- /**
- * The long description of this property.
- */
- public string blurb {
- get {
- if (_blurb == null) {
- _blurb = get_canonical_name ();
- }
- return _blurb;
- }
- set { _blurb = value; }
- }
-
private bool lock_used = false;
private DataType _data_type;
- private string? _nick;
- private string? _blurb;
-
private weak Property _base_property;
private Property _base_interface_property;
private bool base_properties_valid;
@@ -225,77 +180,6 @@ public class Vala.Property : Symbol, Lockable {
}
}
- /**
- * Returns the C name of this property in upper case. Words are
- * separated by underscores. The upper case C name of the class is
- * prefix of the result.
- *
- * @return the upper case name to be used in C code
- */
- public string get_upper_case_cname () {
- return "%s_%s".printf (parent_symbol.get_lower_case_cname (null), camel_case_to_lower_case (name)).up ();
- }
-
- /**
- * Returns the string literal of this property to be used in C code.
- *
- * @return string literal to be used in C code
- */
- public CCodeConstant get_canonical_cconstant () {
- return new CCodeConstant ("\"%s\"".printf (get_canonical_name ()));
- }
-
- public string get_canonical_name () {
- var str = new StringBuilder ();
-
- string i = name;
-
- while (i.length > 0) {
- unichar c = i.get_char ();
- if (c == '_') {
- str.append_c ('-');
- } else {
- str.append_unichar (c);
- }
-
- i = i.next_char ();
- }
-
- return str.str;
- }
-
- void process_ccode_attribute (Attribute a) {
- if (a.has_argument ("notify")) {
- notify = a.get_bool ("notify");
- }
- if (a.has_argument ("array_length")) {
- no_array_length = !a.get_bool ("array_length");
- }
- if (a.has_argument ("array_null_terminated")) {
- array_null_terminated = a.get_bool ("array_null_terminated");
- }
- }
-
- /**
- * 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 == "NoAccessorMethod") {
- no_accessor_method = true;
- } else if (a.name == "Description") {
- if (a.has_argument ("nick")) {
- nick = a.get_string ("nick");
- }
- if (a.has_argument ("blurb")) {
- blurb = a.get_string ("blurb");
- }
- }
- }
- }
-
public bool get_lock_used () {
return lock_used;
}
@@ -424,8 +308,6 @@ public class Vala.Property : Symbol, Lockable {
checked = true;
- process_attributes ();
-
if (is_abstract) {
if (parent_symbol is Class) {
var cl = (Class) parent_symbol;
diff --git a/vala/valapropertyaccessor.vala b/vala/valapropertyaccessor.vala
index dc4a8b3d3..47a197772 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;
@@ -229,8 +192,4 @@ public class Vala.PropertyAccessor : Subroutine {
value_type = new_type;
}
}
-
- public override List<string> get_cheader_filenames () {
- return parent_symbol.get_cheader_filenames ();
- }
}
diff --git a/vala/valasemanticanalyzer.vala b/vala/valasemanticanalyzer.vala
index a2a3a1059..97f910dea 100644
--- a/vala/valasemanticanalyzer.vala
+++ b/vala/valasemanticanalyzer.vala
@@ -152,6 +152,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
public DataType type_type;
public Class object_type;
public StructValueType gvalue_type;
+ public ObjectType gvariant_type;
public DataType glist_type;
public DataType gslist_type;
public DataType garray_type;
@@ -213,6 +214,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
object_type = (Class) glib_ns.scope.lookup ("Object");
type_type = new IntegerType ((Struct) glib_ns.scope.lookup ("Type"));
gvalue_type = new StructValueType ((Struct) glib_ns.scope.lookup ("Value"));
+ gvariant_type = new ObjectType ((Class) glib_ns.scope.lookup ("Variant"));
glist_type = new ObjectType ((Class) glib_ns.scope.lookup ("List"));
gslist_type = new ObjectType ((Class) glib_ns.scope.lookup ("SList"));
diff --git a/vala/valasignal.vala b/vala/valasignal.vala
index e041ec039..fb5895ab9 100644
--- a/vala/valasignal.vala
+++ b/vala/valasignal.vala
@@ -48,11 +48,6 @@ public class Vala.Signal : Symbol, Lockable {
}
/**
- * Specifies whether this signal has an emitter wrapper function.
- */
- public bool has_emitter { get; set; }
-
- /**
* Specifies whether this signal has virtual method handler.
*/
public bool is_virtual { get; set; }
@@ -64,19 +59,6 @@ public class Vala.Signal : Symbol, Lockable {
* */
public Method default_handler { get; private set; }
- public bool is_detailed { get; set; }
-
- public bool no_recurse { get; set; }
-
- public string run_type { get; set; }
-
- public bool is_action { get; set; }
-
- public bool no_hooks { get; set; }
-
-
- private string cname;
-
private bool lock_used = false;
private DataType _return_type;
@@ -94,7 +76,6 @@ public class Vala.Signal : Symbol, Lockable {
public Signal (string name, DataType return_type, SourceReference? source_reference = null, Comment? comment = null) {
base (name, source_reference, comment);
this.return_type = return_type;
- this.run_type = "last";
}
/**
@@ -103,12 +84,6 @@ public class Vala.Signal : Symbol, Lockable {
* @param param a formal parameter
*/
public void add_parameter (Parameter param) {
- // default C parameter position
- param.cparameter_position = parameters.size + 1;
- param.carray_length_parameter_position = param.cparameter_position + 0.1;
- param.cdelegate_target_parameter_position = param.cparameter_position + 0.1;
- param.cdestroy_notify_parameter_position = param.cparameter_position + 0.1;
-
parameters.add (param);
scope.add (param.name, param);
}
@@ -167,54 +142,7 @@ 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.
- *
- * @return string literal to be used in C code
- */
- public CCodeConstant get_canonical_cconstant (string? detail = null) {
- var str = new StringBuilder ("\"");
-
- string i = get_cname ();
-
- while (i.length > 0) {
- unichar c = i.get_char ();
- if (c == '_') {
- str.append_c ('-');
- } else {
- str.append_unichar (c);
- }
-
- i = i.next_char ();
- }
-
- if (detail != null) {
- str.append ("::");
- str.append (detail);
- }
-
- str.append_c ('"');
-
- return new CCodeConstant (str.str);
- }
-
public override void accept (CodeVisitor visitor) {
visitor.visit_signal (this);
}
@@ -232,46 +160,6 @@ public class Vala.Signal : Symbol, Lockable {
}
}
- void process_signal_attribute (Attribute a) {
- if (a.has_argument ("detailed")) {
- is_detailed = a.get_bool ("detailed");
- }
- if (a.has_argument ("no_recurse")) {
- no_recurse = a.get_bool ("no_recurse");
- }
- if (a.has_argument ("run")) {
- var arg = a.get_string ("run");
- if (arg == "first") {
- run_type = "first";
- } else if (arg == "last") {
- run_type = "last";
- } else if (arg == "cleanup") {
- run_type = "cleanup";
- }
- }
-
- if (a.has_argument ("action")) {
- is_action = a.get_bool ("action");
- }
-
- if (a.has_argument ("no_hooks")) {
- no_hooks = a.get_bool ("no_hooks");
- }
- }
-
- /**
- * Process all associated attributes.
- */
- public void process_attributes () {
- foreach (Attribute a in attributes) {
- if (a.name == "HasEmitter") {
- has_emitter = true;
- } else if (a.name == "Signal") {
- process_signal_attribute (a);
- }
- }
- }
-
public bool get_lock_used () {
return lock_used;
}
@@ -293,8 +181,6 @@ public class Vala.Signal : Symbol, Lockable {
checked = true;
- process_attributes ();
-
return_type.check (context);
foreach (Parameter param in parameters) {
@@ -314,7 +200,6 @@ public class Vala.Signal : Symbol, Lockable {
default_handler.external = external;
default_handler.hides = hides;
default_handler.is_virtual = true;
- default_handler.vfunc_name = name;
default_handler.signal_reference = this;
default_handler.body = body;
diff --git a/vala/valastruct.vala b/vala/valastruct.vala
index 443dc040f..f913a019c 100644
--- a/vala/valastruct.vala
+++ b/vala/valastruct.vala
@@ -33,11 +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 type_id;
- private string lower_case_cprefix;
- private string lower_case_csuffix;
private bool? boolean_type;
private bool? integer_type;
private bool? floating_type;
@@ -47,13 +42,6 @@ public class Vala.Struct : TypeSymbol {
private int? _width;
private bool? _signed;
private bool? _is_immutable;
- private string marshaller_type_name;
- private string get_value_function;
- private string set_value_function;
- private string take_value_function;
- private string default_value = null;
- private string copy_function;
- private string destroy_function;
/**
* Specifies the base type.
@@ -102,11 +90,6 @@ public class Vala.Struct : TypeSymbol {
}
}
- /**
- * Specifies whether this struct has a registered GType.
- */
- public bool has_type_id { get; set; default = true; }
-
public int width {
get {
if (_width == null) {
@@ -141,10 +124,6 @@ public class Vala.Struct : TypeSymbol {
}
}
- public bool has_copy_function { get; set; default = true; }
-
- public bool has_destroy_function { get; set; default = true; }
-
/**
* Creates a new struct.
*
@@ -316,70 +295,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) {
- var attr = get_attribute ("CCode");
- if (attr != null) {
- cname = attr.get_string ("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 ());
- }
-
- public override string? get_upper_case_cname (string? infix) {
- return get_lower_case_cname (infix).up ();
- }
-
/**
* Returns whether this is a boolean type.
*
@@ -446,10 +361,15 @@ public class Vala.Struct : TypeSymbol {
*/
public int get_rank () {
if (rank == null) {
- if (is_integer_type ()) {
+ if (is_integer_type () && has_attribute_argument ("IntegerType", "rank")) {
rank = get_attribute_integer ("IntegerType", "rank");
- } else {
+ } else if (has_attribute_argument ("FloatingType", "rank")) {
rank = get_attribute_integer ("FloatingType", "rank");
+ } else {
+ var st = base_struct;
+ if (st != null) {
+ rank = st.get_rank ();
+ }
}
}
return rank;
@@ -469,233 +389,6 @@ public class Vala.Struct : TypeSymbol {
}
}
- private void process_gir_attribute (Attribute a) {
- if (a.has_argument ("name")) {
- gir_name = a.get_string ("name");
- }
- }
-
- 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");
- }
- if (a.has_argument ("cheader_filename")) {
- var val = a.get_string ("cheader_filename");
- foreach (string filename in val.split (",")) {
- add_cheader_filename (filename);
- }
- }
- if (a.has_argument ("has_type_id")) {
- has_type_id = a.get_bool ("has_type_id");
- }
- if (a.has_argument ("type_id")) {
- set_type_id (a.get_string ("type_id"));
- }
- if (a.has_argument ("marshaller_type_name")) {
- set_marshaller_type_name (a.get_string ("marshaller_type_name"));
- }
- if (a.has_argument ("get_value_function")) {
- set_get_value_function (a.get_string ("get_value_function"));
- }
- if (a.has_argument ("set_value_function")) {
- set_set_value_function (a.get_string ("set_value_function"));
- }
- if (a.has_argument ("take_value_function")) {
- set_take_value_function (a.get_string ("take_value_function"));
- }
- if (a.has_argument ("default_value")) {
- set_default_value (a.get_string ("default_value"));
- }
- if (a.has_argument ("copy_function")) {
- set_copy_function (a.get_string ("copy_function"));
- }
- if (a.has_argument ("has_copy_function")) {
- has_copy_function = a.get_bool ("has_copy_function");
- }
- if (a.has_argument ("destroy_function")) {
- set_destroy_function (a.get_string ("destroy_function"));
- }
- if (a.has_argument ("has_destroy_function")) {
- has_destroy_function = a.get_bool ("has_destroy_function");
- }
- }
-
- /**
- * 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 == "GIR") {
- process_gir_attribute (a);
- }
- }
- }
-
- public override string? get_type_id () {
- if (type_id == null) {
- if (!has_type_id) {
- if (base_type != null) {
- var st = base_struct;
- if (st != null) {
- return st.get_type_id ();
- }
- }
- if (is_simple_type ()) {
- return null;
- } else {
- return "G_TYPE_POINTER";
- }
- } else {
- type_id = get_upper_case_cname ("TYPE_");
- }
- }
- return type_id;
- }
-
- public void set_type_id (string? name) {
- this.type_id = name;
- }
-
- public override string? get_marshaller_type_name () {
- if (marshaller_type_name == null) {
- if (base_type != null) {
- var st = base_struct;
- if (st != null) {
- return st.get_marshaller_type_name ();
- }
- }
- if (is_simple_type ()) {
- Report.error (source_reference, "The type `%s` doesn't declare a marshaller type name".printf (get_full_name ()));
- // set marshaller_type_name to avoid multiple errors
- marshaller_type_name = "";
- return "";
- } else if (has_type_id) {
- return "BOXED";
- } else {
- return "POINTER";
- }
- }
- return marshaller_type_name;
- }
-
- private void set_marshaller_type_name (string? name) {
- this.marshaller_type_name = name;
- }
-
- public override string? get_get_value_function () {
- if (get_value_function == null) {
- if (base_type != null) {
- var st = base_struct;
- if (st != null) {
- return st.get_get_value_function ();
- }
- }
- if (is_simple_type ()) {
- Report.error (source_reference, "The value type `%s` doesn't declare a GValue get function".printf (get_full_name ()));
- // set get_value_function to avoid multiple errors
- get_value_function = "";
- return "";
- } else if (has_type_id) {
- return "g_value_get_boxed";
- } else {
- return "g_value_get_pointer";
- }
- } else {
- return get_value_function;
- }
- }
-
- public override string? get_set_value_function () {
- if (set_value_function == null) {
- if (base_type != null) {
- var st = base_struct;
- if (st != null) {
- return st.get_set_value_function ();
- }
- }
- if (is_simple_type ()) {
- Report.error (source_reference, "The value type `%s` doesn't declare a GValue set function".printf (get_full_name ()));
- // set set_value_function to avoid multiple errors
- set_value_function = "";
- return "";
- } else if (has_type_id) {
- return "g_value_set_boxed";
- } else {
- return "g_value_set_pointer";
- }
- } else {
- return set_value_function;
- }
- }
-
- public override string? get_take_value_function () {
- if (take_value_function == null) {
- if (base_type != null) {
- var st = base_struct;
- if (st != null) {
- return st.get_take_value_function ();
- }
- }
- if (is_simple_type ()) {
- Report.error (source_reference, "The value type `%s` doesn't declare a GValue take function".printf (get_full_name ()));
- // set take_value_function to avoid multiple errors
- take_value_function = "";
- return "";
- } else if (has_type_id) {
- return "g_value_take_boxed";
- } else {
- return "g_value_take_pointer";
- }
- } else {
- return take_value_function;
- }
- }
-
- private void set_get_value_function (string? function) {
- get_value_function = function;
- }
-
- private void set_set_value_function (string? function) {
- set_value_function = function;
- }
-
- private void set_take_value_function (string? function) {
- take_value_function = function;
- }
-
- public override string? get_default_value () {
- if (default_value != null) {
- return default_value;
- }
-
- // inherit default value from base type
- if (base_type != null) {
- var st = base_struct;
- if (st != null) {
- return st.get_default_value ();
- }
- }
-
- if (CodeContext.get ().profile == Profile.DOVA) {
- if (is_boolean_type ()) {
- return "false";
- } else if (is_integer_type () || is_floating_type ()) {
- return "0";
- }
- }
-
- return null;
- }
-
- private void set_default_value (string? value) {
- default_value = value;
- }
-
public override int get_type_parameter_index (string name) {
int i = 0;
@@ -756,54 +449,6 @@ public class Vala.Struct : TypeSymbol {
return false;
}
- public override string? get_dup_function () {
- // TODO use attribute check instead
- if (external_package) {
- return null;
- } else {
- return get_lower_case_cprefix () + "dup";
- }
- }
-
- public override string? get_free_function () {
- // TODO use attribute check instead
- if (external_package) {
- return null;
- } else {
- return get_lower_case_cprefix () + "free";
- }
- }
-
- public string get_default_copy_function () {
- return get_lower_case_cprefix () + "copy";
- }
-
- public override string? get_copy_function () {
- if (copy_function == null) {
- copy_function = get_default_copy_function ();
- }
- return copy_function;
- }
-
- public void set_copy_function (string name) {
- this.copy_function = name;
- }
-
- public string get_default_destroy_function () {
- return get_lower_case_cprefix () + "destroy";
- }
-
- public override string? get_destroy_function () {
- if (destroy_function == null) {
- destroy_function = get_default_destroy_function ();
- }
- return destroy_function;
- }
-
- public void set_destroy_function (string name) {
- this.destroy_function = name;
- }
-
public bool is_disposable () {
if (get_attribute_string ("CCode", "destroy_function") != null) {
return true;
@@ -842,8 +487,6 @@ public class Vala.Struct : TypeSymbol {
checked = true;
- process_attributes ();
-
var old_source_file = context.analyzer.current_source_file;
var old_symbol = context.analyzer.current_symbol;
diff --git a/vala/valasymbol.vala b/vala/valasymbol.vala
index 46e26c28d..98138019d 100644
--- a/vala/valasymbol.vala
+++ b/vala/valasymbol.vala
@@ -53,18 +53,6 @@ public abstract class Vala.Symbol : CodeNode {
}
/**
- * The GIR name.
- */
- public string? gir_name {
- get {
- return _gir_name == null ? name : _gir_name;
- }
- set {
- _gir_name = value;
- }
- }
-
- /**
* The symbol name.
*/
public string? name { get; set; }
@@ -150,8 +138,6 @@ public abstract class Vala.Symbol : CodeNode {
public Comment? comment { get; set; }
- private List<string> cheader_filenames;
-
/**
* Specifies whether this method explicitly hides a member of a base
* type.
@@ -229,7 +215,6 @@ public abstract class Vala.Symbol : CodeNode {
private weak Scope _owner;
private Scope _scope;
- private string? _gir_name = null;
private bool? _deprecated;
private bool? _experimental;
@@ -239,34 +224,7 @@ public abstract class Vala.Symbol : CodeNode {
this.comment = comment;
_scope = new Scope (this);
}
-
- /**
- * Returns the fully expanded GIR name of this symbol
- *
- * @return full GIR name
- */
- public string get_full_gir_name () {
- if (parent_symbol == null) {
- return gir_name;
- }
-
- if (name == null) {
- return parent_symbol.get_full_gir_name ();
- }
-
- if (parent_symbol.get_full_gir_name () == null) {
- return gir_name;
- }
- string parent_gir_name = parent_symbol.get_full_gir_name ();
- string self_gir_name = gir_name.has_prefix (".") ? gir_name.substring (1) : gir_name;
- if ("." in parent_gir_name) {
- return "%s%s".printf (parent_gir_name, self_gir_name);
- } else {
- return "%s.%s".printf (parent_gir_name, self_gir_name);
- }
- }
-
/**
* Returns the fully expanded name of this symbol for use in
* human-readable messages.
@@ -292,77 +250,8 @@ public abstract class Vala.Symbol : CodeNode {
return "%s.%s".printf (parent_symbol.get_full_name (), name);
}
}
-
- /**
- * Returns the camel case string to be prepended to the name of members
- * of this symbol when used in C code.
- *
- * @return the camel case prefix to be used in C code
- */
- public virtual string get_cprefix () {
- if (name == null) {
- return "";
- } else {
- return name;
- }
- }
/**
- * 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 "";
- }
-
- static List<string> _empty_string_list;
-
- /**
- * Returns a list of C header filenames users of this symbol must
- * include.
- *
- * @return list of C header filenames for this symbol
- */
- public virtual List<string> get_cheader_filenames () {
- if (cheader_filenames == null || cheader_filenames.size == 0) {
- // parent_symbol can be null on incremental parsing
- if (parent_symbol != null) {
- /* default to header filenames of the namespace */
- var parent_header_filenames = parent_symbol.get_cheader_filenames ();
- if (parent_header_filenames.size > 0) {
- return parent_header_filenames;
- }
- }
-
- if (source_reference != null && !external_package) {
- // don't add default include directives for VAPI files
- add_cheader_filename (source_reference.file.get_cinclude_filename ());
- } else {
- if (_empty_string_list == null) {
- _empty_string_list = new ArrayList<string> ();
- }
- return _empty_string_list;
- }
- }
- return cheader_filenames;
- }
-
- /**
* Converts a string from CamelCase to lower_case.
*
* @param camel_case a string in camel case
@@ -541,30 +430,6 @@ public abstract class Vala.Symbol : CodeNode {
}
}
- /**
- * Sets the C header filename of this namespace to the specified
- * filename.
- *
- * @param cheader_filename header filename
- */
- public void set_cheader_filename (string cheader_filename) {
- cheader_filenames = new ArrayList<string> ();
- cheader_filenames.add (cheader_filename);
- }
-
- /**
- * Adds a filename to the list of C header filenames users of this data
- * type must include.
- *
- * @param filename a C header filename
- */
- public void add_cheader_filename (string filename) {
- if (cheader_filenames == null) {
- cheader_filenames = new ArrayList<string> ();
- }
- cheader_filenames.add (filename);
- }
-
public Symbol? get_hidden_member () {
Symbol sym = null;
diff --git a/vala/valatypesymbol.vala b/vala/valatypesymbol.vala
index 956939b8e..8ba3aef57 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,179 +41,6 @@ public abstract class Vala.TypeSymbol : Symbol {
public virtual bool is_reference_type () {
return false;
}
-
- /**
- * Returns the C function name that duplicates instances of this data
- * type. The specified C function must accept one argument referencing
- * the instance of this data type and return a reference to the
- * duplicate.
- *
- * @return the name of the C function if supported or null otherwise
- */
- public virtual string? get_dup_function () {
- return null;
- }
-
- /**
- * Returns the C function name that frees instances of this data type.
- * The specified C function must accept one argument pointing to the
- * instance to be freed.
- *
- * @return the name of the C function if supported or null otherwise
- */
- public virtual string? get_free_function () {
- return null;
- }
-
- /**
- * Returns the C function name that copies contents of instances of
- * this data type. This is only applicable to structs. The specified
- * C function must accept two arguments, the first is the source value
- * and the second is the destination value.
- *
- * @return the name of the C function if supported or null otherwise
- */
- public virtual string? get_copy_function () {
- return null;
- }
-
- /**
- * Returns the C function name that destroys the contents of instances
- * of this data type. This is only applicable to structs. The specified
- * C function must accept one argument pointing to the instance to be
- * destroyed.
- *
- * @return the name of the C function if supported or null otherwise
- */
- public virtual string? get_destroy_function () {
- return null;
- }
-
- /**
- * Checks whether this data type supports reference counting. This is
- * only valid for reference types.
- *
- * @return true if this data type supports reference counting
- */
- public virtual bool is_reference_counting () {
- return false;
- }
-
- /**
- * Returns the C function name that increments the reference count of
- * instances of this data type. This is only valid for data types
- * supporting reference counting. The specified C function must accept
- * one argument referencing the instance of this data type and return
- * the reference.
- *
- * @return the name of the C function or null if this data type does not
- * support reference counting
- */
- public virtual string? get_ref_function () {
- return null;
- }
-
- /**
- * Returns the C function name that decrements the reference count of
- * instances of this data type. This is only valid for data types
- * supporting reference counting. The specified C function must accept
- * one argument referencing the instance of this data type.
- *
- * @return the name of the C function or null if this data type does not
- * support reference counting
- */
- public virtual string? get_unref_function () {
- return null;
- }
-
- /**
- * Returns the C function name that sinks the reference count of
- * "floating" instances of this data type. This is only valid for data
- * types supporting floating references. The specified C function must
- * accept one argument referencing the instance of this data type and
- * return a non-floating reference.
- *
- * The ref_sink function is called for any constructor of the class and
- * for other methods that have the class as a return value and are
- * marked with the 'floating' attribute.
- *
- * @return the name of the C function or null if this data type does not
- * support floating reference counts
- */
- public virtual string? get_ref_sink_function () {
- return null;
- }
-
- /**
- * Returns the C symbol representing the runtime type id for this data
- * type. The specified symbol must express a registered GType.
- *
- * @return the name of the GType name in C code or null if this data
- * type is not registered with GType
- */
- public virtual string? get_type_id () {
- return null;
- }
-
- /**
- * Returns the name of this data type as used in C code marshallers
- *
- * @return type name for marshallers
- */
- public virtual string? get_marshaller_type_name () {
- return null;
- }
-
- /**
- * Returns the cname of the GValue parameter spec function.
- */
- public virtual string? get_param_spec_function () {
- return null;
- }
-
- /**
- * Returns the cname of the GValue getter function.
- */
- public virtual string? get_get_value_function () {
- return null;
- }
-
- /**
- * Returns the cname of the GValue setter function.
- */
- public virtual string? get_set_value_function () {
- return null;
- }
-
- /**
- * Returns the cname of the GValue taker function.
- */
- public virtual string? get_take_value_function () {
- return null;
- }
-
- /**
- * Returns the C name of this data type in upper case. Words are
- * separated by underscores. The upper case C name of the namespace is
- * prefix of the result.
- *
- * @param infix a string to be placed between namespace and data type
- * name or null
- * @return the upper case name to be used in C code
- */
- public virtual string? get_upper_case_cname (string? infix = null) {
- return null;
- }
-
- /**
- * Returns the default value for the given type. Returning null means
- * there is no default value (i.e. not that the default name is NULL).
- *
- * @return the name of the default value
- */
- public virtual string? get_default_value () {
- 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 baec19eb7..d78af9960 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/valavariable.vala b/vala/valavariable.vala
index 56cb1aed4..9337751e1 100644
--- a/vala/valavariable.vala
+++ b/vala/valavariable.vala
@@ -49,123 +49,12 @@ public class Vala.Variable : Symbol {
}
}
- /**
- * Specifies whether an array length field should implicitly be created
- * if the field type is an array.
- */
- public bool no_array_length { get; set; }
-
- /**
- * Specifies whether a delegate target field should implicitly be created
- * if the field type is a delegate.
- */
- public bool no_delegate_target { get; set; }
-
- /**
- * Specifies whether the array is null terminated.
- */
- public bool array_null_terminated { get; set; }
-
- /**
- * Specifies whether the array length field uses a custom name in C.
- */
- public bool has_array_length_cname {
- get { return (array_length_cname != null); }
- }
-
- /**
- * Specifies whether the array uses a custom C expression as length.
- */
- public bool has_array_length_cexpr {
- get { return (array_length_cexpr != null); }
- }
-
- /**
- * Specifies a custom type for the array length.
- */
- public string? array_length_type { get; set; default = null; }
-
Expression? _initializer;
DataType? _variable_type;
- private string? array_length_cname;
-
- private string? array_length_cexpr;
-
public Variable (DataType? variable_type, string? name, Expression? initializer = null, SourceReference? source_reference = null, Comment? comment = null) {
base (name, source_reference, comment);
this.variable_type = variable_type;
this.initializer = initializer;
}
-
- /**
- * Returns the name of the array length variable as it is used in C code
- *
- * @return the name of the array length variable to be used in C code
- */
- public string? get_array_length_cname () {
- return this.array_length_cname;
- }
-
- /**
- * Sets the name of the array length variable as it is used in C code
- *
- * @param array_length_cname the name of the array length variable to be
- * used in C code
- */
- public void set_array_length_cname (string? array_length_cname) {
- this.array_length_cname = array_length_cname;
- }
-
- /**
- * Returns the array length expression as it is used in C code
- *
- * @return the array length expression to be used in C code
- */
- public string? get_array_length_cexpr () {
- return this.array_length_cexpr;
- }
-
-
- /**
- * Sets the array length expression as it is used in C code
- *
- * @param array_length_cexpr the array length expression to be used in C
- * code
- */
- public void set_array_length_cexpr (string? array_length_cexpr) {
- this.array_length_cexpr = array_length_cexpr;
- }
-
- void process_ccode_attribute (Attribute a) {
- if (a.has_argument ("array_length")) {
- no_array_length = !a.get_bool ("array_length");
- }
- if (a.has_argument ("array_null_terminated")) {
- array_null_terminated = a.get_bool ("array_null_terminated");
- }
- if (a.has_argument ("array_length_cname")) {
- set_array_length_cname (a.get_string ("array_length_cname"));
- }
- if (a.has_argument ("array_length_cexpr")) {
- set_array_length_cexpr (a.get_string ("array_length_cexpr"));
- }
- if (a.has_argument ("array_length_type")) {
- array_length_type = a.get_string ("array_length_type");
- }
- if (a.has_argument ("delegate_target")) {
- no_delegate_target = !a.get_bool ("delegate_target");
- }
- }
-
- /**
- * Process all associated attributes.
- */
- public virtual void process_attributes () {
- foreach (Attribute a in attributes) {
- if (a.name == "CCode") {
- process_ccode_attribute (a);
- }
- }
- }
}
diff --git a/vala/valavoidtype.vala b/vala/valavoidtype.vala
index b328f5578..9035c25c8 100644
--- a/vala/valavoidtype.vala
+++ b/vala/valavoidtype.vala
@@ -38,15 +38,7 @@ public class Vala.VoidType : DataType {
return "void";
}
- public override string? get_cname () {
- return "void";
- }
-
public override DataType copy () {
return new VoidType (source_reference);
}
-
- public override string? get_type_id () {
- return "G_TYPE_NONE";
- }
}