[vala/wip/abi: 6/9] codegen: Add "padding" CCode attributes for classes/interfaces



commit 28ff7968d18a0d6cdd1334ddc2cac5f851fa1dc5
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Wed Jan 17 15:10:37 2018 +0100

    codegen: Add "padding" CCode attributes for classes/interfaces
    
    New CCode attribute are:
     * "class_padding" and "instance_padding" of integer type
     * "class_padding_ctype" and "instance_padding_ctype" of string type
    
    The *_ctype attributes default to "void *" and for *_padding > 0 a field
    will be appended to the respective struct, e.g. "void * _vala_padding[3];".
    
    https://bugzilla.gnome.org/show_bug.cgi?id=789069

 codegen/valagtypemodule.vala |   11 +++++++++++
 vala/valausedattr.vala       |    2 +-
 2 files changed, 12 insertions(+), 1 deletions(-)
---
diff --git a/codegen/valagtypemodule.vala b/codegen/valagtypemodule.vala
index 95d119b..1a304ba 100644
--- a/codegen/valagtypemodule.vala
+++ b/codegen/valagtypemodule.vala
@@ -296,6 +296,17 @@ public class Vala.GTypeModule : GErrorModule {
                if (is_gtypeinstance) {
                        if (context.abi_stability) {
                                instance_struct.add_field ("%sPrivate *".printf (get_ccode_name (cl)), 
"priv");
+
+                               var instance_padding = cl.get_attribute_integer ("CCode", "instance_padding", 
0);
+                               if (instance_padding > 0) {
+                                       var instance_padding_ctype = cl.get_attribute_string ("CCode", 
"instance_padding_ctype", "void *");
+                                       instance_struct.add_field (instance_padding_ctype, 
"_vala_padding[%i]".printf (instance_padding));
+                               }
+                               var class_padding = cl.get_attribute_integer ("CCode", "class_padding", 0);
+                               if (class_padding > 0) {
+                                       var class_padding_ctype = cl.get_attribute_string ("CCode", 
"class_padding_ctype", "void *");
+                                       type_struct.add_field (class_padding_ctype, 
"_vala_padding[%i]".printf (class_padding));
+                               }
                        }
                        decl_space.add_type_definition (type_struct);
                }
diff --git a/vala/valausedattr.vala b/vala/valausedattr.vala
index 9b0a859..9f6919d 100644
--- a/vala/valausedattr.vala
+++ b/vala/valausedattr.vala
@@ -40,7 +40,7 @@ public class Vala.UsedAttr : CodeVisitor {
                "array_length_type", "array_length", "array_length_cname", "array_length_cexpr", 
"array_null_terminated",
                "vfunc_name", "finish_vfunc_name", "finish_name", "free_function_address_of", "pos", 
"delegate_target", "delegate_target_cname",
                "array_length_pos", "delegate_target_pos", "destroy_notify_pos", "ctype", "has_new_function", 
"notify", "finish_instance",
-               "use_inplace", "",
+               "use_inplace", "class_padding", "class_padding_ctype", "instance_padding", 
"instance_padding_ctype", "",
 
                "Immutable", "",
                "Compact", "",


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