summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2017-12-01 00:43:12 -0300
committerLauro Moura <lauromoura@expertisesolutions.com.br>2017-12-04 15:47:53 -0300
commite19465bc354a8e831581e34a5cefa36950462667 (patch)
tree09414ffca69304467cf6e1fee5200509dc978d23 /src/bin
parent3c5efa1e8dfee3d619e1b4fc6f23d6ae29085000 (diff)
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.
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/eolian_mono/eolian/mono/struct_definition.hh12
1 files changed, 11 insertions, 1 deletions
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
50 .generate(sink, struct_.cxx_name, context)) 50 .generate(sink, struct_.cxx_name, context))
51 return false; 51 return false;
52 52
53 // iterate enum fiels 53 // iterate struct fields
54 for(auto first = std::begin(struct_.fields) 54 for(auto first = std::begin(struct_.fields)
55 , last = std::end(struct_.fields); first != last; ++first) 55 , last = std::end(struct_.fields); first != last; ++first)
56 { 56 {
@@ -65,6 +65,16 @@ struct struct_definition_generator
65 return false; 65 return false;
66 } 66 }
67 67
68 // Check whether this is an extern struct without declared fields in .eo file and generate a
69 // placeholder field if positive.
70 // Mono's JIT is picky when generating function pointer for delegates with empty structs, leading to
71 // those 'mini-amd64.c condition fields not met' crashes.
72 if (struct_.fields.size() == 0)
73 {
74 if (!as_generator("public IntPtr field;\n").generate(sink, nullptr, context))
75 return false;
76 }
77
68 if(!as_generator("}\n").generate(sink, attributes::unused, context)) return false; 78 if(!as_generator("}\n").generate(sink, attributes::unused, context)) return false;
69 79
70 auto close_namespace = *(lit("} ")) << "\n"; 80 auto close_namespace = *(lit("} ")) << "\n";