]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Add support for [Compact] class attribute, register non-compact classes
authorJuerg Billeter <j@bitron.ch>
Sun, 25 May 2008 13:29:24 +0000 (13:29 +0000)
committerJürg Billeter <juergbi@src.gnome.org>
Sun, 25 May 2008 13:29:24 +0000 (13:29 +0000)
2008-05-25  Juerg Billeter  <j@bitron.ch>

* vala/valaclass.vala:
* vala/valainterfacewriter.vala:
* gobject/valaccodeclassbinding.vala:
* gobject/valaccodegenerator.vala:
* gobject/valaccodememberaccessbinding.vala:
* gobject/valaccodemethodbinding.vala:
* gobject/valatyperegisterfunction.vala:

Add support for [Compact] class attribute, register non-compact
classes with GType, fixes bug 532518

* gee/hashmap.vala:
* gee/hashset.vala:
* gobject-introspection/gidl.vapi:
* tests/classes.exp:
* tests/classes.vala:
* vapi/glib-2.0.vapi:

Update to use compact classes where appropriate

svn path=/trunk/; revision=1425

14 files changed:
ChangeLog
gee/hashmap.vala
gee/hashset.vala
gobject-introspection/gidl.vapi
gobject/valaccodeclassbinding.vala
gobject/valaccodegenerator.vala
gobject/valaccodememberaccessbinding.vala
gobject/valaccodemethodbinding.vala
gobject/valatyperegisterfunction.vala
tests/classes.exp
tests/classes.vala
vala/valaclass.vala
vala/valainterfacewriter.vala
vapi/glib-2.0.vapi

index d511c252c4e8e2074910f307d0b6c2717ccc7329..0282662f8b8285745bdcb33f60ae46cc5cba036d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2008-05-25  Jürg Billeter  <j@bitron.ch>
+
+       * vala/valaclass.vala:
+       * vala/valainterfacewriter.vala:
+       * gobject/valaccodeclassbinding.vala:
+       * gobject/valaccodegenerator.vala:
+       * gobject/valaccodememberaccessbinding.vala:
+       * gobject/valaccodemethodbinding.vala:
+       * gobject/valatyperegisterfunction.vala:
+
+       Add support for [Compact] class attribute, register non-compact
+       classes with GType, fixes bug 532518
+
+       * gee/hashmap.vala:
+       * gee/hashset.vala:
+       * gobject-introspection/gidl.vapi:
+       * tests/classes.exp:
+       * tests/classes.vala:
+       * vapi/glib-2.0.vapi:
+
+       Update to use compact classes where appropriate
+
 2008-05-25  Jürg Billeter  <j@bitron.ch>
 
        * vala/valaparser.vala:
index 9269c75bb42f7081efa6b51a4640aab393c186c2..3802468b6a9e3713c873735051894643618e3d32 100644 (file)
@@ -168,6 +168,7 @@ public class Gee.HashMap<K,V> : Object, Map<K,V> {
                clear ();
        }
 
