felipealmeida pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=e19465bc354a8e831581e34a5cefa36950462667

commit e19465bc354a8e831581e34a5cefa36950462667
Author: Lauro Moura <lauromo...@expertisesolutions.com.br>
Date:   Fri Dec 1 00:43:12 2017 -0300

    eolian_mono: Generate placeholder fields for empty structs
    
    Mono's JIT fails to generate function pointer for delegates with empty
    structs in the signature, leading to those mini-amd64.c crashes on empty
    fields.
    
    This commit generates a placeholder IntPtr field in empty structs.
---
 src/bin/eolian_mono/eolian/mono/struct_definition.hh | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/bin/eolian_mono/eolian/mono/struct_definition.hh 
b/src/bin/eolian_mono/eolian/mono/struct_definition.hh
index 1b5e27c8a9..ee05852904 100644
--- a/src/bin/eolian_mono/eolian/mono/struct_definition.hh
+++ b/src/bin/eolian_mono/eolian/mono/struct_definition.hh
@@ -50,7 +50,7 @@ struct struct_definition_generator
         .generate(sink, struct_.cxx_name, context))
        return false;
 
-     // iterate enum fiels
+     // iterate struct fields
      for(auto first = std::begin(struct_.fields)
              , last = std::end(struct_.fields); first != last; ++first)
        {
@@ -65,6 +65,16 @@ struct struct_definition_generator
             return false;
        }
 
+     // Check whether this is an extern struct without declared fields in .eo 
file and generate a
+     // placeholder field if positive.
+     // Mono's JIT is picky when generating function pointer for delegates 
with empty structs, leading to
+     // those 'mini-amd64.c condition fields not met' crashes.
+     if (struct_.fields.size() == 0)
+       {
+           if (!as_generator("public IntPtr field;\n").generate(sink, nullptr, 
context))
+             return false;
+       }
+
      if(!as_generator("}\n").generate(sink, attributes::unused, context)) 
return false;
 
      auto close_namespace = *(lit("} ")) << "\n";

-- 


Reply via email to