summaryrefslogtreecommitdiff
path: root/src/bin/eolian_mono/eolian/mono/function_definition.hh
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2017-12-06 21:03:55 -0300
committerFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2017-12-20 19:57:17 -0200
commit46b202b86ce1912653bfcae2db2dac045af9bb2b (patch)
tree37e0256e4d3046bb24c555b472791f81b4f6d28f /src/bin/eolian_mono/eolian/mono/function_definition.hh
parent0609c68e34940e40e0caae1bb9dfc48d4eaa306e (diff)
eolian-mono: Add documentation generation support
This commit adds the "documentation" generator, which gets the documentation_def attribute of the given item and generates xml comments to be exported by MCS. For items requiring some customization of the generated comments (e.g. functions and its parameters), the helpers to generate the preamble (summary), body (paragraphs) and epilogue (currently just the @since tag) were added. Currently we do not support converting Eolian references into xmldoc references. As we explicitly generate Get/Set methods for properties, for now the generator tries to get the get/set specific documentation first. If it is not present, fallback to the common docs. Later this could be changed to generate the common one as paragraphs of the Get/Set. Also some generated code like the wrappers for calling C# methods from C can be private. This will cleanup the introspection results and warnings when generating documentation. Due to this visibility change, the binbuf tests had to be changed to add redirect calls to the native methods instead of directly calling the DllImport'd methods.
Diffstat (limited to 'src/bin/eolian_mono/eolian/mono/function_definition.hh')
-rw-r--r--src/bin/eolian_mono/eolian/mono/function_definition.hh15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/bin/eolian_mono/eolian/mono/function_definition.hh b/src/bin/eolian_mono/eolian/mono/function_definition.hh
index 2a4c027..04e8921 100644
--- a/src/bin/eolian_mono/eolian/mono/function_definition.hh
+++ b/src/bin/eolian_mono/eolian/mono/function_definition.hh
@@ -15,6 +15,7 @@
15#include "marshall_type.hh" 15#include "marshall_type.hh"
16#include "parameter.hh" 16#include "parameter.hh"
17#include "keyword.hh" 17#include "keyword.hh"
18#include "documentation.hh"
18#include "using_decl.hh" 19#include "using_decl.hh"
19#include "generation_contexts.hh" 20#include "generation_contexts.hh"
20 21
@@ -34,7 +35,7 @@ struct native_function_definition_generator
34 if(!as_generator 35 if(!as_generator
35 ("\n\n" << scope_tab 36 ("\n\n" << scope_tab
36 << eolian_mono::marshall_native_annotation(true) 37 << eolian_mono::marshall_native_annotation(true)
37 << " public delegate " 38 << " private delegate "
38 << eolian_mono::marshall_type(true) 39 << eolian_mono::marshall_type(true)
39 << " " 40 << " "
40 << string 41 << string
@@ -50,7 +51,7 @@ struct native_function_definition_generator
50 if(!as_generator 51 if(!as_generator
51 (scope_tab << "[System.Runtime.InteropServices.DllImport(" << context_find_tag<library_context>(context).actual_library_name(f.filename) << ")] " 52 (scope_tab << "[System.Runtime.InteropServices.DllImport(" << context_find_tag<library_context>(context).actual_library_name(f.filename) << ")] "
52 << eolian_mono::marshall_native_annotation(true) 53 << eolian_mono::marshall_native_annotation(true)
53 << " public static extern " 54 << " private static extern "
54 << eolian_mono::marshall_type(true) 55 << eolian_mono::marshall_type(true)
55 << " " << string 56 << " " << string
56 << "(System.IntPtr obj" 57 << "(System.IntPtr obj"
@@ -68,7 +69,7 @@ struct native_function_definition_generator
68 69
69 if(!as_generator 70 if(!as_generator
70 (scope_tab 71 (scope_tab
71 << " public static " 72 << " private static "
72 << eolian_mono::marshall_type(true) << " " 73 << eolian_mono::marshall_type(true) << " "
73 << string 74 << string
74 << "(System.IntPtr obj, System.IntPtr pd" 75 << "(System.IntPtr obj, System.IntPtr pd"
@@ -108,7 +109,7 @@ struct native_function_definition_generator
108 return false; 109 return false;
109 110
110 if(!as_generator 111 if(!as_generator
111 (scope_tab << "public static " 112 (scope_tab << "private static "
112 << string 113 << string
113 << "_delegate " 114 << "_delegate "
114 << string << "_static_delegate = new " << string << "_delegate(" << string << "NativeInherit." << string << ");\n" 115 << string << "_static_delegate = new " << string << "_delegate(" << string << "NativeInherit." << string << ");\n"
@@ -137,7 +138,7 @@ struct function_definition_generator
137 if(!as_generator 138 if(!as_generator
138 ("\n\n" << scope_tab << "[System.Runtime.InteropServices.DllImport(" << context_find_tag<library_context>(context).actual_library_name(f.filename) << ")]\n" 139 ("\n\n" << scope_tab << "[System.Runtime.InteropServices.DllImport(" << context_find_tag<library_context>(context).actual_library_name(f.filename) << ")]\n"
139 << scope_tab << eolian_mono::marshall_annotation(true) 140 << scope_tab << eolian_mono::marshall_annotation(true)
140 << " public static extern " 141 << " private static extern "
141 << eolian_mono::marshall_type(true) 142 << eolian_mono::marshall_type(true)
142 << " " << string 143 << " " << string
143 << "(System.IntPtr obj" 144 << "(System.IntPtr obj"
@@ -154,6 +155,10 @@ struct function_definition_generator
154 return false; 155 return false;
155 156
156 if(!as_generator 157 if(!as_generator
158 (documentation(1)).generate(sink, f, context))
159 return false;
160
161 if(!as_generator
157 (scope_tab << (do_super ? "virtual " : "") << "public " << return_type << " " << string << "(" << (parameter % ", ") 162 (scope_tab << (do_super ? "virtual " : "") << "public " << return_type << " " << string << "(" << (parameter % ", ")
158 << ") {\n " 163 << ") {\n "
159 << eolian_mono::function_definition_preamble() << string << "(" 164 << eolian_mono::function_definition_preamble() << string << "("