[vala/wip/abi: 1/2] codegen: Add "class_padding/instance_padding" CCode attributes for classes/interfaces



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

    codegen: Add "class_padding/instance_padding" CCode attributes for classes/interfaces
    
    This appends "void * _vala_padding[x];" this the respective struct.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=789069

 codegen/valagtypemodule.vala |    9 +++++++++
 vala/valausedattr.vala       |    2 +-
 2 files changed, 10 insertions(+), 1 deletions(-)
---
diff --git a/codegen/valagtypemodule.vala b/codegen/valagtypemodule.vala
index 6a4b67b..3b9d4e5 100644
--- a/codegen/valagtypemodule.vala
+++ b/codegen/valagtypemodule.vala
@@ -405,6 +405,15 @@ 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) {
+                                       instance_struct.add_field ("void *", "_vala_padding[%i]".printf 
(instance_padding));
+                               }
+                               var class_padding = cl.get_attribute_integer ("CCode", "class_padding", 0);
+                               if (class_padding > 0) {
+                                       type_struct.add_field ("void *", "_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..78813ee 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", "instance_padding", "class_padding", "",
 
                "Immutable", "",
                "Compact", "",


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