[Vala] [PATCH 2/2] Map GIRepository "record" type to Class instead of Struct



The GObject Introspection "record" type is actually a reference type,
unlike the pass-by-value semantics of the Vala Struct. Map the "record"
type to Vala's Class (with is_compact set), as that seems to be the
closest mapping.
---
 vala/valagirparser.vala |   15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/vala/valagirparser.vala b/vala/valagirparser.vala
index c47b36b..d2f9ae1 100644
--- a/vala/valagirparser.vala
+++ b/vala/valagirparser.vala
@@ -287,11 +287,11 @@ public class Vala.GirParser : CodeVisitor {
                return ns;
        }
 
-       Struct parse_alias () {
+       Class parse_alias () {
                start_element ("alias");
-               var st = new Struct (reader.get_attribute ("name"), get_current_src ());
+               var st = new Class (reader.get_attribute ("name"), get_current_src ());
                st.access = SymbolAccessibility.PUBLIC;
-               st.base_type = parse_type_from_name (reader.get_attribute ("target"));
+               st.add_base_type(parse_type_from_name (reader.get_attribute ("target")));
                st.external = true;
                next ();
                end_element ("alias");
@@ -565,13 +565,16 @@ public class Vala.GirParser : CodeVisitor {
                return gir_module_name;
        }
 
-       Struct parse_record () {
+       Class parse_record () {
                start_element ("record");
-               var st = new Struct (reader.get_attribute ("name"), get_current_src ());
+               var st = new Class (reader.get_attribute ("name"), get_current_src ());
                st.external = true;
+               st.is_compact = true;
 
                string glib_is_gtype_struct_for = reader.get_attribute ("glib:is-gtype-struct-for");
 
+               st.set_cname (reader.get_attribute ("c:type"));
+
                st.access = SymbolAccessibility.PUBLIC;
                next ();
                while (current_token == MarkupTokenType.START_ELEMENT) {
@@ -1253,7 +1256,7 @@ public class Vala.GirParser : CodeVisitor {
                        } else if (reader.name == "method") {
                                st.add_method (parse_method ("method"));
                        } else if (reader.name == "record") {
-                               Struct s = parse_record ();
+                               Class s = parse_record ();
                                var fs = s.get_fields ();
                                foreach (var f in fs) {
                                        f.set_cname (s.get_cname () + "." + f.get_cname ());
-- 
1.7.2




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]