summaryrefslogtreecommitdiff
path: root/src/bin/eolian_mono
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
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')
-rw-r--r--src/bin/eolian_mono/eolian/mono/documentation.hh201
-rw-r--r--src/bin/eolian_mono/eolian/mono/enum_definition.hh7
-rw-r--r--src/bin/eolian_mono/eolian/mono/function_declaration.hh9
-rw-r--r--src/bin/eolian_mono/eolian/mono/function_definition.hh15
-rw-r--r--src/bin/eolian_mono/eolian/mono/function_pointer.hh17
-rw-r--r--src/bin/eolian_mono/eolian/mono/klass.hh93
-rw-r--r--src/bin/eolian_mono/eolian/mono/struct_definition.hh25
-rw-r--r--src/bin/eolian_mono/eolian/mono/using_decl.hh8
8 files changed, 325 insertions, 50 deletions
diff --git a/src/bin/eolian_mono/eolian/mono/documentation.hh b/src/bin/eolian_mono/eolian/mono/documentation.hh
new file mode 100644
index 0000000000..42fe9d24e1
--- /dev/null
+++ b/src/bin/eolian_mono/eolian/mono/documentation.hh
@@ -0,0 +1,201 @@
1#ifndef EOLIAN_MONO_DOCUMENTATION_HPP
2#define EOLIAN_MONO_DOCUMENTATION_HPP
3
4#include "grammar/generator.hpp"
5#include "grammar/klass_def.hpp"
6#include "grammar/html_escaped_string.hpp"
7#include "using_decl.hh"
8#include "keyword.hh"
9
10#include <Eina.h>
11
12namespace eolian_mono {
13
14struct documentation_generator
15{
16
17 int scope_size = 0;
18
19 documentation_generator(int scope_size)
20 : scope_size(scope_size) {}
21
22 /// Tag generator helpers
23 template<typename OutputIterator, typename Context>
24 bool generate_tag(OutputIterator sink, std::string const& tag, std::string const &text, Context const& context) const
25 {
26 if (text.empty())
27 return true;
28
29 return as_generator( scope_tab(scope_size) << "///<" << tag << ">" << html_escaped_string << "</" << tag << ">\n").generate(sink, text, context);
30 }
31
32 template<typename OutputIterator, typename Context>
33 bool generate_tag_summary(OutputIterator sink, std::string const& text, Context const& context) const
34 {
35 return generate_tag(sink, "summary", text, context);
36 }
37
38 template<typename OutputIterator, typename Context>
39 bool generate_tag_para(OutputIterator sink, std::string const& text, Context const& context) const
40 {
41 return generate_tag(sink, "para", text, context);
42 }
43
44 template<typename OutputIterator, typename Context>
45 bool generate_tag_param(OutputIterator sink, std::string const& name, std::string const& text, Context const& context) const
46 {
47 return as_generator( scope_tab(scope_size) << "///<param name=\"" << name << "\">"
48 << html_escaped_string << "</param>\n").generate(sink, text, context);
49 }
50
51 template<typename OutputIterator, typename Context>
52 bool generate_tag_return(OutputIterator sink, std::string const& text, Context const& context) const
53 {
54 return generate_tag(sink, "return", text, context);
55 }
56
57 // Actual exported generators
58 template<typename OutputIterator, typename Attribute, typename Context>
59 bool generate(OutputIterator sink, Attribute const& attr, Context const& context) const
60 {
61 return generate(sink, attr.documentation, context);
62 }
63
64 template<typename OutputIterator, typename Context>
65 bool generate(OutputIterator sink, attributes::function_def const& func, Context const& context) const
66 {
67 if (func.type == attributes::function_type::prop_get || func.type == attributes::function_type::prop_set)
68 return generate_property(sink, func, context);
69 else
70 return generate_function(sink, func, context);
71 return true;
72 }
73
74 template<typename OutputIterator, typename Context>
75 bool generate_property(OutputIterator sink, attributes::function_def const& func, Context const& context) const
76 {
77
78 // First, try the get/set specific documentation
79 if (!func.documentation.summary.empty())
80 {
81 if (!generate(sink, func.documentation, context))
82 return false;
83 }
84 else // fallback to common property documentation
85 {
86 if (!generate(sink, func.property_documentation, context))
87 return false;
88 }
89
90 for (auto&& param : func.parameters)
91 if (!generate_parameter(sink, param, context))
92 return false;
93
94 if (!generate_tag_return(sink, func.return_documentation.summary, context))
95 return false;
96
97 return true;
98 }
99
100 template<typename OutputIterator, typename Context>
101 bool generate_function(OutputIterator sink, attributes::function_def const& func, Context const& context) const
102 {
103 if (!generate(sink, func.documentation, context))
104 return false;
105
106 for (auto&& param : func.parameters)
107 if (!generate_parameter(sink, param, context))
108 return false;
109
110 if (!generate_tag_return(sink, func.return_documentation.summary, context))
111 return false;
112
113 return true;
114 }
115
116 template<typename OutputIterator, typename Context>
117 bool generate_parameter(OutputIterator sink, attributes::parameter_def const& param, Context const& context) const
118 {
119 return generate_tag_param(sink, escape_keyword(param.param_name), param.documentation.summary, context);
120 }
121
122 template<typename OutputIterator, typename Context>
123 bool generate(OutputIterator sink, attributes::documentation_def const& doc, Context const& context) const
124 {
125 if (!generate_preamble(sink, doc, context))
126 return false;
127 if (!generate_body(sink, doc, context))
128 return false;
129 if (!generate_epilogue(sink, doc, context))
130 return false;
131
132 return true;
133 }
134
135 template<typename OutputIterator, typename Context>
136 bool generate_preamble(OutputIterator sink, attributes::documentation_def const& doc, Context const context) const
137 {
138 return generate_tag_summary(sink, doc.summary, context);
139 }
140
141
142 template<typename OutputIterator, typename Context>
143 bool generate_body(OutputIterator sink, attributes::documentation_def const& doc, Context const context) const
144 {
145 for (auto&& para : doc.desc_paragraphs)
146 {
147 if (!generate_tag_para(sink, para, context))
148 return false;
149 }
150
151 return true;
152 }
153
154 template<typename OutputIterator, typename Context>
155 bool generate_epilogue(OutputIterator sink, attributes::documentation_def const& doc, Context const context) const
156 {
157 if (doc.since.empty())
158 return true;
159
160 if (!generate_tag_para(sink, doc.since, context))
161 return false;
162
163 return true;
164 }
165};
166
167struct documentation_terminal
168{
169 documentation_generator operator()(int n) const
170 {
171 return documentation_generator(n);
172 }
173} const documentation = {};
174
175documentation_generator as_generator(documentation_terminal)
176{
177 return documentation_generator(0);
178}
179
180} // namespace eolian_mono
181
182
183namespace efl { namespace eolian { namespace grammar {
184
185template<>
186struct is_eager_generator<::eolian_mono::documentation_generator> : std::true_type {};
187template<>
188struct is_generator<::eolian_mono::documentation_generator> : std::true_type {};
189
190template<>
191struct is_generator<::eolian_mono::documentation_terminal> : std::true_type {};
192
193namespace type_traits {
194template<>
195struct attributes_needed<struct ::eolian_mono::documentation_generator> : std::integral_constant<int, 1> {};
196template<>
197struct attributes_needed<struct ::eolian_mono::documentation_terminal> : std::integral_constant<int, 1> {};
198}
199} } }
200
201#endif
diff --git a/src/bin/eolian_mono/eolian/mono/enum_definition.hh b/src/bin/eolian_mono/eolian/mono/enum_definition.hh
index ae9775e71f..d8bc54c175 100644
--- a/src/bin/eolian_mono/eolian/mono/enum_definition.hh
+++ b/src/bin/eolian_mono/eolian/mono/enum_definition.hh
@@ -22,6 +22,9 @@ struct enum_definition_generator
22 auto open_namespace = *("namespace " << string << " { ") << "\n"; 22 auto open_namespace = *("namespace " << string << " { ") << "\n";
23 if(!as_generator(open_namespace).generate(sink, cpp_namespaces, add_lower_case_context(context))) return false; 23 if(!as_generator(open_namespace).generate(sink, cpp_namespaces, add_lower_case_context(context))) return false;
24 24
25 if(!as_generator(documentation).generate(sink, enum_, context))
26 return false;
27
25 if(!as_generator 28 if(!as_generator
26 ( 29 (
27 "public enum " << string << "\n{\n" 30 "public enum " << string << "\n{\n"
@@ -38,9 +41,9 @@ struct enum_definition_generator
38 name[0] = std::toupper(name[0]); // Hack to allow 'static' as a field name 41 name[0] = std::toupper(name[0]); // Hack to allow 'static' as a field name
39 if (!as_generator 42 if (!as_generator
40 ( 43 (
41 string << " = " << string << ",\n" 44 documentation << string << " = " << string << ",\n"
42 ) 45 )
43 .generate(sink, std::make_tuple(name, literal), context)) 46 .generate(sink, std::make_tuple(*first, name, literal), context))
44 return false; 47 return false;
45 } 48 }
46 49
diff --git a/src/bin/eolian_mono/eolian/mono/function_declaration.hh b/src/bin/eolian_mono/eolian/mono/function_declaration.hh
index 561c975118..76bbd6103b 100644
--- a/src/bin/eolian_mono/eolian/mono/function_declaration.hh
+++ b/src/bin/eolian_mono/eolian/mono/function_declaration.hh
@@ -21,10 +21,13 @@ struct function_declaration_generator
21 { 21 {
22 if(is_function_blacklisted(f.c_name)) 22 if(is_function_blacklisted(f.c_name))
23 return true; 23 return true;
24 else 24
25 return as_generator 25 if(!as_generator(documentation).generate(sink, f, context))
26 return false;
27
28 return as_generator
26 (eolian_mono::type(true) << " " << string << "(" << (parameter % ", ") << ");\n") 29 (eolian_mono::type(true) << " " << string << "(" << (parameter % ", ") << ");\n")
27 .generate(sink, std::make_tuple(f.return_type, managed_method_name(f.name), f.parameters), context); 30 .generate(sink, std::make_tuple(f.return_type, managed_method_name(f.name), f.parameters), context);
28 } 31 }
29}; 32};
30 33
diff --git a/src/bin/eolian_mono/eolian/mono/function_definition.hh b/src/bin/eolian_mono/eolian/mono/function_definition.hh
index 2a4c027896..04e8921fad 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 << "("
diff --git a/src/bin/eolian_mono/eolian/mono/function_pointer.hh b/src/bin/eolian_mono/eolian/mono/function_pointer.hh
index 0f91a4c41c..0890edcb51 100644
--- a/src/bin/eolian_mono/eolian/mono/function_pointer.hh
+++ b/src/bin/eolian_mono/eolian/mono/function_pointer.hh
@@ -6,6 +6,8 @@
6#include <vector> 6#include <vector>
7#include <string> 7#include <string>
8 8
9#include "documentation.hh"
10
9namespace eolian_mono { 11namespace eolian_mono {
10 12
11// Blacklist structs that require some kind of manual binding. 13// Blacklist structs that require some kind of manual binding.
@@ -36,25 +38,26 @@ struct function_pointer {
36 if(!as_generator(open_namespace).generate(sink, namespaces, add_lower_case_context(context))) return false; 38 if(!as_generator(open_namespace).generate(sink, namespaces, add_lower_case_context(context))) return false;
37 39
38 // C# visible delegate 40 // C# visible delegate
39 if (!as_generator("public delegate " << type << " " << string 41 if (!as_generator(documentation
42 << "public delegate " << type << " " << string
40 << "(" << (parameter % ", ") << ");\n") 43 << "(" << (parameter % ", ") << ");\n")
41 .generate(sink, std::make_tuple(f.return_type, escape_keyword(f.name), f.parameters), context)) 44 .generate(sink, std::make_tuple(f, f.return_type, escape_keyword(f.name), f.parameters), context))
42 return false; 45 return false;
43 // "Internal" delegate, 1-to-1 with the Unamaged function type 46 // "Internal" delegate, 1-to-1 with the Unamaged function type
44 if (!as_generator("public delegate " << type << " " << string // public? 47 if (!as_generator("internal delegate " << type << " " << string // public?
45 << "Internal(IntPtr data, " << (parameter % ", ") << ");\n") 48 << "Internal(IntPtr data, " << (parameter % ", ") << ");\n")
46 .generate(sink, std::make_tuple(f.return_type, escape_keyword(f.name), f.parameters), context)) 49 .generate(sink, std::make_tuple(f.return_type, escape_keyword(f.name), f.parameters), context))
47 return false; 50 return false;
48 51
49 std::string f_name = escape_keyword(f.name); 52 std::string f_name = escape_keyword(f.name);
50 // Wrapper type, with callback matching the Unamanaged one 53 // Wrapper type, with callback matching the Unamanaged one
51 if (!as_generator("public class " << f_name << "Wrapper\n" 54 if (!as_generator("internal class " << f_name << "Wrapper\n"
52 << "{\n\n" 55 << "{\n\n"
53 << scope_tab << "private " << f_name << "Internal _cb;\n" 56 << scope_tab << "private " << f_name << "Internal _cb;\n"
54 << scope_tab << "private IntPtr _cb_data;\n" 57 << scope_tab << "private IntPtr _cb_data;\n"
55 << scope_tab << "private Eina_Free_Cb _cb_free_cb;\n\n" 58 << scope_tab << "private Eina_Free_Cb _cb_free_cb;\n\n"
56 59
57 << scope_tab << "public " << f_name << "Wrapper (" << f_name << "Internal _cb, IntPtr _cb_data, Eina_Free_Cb _cb_free_cb)\n" 60 << scope_tab << "internal " << f_name << "Wrapper (" << f_name << "Internal _cb, IntPtr _cb_data, Eina_Free_Cb _cb_free_cb)\n"
58 << scope_tab << "{\n" 61 << scope_tab << "{\n"
59 << scope_tab << scope_tab << "this._cb = _cb;\n" 62 << scope_tab << scope_tab << "this._cb = _cb;\n"
60 << scope_tab << scope_tab << "this._cb_data = _cb_data;\n" 63 << scope_tab << scope_tab << "this._cb_data = _cb_data;\n"
@@ -67,12 +70,12 @@ struct function_pointer {
67 << scope_tab << scope_tab << scope_tab << "this._cb_free_cb(this._cb_data);\n" 70 << scope_tab << scope_tab << scope_tab << "this._cb_free_cb(this._cb_data);\n"
68 << scope_tab << "}\n\n" 71 << scope_tab << "}\n\n"
69 72
70 << scope_tab << "public " << type << " ManagedCb(" << (parameter % ",") << ")\n" 73 << scope_tab << "internal " << type << " ManagedCb(" << (parameter % ",") << ")\n"
71 << scope_tab << "{\n" 74 << scope_tab << "{\n"
72 << scope_tab << scope_tab << (f.return_type.c_type != "void" ? "return ": "") << "_cb(_cb_data, " << (argument_invocation_no_conversion % ", ") << ");\n" 75 << scope_tab << scope_tab << (f.return_type.c_type != "void" ? "return ": "") << "_cb(_cb_data, " << (argument_invocation_no_conversion % ", ") << ");\n"
73 << scope_tab << "}\n\n" 76 << scope_tab << "}\n\n"
74 77
75 << scope_tab << "public static " << type << " Cb(IntPtr cb_data, " << (parameter % ", ") << ")\n" 78 << scope_tab << "internal static " << type << " Cb(IntPtr cb_data, " << (parameter % ", ") << ")\n"
76 << scope_tab << "{\n" 79 << scope_tab << "{\n"
77 << scope_tab << scope_tab << "GCHandle handle = GCHandle.FromIntPtr(cb_data);\n" 80 << scope_tab << scope_tab << "GCHandle handle = GCHandle.FromIntPtr(cb_data);\n"
78 << scope_tab << scope_tab << string << " cb = (" << string << ")handle.Target;\n" 81 << scope_tab << scope_tab << string << " cb = (" << string << ")handle.Target;\n"
diff --git a/src/bin/eolian_mono/eolian/mono/klass.hh b/src/bin/eolian_mono/eolian/mono/klass.hh
index 639e263054..d8bea22024 100644
--- a/src/bin/eolian_mono/eolian/mono/klass.hh
+++ b/src/bin/eolian_mono/eolian/mono/klass.hh
@@ -14,6 +14,7 @@
14#include "function_definition.hh" 14#include "function_definition.hh"
15#include "function_registration.hh" 15#include "function_registration.hh"
16#include "function_declaration.hh" 16#include "function_declaration.hh"
17#include "documentation.hh"
17#include "grammar/string.hpp" 18#include "grammar/string.hpp"
18#include "grammar/attribute_replace.hpp" 19#include "grammar/attribute_replace.hpp"
19#include "grammar/integral.hpp" 20#include "grammar/integral.hpp"
@@ -30,7 +31,8 @@ template <typename OutputIterator, typename Context>
30static bool generate_static_cast_method(OutputIterator sink, const std::string &class_name, Context const &context) 31static bool generate_static_cast_method(OutputIterator sink, const std::string &class_name, Context const &context)
31{ 32{
32 return as_generator( 33 return as_generator(
33 scope_tab << "public static " << class_name << " static_cast(efl.Object obj)\n" 34 scope_tab << "///<summary>Casts obj into an instance of this type.</summary>\n"
35 << scope_tab << "public static " << class_name << " static_cast(efl.Object obj)\n"
34 << scope_tab << "{\n" 36 << scope_tab << "{\n"
35 << scope_tab << scope_tab << "if (obj == null)\n" 37 << scope_tab << scope_tab << "if (obj == null)\n"
36 << scope_tab << scope_tab << scope_tab << "throw new System.ArgumentNullException(\"obj\");\n" 38 << scope_tab << scope_tab << scope_tab << "throw new System.ArgumentNullException(\"obj\");\n"
@@ -43,13 +45,15 @@ template <typename OutputIterator, typename Context>
43static bool generate_equals_method(OutputIterator sink, Context const &context) 45static bool generate_equals_method(OutputIterator sink, Context const &context)
44{ 46{
45 return as_generator( 47 return as_generator(
46 scope_tab << "public override bool Equals(object obj)\n" 48 scope_tab << "///<summary>Verifies if the given object is equals to this.</summary>\n"
49 << scope_tab << "public override bool Equals(object obj)\n"
47 << scope_tab << "{\n" 50 << scope_tab << "{\n"
48 << scope_tab << scope_tab << "var other = obj as efl.Object;\n" 51 << scope_tab << scope_tab << "var other = obj as efl.Object;\n"
49 << scope_tab << scope_tab << "if (other == null)\n" 52 << scope_tab << scope_tab << "if (other == null)\n"
50 << scope_tab << scope_tab << scope_tab << "return false;\n" 53 << scope_tab << scope_tab << scope_tab << "return false;\n"
51 << scope_tab << scope_tab << "return this.raw_handle == other.raw_handle;\n" 54 << scope_tab << scope_tab << "return this.raw_handle == other.raw_handle;\n"
52 << scope_tab << "}\n" 55 << scope_tab << "}\n"
56 << scope_tab << "///<summary>Gets the hash code for this object based on the native pointer it points to.</summary>\n"
53 << scope_tab << "public override int GetHashCode()\n" 57 << scope_tab << "public override int GetHashCode()\n"
54 << scope_tab << "{\n" 58 << scope_tab << "{\n"
55 << scope_tab << scope_tab << "return this.raw_handle.ToInt32();\n" 59 << scope_tab << scope_tab << "return this.raw_handle.ToInt32();\n"
@@ -156,8 +160,12 @@ struct klass
156 std::replace(evt_name.begin(), evt_name.end(), ',', '_'); 160 std::replace(evt_name.begin(), evt_name.end(), ',', '_');
157 std::string arg_type = (*etype).original_type.visit(get_csharp_type_visitor{}); 161 std::string arg_type = (*etype).original_type.visit(get_csharp_type_visitor{});
158 162
163 if (!as_generator("///<summary>Event argument wrapper for event " << string << ".</summary>\n"
164 ).generate(sink, evt_name, context))
165 return false;
159 166
160 if (!as_generator("public class " << evt_name << "_Args : EventArgs {\n" 167 if (!as_generator("public class " << evt_name << "_Args : EventArgs {\n"
168 << scope_tab << "///<summary>Actual event payload.</summary>\n"
161 << scope_tab << "public " << arg_type << " arg { get; set; }\n" 169 << scope_tab << "public " << arg_type << " arg { get; set; }\n"
162 << "}\n").generate(sink, NULL, context)) 170 << "}\n").generate(sink, NULL, context))
163 return false; 171 return false;
@@ -166,6 +174,10 @@ struct klass
166 // Interface class 174 // Interface class
167 { 175 {
168 auto iface_cxt = context_add_tag(class_context{class_context::interface}, context); 176 auto iface_cxt = context_add_tag(class_context{class_context::interface}, context);
177
178 if(!as_generator(documentation).generate(sink, cls, iface_cxt))
179 return false;
180
169 if(!as_generator 181 if(!as_generator
170 ( 182 (
171 "public " /*<< class_type*/ "interface" /*<<*/ " " << string << " : " 183 "public " /*<< class_type*/ "interface" /*<<*/ " " << string << " : "
@@ -199,6 +211,10 @@ struct klass
199 if (etype.is_engaged()) 211 if (etype.is_engaged())
200 wrapper_args_type = "<" + evt_name + "_Args>"; 212 wrapper_args_type = "<" + evt_name + "_Args>";
201 213
214
215 if (!as_generator(documentation(1)).generate(sink, e, iface_cxt))
216 return false;
217
202 //FIXME Add a way to generate camelcase names 218 //FIXME Add a way to generate camelcase names
203 if (!as_generator( 219 if (!as_generator(
204 scope_tab << "event EventHandler" << wrapper_args_type << " " 220 scope_tab << "event EventHandler" << wrapper_args_type << " "
@@ -218,19 +234,26 @@ struct klass
218 auto concrete_cxt = context_add_tag(class_context{class_context::concrete}, context); 234 auto concrete_cxt = context_add_tag(class_context{class_context::concrete}, context);
219 if(!as_generator 235 if(!as_generator
220 ( 236 (
221 "public class " << string << "Concrete : " << string << "\n{\n" 237 documentation
238 << "sealed public class " << string << "Concrete : " << string << "\n{\n"
222 << scope_tab << "System.IntPtr handle;\n" 239 << scope_tab << "System.IntPtr handle;\n"
240 << scope_tab << "///<summary>Pointer to the native instance.</summary>\n"
223 << scope_tab << "public System.IntPtr raw_handle {\n" 241 << scope_tab << "public System.IntPtr raw_handle {\n"
224 << scope_tab << scope_tab << "get { return handle; }\n" 242 << scope_tab << scope_tab << "get { return handle; }\n"
225 << scope_tab << "}\n" 243 << scope_tab << "}\n"
244 << scope_tab << "///<summary>Pointer to the native class description.</summary>\n"
226 << scope_tab << "public System.IntPtr raw_klass {\n" 245 << scope_tab << "public System.IntPtr raw_klass {\n"
227 << scope_tab << scope_tab << "get { return efl.eo.Globals.efl_class_get(handle); }\n" 246 << scope_tab << scope_tab << "get { return efl.eo.Globals.efl_class_get(handle); }\n"
228 << scope_tab << "}\n" 247 << scope_tab << "}\n"
248 << scope_tab << "///<summary>Delegate for function to be called from inside the native constructor.</summary>\n"
229 << scope_tab << "public delegate void ConstructingMethod(" << string << " obj);\n" 249 << scope_tab << "public delegate void ConstructingMethod(" << string << " obj);\n"
230 << scope_tab << "[System.Runtime.InteropServices.DllImport(" << context_find_tag<library_context>(concrete_cxt).actual_library_name(cls.filename) 250 << scope_tab << "[System.Runtime.InteropServices.DllImport(" << context_find_tag<library_context>(concrete_cxt).actual_library_name(cls.filename)
231 << ")] static extern System.IntPtr\n" 251 << ")] private static extern System.IntPtr\n"
232 << scope_tab << scope_tab << class_get_name << "();\n" 252 << scope_tab << scope_tab << class_get_name << "();\n"
233 << (class_type == "class" ? "" : "/*") 253 << (class_type == "class" ? "" : "/*")
254 << scope_tab << "///<summary>Creates a new instance.</summary>\n"
255 << scope_tab << "///<param>Parent instance.</param>\n"
256 << scope_tab << "///<param>Delegate to call constructing methods that should be run inside the constructor.</param>\n"
234 << scope_tab << "public " << string << "Concrete(efl.Object parent = null, ConstructingMethod init_cb=null)\n" 257 << scope_tab << "public " << string << "Concrete(efl.Object parent = null, ConstructingMethod init_cb=null)\n"
235 << scope_tab << "{\n" 258 << scope_tab << "{\n"
236 << scope_tab << scope_tab << "System.IntPtr klass = " << class_get_name << "();\n" 259 << scope_tab << scope_tab << "System.IntPtr klass = " << class_get_name << "();\n"
@@ -246,22 +269,26 @@ struct klass
246 << scope_tab << scope_tab << "eina.Error.RaiseIfOccurred();\n" 269 << scope_tab << scope_tab << "eina.Error.RaiseIfOccurred();\n"
247 << scope_tab << "}\n" 270 << scope_tab << "}\n"
248 << (class_type == "class" ? "" : "*/") 271 << (class_type == "class" ? "" : "*/")
272 << scope_tab << "///<summary>Constructs an instance from a native pointer.</summary>\n"
249 << scope_tab << "public " << string << "Concrete(System.IntPtr raw)\n" 273 << scope_tab << "public " << string << "Concrete(System.IntPtr raw)\n"
250 << scope_tab << "{\n" 274 << scope_tab << "{\n"
251 << scope_tab << scope_tab << "handle = raw;\n" 275 << scope_tab << scope_tab << "handle = raw;\n"
252 << scope_tab << scope_tab << "register_event_proxies();\n" 276 << scope_tab << scope_tab << "register_event_proxies();\n"
253 << scope_tab << "}\n" 277 << scope_tab << "}\n"
278 << scope_tab << "///<summary>Destructor.</summary>\n"
254 << scope_tab << "~" << string << "Concrete()\n" 279 << scope_tab << "~" << string << "Concrete()\n"
255 << scope_tab << "{\n" 280 << scope_tab << "{\n"
256 << scope_tab << scope_tab << "Dispose(false);\n" 281 << scope_tab << scope_tab << "Dispose(false);\n"
257 << scope_tab << "}\n" 282 << scope_tab << "}\n"
258 << scope_tab << "protected virtual void Dispose(bool disposing)\n" 283 << scope_tab << "///<summary>Releases the underlying native instance.</summary>\n"
284 << scope_tab << "protected void Dispose(bool disposing)\n"
259 << scope_tab << "{\n" 285 << scope_tab << "{\n"
260 << scope_tab << scope_tab << "if (handle != System.IntPtr.Zero) {\n" 286 << scope_tab << scope_tab << "if (handle != System.IntPtr.Zero) {\n"
261 << scope_tab << scope_tab << scope_tab << "efl.eo.Globals.efl_unref(handle);\n" 287 << scope_tab << scope_tab << scope_tab << "efl.eo.Globals.efl_unref(handle);\n"
262 << scope_tab << scope_tab << scope_tab << "handle = System.IntPtr.Zero;\n" 288 << scope_tab << scope_tab << scope_tab << "handle = System.IntPtr.Zero;\n"
263 << scope_tab << scope_tab << "}\n" 289 << scope_tab << scope_tab << "}\n"
264 << scope_tab << "}\n" 290 << scope_tab << "}\n"
291 << scope_tab << "///<summary>Releases the underlying native instance.</summary>\n"
265 << scope_tab << "public void Dispose()\n" 292 << scope_tab << "public void Dispose()\n"
266 << scope_tab << "{\n" 293 << scope_tab << "{\n"
267 << scope_tab << scope_tab << "Dispose(true);\n" 294 << scope_tab << scope_tab << "Dispose(true);\n"
@@ -269,7 +296,7 @@ struct klass
269 << scope_tab << "}\n" 296 << scope_tab << "}\n"
270 ) 297 )
271 .generate(sink 298 .generate(sink
272 , std::make_tuple( 299 , std::make_tuple( cls,
273 cls.cxx_name, cls.cxx_name, cls.cxx_name, cls.namespaces, cls.eolian_name 300 cls.cxx_name, cls.cxx_name, cls.cxx_name, cls.namespaces, cls.eolian_name
274 , cls.cxx_name, cls.namespaces, cls.eolian_name, cls.cxx_name 301 , cls.cxx_name, cls.namespaces, cls.eolian_name, cls.cxx_name
275 , cls.cxx_name) 302 , cls.cxx_name)
@@ -304,22 +331,29 @@ struct klass
304 331
305 if(!as_generator 332 if(!as_generator
306 ( 333 (
307 "public " << class_type << " " << string << "Inherit : " << string << "\n{\n" 334 documentation
335 << "public " << class_type << " " << string << "Inherit : " << string << "\n{\n"
308 << scope_tab << "System.IntPtr handle;\n" 336 << scope_tab << "System.IntPtr handle;\n"
309 << scope_tab << "public static System.IntPtr klass = System.IntPtr.Zero;\n" 337 << scope_tab << "internal static System.IntPtr klass = System.IntPtr.Zero;\n"
310 << scope_tab << "private static readonly object klassAllocLock = new object();\n" 338 << scope_tab << "private static readonly object klassAllocLock = new object();\n"
311 << scope_tab << (cls_has_string_return ? ("public Dictionary<String, IntPtr> cached_strings = new Dictionary<String, IntPtr>();") : "") << "\n" 339 << scope_tab << (cls_has_string_return ? ("internal Dictionary<String, IntPtr> cached_strings = new Dictionary<String, IntPtr>();") : "") << "\n"
312 << scope_tab << (cls_has_stringshare_return ? ("public Dictionary<String, IntPtr> cached_stringshares = new Dictionary<String, IntPtr>();") : "") << "\n" 340 << scope_tab << (cls_has_stringshare_return ? ("internal Dictionary<String, IntPtr> cached_stringshares = new Dictionary<String, IntPtr>();") : "") << "\n"
341 << scope_tab << "///<summary>Pointer to the native instance.</summary>\n"
313 << scope_tab << "public System.IntPtr raw_handle {\n" 342 << scope_tab << "public System.IntPtr raw_handle {\n"
314 << scope_tab << scope_tab << "get { return handle; }\n" 343 << scope_tab << scope_tab << "get { return handle; }\n"
315 << scope_tab << "}\n" 344 << scope_tab << "}\n"
345 << scope_tab << "///<summary>Pointer to the native class description.</summary>\n"
316 << scope_tab << "public System.IntPtr raw_klass {\n" 346 << scope_tab << "public System.IntPtr raw_klass {\n"
317 << scope_tab << scope_tab << "get { return klass; }\n" 347 << scope_tab << scope_tab << "get { return klass; }\n"
318 << scope_tab << "}\n" 348 << scope_tab << "}\n"
349 << scope_tab << "///<summary>Delegate for function to be called from inside the native constructor.</summary>\n"
319 << scope_tab << "public delegate void ConstructingMethod(" << string << " obj);\n" 350 << scope_tab << "public delegate void ConstructingMethod(" << string << " obj);\n"
320 << scope_tab << "[System.Runtime.InteropServices.DllImport(" << context_find_tag<library_context>(inherit_cxt).actual_library_name(cls.filename) 351 << scope_tab << "[System.Runtime.InteropServices.DllImport(" << context_find_tag<library_context>(inherit_cxt).actual_library_name(cls.filename)
321 << ")] static extern System.IntPtr\n" 352 << ")] private static extern System.IntPtr\n"
322 << scope_tab << scope_tab << class_get_name << "();\n" 353 << scope_tab << scope_tab << class_get_name << "();\n"
354 << scope_tab << "///<summary>Creates a new instance.</summary>\n"
355 << scope_tab << "///<param>Parent instance.</param>\n"
356 << scope_tab << "///<param>Delegate to call constructing methods that should be run inside the constructor.</param>\n"
323 << scope_tab << "public " << string << "Inherit(efl.Object parent = null, ConstructingMethod init_cb=null)\n" 357 << scope_tab << "public " << string << "Inherit(efl.Object parent = null, ConstructingMethod init_cb=null)\n"
324 << scope_tab << "{\n" 358 << scope_tab << "{\n"
325 << scope_tab << scope_tab << "if (klass == System.IntPtr.Zero) {\n" 359 << scope_tab << scope_tab << "if (klass == System.IntPtr.Zero) {\n"
@@ -339,10 +373,12 @@ struct klass
339 << scope_tab << scope_tab << "register_event_proxies();\n" 373 << scope_tab << scope_tab << "register_event_proxies();\n"
340 << scope_tab << scope_tab << "eina.Error.RaiseIfOccurred();\n" 374 << scope_tab << scope_tab << "eina.Error.RaiseIfOccurred();\n"
341 << scope_tab << "}\n" 375 << scope_tab << "}\n"
376 << scope_tab << "///<summary>Destructor.</summary>\n"
342 << scope_tab << "~" << string << "Inherit()\n" 377 << scope_tab << "~" << string << "Inherit()\n"
343 << scope_tab << "{\n" 378 << scope_tab << "{\n"
344 << scope_tab << scope_tab << "Dispose(false);\n" 379 << scope_tab << scope_tab << "Dispose(false);\n"
345 << scope_tab << "}\n" 380 << scope_tab << "}\n"
381 << scope_tab << "///<summary>Releases the underlying native instance.</summary>\n"
346 << scope_tab << "protected virtual void Dispose(bool disposing)\n" 382 << scope_tab << "protected virtual void Dispose(bool disposing)\n"
347 << scope_tab << "{\n" 383 << scope_tab << "{\n"
348 << scope_tab << scope_tab << "if (handle != System.IntPtr.Zero) {\n" 384 << scope_tab << scope_tab << "if (handle != System.IntPtr.Zero) {\n"
@@ -350,6 +386,7 @@ struct klass
350 << scope_tab << scope_tab << scope_tab << "handle = System.IntPtr.Zero;\n" 386 << scope_tab << scope_tab << scope_tab << "handle = System.IntPtr.Zero;\n"
351 << scope_tab << scope_tab << "}\n" 387 << scope_tab << scope_tab << "}\n"
352 << scope_tab << "}\n" 388 << scope_tab << "}\n"
389 << scope_tab << "///<summary>Releases the underlying native instance.</summary>\n"
353 << scope_tab << "public void Dispose()\n" 390 << scope_tab << "public void Dispose()\n"
354 << scope_tab << "{\n" 391 << scope_tab << "{\n"
355 << scope_tab << (cls_has_string_return ? "efl.eo.Globals.free_dict_values(cached_strings);" : "") << "\n" 392 << scope_tab << (cls_has_string_return ? "efl.eo.Globals.free_dict_values(cached_strings);" : "") << "\n"
@@ -360,7 +397,7 @@ struct klass
360 ) 397 )
361 .generate(sink 398 .generate(sink
362 , std::make_tuple( 399 , std::make_tuple(
363 cls.cxx_name, cls.cxx_name, cls.cxx_name, cls.namespaces, cls.eolian_name 400 cls, cls.cxx_name, cls.cxx_name, cls.cxx_name, cls.namespaces, cls.eolian_name
364 , cls.cxx_name, cls.cxx_name, cls.namespaces, cls.eolian_name, cls.cxx_name 401 , cls.cxx_name, cls.cxx_name, cls.namespaces, cls.eolian_name, cls.cxx_name
365 , cls.cxx_name) 402 , cls.cxx_name)
366 , inherit_cxt)) 403 , inherit_cxt))
@@ -399,7 +436,7 @@ struct klass
399 auto inative_cxt = context_add_tag(class_context{class_context::inherit_native}, context); 436 auto inative_cxt = context_add_tag(class_context{class_context::inherit_native}, context);
400 if(!as_generator 437 if(!as_generator
401 ( 438 (
402 "public " << class_type << " " << string << "NativeInherit {\n" 439 "internal " << class_type << " " << string << "NativeInherit {\n"
403 << scope_tab << "public static byte class_initializer(IntPtr klass)\n" 440 << scope_tab << "public static byte class_initializer(IntPtr klass)\n"
404 << scope_tab << "{\n" 441 << scope_tab << "{\n"
405 << scope_tab << scope_tab << "Efl_Op_Description[] descs = new Efl_Op_Description[" << grammar::int_ << "];\n" 442 << scope_tab << scope_tab << "Efl_Op_Description[] descs = new Efl_Op_Description[" << grammar::int_ << "];\n"
@@ -528,7 +565,7 @@ struct klass
528 << scope_tab << scope_tab << scope_tab << "efl.kw_event.Description desc = new efl.kw_event.Description(key);\n" 565 << scope_tab << scope_tab << scope_tab << "efl.kw_event.Description desc = new efl.kw_event.Description(key);\n"
529 << scope_tab << scope_tab << scope_tab << "bool result = efl.eo.Globals.efl_event_callback_priority_add(handle, desc, 0, evt_delegate, System.IntPtr.Zero);\n" 566 << scope_tab << scope_tab << scope_tab << "bool result = efl.eo.Globals.efl_event_callback_priority_add(handle, desc, 0, evt_delegate, System.IntPtr.Zero);\n"
530 << scope_tab << scope_tab << scope_tab << "if (!result) {\n" 567 << scope_tab << scope_tab << scope_tab << "if (!result) {\n"
531 << scope_tab << scope_tab << scope_tab << scope_tab << "eina.Log.Error(\"Failed to add event proxy for event ${key}\");\n" 568 << scope_tab << scope_tab << scope_tab << scope_tab << "eina.Log.Error($\"Failed to add event proxy for event {key}\");\n"
532 << scope_tab << scope_tab << scope_tab << scope_tab << "return false;\n" 569 << scope_tab << scope_tab << scope_tab << scope_tab << "return false;\n"
533 << scope_tab << scope_tab << scope_tab << "}\n" 570 << scope_tab << scope_tab << scope_tab << "}\n"
534 << scope_tab << scope_tab << scope_tab << "eina.Error.RaiseIfOccurred();\n" 571 << scope_tab << scope_tab << scope_tab << "eina.Error.RaiseIfOccurred();\n"
@@ -544,12 +581,12 @@ struct klass
544 << scope_tab << scope_tab << scope_tab << "efl.kw_event.Description desc = new efl.kw_event.Description(key);\n" 581 << scope_tab << scope_tab << scope_tab << "efl.kw_event.Description desc = new efl.kw_event.Description(key);\n"
545 << scope_tab << scope_tab << scope_tab << "bool result = efl.eo.Globals.efl_event_callback_del(handle, desc, evt_delegate, System.IntPtr.Zero);\n" 582 << scope_tab << scope_tab << scope_tab << "bool result = efl.eo.Globals.efl_event_callback_del(handle, desc, evt_delegate, System.IntPtr.Zero);\n"
546 << scope_tab << scope_tab << scope_tab << "if (!result) {\n" 583 << scope_tab << scope_tab << scope_tab << "if (!result) {\n"
547 << scope_tab << scope_tab << scope_tab << scope_tab << "eina.Log.Error(\"Failed to remove event proxy for event ${key}\");\n" 584 << scope_tab << scope_tab << scope_tab << scope_tab << "eina.Log.Error($\"Failed to remove event proxy for event {key}\");\n"
548 << scope_tab << scope_tab << scope_tab << scope_tab << "return false;\n" 585 << scope_tab << scope_tab << scope_tab << scope_tab << "return false;\n"
549 << scope_tab << scope_tab << scope_tab << "}\n" 586 << scope_tab << scope_tab << scope_tab << "}\n"
550 << scope_tab << scope_tab << scope_tab << "eina.Error.RaiseIfOccurred();\n" 587 << scope_tab << scope_tab << scope_tab << "eina.Error.RaiseIfOccurred();\n"
551 << scope_tab << scope_tab << "} else if (event_count == 0) {\n" 588 << scope_tab << scope_tab << "} else if (event_count == 0) {\n"
552 << scope_tab << scope_tab << scope_tab << "eina.Log.Error(\"Trying to remove proxy for event ${key} when there is nothing registered.\");\n" 589 << scope_tab << scope_tab << scope_tab << "eina.Log.Error($\"Trying to remove proxy for event {key} when there is nothing registered.\");\n"
553 << scope_tab << scope_tab << scope_tab << "return false;\n" 590 << scope_tab << scope_tab << scope_tab << "return false;\n"
554 << scope_tab << scope_tab << "} \n" 591 << scope_tab << scope_tab << "} \n"
555 << scope_tab << scope_tab << "event_cb_count[key]--;\n" 592 << scope_tab << scope_tab << "event_cb_count[key]--;\n"
@@ -586,8 +623,12 @@ struct klass
586 // Marshal.PtrToStructure for value types 623 // Marshal.PtrToStructure for value types
587 624
588 // Wrapper event declaration 625 // Wrapper event declaration
626 if(!as_generator(documentation(1)).generate(sink, e, context))
627 return false;
628
589 if(!as_generator( 629 if(!as_generator(
590 scope_tab << "protected event EventHandler" << wrapper_args_template << " " << upper_name << ";\n" 630 scope_tab << "protected event EventHandler" << wrapper_args_template << " " << upper_name << ";\n"
631 << scope_tab << "///<summary>Method to raise event "<< event_name << ".</summary>\n"
591 << scope_tab << "protected void On_" << event_name << "(" << wrapper_args_type << " e)\n" 632 << scope_tab << "protected void On_" << event_name << "(" << wrapper_args_type << " e)\n"
592 << scope_tab << "{\n" 633 << scope_tab << "{\n"
593 << scope_tab << scope_tab << "EventHandler" << wrapper_args_template << " evt;\n" 634 << scope_tab << scope_tab << "EventHandler" << wrapper_args_template << " evt;\n"
@@ -596,13 +637,13 @@ struct klass
596 << scope_tab << scope_tab << "}\n" 637 << scope_tab << scope_tab << "}\n"
597 << scope_tab << scope_tab << "if (evt != null) { evt(this, e); }\n" 638 << scope_tab << scope_tab << "if (evt != null) { evt(this, e); }\n"
598 << scope_tab << "}\n" 639 << scope_tab << "}\n"
599 << scope_tab << "public void on_" << event_name << "_NativeCallback(System.IntPtr data, ref efl.Event evt)\n" 640 << scope_tab << "private void on_" << event_name << "_NativeCallback(System.IntPtr data, ref efl.Event evt)\n"
600 << scope_tab << "{\n" 641 << scope_tab << "{\n"
601 << scope_tab << event_args 642 << scope_tab << event_args
602 << scope_tab << scope_tab << "try {\n" 643 << scope_tab << scope_tab << "try {\n"
603 << scope_tab << scope_tab << scope_tab << "On_" << event_name << "(args);\n" 644 << scope_tab << scope_tab << scope_tab << "On_" << event_name << "(args);\n"
604 << scope_tab << scope_tab << "} catch (Exception e) {\n" 645 << scope_tab << scope_tab << "} catch (Exception e) {\n"
605 << scope_tab << scope_tab << scope_tab << "eina.Log.Warning(e.ToString());\n" 646 << scope_tab << scope_tab << scope_tab << "eina.Log.Error(e.ToString());\n"
606 << scope_tab << scope_tab << scope_tab << "eina.Error.Set(eina.Error.EFL_ERROR);\n" 647 << scope_tab << scope_tab << scope_tab << "eina.Error.Set(eina.Error.EFL_ERROR);\n"
607 << scope_tab << scope_tab << "}\n" 648 << scope_tab << scope_tab << "}\n"
608 << scope_tab << "}\n" 649 << scope_tab << "}\n"
@@ -618,7 +659,7 @@ struct klass
618 << scope_tab << scope_tab << scope_tab << scope_tab << "if (add_cpp_event_handler(key, this.evt_" << event_name << "_delegate))\n" 659 << scope_tab << scope_tab << scope_tab << scope_tab << "if (add_cpp_event_handler(key, this.evt_" << event_name << "_delegate))\n"
619 << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << upper_name << " += value;\n" 660 << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << upper_name << " += value;\n"
620 << scope_tab << scope_tab << scope_tab << scope_tab << "else\n" 661 << scope_tab << scope_tab << scope_tab << scope_tab << "else\n"
621 << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << "eina.Log.Error(\"Error adding proxy for event ${key}\");\n" 662 << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << "eina.Log.Error($\"Error adding proxy for event {key}\");\n"
622 << scope_tab << scope_tab << scope_tab << "}\n" // End of lock block 663 << scope_tab << scope_tab << scope_tab << "}\n" // End of lock block
623 << scope_tab << scope_tab << "}\n" 664 << scope_tab << scope_tab << "}\n"
624 << scope_tab << scope_tab << "remove {\n" 665 << scope_tab << scope_tab << "remove {\n"
@@ -627,7 +668,7 @@ struct klass
627 << scope_tab << scope_tab << scope_tab << scope_tab << "if (remove_cpp_event_handler(key, this.evt_" << event_name << "_delegate))\n" 668 << scope_tab << scope_tab << scope_tab << scope_tab << "if (remove_cpp_event_handler(key, this.evt_" << event_name << "_delegate))\n"
628 << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << upper_name << " -= value;\n" 669 << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << upper_name << " -= value;\n"
629 << scope_tab << scope_tab << scope_tab << scope_tab << "else\n" 670 << scope_tab << scope_tab << scope_tab << scope_tab << "else\n"
630 << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << "eina.Log.Error(\"Error removing proxy for event ${key}\");\n" 671 << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << "eina.Log.Error($\"Error removing proxy for event {key}\");\n"
631 << scope_tab << scope_tab << scope_tab << "}\n" // End of lock block 672 << scope_tab << scope_tab << scope_tab << "}\n" // End of lock block
632 << scope_tab << scope_tab << "}\n" 673 << scope_tab << scope_tab << "}\n"
633 << scope_tab << "}\n") 674 << scope_tab << "}\n")
@@ -672,8 +713,12 @@ struct klass
672 wrapper_args_type << "EventArgs"; 713 wrapper_args_type << "EventArgs";
673 } 714 }
674 715
716 if (!as_generator(documentation(1)).generate(sink, e, context))
717 return false;
718
675 if (!as_generator( 719 if (!as_generator(
676 scope_tab << "protected event EventHandler" << wrapper_args_template << " " << wrapper_evt_name << ";\n" 720 scope_tab << "protected event EventHandler" << wrapper_args_template << " " << wrapper_evt_name << ";\n"
721 << scope_tab << "///<summary>Method to raise event "<< wrapper_evt_name << ".</summary>\n"
677 << scope_tab << "protected void On_" << wrapper_evt_name << "(" << wrapper_args_type.str() << " e)\n" 722 << scope_tab << "protected void On_" << wrapper_evt_name << "(" << wrapper_args_type.str() << " e)\n"
678 << scope_tab << "{\n" 723 << scope_tab << "{\n"
679 << scope_tab << scope_tab << "EventHandler" << wrapper_args_template << " evt;\n" 724 << scope_tab << scope_tab << "EventHandler" << wrapper_args_template << " evt;\n"
@@ -683,13 +728,13 @@ struct klass
683 << scope_tab << scope_tab << "if (evt != null) { evt(this, e); }\n" 728 << scope_tab << scope_tab << "if (evt != null) { evt(this, e); }\n"
684 << scope_tab << "}\n" 729 << scope_tab << "}\n"
685 << scope_tab << "efl.Event_Cb evt_" << wrapper_evt_name << "_delegate;\n" 730 << scope_tab << "efl.Event_Cb evt_" << wrapper_evt_name << "_delegate;\n"
686 << scope_tab << "protected void on_" << wrapper_evt_name << "_NativeCallback(System.IntPtr data, ref efl.Event evt)" 731 << scope_tab << "private void on_" << wrapper_evt_name << "_NativeCallback(System.IntPtr data, ref efl.Event evt)"
687 << scope_tab << "{\n" 732 << scope_tab << "{\n"
688 << scope_tab << event_args 733 << scope_tab << event_args
689 << scope_tab << scope_tab << "try {\n" 734 << scope_tab << scope_tab << "try {\n"
690 << scope_tab << scope_tab << scope_tab << "On_" << wrapper_evt_name << "(args);\n" 735 << scope_tab << scope_tab << scope_tab << "On_" << wrapper_evt_name << "(args);\n"
691 << scope_tab << scope_tab << "} catch (Exception e) {\n" 736 << scope_tab << scope_tab << "} catch (Exception e) {\n"
692 << scope_tab << scope_tab << scope_tab << "eina.Log.Warning(e.ToString());\n" 737 << scope_tab << scope_tab << scope_tab << "eina.Log.Error(e.ToString());\n"
693 << scope_tab << scope_tab << scope_tab << "eina.Error.Set(eina.Error.EFL_ERROR);\n" 738 << scope_tab << scope_tab << scope_tab << "eina.Error.Set(eina.Error.EFL_ERROR);\n"
694 << scope_tab << scope_tab << "}\n" 739 << scope_tab << scope_tab << "}\n"
695 << scope_tab << "}\n" 740 << scope_tab << "}\n"
@@ -703,7 +748,7 @@ struct klass
703 << scope_tab << scope_tab << scope_tab << scope_tab << "if (add_cpp_event_handler(key, this.evt_" << wrapper_evt_name << "_delegate))\n" 748 << scope_tab << scope_tab << scope_tab << scope_tab << "if (add_cpp_event_handler(key, this.evt_" << wrapper_evt_name << "_delegate))\n"
704 << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << wrapper_evt_name << " += value;\n" 749 << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << wrapper_evt_name << " += value;\n"
705 << scope_tab << scope_tab << scope_tab << scope_tab << "else\n" 750 << scope_tab << scope_tab << scope_tab << scope_tab << "else\n"
706 << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << "eina.Log.Error(\"Error adding proxy for event ${key}\");\n" 751 << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << "eina.Log.Error($\"Error adding proxy for event {key}\");\n"
707 << scope_tab << scope_tab << scope_tab << "}\n" // End of lock block 752 << scope_tab << scope_tab << scope_tab << "}\n" // End of lock block
708 << scope_tab << scope_tab << "}\n" 753 << scope_tab << scope_tab << "}\n"
709 << scope_tab << scope_tab << "remove {\n" 754 << scope_tab << scope_tab << "remove {\n"
@@ -712,7 +757,7 @@ struct klass
712 << scope_tab << scope_tab << scope_tab << scope_tab << "if (remove_cpp_event_handler(key, this.evt_" << wrapper_evt_name << "_delegate))\n" 757 << scope_tab << scope_tab << scope_tab << scope_tab << "if (remove_cpp_event_handler(key, this.evt_" << wrapper_evt_name << "_delegate))\n"
713 << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << wrapper_evt_name << " -= value;\n" 758 << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << wrapper_evt_name << " -= value;\n"
714 << scope_tab << scope_tab << scope_tab << scope_tab << "else\n" 759 << scope_tab << scope_tab << scope_tab << scope_tab << "else\n"
715 << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << "eina.Log.Error(\"Error removing proxy for event ${key}\");\n" 760 << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << "eina.Log.Error($\"Error removing proxy for event {key}\");\n"
716 << scope_tab << scope_tab << scope_tab << "}\n" // End of lock block 761 << scope_tab << scope_tab << scope_tab << "}\n" // End of lock block
717 << scope_tab << scope_tab << "}\n" 762 << scope_tab << scope_tab << "}\n"
718 << scope_tab << "}\n") 763 << scope_tab << "}\n")
diff --git a/src/bin/eolian_mono/eolian/mono/struct_definition.hh b/src/bin/eolian_mono/eolian/mono/struct_definition.hh
index 85cc14cc0d..5db84e0a9b 100644
--- a/src/bin/eolian_mono/eolian/mono/struct_definition.hh
+++ b/src/bin/eolian_mono/eolian/mono/struct_definition.hh
@@ -10,6 +10,7 @@
10#include "type.hh" 10#include "type.hh"
11#include "keyword.hh" 11#include "keyword.hh"
12#include "using_decl.hh" 12#include "using_decl.hh"
13#include "documentation.hh"
13 14
14namespace eolian_mono { 15namespace eolian_mono {
15 16
@@ -35,6 +36,9 @@ struct struct_definition_generator
35 template <typename OutputIterator, typename Context> 36 template <typename OutputIterator, typename Context>
36 bool generate(OutputIterator sink, attributes::struct_def const& struct_, Context const& context) const 37 bool generate(OutputIterator sink, attributes::struct_def const& struct_, Context const& context) const
37 { 38 {
39
40 if(!as_generator(documentation).generate(sink, struct_, context))
41 return false;
38 if(!as_generator 42 if(!as_generator
39 ( 43 (
40 "[StructLayout(LayoutKind.Sequential)]\n" 44 "[StructLayout(LayoutKind.Sequential)]\n"
@@ -46,11 +50,14 @@ struct struct_definition_generator
46 // iterate struct fields 50 // iterate struct fields
47 for (auto const& field : struct_.fields) 51 for (auto const& field : struct_.fields)
48 { 52 {
53 auto field_name = field.name;
54 field_name[0] = std::toupper(field_name[0]); // Hack to allow 'static' as a field name
49 if (!as_generator 55 if (!as_generator
50 ( 56 (
51 " public " << type << " " << string << ";\n" 57 documentation(1)
58 << scope_tab(1) << "public " << type << " " << string << ";\n"
52 ) 59 )
53 .generate(sink, std::make_tuple(field.type, to_field_name(field.name)), context)) 60 .generate(sink, std::make_tuple(field, field.type, to_field_name(field.name)), context))
54 return false; 61 return false;
55 } 62 }
56 63
@@ -79,7 +86,7 @@ struct struct_internal_definition_generator
79 if (!as_generator 86 if (!as_generator
80 ( 87 (
81 "[StructLayout(LayoutKind.Sequential)]\n" 88 "[StructLayout(LayoutKind.Sequential)]\n"
82 "public struct " << string << "\n{\n" 89 "internal struct " << string << "\n{\n"
83 ) 90 )
84 .generate(sink, binding_struct_internal_name(struct_), context)) 91 .generate(sink, binding_struct_internal_name(struct_), context))
85 return false; 92 return false;
@@ -97,11 +104,11 @@ struct struct_internal_definition_generator
97 || regular->base_type == "stringshare" 104 || regular->base_type == "stringshare"
98 || regular->base_type == "any_value_ptr"))) 105 || regular->base_type == "any_value_ptr")))
99 { 106 {
100 if (!as_generator(" public System.IntPtr " << string << ";\n") 107 if (!as_generator(" internal System.IntPtr " << string << ";\n")
101 .generate(sink, field_name, context)) 108 .generate(sink, field_name, context))
102 return false; 109 return false;
103 } 110 }
104 else if (!as_generator(eolian_mono::marshall_annotation(false) << " public " << eolian_mono::marshall_type(false) << " " << string << ";\n") 111 else if (!as_generator(eolian_mono::marshall_annotation(false) << " internal " << eolian_mono::marshall_type(false) << " " << string << ";\n")
105 .generate(sink, std::make_tuple(field.type, field.type, field_name), context)) 112 .generate(sink, std::make_tuple(field.type, field.type, field_name), context))
106 return false; 113 return false;
107 } 114 }
@@ -112,7 +119,7 @@ struct struct_internal_definition_generator
112 // those 'mini-amd64.c condition fields not met' crashes. 119 // those 'mini-amd64.c condition fields not met' crashes.
113 if (struct_.fields.size() == 0) 120 if (struct_.fields.size() == 0)
114 { 121 {
115 if (!as_generator("public IntPtr field;\n").generate(sink, nullptr, context)) 122 if (!as_generator("internal IntPtr field;\n").generate(sink, nullptr, context))
116 return false; 123 return false;
117 } 124 }
118 125
@@ -330,7 +337,7 @@ struct struct_binding_conversion_functions_generator
330 // Open conversion class 337 // Open conversion class
331 if (!as_generator 338 if (!as_generator
332 ( 339 (
333 "public static class " << string << "_StructConvertion\n{\n" 340 "internal static class " << string << "_StructConvertion\n{\n"
334 ) 341 )
335 .generate(sink, struct_.cxx_name, context)) 342 .generate(sink, struct_.cxx_name, context))
336 return false; 343 return false;
@@ -338,7 +345,7 @@ struct struct_binding_conversion_functions_generator
338 // to internal 345 // to internal
339 if (!as_generator 346 if (!as_generator
340 ( 347 (
341 scope_tab << "public static " << string << " ToInternal(" << string << " _external_struct)\n" 348 scope_tab << "internal static " << string << " ToInternal(" << string << " _external_struct)\n"
342 << scope_tab << "{\n" 349 << scope_tab << "{\n"
343 << scope_tab << scope_tab << "var _internal_struct = new " << string << "();\n\n" 350 << scope_tab << scope_tab << "var _internal_struct = new " << string << "();\n\n"
344 ) 351 )
@@ -366,7 +373,7 @@ struct struct_binding_conversion_functions_generator
366 // to external 373 // to external
367 if (!as_generator 374 if (!as_generator
368 ( 375 (
369 scope_tab << "public static " << string << " ToExternal(" << string << " _internal_struct)\n" 376 scope_tab << "internal static " << string << " ToExternal(" << string << " _internal_struct)\n"
370 << scope_tab << "{\n" 377 << scope_tab << "{\n"
371 << scope_tab << scope_tab << "var _external_struct = new " << string << "();\n\n" 378 << scope_tab << scope_tab << "var _external_struct = new " << string << "();\n\n"
372 ) 379 )
diff --git a/src/bin/eolian_mono/eolian/mono/using_decl.hh b/src/bin/eolian_mono/eolian/mono/using_decl.hh
index 97bf62c526..fdea162f59 100644
--- a/src/bin/eolian_mono/eolian/mono/using_decl.hh
+++ b/src/bin/eolian_mono/eolian/mono/using_decl.hh
@@ -1,11 +1,19 @@
1#ifndef EOLIAN_MONO_USING_DECL_HH 1#ifndef EOLIAN_MONO_USING_DECL_HH
2#define EOLIAN_MONO_USING_DECL_HH 2#define EOLIAN_MONO_USING_DECL_HH
3 3
4#include <grammar/generator.hpp>
5#include <grammar/context.hpp>
6#include <grammar/kleene.hpp>
7#include <grammar/integral.hpp>
8#include <grammar/string.hpp>
9#include <grammar/html_escaped_string.hpp>
10
4namespace eolian_mono { 11namespace eolian_mono {
5 12
6namespace grammar = efl::eolian::grammar; 13namespace grammar = efl::eolian::grammar;
7using efl::eolian::grammar::as_generator; 14using efl::eolian::grammar::as_generator;
8using efl::eolian::grammar::string; 15using efl::eolian::grammar::string;
16using efl::eolian::grammar::html_escaped_string;
9using efl::eolian::grammar::operator<<; 17using efl::eolian::grammar::operator<<;
10using efl::eolian::grammar::operator%; 18using efl::eolian::grammar::operator%;
11using efl::eolian::grammar::operator*; 19using efl::eolian::grammar::operator*;