diff options
author | Jürg Billeter <j@bitron.ch> | 2008-12-15 08:19:39 +0000 |
---|---|---|
committer | Jürg Billeter <juergbi@src.gnome.org> | 2008-12-15 08:19:39 +0000 |
commit | 3696a4b1ca1a539d0415cab38958d82fee5590bf (patch) | |
tree | 30e91f8a1c9969ff905c39a12cfc363f65de8688 /vala | |
parent | 78be2505bbd34cd7d39e939f21dd76fd82dadfaa (diff) | |
download | vala-3696a4b1ca1a539d0415cab38958d82fee5590bf.tar.gz |
Register structs as boxed types, generate dup, copy, and free functions,
2008-12-15 Jürg Billeter <j@bitron.ch>
* vala/valastruct.vala:
* gobject/Makefile.am:
* gobject/valaccodebasemodule.vala:
* gobject/valaccodestructmodule.vala:
* gobject/valagtypemodule.vala:
* gobject/valastructregisterfunction.vala:
* gobject/valatyperegisterfunction.vala:
Register structs as boxed types, generate dup, copy, and free
functions, fixes bug 548864
svn path=/trunk/; revision=2151
Diffstat (limited to 'vala')
-rw-r--r-- | vala/valastruct.vala | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/vala/valastruct.vala b/vala/valastruct.vala index daab55369..e623124ff 100644 --- a/vala/valastruct.vala +++ b/vala/valastruct.vala @@ -373,16 +373,21 @@ public class Vala.Struct : TypeSymbol { public override string? get_type_id () { if (type_id == null) { - foreach (DataType type in base_types) { - var st = type.data_type as Struct; - if (st != null) { - return st.get_type_id ();; + // TODO use attribute check instead + if (external_package) { + foreach (DataType type in base_types) { + var st = type.data_type as Struct; + if (st != null) { + return st.get_type_id ();; + } + } + if (is_simple_type ()) { + Report.error (source_reference, "The type `%s` doesn't declare a type id".printf (get_full_name ())); + } else { + return "G_TYPE_POINTER"; } - } - if (is_simple_type ()) { - Report.error (source_reference, "The type `%s` doesn't declare a type id".printf (get_full_name ())); } else { - return "G_TYPE_POINTER"; + type_id = get_upper_case_cname ("TYPE_"); } } return type_id; @@ -555,6 +560,24 @@ 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"; } |