efl-mono: Enable selecting to build @beta items
Summary: For autotools, use --enable-csharp-beta to enable the generation of beta methods and properties, for meson use -Dmono-beta=true. By default, no beta method or property is generated. Reviewers: woohyun, segfaultxavi, bu5hm4n, lauromoura Reviewed By: woohyun Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D7637
This commit is contained in:
parent
adc2e674af
commit
586bc5207e
16
configure.ac
16
configure.ac
|
@ -1349,6 +1349,17 @@ EFL_LIB_END_OPTIONAL([Eo_Js])
|
|||
#### End of Eo JS
|
||||
|
||||
#### Efl C Sharp Bindings
|
||||
want_csharp_beta="no"
|
||||
AC_ARG_ENABLE([csharp-beta],
|
||||
[AS_HELP_STRING([--enable-csharp-beta],[enable C Sharp bindings. @<:@default=disabled@:>@])],
|
||||
[
|
||||
if test "x${enableval}" = "xyes" ; then
|
||||
want_csharp_beta="yes"
|
||||
else
|
||||
want_csharp_beta="no"
|
||||
fi
|
||||
],
|
||||
[want_csharp_beta="no"])
|
||||
|
||||
want_csharp="no"
|
||||
AC_ARG_ENABLE([csharp-bindings],
|
||||
|
@ -1372,6 +1383,11 @@ AC_DEFINE_IF([HAVE_CSHARP], [test "x${want_csharp}" = "xyes"],
|
|||
[1], [Compiling bindings for C Sharp])
|
||||
AC_SUBST([want_csharp])
|
||||
|
||||
AM_CONDITIONAL([HAVE_CSHARP_BETA], [test "x${want_csharp_beta}" = "xyes"])
|
||||
AC_DEFINE_IF([HAVE_CSHARP_BETA], [test "x${want_csharp_beta}" = "xyes"],
|
||||
[1], [Compiling bindings for C Sharp with beta methods, properties and classes])
|
||||
AC_SUBST([want_csharp_beta])
|
||||
|
||||
if test "x${have_windows}" = "xyes"; then
|
||||
eflmonodlldir="$prefix/bin"
|
||||
else
|
||||
|
|
|
@ -317,6 +317,12 @@ option('bindings',
|
|||
description : 'Add values here to enable the bindings',
|
||||
)
|
||||
|
||||
option('mono-beta',
|
||||
type: 'boolean',
|
||||
value: false,
|
||||
description: 'Flag for enabling @beta Eo methods in the api'
|
||||
)
|
||||
|
||||
option('native-arch-optimization',
|
||||
type: 'boolean',
|
||||
value: true,
|
||||
|
|
|
@ -8,7 +8,11 @@ EOLIAN_MONO = EFL_RUN_IN_TREE=1 $(top_builddir)/src/bin/eolian_mono/eolian_mono$
|
|||
_EOLIAN_MONO_DEP = bin/eolian_mono/eolian_mono${EXEEXT}
|
||||
endif
|
||||
|
||||
if HAVE_CSHARP_BETA
|
||||
EOLIAN_MONO_FLAGS = -b -M @VMAJ@ -m @VMIN@
|
||||
else
|
||||
EOLIAN_MONO_FLAGS = -M @VMAJ@ -m @VMIN@
|
||||
endif
|
||||
|
||||
AM_V_EOLMONO = $(am__v_EOLMONO_@AM_V@)
|
||||
am__v_EOLMONO_ = $(am__v_EOLMONO_@AM_DEFAULT_V@)
|
||||
|
|
|
@ -48,7 +48,7 @@ struct async_function_declaration_generator
|
|||
{
|
||||
if (f.is_static)
|
||||
return true;
|
||||
if (blacklist::is_function_blacklisted(f.c_name))
|
||||
if (blacklist::is_function_blacklisted(f, context))
|
||||
return true;
|
||||
if (!f.return_type.original_type.visit(is_future{}))
|
||||
return true;
|
||||
|
@ -76,7 +76,7 @@ struct async_function_definition_generator
|
|||
|
||||
if(do_super && f.is_static) // Static methods goes only on Concrete classes.
|
||||
return true;
|
||||
if(blacklist::is_function_blacklisted(f.c_name))
|
||||
if(blacklist::is_function_blacklisted(f, context))
|
||||
return true;
|
||||
if(!f.return_type.original_type.visit(is_future{}))
|
||||
return true;
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
#define EOLIAN_MONO_BLACKLIST_HH
|
||||
|
||||
#include "grammar/klass_def.hpp"
|
||||
#include "grammar/context.hpp"
|
||||
#include "name_helpers.hh"
|
||||
#include "generation_contexts.hh"
|
||||
|
||||
namespace eolian_mono {
|
||||
|
||||
|
@ -49,6 +51,19 @@ inline bool is_function_blacklisted(std::string const& c_name)
|
|||
;
|
||||
}
|
||||
|
||||
template<typename Context>
|
||||
inline bool is_function_blacklisted(attributes::function_def const& func, Context context)
|
||||
{
|
||||
auto options = efl::eolian::grammar::context_find_tag<options_context>(context);
|
||||
auto c_name = func.c_name;
|
||||
|
||||
if (func.is_beta && !options.want_beta)
|
||||
return true;
|
||||
|
||||
return is_function_blacklisted(c_name);
|
||||
}
|
||||
|
||||
|
||||
// Blacklist structs that require some kind of manual binding.
|
||||
inline bool is_struct_blacklisted(std::string const& full_name)
|
||||
{
|
||||
|
@ -85,9 +100,17 @@ inline bool is_property_blacklisted(std::string const& name)
|
|||
|| name == "Efl.Text.Text";
|
||||
}
|
||||
|
||||
inline bool is_property_blacklisted(attributes::property_def const& property)
|
||||
template<typename Context>
|
||||
inline bool is_property_blacklisted(attributes::property_def const& property, Context context)
|
||||
{
|
||||
auto name = name_helpers::klass_full_concrete_or_interface_name(property.klass) + "." + name_helpers::property_managed_name(property);
|
||||
|
||||
if (property.getter.is_engaged())
|
||||
if (is_function_blacklisted(*property.getter, context))
|
||||
return true;
|
||||
if (property.setter.is_engaged())
|
||||
if (is_function_blacklisted(*property.setter, context))
|
||||
return true;
|
||||
return is_property_blacklisted(name);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ struct function_declaration_generator
|
|||
template <typename OutputIterator, typename Context>
|
||||
bool generate(OutputIterator sink, attributes::function_def const& f, Context const& context) const
|
||||
{
|
||||
if(blacklist::is_function_blacklisted(f.c_name) || f.is_static)
|
||||
if(blacklist::is_function_blacklisted(f, context) || f.is_static)
|
||||
return true;
|
||||
|
||||
if(!as_generator(documentation).generate(sink, f, context))
|
||||
|
|
|
@ -32,7 +32,7 @@ struct native_function_definition_generator
|
|||
bool generate(OutputIterator sink, attributes::function_def const& f, Context const& context) const
|
||||
{
|
||||
EINA_CXX_DOM_LOG_DBG(eolian_mono::domain) << "native_function_definition_generator: " << f.c_name << std::endl;
|
||||
if(blacklist::is_function_blacklisted(f.c_name) || f.is_static) // Only Concrete classes implement static methods.
|
||||
if(blacklist::is_function_blacklisted(f, context) || f.is_static) // Only Concrete classes implement static methods.
|
||||
return true;
|
||||
else
|
||||
{
|
||||
|
@ -138,7 +138,7 @@ struct function_definition_generator
|
|||
bool generate(OutputIterator sink, attributes::function_def const& f, Context const& context) const
|
||||
{
|
||||
EINA_CXX_DOM_LOG_DBG(eolian_mono::domain) << "function_definition_generator: " << f.c_name << std::endl;
|
||||
if(blacklist::is_function_blacklisted(f.c_name))
|
||||
if(blacklist::is_function_blacklisted(f, context))
|
||||
return true;
|
||||
|
||||
if(!as_generator
|
||||
|
@ -213,7 +213,7 @@ struct property_wrapper_definition_generator
|
|||
template<typename OutputIterator, typename Context>
|
||||
bool generate(OutputIterator sink, attributes::property_def const& property, Context context) const
|
||||
{
|
||||
if (blacklist::is_property_blacklisted(property))
|
||||
if (blacklist::is_property_blacklisted(property, context))
|
||||
return true;
|
||||
|
||||
bool interface = context_find_tag<class_context>(context).current_wrapper_kind == class_context::interface;
|
||||
|
|
|
@ -30,7 +30,7 @@ struct function_registration_generator
|
|||
bool generate(OutputIterator sink, attributes::function_def const& f, Context const& context) const
|
||||
{
|
||||
EINA_CXX_DOM_LOG_DBG(eolian_mono::domain) << "function_registration_generator: " << f.name << std::endl;
|
||||
if(blacklist::is_function_blacklisted(f.c_name) || f.is_static) // Static methods aren't overrideable
|
||||
if(blacklist::is_function_blacklisted(f, context) || f.is_static) // Static methods aren't overrideable
|
||||
return true;
|
||||
else
|
||||
{
|
||||
|
|
|
@ -45,6 +45,10 @@ struct eolian_state_context {
|
|||
const Eolian_State *state;
|
||||
};
|
||||
|
||||
struct options_context {
|
||||
bool want_beta;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -71,13 +71,14 @@ static bool generate_equals_method(OutputIterator sink, Context const &context)
|
|||
}
|
||||
|
||||
/* Get the actual number of functions of a class, checking for blacklisted ones */
|
||||
template<typename Context>
|
||||
static std::size_t
|
||||
get_implementable_function_count(grammar::attributes::klass_def const& cls)
|
||||
get_implementable_function_count(grammar::attributes::klass_def const& cls, Context context)
|
||||
{
|
||||
auto methods = helpers::get_all_implementable_methods(cls);
|
||||
return std::count_if(methods.cbegin(), methods.cend(), [](grammar::attributes::function_def const& func)
|
||||
return std::count_if(methods.cbegin(), methods.cend(), [&context](grammar::attributes::function_def const& func)
|
||||
{
|
||||
return !blacklist::is_function_blacklisted(func.c_name) && !func.is_static;
|
||||
return !blacklist::is_function_blacklisted(func, context) && !func.is_static;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@ struct options_type
|
|||
mutable Eolian_Unit const* unit;
|
||||
int v_major;
|
||||
int v_minor;
|
||||
bool want_beta;
|
||||
std::map<const std::string, std::string> references_map;
|
||||
};
|
||||
|
||||
|
@ -144,7 +145,9 @@ run(options_type const& opts)
|
|||
opts.references_map},
|
||||
efl::eolian::grammar::context_null());
|
||||
|
||||
auto context = efl::eolian::grammar::context_add_tag(eolian_mono::eolian_state_context{opts.state}, lib_context);
|
||||
auto options_context = efl::eolian::grammar::context_add_tag(eolian_mono::options_context{opts.want_beta}, lib_context);
|
||||
|
||||
auto context = efl::eolian::grammar::context_add_tag(eolian_mono::eolian_state_context{opts.state}, options_context);
|
||||
|
||||
EINA_ITERATOR_FOREACH(aliases, tp)
|
||||
{
|
||||
|
@ -273,6 +276,7 @@ _usage(const char *progname)
|
|||
<< " -n, --namespace <ns> Wrap generated code in a namespace. [Eg: efl::ecore::file]" << std::endl
|
||||
<< " -r, --recurse Recurse input directories loading .eo files." << std::endl
|
||||
<< " -v, --version Print the version." << std::endl
|
||||
<< " -b, --beta Enable @beta methods." << std::endl
|
||||
<< " -h, --help Print this help." << std::endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
@ -302,9 +306,10 @@ opts_get(int argc, char **argv)
|
|||
{ "vmaj", required_argument, 0, 'M' },
|
||||
{ "vmin", required_argument, 0, 'm' },
|
||||
{ "references", required_argument, 0, 'r'},
|
||||
{ "beta", no_argument, 0, 'b'},
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
const char* options = "I:D:o:c:M:m:ar:vh";
|
||||
const char* options = "I:D:o:c:M:m:ar:vhb";
|
||||
|
||||
int c, idx;
|
||||
while ( (c = getopt_long(argc, argv, options, long_options, &idx)) != -1)
|
||||
|
@ -356,6 +361,10 @@ opts_get(int argc, char **argv)
|
|||
_print_version();
|
||||
if (argc == 2) exit(EXIT_SUCCESS);
|
||||
}
|
||||
else if (c == 'b')
|
||||
{
|
||||
opts.want_beta = true;
|
||||
}
|
||||
}
|
||||
if (optind == argc-1)
|
||||
{
|
||||
|
|
|
@ -67,6 +67,11 @@ efl_mono_lib = library('eflcustomexportsmono',
|
|||
dependencies : [eo, eina]
|
||||
)
|
||||
|
||||
beta_option = []
|
||||
if (get_option('mono-beta'))
|
||||
beta_option = '-b'
|
||||
endif
|
||||
|
||||
mono_generator_target = []
|
||||
mono_files = []
|
||||
foreach lib : mono_sublibs
|
||||
|
@ -88,7 +93,7 @@ foreach lib : mono_sublibs
|
|||
mono_generator_target += custom_target('eolian_mono_gen_'+mono_gen_file.underscorify()+'',
|
||||
input : join_paths(subdir_file_location, mono_gen_file),
|
||||
output : [mono_gen_file + '.cs'],
|
||||
command : [eolian_mono_gen, '-I', meson.current_source_dir(), eolian_include_directories,
|
||||
command : [eolian_mono_gen, beta_option, '-I', meson.current_source_dir(), eolian_include_directories,
|
||||
'--dllimport', package_name,
|
||||
'-o', join_paths(meson.current_build_dir(), mono_gen_file + '.cs'),
|
||||
'@INPUT@'])
|
||||
|
@ -107,7 +112,7 @@ foreach mono_gen_file : legacy_evas_required_by_mono
|
|||
mono_generator_target += custom_target('eolian_mono_gen_'+mono_gen_file.underscorify()+'',
|
||||
input : join_paths(subdir_file_location, mono_gen_file),
|
||||
output : [mono_gen_file + '.cs'],
|
||||
command : [eolian_mono_gen, '-I', meson.current_source_dir(), eolian_include_directories,
|
||||
command : [eolian_mono_gen, beta_option, '-I', meson.current_source_dir(), eolian_include_directories,
|
||||
'--dllimport', 'evas',
|
||||
'-o', join_paths(meson.current_build_dir(), mono_gen_file + '.cs'),
|
||||
'@INPUT@'])
|
||||
|
|
Loading…
Reference in New Issue