summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorVitor Sousa <vitorsousa@expertisesolutions.com.br>2019-08-05 19:06:11 -0300
committerFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2019-08-05 19:15:35 -0300
commitc1b76d3008ecb7c558ad4ad8de02f1e03ffddf68 (patch)
tree631410fd51486827d2fb36954fd03f34ce4e687c /src/bin
parente6a52ef371430c69da7ce3e7b22f1455a64f1637 (diff)
csharp: fix ownership of value types in arrays and lists
Summary: `eolian_mono` now considers the implicit ownership of value types in arrays and lists when generating ownership flags. Also, update manual bindings for arrays and lists to no longer free elements in the `Dispose` method when the container has ownership of the elements but C# itself does not have ownership of the container; the elements will be freed by whoever owns the container. Modifying and removing elements will still free them though. Re-enabled unit tests that required ownership of value type elements. Reviewers: felipealmeida, q66, vitor.sousa Reviewed By: felipealmeida Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D9457
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/eolian_mono/eolian/mono/parameter.hh15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/bin/eolian_mono/eolian/mono/parameter.hh b/src/bin/eolian_mono/eolian/mono/parameter.hh
index e1e8661bcb..954ac25c70 100644
--- a/src/bin/eolian_mono/eolian/mono/parameter.hh
+++ b/src/bin/eolian_mono/eolian/mono/parameter.hh
@@ -612,7 +612,7 @@ struct native_convert_in_variable_generator
612 return as_generator( 612 return as_generator(
613 "var " << string << " = new " << type << "(" << escape_keyword(param.param_name) 613 "var " << string << " = new " << type << "(" << escape_keyword(param.param_name)
614 << ", " << (param.type.has_own ? "true" : "false") 614 << ", " << (param.type.has_own ? "true" : "false")
615 << ", " << (complex->subtypes.front().has_own ? "true" : "false") 615 << ", " << (complex->subtypes.front().is_value_type || complex->subtypes.front().has_own ? "true" : "false")
616 << ");\n" 616 << ");\n"
617 ).generate(sink, std::make_tuple(in_variable_name(param.param_name), param.type), context); 617 ).generate(sink, std::make_tuple(in_variable_name(param.param_name), param.type), context);
618 } 618 }
@@ -724,7 +724,8 @@ struct convert_in_variable_generator
724 ) 724 )
725 return true; 725 return true;
726 726
727 if (complex->subtypes.front().has_own && !as_generator( 727 if (!complex->subtypes.front().is_value_type && complex->subtypes.front().has_own
728 && !as_generator(
728 escape_keyword(param.param_name) << ".OwnContent = false;\n" 729 escape_keyword(param.param_name) << ".OwnContent = false;\n"
729 ).generate(sink, attributes::unused, context)) 730 ).generate(sink, attributes::unused, context))
730 return false; 731 return false;
@@ -963,7 +964,7 @@ struct convert_out_assign_generator
963 return as_generator( 964 return as_generator(
964 string << " = new " << type << "(" << string 965 string << " = new " << type << "(" << string
965 << ", " << (param.type.has_own ? "true" : "false") 966 << ", " << (param.type.has_own ? "true" : "false")
966 << ", " << (complex->subtypes.front().has_own ? "true" : "false") 967 << ", " << (complex->subtypes.front().is_value_type || complex->subtypes.front().has_own ? "true" : "false")
967 << ");\n" 968 << ");\n"
968 ).generate(sink, std::make_tuple(escape_keyword(param.param_name), param.type, out_variable_name(param.param_name)), context); 969 ).generate(sink, std::make_tuple(escape_keyword(param.param_name), param.type, out_variable_name(param.param_name)), context);
969 } 970 }
@@ -1092,7 +1093,7 @@ struct convert_return_generator
1092 if (!complex) 1093 if (!complex)
1093 return false; 1094 return false;
1094 if (!as_generator("return new " << type << "(_ret_var, " << std::string{ret_type.has_own ? "true" : "false"} 1095 if (!as_generator("return new " << type << "(_ret_var, " << std::string{ret_type.has_own ? "true" : "false"}
1095 << ", " << (complex->subtypes.front().has_own ? "true" : "false") 1096 << ", " << (complex->subtypes.front().is_value_type || complex->subtypes.front().has_own ? "true" : "false")
1096 << ");\n") 1097 << ");\n")
1097 .generate(sink, ret_type, context)) 1098 .generate(sink, ret_type, context))
1098 return false; 1099 return false;
@@ -1244,7 +1245,8 @@ struct native_convert_out_assign_generator
1244 ) 1245 )
1245 return true; 1246 return true;
1246 1247
1247 if (complex->subtypes.front().has_own && !as_generator( 1248 if (!complex->subtypes.front().is_value_type && complex->subtypes.front().has_own
1249 && !as_generator(
1248 string << ".OwnContent = false;\n" 1250 string << ".OwnContent = false;\n"
1249 ).generate(sink, outvar, context)) 1251 ).generate(sink, outvar, context))
1250 return false; 1252 return false;
@@ -1370,7 +1372,8 @@ struct native_convert_return_generator
1370 && ret_type.c_type != "Eina_Accessor *" && ret_type.c_type != "const Eina_Accessor *" 1372 && ret_type.c_type != "Eina_Accessor *" && ret_type.c_type != "const Eina_Accessor *"
1371 ) 1373 )
1372 { 1374 {
1373 if (complex->subtypes.front().has_own && !as_generator("_ret_var.OwnContent = false; ") 1375 if (!complex->subtypes.front().is_value_type && complex->subtypes.front().has_own
1376 && !as_generator("_ret_var.OwnContent = false; ")
1374 .generate(sink, attributes::unused, context)) 1377 .generate(sink, attributes::unused, context))
1375 return false; 1378 return false;
1376 } 1379 }