summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2019-05-03 10:09:58 +0200
committerXavi Artigas <xavierartigas@yahoo.es>2019-05-03 13:59:11 +0200
commit7047a056abb6e44811f12bab37546bdfb1ad98ab (patch)
treefb9126db459831cdd938b891c38ec10bee54c0e8 /src/bin
parent2426656fd6b444b5b5fa86920dc9b61ff2fa10b1 (diff)
csharp: Some docs improvements.
Summary: - Silent missing docs warnign for API delegates - Document variables - Better docs for async functions Reviewers: segfaultxavi, vitor.sousa Reviewed By: segfaultxavi Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D8809
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/eolian_mono/eolian/mono/async_function_definition.hh32
-rw-r--r--src/bin/eolian_mono/eolian/mono/klass.hh14
-rw-r--r--src/bin/eolian_mono/eolian/mono/struct_definition.hh11
-rw-r--r--src/bin/eolian_mono/eolian/mono/variable_definition.hh5
4 files changed, 48 insertions, 14 deletions
diff --git a/src/bin/eolian_mono/eolian/mono/async_function_definition.hh b/src/bin/eolian_mono/eolian/mono/async_function_definition.hh
index f6a3ff5dc2..b3ab6d4102 100644
--- a/src/bin/eolian_mono/eolian/mono/async_function_definition.hh
+++ b/src/bin/eolian_mono/eolian/mono/async_function_definition.hh
@@ -54,8 +54,20 @@ struct async_function_declaration_generator
54 return true; 54 return true;
55 55
56 if (!as_generator( 56 if (!as_generator(
57 scope_tab << "System.Threading.Tasks.Task<Eina.Value> " << name_helpers::managed_async_method_name(f) << "(" << *(parameter << ",") << 57 scope_tab << "/// <summary>Async wrapper for <see cref=\"" << name_helpers::managed_method_name(f) << "\" />.</summary>\n"
58 " System.Threading.CancellationToken token = default(System.Threading.CancellationToken));\n" 58 ).generate(sink, attributes::unused, context))
59 return false;
60
61 // generate_parameter is not a proper as_generator-compatible generator, so we had to do an old fashioned loop
62 for (auto&& param : f.parameters)
63 if (!documentation(1).generate_parameter(sink, param, context))
64 return false;
65
66 if (!as_generator(
67 scope_tab << "/// <param name=\"token\">Token to notify the async operation of external request to cancel.</param>\n"
68 << scope_tab << "/// <returns>An async task wrapping the result of the operation.</returns>\n"
69 << scope_tab << "System.Threading.Tasks.Task<Eina.Value> " << name_helpers::managed_async_method_name(f) << "(" << *(parameter << ",") <<
70 " System.Threading.CancellationToken token = default(System.Threading.CancellationToken));\n\n"
59 ).generate(sink, f.parameters, context)) 71 ).generate(sink, f.parameters, context))
60 return false; 72 return false;
61 73
@@ -88,12 +100,24 @@ struct async_function_definition_generator
88 100
89 std::transform(f.parameters.begin(), f.parameters.end(), std::back_inserter(param_forwarding), parameter_forwarding); 101 std::transform(f.parameters.begin(), f.parameters.end(), std::back_inserter(param_forwarding), parameter_forwarding);
90 102
103 if (!as_generator(
104 scope_tab << "/// <summary>Async wrapper for <see cref=\"" << name_helpers::managed_method_name(f) << "\" />.</summary>\n"
105 ).generate(sink, attributes::unused, context))
106 return false;
107
108 // generate_parameter is not a proper as_generator-compatible generator, so we had to do an old fashioned loop
109 for (auto&& param : f.parameters)
110 if (!documentation(1).generate_parameter(sink, param, context))
111 return false;
112
91 if(!as_generator( 113 if(!as_generator(
92 scope_tab << "public System.Threading.Tasks.Task<Eina.Value> " << name_helpers::managed_async_method_name(f) << "(" << *(parameter << ",") << " System.Threading.CancellationToken token = default(System.Threading.CancellationToken))\n" 114 scope_tab << "/// <param name=\"token\">Token to notify the async operation of external request to cancel.</param>\n"
115 << scope_tab << "/// <returns>An async task wrapping the result of the operation.</returns>\n"
116 << scope_tab << "public System.Threading.Tasks.Task<Eina.Value> " << name_helpers::managed_async_method_name(f) << "(" << *(parameter << ",") << " System.Threading.CancellationToken token = default(System.Threading.CancellationToken))\n"
93 << scope_tab << "{\n" 117 << scope_tab << "{\n"
94 << scope_tab << scope_tab << "Eina.Future future = " << name_helpers::managed_method_name(f) << "(" << (string % ",") << ");\n" 118 << scope_tab << scope_tab << "Eina.Future future = " << name_helpers::managed_method_name(f) << "(" << (string % ",") << ");\n"
95 << scope_tab << scope_tab << "return Efl.Eo.Globals.WrapAsync(future, token);\n" 119 << scope_tab << scope_tab << "return Efl.Eo.Globals.WrapAsync(future, token);\n"
96 << scope_tab << "}\n" 120 << scope_tab << "}\n\n"
97 ).generate(sink, std::make_tuple(f.parameters, param_forwarding), context)) 121 ).generate(sink, std::make_tuple(f.parameters, param_forwarding), context))
98 return false; 122 return false;
99 return true; 123 return true;
diff --git a/src/bin/eolian_mono/eolian/mono/klass.hh b/src/bin/eolian_mono/eolian/mono/klass.hh
index c81a23fe08..9d3711fb61 100644
--- a/src/bin/eolian_mono/eolian/mono/klass.hh
+++ b/src/bin/eolian_mono/eolian/mono/klass.hh
@@ -465,9 +465,9 @@ struct klass
465 465
466 // Native method definitions 466 // Native method definitions
467 if(!as_generator( 467 if(!as_generator(
468 indent << scope_tab << "#pragma warning disable CA1707, SA1300, SA1600\n\n" 468 indent << scope_tab << "#pragma warning disable CA1707, CS1591, SA1300, SA1600\n\n"
469 << *(native_function_definition(cls)) 469 << *(native_function_definition(cls))
470 << indent << scope_tab << "#pragma warning restore CA1707, SA1300, SA1600\n\n") 470 << indent << scope_tab << "#pragma warning restore CA1707, CS1591, SA1300, SA1600\n\n")
471 .generate(sink, implementable_methods, change_indentation(indent.inc(), inative_cxt))) return false; 471 .generate(sink, implementable_methods, change_indentation(indent.inc(), inative_cxt))) return false;
472 472
473 if(!as_generator("}\n").generate(sink, attributes::unused, inative_cxt)) return false; 473 if(!as_generator("}\n").generate(sink, attributes::unused, inative_cxt)) return false;
@@ -516,15 +516,19 @@ struct klass
516 return true; 516 return true;
517 517
518 if (cls.get_all_events().size() > 0) 518 if (cls.get_all_events().size() > 0)
519 if (!as_generator(scope_tab << visibility << "Dictionary<(IntPtr desc, object evtDelegate), (IntPtr evtCallerPtr, Efl.EventCb evtCaller)> eoEvents = new Dictionary<(IntPtr desc, object evtDelegate), (IntPtr evtCallerPtr, Efl.EventCb evtCaller)>();\n" 519 if (!as_generator(
520 << scope_tab << visibility << "readonly object eventLock = new object();\n") 520 scope_tab << "/// <summary>Internal usage by derived classes to track native events.</summary>\n"
521 << scope_tab << visibility << "Dictionary<(IntPtr desc, object evtDelegate), (IntPtr evtCallerPtr, Efl.EventCb evtCaller)> eoEvents = new Dictionary<(IntPtr desc, object evtDelegate), (IntPtr evtCallerPtr, Efl.EventCb evtCaller)>();\n"
522 << scope_tab << "/// <summary>Internal usage by derived classes to lock native event handlers.</summary>\n"
523 << scope_tab << visibility << "readonly object eventLock = new object();\n")
521 .generate(sink, attributes::unused, context)) 524 .generate(sink, attributes::unused, context))
522 return false; 525 return false;
523 526
524 if (is_inherit) 527 if (is_inherit)
525 { 528 {
526 if (!as_generator( 529 if (!as_generator(
527 scope_tab << "protected bool inherited;\n" 530 scope_tab << "/// <summary>Internal usage to detect whether this instance is from a generated class or not.</summary>\n"
531 << scope_tab << "protected bool inherited;\n"
528 ).generate(sink, attributes::unused, context)) 532 ).generate(sink, attributes::unused, context))
529 return false; 533 return false;
530 } 534 }
diff --git a/src/bin/eolian_mono/eolian/mono/struct_definition.hh b/src/bin/eolian_mono/eolian/mono/struct_definition.hh
index d8f03118e7..14d3f7fdb3 100644
--- a/src/bin/eolian_mono/eolian/mono/struct_definition.hh
+++ b/src/bin/eolian_mono/eolian/mono/struct_definition.hh
@@ -267,7 +267,8 @@ struct struct_internal_definition_generator
267 auto const& indent = current_indentation(context); 267 auto const& indent = current_indentation(context);
268 if (!as_generator 268 if (!as_generator
269 ( 269 (
270 indent << "///<summary>Internal wrapper for struct " << string << ".</summary>\n" 270 indent << "#pragma warning disable CS1591\n\n"
271 << indent << "///<summary>Internal wrapper for struct " << string << ".</summary>\n"
271 << indent << "[StructLayout(LayoutKind.Sequential)]\n" 272 << indent << "[StructLayout(LayoutKind.Sequential)]\n"
272 << indent << "public struct " << string << "\n" 273 << indent << "public struct " << string << "\n"
273 << indent << "{\n" 274 << indent << "{\n"
@@ -367,7 +368,9 @@ struct struct_internal_definition_generator
367 return false; 368 return false;
368 369
369 // close internal class 370 // close internal class
370 if(!as_generator(indent << "}\n\n").generate(sink, attributes::unused, context)) return false; 371 if(!as_generator(indent << "}\n\n"
372 << indent << "#pragma warning restore CS1591\n\n"
373 ).generate(sink, attributes::unused, context)) return false;
371 374
372 return true; 375 return true;
373 } 376 }
@@ -435,7 +438,9 @@ struct struct_definition_generator
435 } 438 }
436 439
437 if(!as_generator( 440 if(!as_generator(
438 indent << scope_tab << "public static implicit operator " << struct_name << "(IntPtr ptr)\n" 441 indent << scope_tab << "///<summary>Implicit conversion to the managed representation from a native pointer.</summary>\n"
442 << indent << scope_tab << "///<param name=\"ptr\">Native pointer to be converted.</param>\n"
443 << indent << scope_tab << "public static implicit operator " << struct_name << "(IntPtr ptr)\n"
439 << indent << scope_tab << "{\n" 444 << indent << scope_tab << "{\n"
440 << indent << scope_tab << scope_tab << "var tmp = (" << struct_name << ".NativeStruct)Marshal.PtrToStructure(ptr, typeof(" << struct_name << ".NativeStruct));\n" 445 << indent << scope_tab << scope_tab << "var tmp = (" << struct_name << ".NativeStruct)Marshal.PtrToStructure(ptr, typeof(" << struct_name << ".NativeStruct));\n"
441 << indent << scope_tab << scope_tab << "return tmp;\n" 446 << indent << scope_tab << scope_tab << "return tmp;\n"
diff --git a/src/bin/eolian_mono/eolian/mono/variable_definition.hh b/src/bin/eolian_mono/eolian/mono/variable_definition.hh
index 29211d079a..fdc5219794 100644
--- a/src/bin/eolian_mono/eolian/mono/variable_definition.hh
+++ b/src/bin/eolian_mono/eolian/mono/variable_definition.hh
@@ -58,11 +58,12 @@ struct constant_definition_generator
58 } 58 }
59 59
60 // declare variable 60 // declare variable
61 if (!as_generator(scope_tab(1) 61 if (!as_generator(documentation(1)
62 << scope_tab(1)
62 << "public static readonly " << type 63 << "public static readonly " << type
63 << " " << utils::remove_all(constant.name, '_') 64 << " " << utils::remove_all(constant.name, '_')
64 << " = " << literal << ";\n") 65 << " = " << literal << ";\n")
65 .generate(sink, constant.base_type, context)) 66 .generate(sink, std::make_tuple(constant, constant.base_type), context))
66 return false; 67 return false;
67 68
68 // FIXME missing documentation generator 69 // FIXME missing documentation generator