2019-10-24 06:01:50 -07:00
|
|
|
/*
|
|
|
|
* Copyright 2019 by its authors. See AUTHORS.
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
2017-11-23 16:50:16 -08:00
|
|
|
#ifndef EOLIAN_MONO_TYPE_IMPL_HH
|
|
|
|
#define EOLIAN_MONO_TYPE_IMPL_HH
|
|
|
|
|
|
|
|
#include "grammar/generator.hpp"
|
|
|
|
#include "grammar/klass_def.hpp"
|
|
|
|
#include "grammar/case.hpp"
|
2018-04-16 17:44:27 -07:00
|
|
|
#include "name_helpers.hh"
|
2017-11-23 16:50:16 -08:00
|
|
|
|
|
|
|
namespace eolian_mono {
|
|
|
|
|
|
|
|
namespace eina = efl::eina;
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
T const* as_const_pointer(T* p) { return p; }
|
|
|
|
|
2017-12-12 06:06:46 -08:00
|
|
|
inline
|
2017-11-23 16:50:16 -08:00
|
|
|
attributes::regular_type_def replace_base_type(attributes::regular_type_def v, std::string name)
|
|
|
|
{
|
|
|
|
v.base_type = name;
|
|
|
|
return v;
|
|
|
|
}
|
|
|
|
|
2017-12-12 06:06:46 -08:00
|
|
|
template <typename T>
|
|
|
|
attributes::regular_type_def replace_base_integer(attributes::regular_type_def v)
|
|
|
|
{
|
|
|
|
bool s = std::is_signed<T>::value;
|
|
|
|
switch (sizeof(T))
|
|
|
|
{
|
2019-03-26 10:45:18 -07:00
|
|
|
case 1: return s ? replace_base_type(v, "sbyte") : replace_base_type(v, "byte");
|
|
|
|
case 2: return s ? replace_base_type(v, "short") : replace_base_type(v, "ushort");
|
|
|
|
case 4: return s ? replace_base_type(v, "int") : replace_base_type(v, "uint");
|
|
|
|
case 8: return s ? replace_base_type(v, "long") : replace_base_type(v, "ulong");
|
2017-12-12 06:06:46 -08:00
|
|
|
default: return v;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-01 11:03:02 -08:00
|
|
|
template <typename T>
|
|
|
|
attributes::regular_type_def replace_base_opt_integer(attributes::regular_type_def v)
|
|
|
|
{
|
|
|
|
bool s = std::is_signed<T>::value;
|
|
|
|
switch (sizeof(T))
|
|
|
|
{
|
2019-03-26 10:45:18 -07:00
|
|
|
case 1: return s ? replace_base_type(v, "sbyte?") : replace_base_type(v, "byte?");
|
|
|
|
case 2: return s ? replace_base_type(v, "short?") : replace_base_type(v, "ushort?");
|
|
|
|
case 4: return s ? replace_base_type(v, "int?") : replace_base_type(v, "uint?");
|
|
|
|
case 8: return s ? replace_base_type(v, "long?") : replace_base_type(v, "ulong?");
|
2019-02-01 11:03:02 -08:00
|
|
|
default: return v;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-12 06:06:46 -08:00
|
|
|
inline
|
2017-11-23 16:50:16 -08:00
|
|
|
attributes::complex_type_def replace_outer(attributes::complex_type_def v, attributes::regular_type_def const& regular)
|
|
|
|
{
|
|
|
|
v.outer = regular;
|
|
|
|
return v;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename Array, typename F, int N, typename A>
|
|
|
|
eina::optional<bool> call_match(Array const (&array)[N], F f, A a)
|
|
|
|
{
|
|
|
|
typedef Array const* iterator_type;
|
|
|
|
iterator_type match_iterator = &array[0], match_last = match_iterator + N;
|
|
|
|
match_iterator = std::find_if(match_iterator, match_last, f);
|
|
|
|
if(match_iterator != match_last)
|
|
|
|
{
|
|
|
|
return a(match_iterator->function());
|
|
|
|
}
|
|
|
|
return {nullptr};
|
|
|
|
}
|
2019-03-26 10:45:18 -07:00
|
|
|
|
|
|
|
template <typename OutputIterator, typename Context>
|
|
|
|
struct visitor_regular_type_def_printer
|
|
|
|
{
|
|
|
|
typedef visitor_regular_type_def_printer visitor_type;
|
|
|
|
typedef bool result_type;
|
|
|
|
|
|
|
|
mutable OutputIterator sink;
|
|
|
|
Context const* context;
|
|
|
|
|
|
|
|
bool operator()(grammar::attributes::regular_type_def const ®ular) const
|
|
|
|
{
|
|
|
|
return as_generator(string).generate(sink, name_helpers::type_full_managed_name(regular), *context);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
bool operator()(T const&) const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-11-23 16:50:16 -08:00
|
|
|
template <typename OutputIterator, typename Context>
|
|
|
|
struct visitor_generate
|
|
|
|
{
|
|
|
|
mutable OutputIterator sink;
|
|
|
|
Context const* context;
|
|
|
|
std::string c_type;
|
|
|
|
bool is_out;
|
|
|
|
bool is_return;
|
2017-12-15 16:15:00 -08:00
|
|
|
bool is_ptr;
|
2019-02-01 11:03:02 -08:00
|
|
|
mutable bool is_optional;
|
2019-06-28 06:40:52 -07:00
|
|
|
bool is_special_subtype;
|
2017-11-23 16:50:16 -08:00
|
|
|
|
|
|
|
typedef visitor_generate<OutputIterator, Context> visitor_type;
|
|
|
|
typedef bool result_type;
|
|
|
|
|
|
|
|
bool operator()(attributes::regular_type_def const& regular) const
|
|
|
|
{
|
|
|
|
using attributes::regular_type_def;
|
|
|
|
struct match
|
|
|
|
{
|
|
|
|
eina::optional<std::string> name;
|
|
|
|
eina::optional<bool> has_own;
|
|
|
|
std::function<attributes::type_def::variant_type()> function;
|
|
|
|
}
|
2019-02-01 11:03:02 -08:00
|
|
|
const optional_match_table[] =
|
|
|
|
{
|
|
|
|
// signed primitives
|
2019-03-26 10:45:18 -07:00
|
|
|
{"byte", nullptr, [&] { return replace_base_type(regular, "sbyte?"); }}
|
|
|
|
, {"float", nullptr, [&] { return replace_base_type(regular, "float?"); }}
|
|
|
|
, {"double", nullptr, [&] { return replace_base_type(regular, "double?"); }}
|
|
|
|
, {"bool", nullptr, [&] { return replace_base_type(regular, "bool?"); }}
|
2019-02-01 11:03:02 -08:00
|
|
|
, {"short", nullptr, [&] { return replace_base_opt_integer<short>(regular); }}
|
|
|
|
, {"int", nullptr, [&] { return replace_base_opt_integer<int>(regular); }}
|
|
|
|
, {"long", nullptr, [&] { return replace_base_opt_integer<long>(regular); }}
|
|
|
|
, {"llong", nullptr, [&] { return replace_base_opt_integer<long long>(regular); }}
|
2019-03-26 10:45:18 -07:00
|
|
|
, {"int8", nullptr, [&] { return replace_base_type(regular, "sbyte?"); }}
|
|
|
|
, {"int16", nullptr, [&] { return replace_base_type(regular, "short?"); }}
|
|
|
|
, {"int32", nullptr, [&] { return replace_base_type(regular, "int?"); }}
|
|
|
|
, {"int64", nullptr, [&] { return replace_base_type(regular, "long?"); }}
|
2019-02-01 11:03:02 -08:00
|
|
|
, {"ssize", nullptr, [&] { return replace_base_opt_integer<ssize_t>(regular); }}
|
|
|
|
// unsigned primitives
|
2019-03-26 10:45:18 -07:00
|
|
|
, {"ubyte", nullptr, [&] { return replace_base_type(regular, "byte?"); }}
|
2019-02-01 11:03:02 -08:00
|
|
|
, {"ushort", nullptr, [&] { return replace_base_opt_integer<unsigned short>(regular); }}
|
|
|
|
, {"uint", nullptr, [&] { return replace_base_opt_integer<unsigned int>(regular); }}
|
|
|
|
, {"ulong", nullptr, [&] { return replace_base_opt_integer<unsigned long>(regular); }}
|
|
|
|
, {"ullong", nullptr, [&] { return replace_base_opt_integer<unsigned long long>(regular); }}
|
2019-03-26 10:45:18 -07:00
|
|
|
, {"uint8", nullptr, [&] { return replace_base_type(regular, "byte?"); }}
|
|
|
|
, {"uint16", nullptr, [&] { return replace_base_type(regular, "ushort?"); }}
|
|
|
|
, {"uint32", nullptr, [&] { return replace_base_type(regular, "uint?"); }}
|
|
|
|
, {"uint64", nullptr, [&] { return replace_base_type(regular, "ulong?"); }}
|
2019-02-01 11:03:02 -08:00
|
|
|
, {"size", nullptr, [&] { return replace_base_opt_integer<size_t>(regular); }}
|
|
|
|
|
|
|
|
, {"ptrdiff", nullptr, [&] { return replace_base_opt_integer<ptrdiff_t>(regular); }}
|
2019-03-26 10:45:18 -07:00
|
|
|
, {"intptr", nullptr, [&] { return replace_base_type(regular, "System.IntPtr?"); }}
|
|
|
|
, {"uintptr", nullptr, [&] { return replace_base_type(regular, "System.IntPtr?"); }}
|
|
|
|
, {"void_ptr", nullptr, [&] { return replace_base_type(regular, "System.IntPtr?"); }}
|
2019-02-01 11:03:02 -08:00
|
|
|
};
|
|
|
|
struct match
|
2017-11-23 16:50:16 -08:00
|
|
|
const match_table[] =
|
|
|
|
{
|
|
|
|
// signed primitives
|
2019-03-26 10:45:18 -07:00
|
|
|
{"byte", nullptr, [&] { return replace_base_type(regular, "sbyte"); }}
|
2017-12-12 06:06:46 -08:00
|
|
|
, {"short", nullptr, [&] { return replace_base_integer<short>(regular); }}
|
|
|
|
, {"int", nullptr, [&] { return replace_base_integer<int>(regular); }}
|
|
|
|
, {"long", nullptr, [&] { return replace_base_integer<long>(regular); }}
|
|
|
|
, {"llong", nullptr, [&] { return replace_base_integer<long long>(regular); }}
|
2019-03-26 10:45:18 -07:00
|
|
|
, {"int8", nullptr, [&] { return replace_base_type(regular, "sbyte"); }}
|
|
|
|
, {"int16", nullptr, [&] { return replace_base_type(regular, "short"); }}
|
|
|
|
, {"int32", nullptr, [&] { return replace_base_type(regular, "int"); }}
|
|
|
|
, {"int64", nullptr, [&] { return replace_base_type(regular, "long"); }}
|
2017-12-12 06:06:46 -08:00
|
|
|
, {"ssize", nullptr, [&] { return replace_base_integer<ssize_t>(regular); }}
|
2017-11-23 16:50:16 -08:00
|
|
|
// unsigned primitives
|
2019-03-26 10:45:18 -07:00
|
|
|
, {"ubyte", nullptr, [&] { return replace_base_type(regular, "byte"); }}
|
2017-12-12 06:06:46 -08:00
|
|
|
, {"ushort", nullptr, [&] { return replace_base_integer<unsigned short>(regular); }}
|
|
|
|
, {"uint", nullptr, [&] { return replace_base_integer<unsigned int>(regular); }}
|
|
|
|
, {"ulong", nullptr, [&] { return replace_base_integer<unsigned long>(regular); }}
|
|
|
|
, {"ullong", nullptr, [&] { return replace_base_integer<unsigned long long>(regular); }}
|
2019-03-26 10:45:18 -07:00
|
|
|
, {"uint8", nullptr, [&] { return replace_base_type(regular, "byte"); }}
|
|
|
|
, {"uint16", nullptr, [&] { return replace_base_type(regular, "ushort"); }}
|
|
|
|
, {"uint32", nullptr, [&] { return replace_base_type(regular, "uint"); }}
|
|
|
|
, {"uint64", nullptr, [&] { return replace_base_type(regular, "ulong"); }}
|
2017-12-12 06:06:46 -08:00
|
|
|
, {"size", nullptr, [&] { return replace_base_integer<size_t>(regular); }}
|
2017-11-23 16:50:16 -08:00
|
|
|
|
2017-12-12 06:06:46 -08:00
|
|
|
, {"ptrdiff", nullptr, [&] { return replace_base_integer<ptrdiff_t>(regular); }}
|
2019-03-26 10:45:18 -07:00
|
|
|
, {"intptr", nullptr, [&] { return replace_base_type(regular, "System.IntPtr"); }}
|
|
|
|
, {"uintptr", nullptr, [&] { return replace_base_type(regular, "System.IntPtr"); }}
|
|
|
|
, {"void_ptr", nullptr, [&] { return replace_base_type(regular, "System.IntPtr"); }}
|
2017-11-23 16:50:16 -08:00
|
|
|
, {"void", nullptr, [&]
|
|
|
|
{
|
|
|
|
regular_type_def r = regular;
|
|
|
|
r.namespaces.clear();
|
|
|
|
if (is_out) // @inout too
|
2019-03-26 10:45:18 -07:00
|
|
|
r.base_type = "System.IntPtr";
|
2017-11-23 16:50:16 -08:00
|
|
|
else
|
2019-03-26 10:45:18 -07:00
|
|
|
r.base_type = "void";
|
2017-11-23 16:50:16 -08:00
|
|
|
return r;
|
|
|
|
}}
|
2018-04-18 19:07:22 -07:00
|
|
|
, {"Eina.Error", nullptr, [&] // Eina.Error
|
2017-11-23 16:50:16 -08:00
|
|
|
{
|
2019-03-26 10:45:18 -07:00
|
|
|
return regular_type_def{"Eina.Error", regular.base_qualifier, {}};
|
2017-11-23 16:50:16 -08:00
|
|
|
}} // TODO
|
|
|
|
, {"string", nullptr, [&]
|
|
|
|
{
|
|
|
|
regular_type_def r = regular;
|
|
|
|
r.base_qualifier.qualifier ^= qualifier_info::is_ref;
|
2019-03-26 10:45:18 -07:00
|
|
|
return replace_base_type(r, "System.String");
|
2017-11-23 16:50:16 -08:00
|
|
|
}}
|
|
|
|
, {"mstring", nullptr, [&]
|
|
|
|
{
|
|
|
|
regular_type_def r = regular;
|
|
|
|
r.base_qualifier.qualifier ^= qualifier_info::is_ref;
|
2019-03-26 10:45:18 -07:00
|
|
|
return replace_base_type(r, "System.String");
|
2017-11-23 16:50:16 -08:00
|
|
|
}}
|
|
|
|
, {"stringshare", nullptr, [&]
|
|
|
|
{
|
|
|
|
regular_type_def r = regular;
|
|
|
|
r.base_qualifier.qualifier ^= qualifier_info::is_ref;
|
2019-06-28 06:40:52 -07:00
|
|
|
if (is_special_subtype)
|
|
|
|
return replace_base_type(r, "Eina.Stringshare");
|
2019-03-26 10:45:18 -07:00
|
|
|
return replace_base_type(r, "System.String");
|
2017-11-23 16:50:16 -08:00
|
|
|
}}
|
2018-01-26 12:01:03 -08:00
|
|
|
, {"strbuf", nullptr, [&]
|
|
|
|
{
|
2019-03-26 10:45:18 -07:00
|
|
|
return regular_type_def{"Eina.Strbuf", regular.base_qualifier, {}};
|
2018-01-26 12:01:03 -08:00
|
|
|
}}
|
2019-07-23 05:09:23 -07:00
|
|
|
, {"binbuf", nullptr, [&]
|
|
|
|
{
|
|
|
|
return regular_type_def{"Eina.Binbuf", regular.base_qualifier, {}};
|
|
|
|
}}
|
|
|
|
, {"event", nullptr, [&]
|
|
|
|
{
|
|
|
|
return regular_type_def{"Efl.Event", regular.base_qualifier, {}};
|
|
|
|
}}
|
2017-11-23 16:50:16 -08:00
|
|
|
, {"any_value", true, [&]
|
2019-03-26 10:45:18 -07:00
|
|
|
{ return regular_type_def{"Eina.Value", regular.base_qualifier, {}};
|
2017-11-23 16:50:16 -08:00
|
|
|
}}
|
|
|
|
, {"any_value", false, [&]
|
2019-03-26 10:45:18 -07:00
|
|
|
{ return regular_type_def{"Eina.Value", regular.base_qualifier, {}};
|
2017-11-23 16:50:16 -08:00
|
|
|
}}
|
2019-09-20 09:02:07 -07:00
|
|
|
, {"any_value_ref", nullptr, [&]
|
2019-03-26 10:45:18 -07:00
|
|
|
{ return regular_type_def{"Eina.Value", regular.base_qualifier, {}};
|
2019-09-20 09:02:07 -07:00
|
|
|
}} // FIXME add proper support for any_value_ref
|
2017-11-23 16:50:16 -08:00
|
|
|
};
|
2018-04-27 14:08:25 -07:00
|
|
|
std::string full_type_name = name_helpers::type_full_eolian_name(regular);
|
2017-11-23 16:50:16 -08:00
|
|
|
if(eina::optional<bool> b = call_match
|
2019-02-01 11:03:02 -08:00
|
|
|
(optional_match_table
|
|
|
|
, [&] (match const& m)
|
|
|
|
{
|
|
|
|
return is_optional
|
|
|
|
&& (!m.name || *m.name == regular.base_type || *m.name == full_type_name)
|
|
|
|
&& (!m.has_own || *m.has_own == (bool)(regular.base_qualifier & qualifier_info::is_own))
|
|
|
|
;
|
|
|
|
}
|
|
|
|
, [&] (attributes::type_def::variant_type const& v)
|
|
|
|
{
|
|
|
|
return v.visit(*this); // we want to keep is_out info
|
|
|
|
}))
|
|
|
|
{
|
|
|
|
return *b;
|
|
|
|
}
|
|
|
|
else if (is_optional && (regular.is_struct() || regular.is_enum() || regular.is_struct_opaque()))
|
|
|
|
{
|
|
|
|
attributes::regular_type_def r = regular;
|
|
|
|
r.base_type.push_back('?');
|
|
|
|
is_optional = false;
|
|
|
|
return (*this)(r);
|
|
|
|
}
|
|
|
|
else if(eina::optional<bool> b = call_match
|
2017-11-23 16:50:16 -08:00
|
|
|
(match_table
|
|
|
|
, [&] (match const& m)
|
|
|
|
{
|
2018-04-18 19:07:22 -07:00
|
|
|
return (!m.name || *m.name == regular.base_type || *m.name == full_type_name)
|
2017-11-23 16:50:16 -08:00
|
|
|
&& (!m.has_own || *m.has_own == (bool)(regular.base_qualifier & qualifier_info::is_own))
|
|
|
|
;
|
|
|
|
}
|
|
|
|
, [&] (attributes::type_def::variant_type const& v)
|
|
|
|
{
|
2019-03-26 10:45:18 -07:00
|
|
|
return v.visit(visitor_regular_type_def_printer<OutputIterator, Context>{sink, context}); // we want to keep is_out info
|
2017-11-23 16:50:16 -08:00
|
|
|
}))
|
|
|
|
{
|
|
|
|
return *b;
|
|
|
|
}
|
|
|
|
// in A @optional -> optional<A>
|
|
|
|
// in A& @optional -> optional<A&>
|
|
|
|
// in A& @optional -> optional<A&>
|
|
|
|
// in own(A&) @optional -> A*
|
|
|
|
//
|
|
|
|
// out A @optional -> optional<A&>
|
|
|
|
// out A& @optional -> optional<A&>
|
|
|
|
// out own(A&) @optional -> optional<A*&>
|
|
|
|
// else if(regular.base_qualifier & qualifier_info::is_optional)
|
|
|
|
// {
|
|
|
|
// attributes::regular_type_def no_optional_regular = regular;
|
|
|
|
// no_optional_regular.base_qualifier.qualifier ^= qualifier_info::is_optional;
|
|
|
|
// if(is_out)
|
|
|
|
// {
|
|
|
|
// if(no_optional_regular.base_qualifier & qualifier_info::is_own)
|
|
|
|
// {
|
|
|
|
// return as_generator(" ::efl::eina::optional<").generate(sink, attributes::unused, *context)
|
|
|
|
// && (*this)(no_optional_regular)
|
|
|
|
// && as_generator("&>").generate(sink, attributes::unused, *context);
|
|
|
|
// }
|
|
|
|
// else if(no_optional_regular.base_qualifier & qualifier_info::is_ref)
|
|
|
|
// {
|
|
|
|
// no_optional_regular.base_qualifier.qualifier ^= qualifier_info::is_ref;
|
|
|
|
// return (*this)(no_optional_regular)
|
|
|
|
// && as_generator("**").generate(sink, attributes::unused, *context);
|
|
|
|
// }
|
|
|
|
// else
|
|
|
|
// return (*this)(no_optional_regular)
|
|
|
|
// && as_generator("*").generate(sink, attributes::unused, *context);
|
|
|
|
// }
|
|
|
|
// else
|
|
|
|
// {
|
|
|
|
// // regular.base_qualifier & qualifier_info::is_ref
|
|
|
|
// return as_generator(" ::efl::eina::optional<").generate(sink, attributes::unused, *context)
|
|
|
|
// && (*this)(no_optional_regular)
|
|
|
|
// && as_generator(">").generate(sink, attributes::unused, *context);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// else if((is_return || is_out) && regular.base_qualifier & qualifier_info::is_ref
|
|
|
|
// && regular.base_qualifier & qualifier_info::is_own)
|
|
|
|
// {
|
|
|
|
// if(as_generator
|
|
|
|
// (
|
|
|
|
// " ::std::unique_ptr<"
|
|
|
|
// << *(string << "_")
|
|
|
|
// << string
|
|
|
|
// << (regular.base_qualifier & qualifier_info::is_const ? " const" : "")
|
|
|
|
// << ", ::efl::eina::malloc_deleter>"
|
|
|
|
// )
|
|
|
|
// .generate(sink, std::make_tuple(regular.namespaces, regular.base_type), *context))
|
|
|
|
// return true;
|
|
|
|
// else
|
|
|
|
// return false;
|
|
|
|
// }
|
2018-03-02 14:58:20 -08:00
|
|
|
// else if(Eolian_Typedecl const* typedecl = eolian_state_struct_by_name_get(c_type.c_str()))
|
2017-11-23 16:50:16 -08:00
|
|
|
// {
|
|
|
|
// return as_generator
|
|
|
|
// (
|
|
|
|
// *(string << ".")
|
|
|
|
// << string
|
|
|
|
// )
|
|
|
|
// .generate(sink, std::make_tuple(regular.namespaces, regular.base_type), *context);
|
|
|
|
// }
|
|
|
|
else
|
|
|
|
{
|
2018-04-27 14:08:25 -07:00
|
|
|
return as_generator(string).generate(sink, name_helpers::type_full_managed_name(regular), *context);
|
2017-11-23 16:50:16 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
bool operator()(attributes::klass_name klass) const
|
|
|
|
{
|
2019-02-06 11:50:28 -08:00
|
|
|
// Efl.Class is manually handled in a custom marshall to be represented by a System.Type.
|
|
|
|
if (name_helpers::klass_full_concrete_name(klass) == "Efl.Class")
|
|
|
|
return as_generator(lit("Type")).generate(sink, attributes::unused, *context);
|
csharp: Change to new class API.
Summary:
As discussed in T7204:
- Eo Interfaces/mixins -> C# Interfaces with concrete class
implementations
- Eo Regular/Abstracts -> Proper C# classes
- Added some new generators and helper methods.
- Refactored the class generator, splitting into helper methods
Eo handles now are stored only in the "root" class in any given
inheritance tree (generally, Efl.Object), and accessible to each child.
Methods also are defined in a single place instead of repeatedly
generated in everyfile, reducing the size of the generated .dll from
30MB to around 4.5MB.
Mixins are generated as C# interfaces but any regular class it inherits
from is lost, as we can't have interfaces inheriting from regular
classes. This will be dealt with in a later commit.
Summary of API Changes:
- Merged Inherit/Concrete classes. (These suffixes disappear from
regular classes).
- Interface still have implementations with 'Concrete' suffix for when
they are returned from methods.
- Removed 'I' from interface names.
- Removed interfaces for regular/abstract Eo classes.
- Concrete classes for interfaces/mixins hold the event argument struct.
- Removed '_' from classes, enums, structs, etc, as indicated in C#
naming conventions.
- Namespaces are now Camel.Cased.
- Renamed IWrapper's raw_handle/raw_klass to NativeHandle/NativeClass
Also renamed the test classes as after the namespace change, the
test namespace Test can conflict with the helper Test namespace.
(And use more meaningful names than Test.Testing...)
Also Fixes T7336 by removing a deprecated example and adding
efl_loop_timer_example to build system.
Fixes T7451 by hiding the class_get DllImports and renaming the IWrapper
fields. The native handlers are used in the manual binding.
Still need to work:
- As there are still some events names clashing (e.g. Efl.Ui.Bg with "resize"
from Efl.Gfx.Entity and Efl.Gfx.Image), Events are currently declared on
the interface and implemented "namespaced" in the classes,
requiring the cast to the interface to access the event.
- The Mixin Conundrum. Mixin inheritance will be dealt in a future
commit.
Depends on D7260
Reviewers: segfaultxavi, vitor.sousa, felipealmeida, Jaehyun_Cho
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Maniphest Tasks: T7451, T7336
Differential Revision: https://phab.enlightenment.org/D7262
2018-11-29 15:04:37 -08:00
|
|
|
if(klass.type == attributes::class_type::regular || klass.type == attributes::class_type::abstract_)
|
|
|
|
return as_generator(string).generate(sink, name_helpers::klass_full_concrete_name(klass), *context);
|
|
|
|
else
|
|
|
|
return as_generator(string).generate(sink, name_helpers::klass_full_interface_name(klass), *context);
|
2017-11-23 16:50:16 -08:00
|
|
|
}
|
|
|
|
bool operator()(attributes::complex_type_def const& complex) const
|
|
|
|
{
|
|
|
|
using attributes::regular_type_def;
|
|
|
|
using attributes::complex_type_def;
|
|
|
|
using attributes::qualifier_info;
|
|
|
|
struct match
|
|
|
|
{
|
|
|
|
eina::optional<std::string> name;
|
|
|
|
eina::optional<bool> has_own;
|
|
|
|
eina::optional<bool> is_const;
|
|
|
|
std::function<attributes::type_def::variant_type()> function;
|
|
|
|
} const matches[] =
|
|
|
|
{
|
|
|
|
{"list", nullptr, nullptr, [&]
|
|
|
|
{
|
|
|
|
complex_type_def c = complex;
|
csharp: Change to new class API.
Summary:
As discussed in T7204:
- Eo Interfaces/mixins -> C# Interfaces with concrete class
implementations
- Eo Regular/Abstracts -> Proper C# classes
- Added some new generators and helper methods.
- Refactored the class generator, splitting into helper methods
Eo handles now are stored only in the "root" class in any given
inheritance tree (generally, Efl.Object), and accessible to each child.
Methods also are defined in a single place instead of repeatedly
generated in everyfile, reducing the size of the generated .dll from
30MB to around 4.5MB.
Mixins are generated as C# interfaces but any regular class it inherits
from is lost, as we can't have interfaces inheriting from regular
classes. This will be dealt with in a later commit.
Summary of API Changes:
- Merged Inherit/Concrete classes. (These suffixes disappear from
regular classes).
- Interface still have implementations with 'Concrete' suffix for when
they are returned from methods.
- Removed 'I' from interface names.
- Removed interfaces for regular/abstract Eo classes.
- Concrete classes for interfaces/mixins hold the event argument struct.
- Removed '_' from classes, enums, structs, etc, as indicated in C#
naming conventions.
- Namespaces are now Camel.Cased.
- Renamed IWrapper's raw_handle/raw_klass to NativeHandle/NativeClass
Also renamed the test classes as after the namespace change, the
test namespace Test can conflict with the helper Test namespace.
(And use more meaningful names than Test.Testing...)
Also Fixes T7336 by removing a deprecated example and adding
efl_loop_timer_example to build system.
Fixes T7451 by hiding the class_get DllImports and renaming the IWrapper
fields. The native handlers are used in the manual binding.
Still need to work:
- As there are still some events names clashing (e.g. Efl.Ui.Bg with "resize"
from Efl.Gfx.Entity and Efl.Gfx.Image), Events are currently declared on
the interface and implemented "namespaced" in the classes,
requiring the cast to the interface to access the event.
- The Mixin Conundrum. Mixin inheritance will be dealt in a future
commit.
Depends on D7260
Reviewers: segfaultxavi, vitor.sousa, felipealmeida, Jaehyun_Cho
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Maniphest Tasks: T7451, T7336
Differential Revision: https://phab.enlightenment.org/D7262
2018-11-29 15:04:37 -08:00
|
|
|
c.outer.base_type = "Eina.List";
|
2017-11-23 16:50:16 -08:00
|
|
|
return c;
|
|
|
|
}}
|
|
|
|
, {"array", nullptr, nullptr, [&]
|
|
|
|
{
|
|
|
|
complex_type_def c = complex;
|
csharp: Change to new class API.
Summary:
As discussed in T7204:
- Eo Interfaces/mixins -> C# Interfaces with concrete class
implementations
- Eo Regular/Abstracts -> Proper C# classes
- Added some new generators and helper methods.
- Refactored the class generator, splitting into helper methods
Eo handles now are stored only in the "root" class in any given
inheritance tree (generally, Efl.Object), and accessible to each child.
Methods also are defined in a single place instead of repeatedly
generated in everyfile, reducing the size of the generated .dll from
30MB to around 4.5MB.
Mixins are generated as C# interfaces but any regular class it inherits
from is lost, as we can't have interfaces inheriting from regular
classes. This will be dealt with in a later commit.
Summary of API Changes:
- Merged Inherit/Concrete classes. (These suffixes disappear from
regular classes).
- Interface still have implementations with 'Concrete' suffix for when
they are returned from methods.
- Removed 'I' from interface names.
- Removed interfaces for regular/abstract Eo classes.
- Concrete classes for interfaces/mixins hold the event argument struct.
- Removed '_' from classes, enums, structs, etc, as indicated in C#
naming conventions.
- Namespaces are now Camel.Cased.
- Renamed IWrapper's raw_handle/raw_klass to NativeHandle/NativeClass
Also renamed the test classes as after the namespace change, the
test namespace Test can conflict with the helper Test namespace.
(And use more meaningful names than Test.Testing...)
Also Fixes T7336 by removing a deprecated example and adding
efl_loop_timer_example to build system.
Fixes T7451 by hiding the class_get DllImports and renaming the IWrapper
fields. The native handlers are used in the manual binding.
Still need to work:
- As there are still some events names clashing (e.g. Efl.Ui.Bg with "resize"
from Efl.Gfx.Entity and Efl.Gfx.Image), Events are currently declared on
the interface and implemented "namespaced" in the classes,
requiring the cast to the interface to access the event.
- The Mixin Conundrum. Mixin inheritance will be dealt in a future
commit.
Depends on D7260
Reviewers: segfaultxavi, vitor.sousa, felipealmeida, Jaehyun_Cho
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Maniphest Tasks: T7451, T7336
Differential Revision: https://phab.enlightenment.org/D7262
2018-11-29 15:04:37 -08:00
|
|
|
c.outer.base_type = "Eina.Array";
|
2017-11-23 16:50:16 -08:00
|
|
|
return c;
|
|
|
|
}}
|
|
|
|
, {"hash", nullptr, nullptr
|
|
|
|
, [&]
|
|
|
|
{
|
|
|
|
complex_type_def c = complex;
|
csharp: Change to new class API.
Summary:
As discussed in T7204:
- Eo Interfaces/mixins -> C# Interfaces with concrete class
implementations
- Eo Regular/Abstracts -> Proper C# classes
- Added some new generators and helper methods.
- Refactored the class generator, splitting into helper methods
Eo handles now are stored only in the "root" class in any given
inheritance tree (generally, Efl.Object), and accessible to each child.
Methods also are defined in a single place instead of repeatedly
generated in everyfile, reducing the size of the generated .dll from
30MB to around 4.5MB.
Mixins are generated as C# interfaces but any regular class it inherits
from is lost, as we can't have interfaces inheriting from regular
classes. This will be dealt with in a later commit.
Summary of API Changes:
- Merged Inherit/Concrete classes. (These suffixes disappear from
regular classes).
- Interface still have implementations with 'Concrete' suffix for when
they are returned from methods.
- Removed 'I' from interface names.
- Removed interfaces for regular/abstract Eo classes.
- Concrete classes for interfaces/mixins hold the event argument struct.
- Removed '_' from classes, enums, structs, etc, as indicated in C#
naming conventions.
- Namespaces are now Camel.Cased.
- Renamed IWrapper's raw_handle/raw_klass to NativeHandle/NativeClass
Also renamed the test classes as after the namespace change, the
test namespace Test can conflict with the helper Test namespace.
(And use more meaningful names than Test.Testing...)
Also Fixes T7336 by removing a deprecated example and adding
efl_loop_timer_example to build system.
Fixes T7451 by hiding the class_get DllImports and renaming the IWrapper
fields. The native handlers are used in the manual binding.
Still need to work:
- As there are still some events names clashing (e.g. Efl.Ui.Bg with "resize"
from Efl.Gfx.Entity and Efl.Gfx.Image), Events are currently declared on
the interface and implemented "namespaced" in the classes,
requiring the cast to the interface to access the event.
- The Mixin Conundrum. Mixin inheritance will be dealt in a future
commit.
Depends on D7260
Reviewers: segfaultxavi, vitor.sousa, felipealmeida, Jaehyun_Cho
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Maniphest Tasks: T7451, T7336
Differential Revision: https://phab.enlightenment.org/D7262
2018-11-29 15:04:37 -08:00
|
|
|
c.outer.base_type = "Eina.Hash";
|
2017-11-23 16:50:16 -08:00
|
|
|
return c;
|
2018-05-07 15:22:59 -07:00
|
|
|
}}
|
2017-11-23 16:50:16 -08:00
|
|
|
, {"future", nullptr, nullptr, [&]
|
|
|
|
{
|
csharp: Change to new class API.
Summary:
As discussed in T7204:
- Eo Interfaces/mixins -> C# Interfaces with concrete class
implementations
- Eo Regular/Abstracts -> Proper C# classes
- Added some new generators and helper methods.
- Refactored the class generator, splitting into helper methods
Eo handles now are stored only in the "root" class in any given
inheritance tree (generally, Efl.Object), and accessible to each child.
Methods also are defined in a single place instead of repeatedly
generated in everyfile, reducing the size of the generated .dll from
30MB to around 4.5MB.
Mixins are generated as C# interfaces but any regular class it inherits
from is lost, as we can't have interfaces inheriting from regular
classes. This will be dealt with in a later commit.
Summary of API Changes:
- Merged Inherit/Concrete classes. (These suffixes disappear from
regular classes).
- Interface still have implementations with 'Concrete' suffix for when
they are returned from methods.
- Removed 'I' from interface names.
- Removed interfaces for regular/abstract Eo classes.
- Concrete classes for interfaces/mixins hold the event argument struct.
- Removed '_' from classes, enums, structs, etc, as indicated in C#
naming conventions.
- Namespaces are now Camel.Cased.
- Renamed IWrapper's raw_handle/raw_klass to NativeHandle/NativeClass
Also renamed the test classes as after the namespace change, the
test namespace Test can conflict with the helper Test namespace.
(And use more meaningful names than Test.Testing...)
Also Fixes T7336 by removing a deprecated example and adding
efl_loop_timer_example to build system.
Fixes T7451 by hiding the class_get DllImports and renaming the IWrapper
fields. The native handlers are used in the manual binding.
Still need to work:
- As there are still some events names clashing (e.g. Efl.Ui.Bg with "resize"
from Efl.Gfx.Entity and Efl.Gfx.Image), Events are currently declared on
the interface and implemented "namespaced" in the classes,
requiring the cast to the interface to access the event.
- The Mixin Conundrum. Mixin inheritance will be dealt in a future
commit.
Depends on D7260
Reviewers: segfaultxavi, vitor.sousa, felipealmeida, Jaehyun_Cho
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Maniphest Tasks: T7451, T7336
Differential Revision: https://phab.enlightenment.org/D7262
2018-11-29 15:04:37 -08:00
|
|
|
(*this)(regular_type_def{" Eina.Future", complex.outer.base_qualifier, {}});
|
2017-11-23 16:50:16 -08:00
|
|
|
return attributes::type_def::variant_type();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
, {"iterator", nullptr, nullptr, [&]
|
|
|
|
{
|
|
|
|
complex_type_def c = complex;
|
csharp: Change to new class API.
Summary:
As discussed in T7204:
- Eo Interfaces/mixins -> C# Interfaces with concrete class
implementations
- Eo Regular/Abstracts -> Proper C# classes
- Added some new generators and helper methods.
- Refactored the class generator, splitting into helper methods
Eo handles now are stored only in the "root" class in any given
inheritance tree (generally, Efl.Object), and accessible to each child.
Methods also are defined in a single place instead of repeatedly
generated in everyfile, reducing the size of the generated .dll from
30MB to around 4.5MB.
Mixins are generated as C# interfaces but any regular class it inherits
from is lost, as we can't have interfaces inheriting from regular
classes. This will be dealt with in a later commit.
Summary of API Changes:
- Merged Inherit/Concrete classes. (These suffixes disappear from
regular classes).
- Interface still have implementations with 'Concrete' suffix for when
they are returned from methods.
- Removed 'I' from interface names.
- Removed interfaces for regular/abstract Eo classes.
- Concrete classes for interfaces/mixins hold the event argument struct.
- Removed '_' from classes, enums, structs, etc, as indicated in C#
naming conventions.
- Namespaces are now Camel.Cased.
- Renamed IWrapper's raw_handle/raw_klass to NativeHandle/NativeClass
Also renamed the test classes as after the namespace change, the
test namespace Test can conflict with the helper Test namespace.
(And use more meaningful names than Test.Testing...)
Also Fixes T7336 by removing a deprecated example and adding
efl_loop_timer_example to build system.
Fixes T7451 by hiding the class_get DllImports and renaming the IWrapper
fields. The native handlers are used in the manual binding.
Still need to work:
- As there are still some events names clashing (e.g. Efl.Ui.Bg with "resize"
from Efl.Gfx.Entity and Efl.Gfx.Image), Events are currently declared on
the interface and implemented "namespaced" in the classes,
requiring the cast to the interface to access the event.
- The Mixin Conundrum. Mixin inheritance will be dealt in a future
commit.
Depends on D7260
Reviewers: segfaultxavi, vitor.sousa, felipealmeida, Jaehyun_Cho
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Maniphest Tasks: T7451, T7336
Differential Revision: https://phab.enlightenment.org/D7262
2018-11-29 15:04:37 -08:00
|
|
|
c.outer.base_type = "Eina.Iterator";
|
2017-11-23 16:50:16 -08:00
|
|
|
return c;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
, {"accessor", nullptr, nullptr, [&]
|
|
|
|
{
|
2018-05-18 19:43:09 -07:00
|
|
|
complex_type_def c = complex;
|
csharp: Change to new class API.
Summary:
As discussed in T7204:
- Eo Interfaces/mixins -> C# Interfaces with concrete class
implementations
- Eo Regular/Abstracts -> Proper C# classes
- Added some new generators and helper methods.
- Refactored the class generator, splitting into helper methods
Eo handles now are stored only in the "root" class in any given
inheritance tree (generally, Efl.Object), and accessible to each child.
Methods also are defined in a single place instead of repeatedly
generated in everyfile, reducing the size of the generated .dll from
30MB to around 4.5MB.
Mixins are generated as C# interfaces but any regular class it inherits
from is lost, as we can't have interfaces inheriting from regular
classes. This will be dealt with in a later commit.
Summary of API Changes:
- Merged Inherit/Concrete classes. (These suffixes disappear from
regular classes).
- Interface still have implementations with 'Concrete' suffix for when
they are returned from methods.
- Removed 'I' from interface names.
- Removed interfaces for regular/abstract Eo classes.
- Concrete classes for interfaces/mixins hold the event argument struct.
- Removed '_' from classes, enums, structs, etc, as indicated in C#
naming conventions.
- Namespaces are now Camel.Cased.
- Renamed IWrapper's raw_handle/raw_klass to NativeHandle/NativeClass
Also renamed the test classes as after the namespace change, the
test namespace Test can conflict with the helper Test namespace.
(And use more meaningful names than Test.Testing...)
Also Fixes T7336 by removing a deprecated example and adding
efl_loop_timer_example to build system.
Fixes T7451 by hiding the class_get DllImports and renaming the IWrapper
fields. The native handlers are used in the manual binding.
Still need to work:
- As there are still some events names clashing (e.g. Efl.Ui.Bg with "resize"
from Efl.Gfx.Entity and Efl.Gfx.Image), Events are currently declared on
the interface and implemented "namespaced" in the classes,
requiring the cast to the interface to access the event.
- The Mixin Conundrum. Mixin inheritance will be dealt in a future
commit.
Depends on D7260
Reviewers: segfaultxavi, vitor.sousa, felipealmeida, Jaehyun_Cho
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Maniphest Tasks: T7451, T7336
Differential Revision: https://phab.enlightenment.org/D7262
2018-11-29 15:04:37 -08:00
|
|
|
c.outer.base_type = "Eina.Accessor";
|
2018-05-18 19:43:09 -07:00
|
|
|
return c;
|
2017-11-23 16:50:16 -08:00
|
|
|
}
|
|
|
|
}
|
2019-07-09 01:00:06 -07:00
|
|
|
, {"slice", nullptr, nullptr, [&]
|
|
|
|
{
|
|
|
|
return regular_type_def{" Eina.Slice", complex.outer.base_qualifier, {}};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
, {"rw_slice", nullptr, nullptr, [&]
|
|
|
|
{
|
|
|
|
return regular_type_def{" Eina.RwSlice", complex.outer.base_qualifier, {}};
|
|
|
|
}
|
|
|
|
}
|
2017-11-23 16:50:16 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
auto default_match = [&] (attributes::complex_type_def const& complex)
|
|
|
|
{
|
|
|
|
regular_type_def no_pointer_regular = complex.outer;
|
|
|
|
// std::vector<attributes::pointer_indirection> pointers;
|
|
|
|
// pointers.swap(no_pointer_regular.pointers);
|
|
|
|
// if(is_out)
|
|
|
|
// pointers.push_back({{attributes::qualifier_info::is_none, {}}, true});
|
2019-07-12 06:07:27 -07:00
|
|
|
return visitor_type{sink, context, c_type, false, false, false, false, false}(no_pointer_regular)
|
2019-06-28 06:40:52 -07:00
|
|
|
&& as_generator("<" << (type(false, false, true) % ", ") << ">").generate(sink, complex.subtypes, *context)
|
2017-11-23 16:50:16 -08:00
|
|
|
;
|
|
|
|
// && detail::generate_pointers(sink, pointers, *context, false);
|
|
|
|
};
|
|
|
|
|
|
|
|
if(eina::optional<bool> b = call_match
|
|
|
|
(matches
|
|
|
|
, [&] (match const& m)
|
|
|
|
{
|
|
|
|
return (!m.name || *m.name == complex.outer.base_type)
|
|
|
|
&& (!m.has_own || *m.has_own == bool(complex.outer.base_qualifier & qualifier_info::is_own))
|
|
|
|
&& (!m.is_const || *m.is_const == bool(complex.outer.base_qualifier & qualifier_info::is_const));
|
|
|
|
}
|
|
|
|
, [&] (attributes::type_def::variant_type const& v)
|
|
|
|
{
|
|
|
|
if(v.empty())
|
|
|
|
return true;
|
|
|
|
else if(attributes::complex_type_def const* complex
|
|
|
|
= eina::get<attributes::complex_type_def>(&v))
|
|
|
|
return default_match(*complex);
|
|
|
|
else
|
|
|
|
return v.visit(*this);
|
|
|
|
}))
|
|
|
|
return *b;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return default_match(complex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|