<< scope_tab << "{\n"
<< scope_tab << scope_tab << "return value.payload;\n"
<< scope_tab << "}\n"
+
+ << scope_tab << "/// <summary>Converts an instance of " << alias_type_doc << " to this struct.</summary>\n"
+ << scope_tab << "/// <param name=\"value\">The value to be converted.</param>\n"
+ << scope_tab << "/// <returns>A struct with the given value.</returns>\n"
+ << scope_tab << "public static " << alias_name << " From" << name_helpers::translate_value_type(alias_type) << "(" << alias_type << " value)\n"
+ << scope_tab << "{\n"
+ << scope_tab << scope_tab << "return value;\n"
+ << scope_tab << "}\n\n"
+
+ << scope_tab << "/// <summary>Converts an instance of this struct to " << alias_type_doc << ".</summary>\n"
+ << scope_tab << "/// <returns>The actual value the alias is wrapping.</returns>\n"
+ << scope_tab << "public " << alias_type << " To" << name_helpers::translate_value_type(alias_type) << "()\n"
+ << scope_tab << "{\n"
+ << scope_tab << scope_tab << "return this;\n"
+ << scope_tab << "}\n"
<< "}\n"
).generate(sink, alias, context))
return false;
return managed_name(tokens.at(tokens.size()-1));
}
+std::string translate_value_type(std::string const& name)
+{
+ static std::map<std::string, std::string> table = {
+ {"sbyte", "SByte"},
+ {"byte","Byte"},
+ {"short","Int16"},
+ {"ushort","UInt16"},
+ {"int", "Int32"},
+ {"uint","UInt32"},
+ {"long","Int64"},
+ {"ulong","UInt64"},
+ {"char","Char"},
+ {"float","Single"},
+ {"double","Double"},
+ {"bool","Boolean"},
+ {"decimal","Decimal"},
+ };
+
+ auto found = table.find(name);
+
+ if (found != table.end())
+ return found->second;
+
+ return name;
+}
+
} // namespace name_helpers
} // namespace eolian_mono
).generate(sink, attributes::unused, context))
return false;
+ if(!as_generator(
+ indent << scope_tab << "/// <summary>Conversion to the managed representation from a native pointer.\n"
+ ).generate(sink, attributes::unused, context))
+ return false;
+
+ if (!struct_.documentation.since.empty())
+ if (!as_generator(indent << scope_tab << "/// <para>Since EFL " + struct_.documentation.since + ".</para>\n"
+ ).generate(sink, attributes::unused, context))
+ return false;
+
+ if (!as_generator(
+ indent << scope_tab << "/// </summary>\n"
+ << indent << scope_tab << "/// <param name=\"ptr\">Native pointer to be converted.</param>\n"
+ << indent << scope_tab << "public static " << struct_name << " FromIntPtr(IntPtr ptr)\n"
+ << indent << scope_tab << "{\n"
+ << indent << scope_tab << scope_tab << "return ptr;\n"
+ << indent << scope_tab << "}\n\n"
+ ).generate(sink, attributes::unused, context))
+ return false;
+
if (!struct_internal_definition.generate(sink, struct_, change_indentation(indent.inc(), context)))
return false;