+       [Compact]
        private class Node<K,V> {
                public K key;
                public V value;
index 96e85f47de8c0b03200078eb33b62447308dc544..d614701bf06de59f168e80b4fc5845eb4ef49e0b 100644 (file)
@@ -152,6 +152,7 @@ public class Gee.HashSet<G> : Object, Iterable<G>, Collection<G>, Set<G> {
                clear ();
        }
 
+       [Compact]
        private class Node<G> {
                public G key;
                public Node<G> next;
index e2bae696b5553b3a6cb85dab5fba338a9f72ba95..539a8a100c44b6057565cbc5e20b35ec843a8d12 100644 (file)
@@ -26,7 +26,8 @@ namespace GLib {
        namespace Idl {
                public List<IdlModule> parse_file (string filename) throws MarkupError;
        }
-       
+
+       [Compact]
        [CCode (free_function = "g_idl_module_free", cheader_filename = "gidlmodule.h")]
        public class IdlModule {
                public string name;
@@ -56,13 +57,15 @@ namespace GLib {
                FIELD,
                XREF
        }
-       
+
+       [Compact]
        [CCode (free_function = "g_idl_node_free", cheader_filename = "gidlnode.h")]
        public class IdlNode {
                public IdlNodeTypeId type;
                public string name;
        }
-       
+
+       [Compact]
        [CCode (free_function = "g_idl_node_free", cheader_filename = "gidlnode.h")]
        public class IdlNodeFunction {
                public bool deprecated;
@@ -79,6 +82,7 @@ namespace GLib {
                public List<IdlNodeParam> parameters;
        }
 
+       [Compact]
        [CCode (free_function = "g_idl_node_free", cheader_filename = "gidlnode.h")]
        public class IdlNodeVFunc 
        {
@@ -91,7 +95,8 @@ namespace GLib {
                public IdlNodeParam result;
                public int offset;
        }
-       
+
+       [Compact]
        [CCode (free_function = "g_idl_node_free", cheader_filename = "gidlnode.h")]
        public class IdlNodeSignal {
                public bool deprecated;
@@ -112,7 +117,8 @@ namespace GLib {
                public List<IdlNodeParam> parameters;
                public IdlNodeParam result;
        }
-       
+
+       [Compact]
        [CCode (free_function = "g_idl_node_free", cheader_filename = "gidlnode.h")]
        public class IdlNodeBoxed {
                public bool deprecated;
@@ -122,7 +128,8 @@ namespace GLib {
                
                public List<IdlNode> members;
        }
-       
+
+       [Compact]
        [CCode (free_function = "g_idl_node_free", cheader_filename = "gidlnode.h")]
        public class IdlNodeEnum {
                public bool deprecated;
@@ -132,7 +139,8 @@ namespace GLib {
                
                public List<IdlNode> values;
        }
-       
+
+       [Compact]
        [CCode (free_function = "g_idl_node_free", cheader_filename = "gidlnode.h")]
        public class IdlNodeField {
                public bool readable;
@@ -142,7 +150,8 @@ namespace GLib {
                
                public IdlNodeType type;
        }
-       
+
+       [Compact]
        [CCode (free_function = "g_idl_node_free", cheader_filename = "gidlnode.h")]
        public class IdlNodeConstant {
                public bool deprecated;
@@ -151,7 +160,8 @@ namespace GLib {
                
                public string value;
        }
-       
+
+       [Compact]
        [CCode (free_function = "g_idl_node_free", cheader_filename = "gidlnode.h")]
        public class IdlNodeInterface {
                public bool deprecated;
@@ -166,7 +176,8 @@ namespace GLib {
                
                public List<IdlNode> members;
        }
-       
+
+       [Compact]
        [CCode (free_function = "g_idl_node_free", cheader_filename = "gidlnode.h")]
        public class IdlNodeParam {
                public bool @in;
@@ -180,7 +191,8 @@ namespace GLib {
                
                public IdlNodeType type;
        }
-       
+
+       [Compact]
        [CCode (free_function = "g_idl_node_free", cheader_filename = "gidlnode.h")]
        public class IdlNodeProperty {
                public bool deprecated;
@@ -194,21 +206,24 @@ namespace GLib {
                
                public IdlNodeType type;
        }
-       
+
+       [Compact]
        [CCode (free_function = "g_idl_node_free", cheader_filename = "gidlnode.h")]
        public class IdlNodeStruct {
                public bool deprecated;
                
                public List<IdlNode> members;
        }
-       
+
+       [Compact]
        [CCode (free_function = "g_idl_node_free", cheader_filename = "gidlnode.h")]
        public class IdlNodeUnion {
                public bool deprecated;
                
                public List<IdlNode> members;
        }
-       
+
+       [Compact]
        [CCode (free_function = "g_idl_node_free", cheader_filename = "gidlnode.h")]
        public class IdlNodeType {
                public bool is_pointer;
index 051c2541e630f31ee02a6197aefa5b7275676425..88fecd7b479e1c3d82a4d6679ae6200c0a8a58ca 100644 (file)
@@ -46,9 +46,9 @@ public class Vala.CCodeClassBinding : CCodeTypesymbolBinding {
                codegen.current_type_symbol = cl;
                codegen.current_class = cl;
                
-               bool is_gtypeinstance = cl.is_subtype_of (codegen.gtypeinstance_type);
+               bool is_gtypeinstance = !cl.is_compact;
                bool is_gobject = cl.is_subtype_of (codegen.gobject_type);
-               bool is_fundamental = (cl.base_class == codegen.gtypeinstance_type);
+               bool is_fundamental = is_gtypeinstance && cl.base_class == null;
 
                if (cl.get_cname().len () < 3) {
                        cl.error = true;
@@ -106,9 +106,9 @@ public class Vala.CCodeClassBinding : CCodeTypesymbolBinding {
 
                if (cl.base_class != null) {
                        codegen.instance_struct.add_field (cl.base_class.get_cname (), "parent_instance");
-                       if (is_fundamental) {
-                               codegen.instance_struct.add_field ("volatile int", "ref_count");
-                       }
+               } else if (is_fundamental) {
+                       codegen.instance_struct.add_field ("GTypeInstance", "parent_instance");
+                       codegen.instance_struct.add_field ("volatile int", "ref_count");
                }
 
                if (is_gtypeinstance) {
index 366cd34d146684136989bccdf3c3ea39c474deea..920350b351937f5f49660d66f734ccf4cca760cb 100644 (file)
@@ -101,7 +101,6 @@ public class Vala.CCodeGenerator : CodeGenerator {
        public DataType float_type;
        public DataType double_type;
        public Typesymbol gtype_type;
-       public Typesymbol gtypeinstance_type;
        public Typesymbol gobject_type;
        public ErrorType gerror_type;
        public Class glist_type;
@@ -228,7 +227,6 @@ public class Vala.CCodeGenerator : CodeGenerator {
                var glib_ns = root_symbol.scope.lookup ("GLib");
 
                gtype_type = (Typesymbol) glib_ns.scope.lookup ("Type");
-               gtypeinstance_type = (Typesymbol) glib_ns.scope.lookup ("TypeInstance");
                gobject_type = (Typesymbol) glib_ns.scope.lookup ("Object");
                gerror_type = new ErrorType (null, null);
                glist_type = (Class) glib_ns.scope.lookup ("List");
@@ -508,7 +506,7 @@ public class Vala.CCodeGenerator : CodeGenerator {
                f.accept_children (this);
 
                var cl = f.parent_symbol as Class;
-               bool is_gtypeinstance = (cl != null && cl.is_subtype_of (gtypeinstance_type));
+               bool is_gtypeinstance = (cl != null && !cl.is_compact);
 
                CCodeExpression lhs = null;
                CCodeStruct st = null;
@@ -2991,7 +2989,7 @@ public class Vala.CCodeGenerator : CodeGenerator {
                                creation_call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, instance));
                        } else if (expr.type_reference.data_type is Class) {
                                var cl = (Class) expr.type_reference.data_type;
-                               if (cl.base_class == gtypeinstance_type) {
+                               if (!cl.is_compact && cl.base_class == null) {
                                        creation_call.add_argument (new CCodeIdentifier (cl.get_type_id ()));
                                }
                        }
@@ -3190,9 +3188,9 @@ public class Vala.CCodeGenerator : CodeGenerator {
        }
 
        public override void visit_cast_expression (CastExpression expr) {
-               if (expr.type_reference.data_type != null
-                   && expr.type_reference.data_type.is_subtype_of (gtypeinstance_type)
-                   && expr.type_reference.data_type != gtypeinstance_type) {
+               var cl = expr.type_reference.data_type as Class;
+               var iface = expr.type_reference.data_type as Interface;
+               if (iface != null || (cl != null && !cl.is_compact)) {
                        // checked cast for strict subtypes of GTypeInstance
                        if (expr.is_silent_cast) {
                                var ccomma = new CCodeCommaExpression ();
@@ -3436,9 +3434,9 @@ public class Vala.CCodeGenerator : CodeGenerator {
                        return cexpr;
                }
 
-               if (context.checking && target_type.data_type != null
-                   && target_type.data_type.is_subtype_of (gtypeinstance_type)
-                   && target_type.data_type != gtypeinstance_type) {
+               var cl = target_type.data_type as Class;
+               var iface = target_type.data_type as Interface;
+               if (context.checking && (iface != null || (cl != null && !cl.is_compact))) {
                        // checked cast for strict subtypes of GTypeInstance
                        return new InstanceCast (cexpr, target_type.data_type);
                } else if (target_type.data_type != null && expression_type.get_cname () != target_type.get_cname ()) {
index 83126df10438bcc9c904597aff1174c68dad348b..db4b97a91cba0551647fa404345882a056fa4855 100644 (file)
@@ -86,7 +86,8 @@ public class Vala.CCodeMemberAccessBinding : CCodeExpressionBinding {
                                var instance_target_type = codegen.get_data_type_for_symbol ((Typesymbol) f.parent_symbol);
                                CCodeExpression typed_inst = codegen.get_implicit_cast_expression (pub_inst, instance_expression_type, instance_target_type);
 
-                               bool is_gtypeinstance = (instance_target_type.data_type.is_subtype_of (codegen.gtypeinstance_type));
+                               var cl = instance_target_type.data_type as Class;
+                               bool is_gtypeinstance = (cl == null || !cl.is_compact);
 
                                CCodeExpression inst;
                                if (is_gtypeinstance && f.access == SymbolAccessibility.PRIVATE) {
index 4dca49812a8747978b0edb469277b31b7ff24876..e98b5289615d0816ab09c6307c809f545da2ec71 100644 (file)
@@ -60,9 +60,9 @@ public class Vala.CCodeMethodBinding : CCodeBinding {
                if (m is CreationMethod) {
                        codegen.in_creation_method = true;
                        var cl = codegen.current_type_symbol as Class;
-                       if (cl != null && cl.is_subtype_of (codegen.gtypeinstance_type)) {
+                       if (cl != null && !cl.is_compact) {
                                in_gtypeinstance_creation_method = true;
-                               if (cl.base_class == codegen.gtypeinstance_type) {
+                               if (cl.base_class == null) {
                                        in_fundamental_creation_method = true;
                                } else if (cl.is_subtype_of (codegen.gobject_type)) {
                                        in_gobject_creation_method = true;
@@ -785,7 +785,7 @@ public class Vala.CCodeMethodBinding : CCodeBinding {
 
        private Class find_fundamental_class (Class cl) {
                var fundamental_class = cl;
-               while (fundamental_class != null && fundamental_class.base_class != codegen.gtypeinstance_type) {
+               while (fundamental_class != null && fundamental_class.base_class != null) {
                        fundamental_class = fundamental_class.base_class;
                }
                return fundamental_class;
index f2edaa0a87669853d13501a5f71389b08bef05e2..72058beba3f60fc54e9ed0306bc50e5ff6bee0b3 100644 (file)
@@ -36,7 +36,7 @@ public abstract class Vala.TypeRegisterFunction : Object {
        public void init_from_type (bool plugin = false) {
                bool fundamental = false;
                Class cl = get_type_declaration () as Class;
-               if (cl != null && cl.base_class != null && cl.base_class.name == "TypeInstance" && cl.base_class.parent_symbol.name == "GLib") {
+               if (cl != null && !cl.is_compact && cl.base_class == null) {
                        fundamental = true;
                }
 
index c416ffb308e5273a6bd68e60a50d8572f6ca69db..79541056360a0d491d1d812b13c7c3ce672e97ae 100644 (file)
@@ -1,13 +1,13 @@
 Classes Test:
-new SimpleClass ()
+new CompactClass ()
 new DerivedClass ()
 new PublicClass ()
 new ClassWithCreationMethod ()
 ClassWithCreationMethod
 new ClassWithNamedCreationMethod ()
 ClassWithNamedCreationMethod
-new ClassWithDestructor ()
-~ClassWithDestructor
+new CompactClassWithDestructor ()
+~CompactClassWithDestructor
 new SimpleGTypeInstanceClass ()
 new DerivedGTypeInstanceClass ()
 new PublicGTypeInstanceClass ()
@@ -20,6 +20,6 @@ new DerivedGObjectClass ()
 new PublicGObjectClass ()
 new GObjectClassWithCreationMethod ()
 new GObjectClassWithNamedCreationMethod ()
-new SimpleClass () { field = 1 }
-simple_class.field = 1
+new CompactClass () { field = 1 }
+compact_class.field = 1
 .
index 674c2dadd57465c0fb956c1b162deaa672181fdb..a89f475e66e627043991a11a8a7dc44e0dd1d5d9 100644 (file)
@@ -1,29 +1,34 @@
 using GLib;
 
-class SimpleClass {
+[Compact]
+class CompactClass {
        public int field;
 }
 
-class ClassWithDestructor {
-       ~ClassWithDestructor () {
-               stdout.printf ("~ClassWithDestructor\n");
+[Compact]
+class CompactClassWithDestructor {
+       ~CompactClassWithDestructor () {
+               stdout.printf ("~CompactClassWithDestructor\n");
        }
 
        /* FIXME bug 533977 */
        public char dummy;
 }
 
-class DerivedClass : SimpleClass {
+class DerivedClass : CompactClass {
 }
 
+[Compact]
 public class PublicClass {
        public int field;
 }
 
+[Compact]
 abstract class AbstractClass {
        public int field;
 }
 
+[Compact]
 class ClassWithCreationMethod {
        public ClassWithCreationMethod () {
                stdout.printf ("ClassWithCreationMethod\n");
@@ -32,6 +37,7 @@ class ClassWithCreationMethod {
        public int field;
 }
 
+[Compact]
 class ClassWithNamedCreationMethod {
        public ClassWithNamedCreationMethod.named () {
                stdout.printf ("ClassWithNamedCreationMethod\n");
@@ -40,22 +46,22 @@ class ClassWithNamedCreationMethod {
        public int field;
 }
 
-class SimpleGTypeInstanceClass : TypeInstance {
+class SimpleGTypeInstanceClass {
 }
 
 class DerivedGTypeInstanceClass : SimpleGTypeInstanceClass {
 }
 
-public class PublicGTypeInstanceClass : TypeInstance {
+public class PublicGTypeInstanceClass {
 }
 
-class GTypeInstanceClassWithCreationMethod : TypeInstance {
+class GTypeInstanceClassWithCreationMethod {
        public GTypeInstanceClassWithCreationMethod () {
                stdout.printf ("GTypeInstanceClassWithCreationMethod\n");
        }
 }
 
-class GTypeInstanceClassWithNamedCreationMethod : TypeInstance {
+class GTypeInstanceClassWithNamedCreationMethod {
        public GTypeInstanceClassWithNamedCreationMethod.named () {
                stdout.printf ("GTypeInstanceClassWithNamedCreationMethod\n");
        }
@@ -86,8 +92,8 @@ class GObjectClassWithNamedCreationMethod : Object {
 void main () {
        stdout.printf ("Classes Test:\n");
 
-       stdout.printf ("new SimpleClass ()\n");
-       var simple_class = new SimpleClass ();
+       stdout.printf ("new CompactClass ()\n");
+       var compact_class = new CompactClass ();
        stdout.printf ("new DerivedClass ()\n");
        var derived_class = new DerivedClass ();
        stdout.printf ("new PublicClass ()\n");
@@ -96,9 +102,9 @@ void main () {
        var class_with_creation_method = new ClassWithCreationMethod ();
        stdout.printf ("new ClassWithNamedCreationMethod ()\n");
        var class_with_named_creation_method = new ClassWithNamedCreationMethod.named ();
-       stdout.printf ("new ClassWithDestructor ()\n");
-       var class_with_destructor = new ClassWithDestructor ();
-       class_with_destructor = null;
+       stdout.printf ("new CompactClassWithDestructor ()\n");
+       var compact_class_with_destructor = new CompactClassWithDestructor ();
+       compact_class_with_destructor = null;
 
        stdout.printf ("new SimpleGTypeInstanceClass ()\n");
        var simple_gtypeinstance_class = new SimpleGTypeInstanceClass ();
@@ -122,9 +128,9 @@ void main () {
        stdout.printf ("new GObjectClassWithNamedCreationMethod ()\n");
        var gobject_class_with_named_creation_method = new GObjectClassWithNamedCreationMethod.named ();
 
-       stdout.printf ("new SimpleClass () { field = 1 }\n");
-       simple_class = new SimpleClass () { field = 1 };
-       stdout.printf ("simple_class.field = %d\n", simple_class.field);
+       stdout.printf ("new CompactClass () { field = 1 }\n");
+       compact_class = new CompactClass () { field = 1 };
+       stdout.printf ("compact_class.field = %d\n", compact_class.field);
 
        stdout.printf (".\n");
 }
index c9522d3cf1a15764aec68f3b58772c63a2f0b53e..3f0276064d461b28f5773825ab5af4a59d8df8d9 100644 (file)
@@ -44,6 +44,23 @@ public class Vala.Class : Typesymbol {
         */
        public bool is_static { get; set; }
 
+       /**
+        * Instances of compact classes are fast to create and have a
+        * compact memory layout. Compact classes don't support runtime
+        * type information or virtual methods.
+        */
+       public bool is_compact {
+               get {
+                       if (base_class != null) {
+                               return base_class.is_compact;
+                       }
+                       return _is_compact;
+               }
+               set {
+                       _is_compact = value;
+               }
+       }
+
        /**
         * Specifies whether this class has private fields.
         */
@@ -53,7 +70,6 @@ public class Vala.Class : Typesymbol {
        private string const_cname;
        private string lower_case_cprefix;
        private string lower_case_csuffix;
-       private bool has_type_id;
        private string type_id;
        private string ref_function;
        private string unref_function;
@@ -63,6 +79,7 @@ public class Vala.Class : Typesymbol {
        private string get_value_function;
        private string set_value_function;
        private string? type_signature;
+       private bool _is_compact;
 
        private Gee.List<TypeParameter> type_parameters = new ArrayList<TypeParameter> ();
 
@@ -498,9 +515,6 @@ public class Vala.Class : Typesymbol {
                if (a.has_argument ("free_function")) {
                        set_free_function (a.get_string ("free_function"));
                }
-               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");
                }
@@ -546,17 +560,15 @@ public class Vala.Class : Typesymbol {
                                process_ccode_attribute (a);
                        } else if (a.name == "ErrorBase") {
                                is_error_base = true;
+                       } else if (a.name == "Compact") {
+                               is_compact = true;
                        }
                }
        }
 
-       private bool get_has_type_id () {
-               return has_type_id || (base_class != null && base_class.get_has_type_id ());
-       }
-
        public override string? get_type_id () {
                if (type_id == null) {
-                       if (get_has_type_id ()) {
+                       if (!is_compact) {
                                type_id = get_upper_case_cname ("TYPE_");
                        } else {
                                type_id = "G_TYPE_POINTER";
@@ -611,9 +623,7 @@ public class Vala.Class : Typesymbol {
        }
 
        bool is_fundamental () {
-               if (base_class != null
-                   && base_class.name == "TypeInstance"
-                   && base_class.parent_symbol.name == "GLib") {
+               if (!is_compact && base_class == null) {
                        return true;
                }
                return false;
index 940b2edafd0a7e4d3941b790d4697b4edab41dd6..78a3b34f4fa87df57d8694f7f6c86eb595db1744 100644 (file)
@@ -92,7 +92,13 @@ public class Vala.InterfaceWriter : CodeVisitor {
                if (!check_accessibility (cl)) {
                        return;
                }
-               
+
+               if (cl.is_compact) {
+                       write_indent ();
+                       write_string ("[Compact]");
+                       write_newline ();
+               }
+
                write_indent ();
                
                write_string ("[CCode (");
index b619f9175467c44a4603ea39b392099c6d5f3f0a..c6a47202652f5c57336c7e9a0066256db3033cd2 100644 (file)
@@ -544,6 +544,7 @@ public enum UnicodeBreakType {
        HANGUL_LVT_SYLLABLE
 }
 
+[Compact]
 [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")]
@@ -692,12 +693,12 @@ namespace GLib {
                public uint instance_size;
        }
 
+       // deprecated
        [CCode (has_type_id = true)]
        public class TypeInstance {
-               [CCode (cname = "G_TYPE_FROM_INSTANCE")]
-               public Type get_type ();
        }
 
+       [Compact]
        [CCode (ref_function = "g_type_class_ref", unref_function = "g_type_class_unref")]
        public class TypeClass {
                [CCode (cname = "G_TYPE_FROM_CLASS")]
@@ -715,6 +716,7 @@ namespace GLib {
        public interface TypePlugin {
        }
 
+       [Compact]
        public class TypeModule : TypePlugin {
                public bool use ();
                public void unuse ();
@@ -722,8 +724,7 @@ namespace GLib {
        }
 
        [CCode (ref_function = "g_param_spec_ref", unref_function = "g_param_spec_unref")]
-       public class ParamSpec : TypeInstance {
-               public TypeInstance g_type_instance;
+       public class ParamSpec {
                public string name;
                public ParamFlags flags;
                public Type value_type;
@@ -798,6 +799,7 @@ namespace GLib {
                public weak EnumValue? get_value_by_nick (string name);
        }
 
+       [Compact]
        public class EnumValue {
                public int value;
                public weak string value_name;
@@ -811,12 +813,14 @@ namespace GLib {
                public weak FlagsValue? get_value_by_nick (string name);
        }
 
+       [Compact]
        public class FlagsValue {
                public int value;
                public weak string value_name;
                public weak string value_nick;
        }
 
+       [Compact]
        [CCode (cname = "gpointer", has_type_id = true, type_id = "G_TYPE_BOXED", marshaller_type_name = "BOXED", get_value_function = "g_value_get_boxed", set_value_function = "g_value_set_boxed")]
        public abstract class Boxed {
        }
@@ -917,6 +921,7 @@ namespace GLib {
 
        public static delegate void Callback ();
 
+       [Compact]
        public class Closure : Boxed {
        }
 
@@ -1104,7 +1109,8 @@ namespace GLib {
        }
 
        /* The Main Event Loop */
-       
+
+       [Compact]
        [CCode (ref_function = "g_main_loop_ref", unref_function = "g_main_loop_unref")]
        public class MainLoop {
                public MainLoop (MainContext? context, bool is_running);
@@ -1121,7 +1127,8 @@ namespace GLib {
                DEFAULT_IDLE,
                LOW
        }
-       
+
+       [Compact]
        [CCode (ref_function = "g_main_context_ref", unref_function = "g_main_context_unref")]
        public class MainContext {
                public MainContext ();
@@ -1195,7 +1202,8 @@ namespace GLib {
                public IOCondition events;
                public IOCondition revents;
        }
-       
+
+       [Compact]
        [CCode (ref_function = "g_source_ref", unref_function = "g_source_unref")]
        public class Source {
                public Source (SourceFuncs source_funcs, uint struct_size /* = sizeof (Source) */);
@@ -1226,6 +1234,7 @@ namespace GLib {
        public static delegate bool SourceDispatchFunc (Source source, SourceFunc _callback);
        public static delegate void SourceFinalizeFunc (Source source);
        
+       [Compact]
        public class SourceFuncs {
                public SourcePrepareFunc prepare;
                public SourceCheckFunc check;
@@ -1237,6 +1246,7 @@ namespace GLib {
        public static delegate void SourceCallbackUnrefFunc (void* cb_data);
        public static delegate void SourceCallbackGetFunc (void* cb_data, Source source, SourceFunc func);
        
+       [Compact]
        public class SourceCallbackFuncs {
                public SourceCallbackRefFunc @ref;
                public SourceCallbackUnrefFunc unref;
@@ -1250,6 +1260,7 @@ namespace GLib {
        }
 
        /* Thread support */
+       [Compact]
        public class ThreadFunctions {
        }
        
@@ -1263,6 +1274,7 @@ namespace GLib {
                URGENT
        }
        
+       [Compact]
        public class Thread {
                public static void init (ThreadFunctions? vtable = null);
                public static bool supported ();
@@ -1279,6 +1291,7 @@ namespace GLib {
                public static void usleep (ulong microseconds);
        }
        
+       [Compact]
        [CCode (free_function = "g_mutex_free")]
        public class Mutex {
                public Mutex ();
@@ -1296,6 +1309,7 @@ namespace GLib {
                public void lock_full ();
        }
 
+       [Compact]
        [CCode (free_function = "g_cond_free")]
        public class Cond {
                public Cond ();
@@ -1306,7 +1320,8 @@ namespace GLib {
        }
        
        /* Thread Pools */
-       
+
+       [Compact]
        [CCode (free_function = "g_thread_pool_free")]
        public class ThreadPool {
                public ThreadPool (Func func, void* user_data, int max_threads, bool exclusive) throws ThreadError;
@@ -1325,7 +1340,8 @@ namespace GLib {
        }
        
        /* Asynchronous Queues */
-       
+
+       [Compact]
        [CCode (ref_function = "g_async_queue_ref", unref_function = "g_async_queue_unref")]
        public class AsyncQueue {
                public AsyncQueue ();
@@ -1374,7 +1390,8 @@ namespace GLib {
        }
 
        /* IO Channels */
-       
+
+       [Compact]
        [CCode (ref_function = "g_io_channel_ref", unref_function = "g_io_channel_unref")]
        public class IOChannel : Boxed {
                [CCode (cname = "g_io_channel_unix_new")]
@@ -1465,6 +1482,7 @@ namespace GLib {
 
        /* Error Reporting */
 
+       [Compact]
        [ErrorBase]
        [CCode (copy_function = "g_error_copy", free_function = "g_error_free")]
        public class Error {
@@ -1602,6 +1620,7 @@ namespace GLib {
                public ssize_t get_length ();
        }
 
+       [Compact]
        [CCode (free_function = "g_checksum_free")]
        public class Checksum {
                public Checksum (ChecksumType checksum_type);
@@ -1769,7 +1788,8 @@ namespace GLib {
        }
 
        /* Random Numbers */
-       
+
+       [Compact]
        [CCode (copy_function = "g_rand_copy", free_function = "g_rand_free")]
        public class Rand {
                public Rand.with_seed (uint32 seed);
@@ -1884,6 +1904,7 @@ namespace GLib {
 
        /* Lexical Scanner */
 
+       [Compact]
        [CCode (free_function = "g_scanner_destroy")]
        public class Scanner {
                public Scanner (ScannerConfig config_templ);
@@ -2012,6 +2033,7 @@ namespace GLib {
 
        /* Timers */
 
+       [Compact]
        [CCode (free_function = "g_timer_destroy")]
        public class Timer {
                public Timer ();
@@ -2155,6 +2177,7 @@ namespace GLib {
                EXISTS
        }
 
+       [Compact]
        [CCode (cname = "FILE", free_function = "fclose", cheader_filename = "stdio.h")]
        public class FileStream {
                [CCode (cname = "fopen")]
@@ -2205,6 +2228,7 @@ namespace GLib {
        public struct Stat {
        }
 
+       [Compact]
        [CCode (free_function = "g_dir_close")]
        public class Dir {
                public static Dir open (string filename, uint _flags = 0) throws FileError;
@@ -2220,7 +2244,8 @@ namespace GLib {
                [CCode (cname = "mkdtemp")]
                public static weak string mkdtemp (string template);
        }
-       
+
+       [Compact]
        [CCode (free_function = "g_mapped_file_free")]
        public class MappedFile {
                public MappedFile (string filename, bool writable) throws FileError;
@@ -2275,6 +2300,7 @@ namespace GLib {
                FAILED
        }
 
+       [Compact]
        [CCode (free_function = "g_option_context_free")]
        public class OptionContext {
                public OptionContext (string parameter_string);
@@ -2335,6 +2361,7 @@ namespace GLib {
                public weak string arg_description;
        }
 
+       [Compact]
        [CCode (free_function = "g_option_group_free")]
        public class OptionGroup {
                public OptionGroup (string name, string description, string help_description, void* user_data, DestroyNotify? destroy);
@@ -2389,6 +2416,7 @@ namespace GLib {
                NEWLINE_ANY
        }
 
+       [Compact]
        [CCode (ref_function = "g_regex_ref", unref_function = "g_regex_unref")]
        public class Regex : Boxed {
                public Regex (string pattern, RegexCompileFlags compile_options = 0, RegexMatchFlags match_options = 0) throws RegexError;
@@ -2416,6 +2444,7 @@ namespace GLib {
 
        public static delegate bool RegexEvalCallback (MatchInfo match_info, StringBuilder result, void* user_data);
 
+       [Compact]
        [CCode (free_function = "g_match_info_free")]
        public class MatchInfo {
                public weak Regex get_regex ();
@@ -2448,7 +2477,8 @@ namespace GLib {
        public enum MarkupParseFlags {
                TREAT_CDATA_AS_TEXT
        }
-       
+
+       [Compact]
        [CCode (free_function = "g_markup_parse_context_free")]
        public class MarkupParseContext {
                public MarkupParseContext (MarkupParser parser, MarkupParseFlags _flags, void* user_data, DestroyNotify? user_data_dnotify);
@@ -2493,6 +2523,7 @@ namespace GLib {
                INVALID_VALUE
        }
 
+       [Compact]
        [CCode (free_function = "g_key_file_free")]
        public class KeyFile {
                public KeyFile ();
@@ -2551,6 +2582,7 @@ namespace GLib {
 
        /* Bookmark file parser */
 
+       [Compact]
        [CCode (free_function = "g_bookmark_file_free")]
        public class BookmarkFile {
                public BookmarkFile ();
@@ -2652,7 +2684,8 @@ namespace GLib {
        }
 
        /* Doubly-Linked Lists */
-       
+
+       [Compact]
        [CCode (dup_function = "g_list_copy", free_function = "g_list_free")]
        public class List<G> {
                [ReturnsModifiedPointer ()]
@@ -2705,7 +2738,8 @@ namespace GLib {
        }
        
        /* Singly-Linked Lists */
-       
+
+       [Compact]
        [CCode (dup_function = "g_slist_copy", free_function = "g_slist_free")]
        public class SList<G> {
                [ReturnsModifiedPointer ()]
@@ -2762,7 +2796,8 @@ namespace GLib {
        public static GLib.CompareFunc strcmp;
        
        /* Double-ended Queues */
-       
+
+       [Compact]
        [CCode (dup_function = "g_queue_copy", free_function = "g_queue_free")]
        public class Queue<G> {
                public weak List<G> head;
@@ -2797,6 +2832,7 @@ namespace GLib {
 
        /* Sequences */
 
+       [Compact]
        [CCode (free_function = "g_sequence_free")]
        public class Sequence<G> {
                public Sequence (DestroyNotify? data_destroy);
@@ -2827,6 +2863,7 @@ namespace GLib {
                public static weak SequenceIter<G> range_get_midpoint (SequenceIter<G> begin, SequenceIter<G> end);
        }
 
+       [Compact]
        [CCode (ref_function = "", unref_function = "")]
        public class SequenceIter<G> {
                public bool is_begin ();
@@ -2842,7 +2879,8 @@ namespace GLib {
        public delegate int SequenceIterCompareFunc<G> (SequenceIter<G> a, SequenceIter<G> b);
 
        /* Hash Tables */
-       
+
+       [Compact]
        [CCode (ref_function = "g_hash_table_ref", unref_function = "g_hash_table_unref")]
        public class HashTable<K,V> : Boxed {
                public HashTable (HashFunc hash_func, EqualFunc key_equal_func);
@@ -2886,6 +2924,7 @@ namespace GLib {
 
        /* Strings */
 
+       [Compact]
        [CCode (cname = "GString", cprefix = "g_string_", free_function = "g_string_free", type_id = "G_TYPE_GSTRING")]
        public class StringBuilder : Boxed {
                public StringBuilder (string init = "");
@@ -2914,19 +2953,22 @@ namespace GLib {
        }
 
        /* Pointer Arrays */
-       
+
+       [Compact]
        [CCode (free_function = "g_ptr_array_free")]
        public class PtrArray {
        }
 
        /* Byte Arrays */
 
+       [Compact]
        [CCode (free_function = "g_byte_array_free")]
        public class ByteArray {
        }
 
        /* N-ary Trees */
 
+       [Compact]
        [CCode (free_function = "g_node_destroy")]
        public class Node<G> {
                public G data;
@@ -2965,7 +3007,8 @@ namespace GLib {
        public delegate void DataForeachFunc<G> (Quark key_id, G data);
 
        /* GArray */
-       
+
+       [Compact]
        public class Array<G> {
                public Array (bool zero_terminated, bool clear, uint element_size);
                [CCode (cname = "g_array_sized_new")]
@@ -3006,7 +3049,8 @@ namespace GLib {
                POST_ORDER,
                LEVEL_ORDER
        }
-       
+
+       [Compact]
        [CCode (free_function = "g_tree_destroy")]
        public class Tree<K,V> {
                public Tree (CompareFunc key_compare_func);
@@ -3120,6 +3164,7 @@ namespace GLib {
                UNBLOCKED
        }
 
+       [Compact]
        public class PatternSpec {
                public PatternSpec (string pattern);
                public void free ();