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_FUNCTION_DECLARATION_HH
|
|
|
|
#define EOLIAN_MONO_FUNCTION_DECLARATION_HH
|
|
|
|
|
|
|
|
#include "grammar/generator.hpp"
|
|
|
|
#include "grammar/klass_def.hpp"
|
|
|
|
|
|
|
|
#include "grammar/indentation.hpp"
|
|
|
|
#include "grammar/list.hpp"
|
|
|
|
#include "grammar/alternative.hpp"
|
|
|
|
#include "type.hh"
|
|
|
|
#include "parameter.hh"
|
2018-04-16 17:44:27 -07:00
|
|
|
#include "name_helpers.hh"
|
2017-11-23 16:50:16 -08:00
|
|
|
#include "using_decl.hh"
|
2018-04-16 12:26:13 -07:00
|
|
|
#include "blacklist.hh"
|
2017-11-23 16:50:16 -08:00
|
|
|
|
|
|
|
namespace eolian_mono {
|
|
|
|
|
|
|
|
struct function_declaration_generator
|
|
|
|
{
|
|
|
|
template <typename OutputIterator, typename Context>
|
|
|
|
bool generate(OutputIterator sink, attributes::function_def const& f, Context const& context) const
|
|
|
|
{
|
2019-01-17 04:43:57 -08:00
|
|
|
if(blacklist::is_function_blacklisted(f, context) || f.is_static)
|
2017-11-23 16:50:16 -08:00
|
|
|
return true;
|
2017-12-06 16:03:55 -08:00
|
|
|
|
csharp: Skip non-public members from interfaces
Summary:
Eolian allows non-public members in interfaces and mixins (usually
@protected). As both kinds are converted to C# interfaces, this
causes problem as non-public members are forbidden in C# interfaces.
This commit changes eolian_mono by removing those members from the C#
interfaces. If a generated class implements the interface, the method is
generated as if it were a protected member of the class directly.
For mixed properties like `Efl.Io.Reader.CanRead { get; set @protected; }`,
the interface has only the public getter and the the implementing class has both
the public getter and the protected setter.
With this, C# devs won't be able to directly implement protected Eo
methods from interfaces. (But this really does not make sense from the
C# point of view).
ref T7494
Reviewers: segfaultxavi, felipealmeida, YOhoho
Reviewed By: YOhoho
Subscribers: cedric, brunobelo, Jaehyun_Cho, #reviewers, woohyun, #committers
Tags: #efl
Maniphest Tasks: T7494
Differential Revision: https://phab.enlightenment.org/D9800
2019-09-10 15:30:46 -07:00
|
|
|
// C# interfaces can't have non-public members
|
|
|
|
if(f.scope != attributes::member_scope::scope_public)
|
|
|
|
return true;
|
|
|
|
|
2019-09-23 16:50:27 -07:00
|
|
|
if(!as_generator(documentation(1)).generate(sink, f, context))
|
2017-12-06 16:03:55 -08:00
|
|
|
return false;
|
|
|
|
|
|
|
|
return as_generator
|
2019-09-23 16:50:27 -07:00
|
|
|
(scope_tab << eolian_mono::type(true) << " " << string << "(" << (parameter % ", ") << ");\n\n")
|
2018-05-02 15:49:37 -07:00
|
|
|
.generate(sink, std::make_tuple(f.return_type, name_helpers::managed_method_name(f), f.parameters), context);
|
2017-11-23 16:50:16 -08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
function_declaration_generator const function_declaration = {};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace efl { namespace eolian { namespace grammar {
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct is_eager_generator< ::eolian_mono::function_declaration_generator> : std::true_type {};
|
|
|
|
template <>
|
|
|
|
struct is_generator< ::eolian_mono::function_declaration_generator> : std::true_type {};
|
|
|
|
|
|
|
|
namespace type_traits {
|
|
|
|
template <>
|
|
|
|
struct attributes_needed< ::eolian_mono::function_declaration_generator> : std::integral_constant<int, 1> {};
|
|
|
|
}
|
|
|
|
|
|
|
|
} } }
|
|
|
|
|
|
|
|
#endif
|