2017-11-23 16:50:16 -08:00
|
|
|
#ifndef EOLIAN_MONO_FUNCTION_REGISTRATION_HH
|
|
|
|
#define EOLIAN_MONO_FUNCTION_REGISTRATION_HH
|
|
|
|
|
|
|
|
#include <Eina.hh>
|
|
|
|
|
|
|
|
#include "grammar/generator.hpp"
|
|
|
|
#include "grammar/klass_def.hpp"
|
|
|
|
|
|
|
|
#include "grammar/indentation.hpp"
|
|
|
|
#include "grammar/list.hpp"
|
|
|
|
#include "grammar/alternative.hpp"
|
|
|
|
#include "grammar/attribute_reorder.hpp"
|
2018-04-27 14:08:25 -07:00
|
|
|
#include "logging.hh"
|
2017-11-23 16:50:16 -08:00
|
|
|
#include "type.hh"
|
|
|
|
#include "marshall_type.hh"
|
|
|
|
#include "parameter.hh"
|
|
|
|
#include "using_decl.hh"
|
|
|
|
#include "generation_contexts.hh"
|
2018-04-16 12:26:13 -07:00
|
|
|
#include "blacklist.hh"
|
2017-11-23 16:50:16 -08:00
|
|
|
|
|
|
|
namespace eolian_mono {
|
|
|
|
|
2019-01-17 04:33:09 -08:00
|
|
|
// template <typename I>
|
2017-11-23 16:50:16 -08:00
|
|
|
struct function_registration_generator
|
|
|
|
{
|
2019-01-17 04:33:09 -08:00
|
|
|
// I index_generator;
|
2017-11-23 16:50:16 -08:00
|
|
|
attributes::klass_def const* klass;
|
|
|
|
|
|
|
|
template <typename OutputIterator, typename Context>
|
|
|
|
bool generate(OutputIterator sink, attributes::function_def const& f, Context const& context) const
|
|
|
|
{
|
2018-04-27 14:08:25 -07:00
|
|
|
EINA_CXX_DOM_LOG_DBG(eolian_mono::domain) << "function_registration_generator: " << f.name << std::endl;
|
2019-01-17 04:43:57 -08:00
|
|
|
if(blacklist::is_function_blacklisted(f, context) || f.is_static) // Static methods aren't overrideable
|
2017-11-23 16:50:16 -08:00
|
|
|
return true;
|
|
|
|
else
|
|
|
|
{
|
2019-01-17 04:33:09 -08:00
|
|
|
// auto index = index_generator();
|
2018-12-14 14:39:09 -08:00
|
|
|
|
|
|
|
if(!as_generator(
|
2019-01-15 23:29:56 -08:00
|
|
|
scope_tab << scope_tab << "if (" << f.c_name << "_static_delegate == null)\n"
|
2019-03-19 19:24:51 -07:00
|
|
|
<< scope_tab << scope_tab << scope_tab << f.c_name << "_static_delegate = new " << f.c_name << "_delegate(" <<
|
2018-12-14 14:39:09 -08:00
|
|
|
escape_keyword(f.name) << ");\n"
|
|
|
|
).generate(sink, attributes::unused, context))
|
|
|
|
return false;
|
|
|
|
|
2017-11-23 16:50:16 -08:00
|
|
|
if(!as_generator
|
2019-04-09 07:16:17 -07:00
|
|
|
(scope_tab << scope_tab
|
|
|
|
<< "if (methods.FirstOrDefault(m => m.Name == \"" << string << "\") != null)\n"
|
|
|
|
<< scope_tab << scope_tab << scope_tab
|
|
|
|
<< "descs.Add(new Efl_Op_Description() {"
|
2017-11-23 16:50:16 -08:00
|
|
|
#ifdef _WIN32
|
2019-01-17 04:33:09 -08:00
|
|
|
<< "api_func = Marshal.StringToHGlobalAnsi(\"" << string << "\")"
|
2017-11-23 16:50:16 -08:00
|
|
|
#else
|
2019-01-15 23:29:56 -08:00
|
|
|
<< "api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(_Module.Module, \"" << string << "\")"
|
2017-11-23 16:50:16 -08:00
|
|
|
#endif
|
2019-01-15 23:29:56 -08:00
|
|
|
<< ", func = Marshal.GetFunctionPointerForDelegate(" << string << "_static_delegate)});\n"
|
2017-11-23 16:50:16 -08:00
|
|
|
)
|
2019-04-09 07:16:17 -07:00
|
|
|
.generate(sink, std::make_tuple(name_helpers::managed_method_name(f), f.c_name, f.c_name), context))
|
2017-11-23 16:50:16 -08:00
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct function_registration_parameterized
|
|
|
|
{
|
2019-01-17 04:33:09 -08:00
|
|
|
function_registration_generator operator()(attributes::klass_def const& klass) const
|
2017-11-23 16:50:16 -08:00
|
|
|
{
|
2019-01-17 04:33:09 -08:00
|
|
|
return {&klass};
|
2017-11-23 16:50:16 -08:00
|
|
|
}
|
|
|
|
} const function_registration;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace efl { namespace eolian { namespace grammar {
|
|
|
|
|
2019-01-17 04:33:09 -08:00
|
|
|
template <>
|
|
|
|
struct is_eager_generator< ::eolian_mono::function_registration_generator> : std::true_type {};
|
|
|
|
template <>
|
|
|
|
struct is_generator< ::eolian_mono::function_registration_generator> : std::true_type {};
|
2017-11-23 16:50:16 -08:00
|
|
|
|
|
|
|
namespace type_traits {
|
|
|
|
|
2019-01-17 04:33:09 -08:00
|
|
|
template <>
|
|
|
|
struct attributes_needed< ::eolian_mono::function_registration_generator> : std::integral_constant<int, 1> {};
|
2017-11-23 16:50:16 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
} } }
|
|
|
|
|
|
|
|
#endif
|