vala r1430 - in trunk: . gobject vala vapi
- From: juergbi svn gnome org
- To: svn-commits-list gnome org
- Subject: vala r1430 - in trunk: . gobject vala vapi
- Date: Sun, 25 May 2008 14:02:57 +0000 (UTC)
Author: juergbi
Date: Sun May 25 14:02:57 2008
New Revision: 1430
URL: http://svn.gnome.org/viewvc/vala?rev=1430&view=rev
Log:
2008-05-25 Juerg Billeter <j bitron ch>
* vala/valaclass.vala:
* gobject/valaccodegenerator.vala:
* vapi/glib-2.0.vapi:
Add support for [Immutable] class attribute, allow duplication of
immutable instances
Modified:
trunk/ChangeLog
trunk/gobject/valaccodegenerator.vala
trunk/vala/valaclass.vala
trunk/vapi/glib-2.0.vapi
Modified: trunk/gobject/valaccodegenerator.vala
==============================================================================
--- trunk/gobject/valaccodegenerator.vala (original)
+++ trunk/gobject/valaccodegenerator.vala Sun May 25 14:02:57 2008
@@ -1254,11 +1254,13 @@
}
private CCodeExpression? get_dup_func_expression (DataType type, SourceReference? source_reference) {
+ var cl = type.data_type as Class;
if (type.data_type != null) {
string dup_function;
if (type.data_type.is_reference_counting ()) {
dup_function = type.data_type.get_ref_function ();
- } else if (type.data_type == string_type.data_type) {
+ } else if (cl != null && cl.is_immutable) {
+ // allow duplicates of immutable instances as for example strings
dup_function = type.data_type.get_dup_function ();
} else if (type is ValueType) {
dup_function = "";
Modified: trunk/vala/valaclass.vala
==============================================================================
--- trunk/vala/valaclass.vala (original)
+++ trunk/vala/valaclass.vala Sun May 25 14:02:57 2008
@@ -62,6 +62,21 @@
}
/**
+ * Instances of immutable classes are immutable after construction.
+ */
+ public bool is_immutable {
+ get {
+ if (base_class != null) {
+ return base_class.is_immutable;
+ }
+ return _is_immutable;
+ }
+ set {
+ _is_immutable = value;
+ }
+ }
+
+ /**
* Specifies whether this class has private fields.
*/
public bool has_private_fields { get; private set; }
@@ -80,6 +95,7 @@
private string set_value_function;
private string? type_signature;
private bool _is_compact;
+ private bool _is_immutable;
private Gee.List<TypeParameter> type_parameters = new ArrayList<TypeParameter> ();
@@ -562,6 +578,8 @@
is_error_base = true;
} else if (a.name == "Compact") {
is_compact = true;
+ } else if (a.name == "Immutable") {
+ is_immutable = true;
}
}
}
Modified: trunk/vapi/glib-2.0.vapi
==============================================================================
--- trunk/vapi/glib-2.0.vapi (original)
+++ trunk/vapi/glib-2.0.vapi Sun May 25 14:02:57 2008
@@ -545,6 +545,7 @@
}
[Compact]
+[Immutable]
[CCode (cname = "char", const_cname = "const char", copy_function = "g_strdup", free_function = "g_free", cheader_filename = "stdlib.h,string.h,glib.h", type_id = "G_TYPE_STRING", marshaller_type_name = "STRING", get_value_function = "g_value_get_string", set_value_function = "g_value_set_string", type_signature = "s")]
public class string {
[CCode (cname = "strstr")]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]