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-12-12 06:06:46 -08:00
|
|
|
#ifndef EOLIAN_MONO_HELPERS_HH
|
|
|
|
#define EOLIAN_MONO_HELPERS_HH
|
|
|
|
|
|
|
|
#include "grammar/klass_def.hpp"
|
2018-04-16 12:26:13 -07:00
|
|
|
#include "blacklist.hh"
|
2019-07-11 01:19:53 -07:00
|
|
|
#include "generation_contexts.hh"
|
2018-04-16 12:26:13 -07:00
|
|
|
#include "name_helpers.hh"
|
2017-12-12 06:06:46 -08:00
|
|
|
|
|
|
|
namespace eolian_mono {
|
|
|
|
|
2018-04-10 18:50:05 -07:00
|
|
|
namespace helpers {
|
|
|
|
|
2018-04-16 12:26:13 -07:00
|
|
|
/* General helpers, not related directly with generating strings (those go in the name_helpers.hh). */
|
2017-12-12 06:06:46 -08:00
|
|
|
|
2018-04-16 12:26:13 -07:00
|
|
|
namespace attributes = efl::eolian::grammar::attributes;
|
2017-12-12 06:06:46 -08:00
|
|
|
|
|
|
|
inline bool need_struct_conversion(attributes::regular_type_def const* regular)
|
|
|
|
{
|
2018-04-16 12:26:13 -07:00
|
|
|
return regular && regular->is_struct() && !blacklist::is_struct_blacklisted(*regular);
|
2017-12-12 06:06:46 -08:00
|
|
|
}
|
|
|
|
|
2018-03-15 16:32:39 -07:00
|
|
|
inline bool need_struct_conversion(attributes::parameter_def const& param, attributes::regular_type_def const* regular)
|
|
|
|
{
|
|
|
|
if (param.direction == attributes::parameter_direction::in && param.type.has_own)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return need_struct_conversion(regular);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool need_struct_conversion_in_return(attributes::type_def const& ret_type, attributes::parameter_direction const& direction)
|
|
|
|
{
|
|
|
|
auto regular = efl::eina::get<attributes::regular_type_def>(&ret_type.original_type);
|
|
|
|
|
|
|
|
if (!regular->is_struct())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (regular->is_struct() && (direction == attributes::parameter_direction::out || direction == attributes::parameter_direction::unknown))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (ret_type.has_own)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-12-15 16:15:00 -08:00
|
|
|
inline bool need_pointer_conversion(attributes::regular_type_def const* regular)
|
|
|
|
{
|
|
|
|
if (!regular)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (regular->is_enum()
|
2018-04-27 14:08:25 -07:00
|
|
|
|| (regular->is_struct() && name_helpers::type_full_eolian_name(*regular) != "Eina.Binbuf")
|
2017-12-15 16:15:00 -08:00
|
|
|
)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
std::set<std::string> const types {
|
|
|
|
"bool", "char"
|
|
|
|
, "byte" , "short" , "int" , "long" , "llong" , "int8" , "int16" , "int32" , "int64" , "ssize"
|
|
|
|
, "ubyte", "ushort", "uint", "ulong", "ullong", "uint8", "uint16", "uint32", "uint64", "size"
|
|
|
|
, "ptrdiff"
|
|
|
|
, "float", "double"
|
|
|
|
};
|
|
|
|
if (types.find(regular->base_type) != types.end())
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
// While klass_def has immediate_inherits, we need a way to get all interfaces inherited by an interface
|
|
|
|
// either directly or through another interface.
|
|
|
|
std::set<attributes::klass_name, attributes::compare_klass_name_by_name> interface_inherits(attributes::klass_def const& cls)
|
|
|
|
{
|
|
|
|
std::set<attributes::klass_name, attributes::compare_klass_name_by_name> inherits;
|
|
|
|
|
|
|
|
std::function<void(attributes::klass_name const&)> inherit_algo =
|
|
|
|
[&] (attributes::klass_name const& klass)
|
|
|
|
{
|
|
|
|
// TODO we could somehow cache klass_def instantiations
|
|
|
|
attributes::klass_def c(get_klass(klass, cls.unit), cls.unit);
|
|
|
|
for(auto&& inherit : c.immediate_inherits)
|
|
|
|
{
|
|
|
|
switch(inherit.type)
|
|
|
|
{
|
|
|
|
case attributes::class_type::mixin:
|
|
|
|
case attributes::class_type::interface_:
|
|
|
|
inherits.insert(inherit);
|
|
|
|
inherit_algo(inherit);
|
|
|
|
break;
|
|
|
|
case attributes::class_type::regular:
|
|
|
|
case attributes::class_type::abstract_:
|
|
|
|
inherit_algo(inherit);
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
inherit_algo(get_klass_name(cls));
|
|
|
|
|
|
|
|
|
|
|
|
return inherits;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Returns the set of interfaces implemented by this type that haven't been implemented
|
|
|
|
// by a regular parent class.
|
efl-csharp: Respect beta for classes and other stuff.
Summary:
In order to work around an issue with Efl.App, which is stable but
inherits from Efl.Core.Command_Line, @beta interfaces/mixins in the
inheritance chain are simply skipped.
Also changed the class used int test for inheritance from C#
Efl.Loop is stable but internally it uses a @beta class as argument to
its Register() method in the constructor. When instantiating a
user-defined C# subclass, the binding calls the C# override in the
NativeInherit class and the marshalling fails as no code is generated
for the beta class.
Also moved Efl.Part test to a beta class. Efl.Part is still beta.
Regarding parts, they are skipped if its class is @beta too.
Also rejected all elm_* files in elm public eo files. They should get
back in as they are converted to Efl.Ui.* api. An exception is
elm_interface_scrollable.eo, as efl_ui_panel depends on it.
Fixes T7730
Test Plan: Run tests
Reviewers: vitor.sousa, segfaultxavi, felipealmeida, cedric, bu5hm4n, zmike
Reviewed By: vitor.sousa
Subscribers: #reviewers, #committers
Tags: #efl
Maniphest Tasks: T7730
Differential Revision: https://phab.enlightenment.org/D8268
2019-03-11 11:46:12 -07:00
|
|
|
template<typename Context>
|
2019-03-22 14:37:50 -07:00
|
|
|
std::set<attributes::klass_name, attributes::compare_klass_name_by_name> non_implemented_interfaces(attributes::klass_def const& cls, Context const& 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
|
|
|
{
|
efl-csharp: Respect beta for classes and other stuff.
Summary:
In order to work around an issue with Efl.App, which is stable but
inherits from Efl.Core.Command_Line, @beta interfaces/mixins in the
inheritance chain are simply skipped.
Also changed the class used int test for inheritance from C#
Efl.Loop is stable but internally it uses a @beta class as argument to
its Register() method in the constructor. When instantiating a
user-defined C# subclass, the binding calls the C# override in the
NativeInherit class and the marshalling fails as no code is generated
for the beta class.
Also moved Efl.Part test to a beta class. Efl.Part is still beta.
Regarding parts, they are skipped if its class is @beta too.
Also rejected all elm_* files in elm public eo files. They should get
back in as they are converted to Efl.Ui.* api. An exception is
elm_interface_scrollable.eo, as efl_ui_panel depends on it.
Fixes T7730
Test Plan: Run tests
Reviewers: vitor.sousa, segfaultxavi, felipealmeida, cedric, bu5hm4n, zmike
Reviewed By: vitor.sousa
Subscribers: #reviewers, #committers
Tags: #efl
Maniphest Tasks: T7730
Differential Revision: https://phab.enlightenment.org/D8268
2019-03-11 11:46:12 -07:00
|
|
|
auto options = efl::eolian::grammar::context_find_tag<options_context>(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
|
|
|
std::set<attributes::klass_name, attributes::compare_klass_name_by_name> implemented_interfaces;
|
|
|
|
std::set<attributes::klass_name, attributes::compare_klass_name_by_name> interfaces;
|
|
|
|
|
|
|
|
std::function<void(attributes::klass_name const&, bool)> inherit_algo =
|
|
|
|
[&] (attributes::klass_name const& klass, bool is_implemented)
|
|
|
|
{
|
|
|
|
// TODO we could somehow cache klass_def instantiations
|
|
|
|
attributes::klass_def c(get_klass(klass, cls.unit), cls.unit);
|
|
|
|
for(auto&& inherit : c.immediate_inherits)
|
|
|
|
{
|
efl-csharp: Respect beta for classes and other stuff.
Summary:
In order to work around an issue with Efl.App, which is stable but
inherits from Efl.Core.Command_Line, @beta interfaces/mixins in the
inheritance chain are simply skipped.
Also changed the class used int test for inheritance from C#
Efl.Loop is stable but internally it uses a @beta class as argument to
its Register() method in the constructor. When instantiating a
user-defined C# subclass, the binding calls the C# override in the
NativeInherit class and the marshalling fails as no code is generated
for the beta class.
Also moved Efl.Part test to a beta class. Efl.Part is still beta.
Regarding parts, they are skipped if its class is @beta too.
Also rejected all elm_* files in elm public eo files. They should get
back in as they are converted to Efl.Ui.* api. An exception is
elm_interface_scrollable.eo, as efl_ui_panel depends on it.
Fixes T7730
Test Plan: Run tests
Reviewers: vitor.sousa, segfaultxavi, felipealmeida, cedric, bu5hm4n, zmike
Reviewed By: vitor.sousa
Subscribers: #reviewers, #committers
Tags: #efl
Maniphest Tasks: T7730
Differential Revision: https://phab.enlightenment.org/D8268
2019-03-11 11:46:12 -07:00
|
|
|
if (inherit.is_beta && !options.want_beta)
|
|
|
|
continue;
|
|
|
|
|
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
|
|
|
switch(inherit.type)
|
|
|
|
{
|
|
|
|
case attributes::class_type::mixin:
|
|
|
|
case attributes::class_type::interface_:
|
|
|
|
interfaces.insert(inherit);
|
|
|
|
if (is_implemented)
|
|
|
|
implemented_interfaces.insert(inherit);
|
|
|
|
inherit_algo(inherit, is_implemented);
|
|
|
|
break;
|
|
|
|
case attributes::class_type::abstract_:
|
|
|
|
case attributes::class_type::regular:
|
|
|
|
inherit_algo(inherit, true);
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
inherit_algo(get_klass_name(cls), false);
|
|
|
|
|
|
|
|
for (auto&& inherit : implemented_interfaces)
|
|
|
|
interfaces.erase(inherit);
|
|
|
|
|
|
|
|
|
|
|
|
return interfaces;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Determines whether this class has any regular ancestor or not
|
|
|
|
*/
|
|
|
|
bool has_regular_ancestor(attributes::klass_def const& cls)
|
|
|
|
{
|
|
|
|
auto inherits = cls.inherits;
|
|
|
|
std::function<bool(attributes::klass_name const&)> is_regular =
|
|
|
|
[&] (attributes::klass_name const& klass)
|
|
|
|
{
|
|
|
|
return klass.type == attributes::class_type::regular || klass.type == attributes::class_type::abstract_;
|
|
|
|
};
|
|
|
|
|
|
|
|
return std::any_of(inherits.begin(), inherits.end(), is_regular);
|
|
|
|
}
|
|
|
|
|
2019-08-19 17:31:20 -07:00
|
|
|
/*
|
|
|
|
* Sugar for checking if a given class in in the inheritance tree
|
|
|
|
*/
|
|
|
|
bool inherits_from(attributes::klass_def const& cls, std::string const& name)
|
|
|
|
{
|
|
|
|
return std::any_of(cls.inherits.begin(), cls.inherits.end(),
|
|
|
|
[&](attributes::klass_name const& inherit)
|
|
|
|
{
|
|
|
|
return name_helpers::klass_full_concrete_or_interface_name(inherit) == name;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
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
|
|
|
/*
|
|
|
|
* Gets all methods that this class should implement (i.e. that come from an unimplemented interface/mixin and the class itself)
|
|
|
|
*/
|
2019-07-11 01:19:53 -07:00
|
|
|
template<typename Context>
|
|
|
|
std::vector<attributes::function_def> get_all_implementable_methods(attributes::klass_def const& cls, Context const& 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
|
|
|
{
|
2019-07-11 01:19:53 -07:00
|
|
|
bool want_beta = efl::eolian::grammar::context_find_tag<options_context>(context).want_beta;
|
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
|
|
|
std::vector<attributes::function_def> ret;
|
2019-07-11 01:19:53 -07:00
|
|
|
auto filter_beta = [&want_beta](attributes::function_def const& func) {
|
|
|
|
if (!want_beta)
|
|
|
|
return !func.is_beta;
|
|
|
|
else
|
|
|
|
return true;
|
|
|
|
};
|
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
|
|
|
|
2019-07-11 01:19:53 -07:00
|
|
|
std::copy_if(cls.functions.begin(), cls.functions.end(), std::back_inserter(ret), filter_beta);
|
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
|
|
|
|
|
|
|
// Non implemented interfaces
|
|
|
|
std::set<attributes::klass_name, attributes::compare_klass_name_by_name> implemented_interfaces;
|
|
|
|
std::set<attributes::klass_name, attributes::compare_klass_name_by_name> interfaces;
|
|
|
|
std::function<void(attributes::klass_name const&, bool)> inherit_algo =
|
|
|
|
[&] (attributes::klass_name const &klass, bool is_implemented)
|
|
|
|
{
|
|
|
|
attributes::klass_def c(get_klass(klass, cls.unit), cls.unit);
|
|
|
|
for (auto&& inherit: c.immediate_inherits)
|
|
|
|
{
|
|
|
|
switch(inherit.type)
|
|
|
|
{
|
|
|
|
case attributes::class_type::mixin:
|
|
|
|
case attributes::class_type::interface_:
|
|
|
|
interfaces.insert(inherit);
|
|
|
|
if (is_implemented)
|
|
|
|
implemented_interfaces.insert(inherit);
|
|
|
|
inherit_algo(inherit, is_implemented);
|
|
|
|
break;
|
|
|
|
case attributes::class_type::abstract_:
|
|
|
|
case attributes::class_type::regular:
|
|
|
|
inherit_algo(inherit, true);
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
inherit_algo(attributes::get_klass_name(cls), false);
|
|
|
|
|
|
|
|
for (auto&& inherit : implemented_interfaces)
|
|
|
|
interfaces.erase(inherit);
|
|
|
|
|
|
|
|
for (auto&& inherit : interfaces)
|
|
|
|
{
|
|
|
|
attributes::klass_def klass(get_klass(inherit, cls.unit), cls.unit);
|
2019-07-11 01:19:53 -07:00
|
|
|
std::copy_if(klass.functions.cbegin(), klass.functions.cend(), std::back_inserter(ret), filter_beta);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2020-01-30 11:49:04 -08:00
|
|
|
/*
|
|
|
|
* Gets all properties that this class should implement (i.e. that come from an unimplemented interface/mixin and the class itself)
|
|
|
|
*/
|
|
|
|
template<typename Context>
|
|
|
|
std::vector<attributes::property_def> get_all_implementable_properties(attributes::klass_def const& cls, Context const& context)
|
|
|
|
{
|
|
|
|
bool want_beta = efl::eolian::grammar::context_find_tag<options_context>(context).want_beta;
|
|
|
|
std::vector<attributes::property_def> ret;
|
|
|
|
auto filter_beta = [&want_beta](attributes::property_def const& prop) {
|
|
|
|
if (!want_beta)
|
|
|
|
return prop.getter && !prop.setter ? !prop.getter->is_beta
|
|
|
|
: prop.getter && prop.setter ? !prop.getter->is_beta || !prop.setter->is_beta
|
|
|
|
: true
|
|
|
|
;
|
|
|
|
else
|
|
|
|
return true;
|
|
|
|
};
|
|
|
|
|
|
|
|
std::copy_if(cls.properties.begin(), cls.properties.end(), std::back_inserter(ret), filter_beta);
|
|
|
|
|
|
|
|
// Non implemented interfaces
|
|
|
|
std::set<attributes::klass_name, attributes::compare_klass_name_by_name> implemented_interfaces;
|
|
|
|
std::set<attributes::klass_name, attributes::compare_klass_name_by_name> interfaces;
|
|
|
|
std::function<void(attributes::klass_name const&, bool)> inherit_algo =
|
|
|
|
[&] (attributes::klass_name const &klass, bool is_implemented)
|
|
|
|
{
|
|
|
|
attributes::klass_def c(get_klass(klass, cls.unit), cls.unit);
|
|
|
|
for (auto&& inherit: c.immediate_inherits)
|
|
|
|
{
|
|
|
|
switch(inherit.type)
|
|
|
|
{
|
|
|
|
case attributes::class_type::mixin:
|
|
|
|
case attributes::class_type::interface_:
|
|
|
|
interfaces.insert(inherit);
|
|
|
|
if (is_implemented)
|
|
|
|
implemented_interfaces.insert(inherit);
|
|
|
|
inherit_algo(inherit, is_implemented);
|
|
|
|
break;
|
|
|
|
case attributes::class_type::abstract_:
|
|
|
|
case attributes::class_type::regular:
|
|
|
|
inherit_algo(inherit, true);
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
inherit_algo(attributes::get_klass_name(cls), false);
|
|
|
|
|
|
|
|
for (auto&& inherit : implemented_interfaces)
|
|
|
|
interfaces.erase(inherit);
|
|
|
|
|
|
|
|
for (auto&& inherit : interfaces)
|
|
|
|
{
|
|
|
|
attributes::klass_def klass(get_klass(inherit, cls.unit), cls.unit);
|
|
|
|
std::copy_if(klass.properties.cbegin(), klass.properties.cend(), std::back_inserter(ret), filter_beta);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
template<typename Klass>
|
|
|
|
inline bool is_managed_interface(Klass const& klass)
|
|
|
|
{
|
|
|
|
return klass.type == attributes::class_type::interface_
|
|
|
|
|| klass.type == attributes::class_type::mixin;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Gets all methods that this class should register (i.e. that comes from it and non-public interface methods
|
|
|
|
* that this class is the first one implementing)
|
|
|
|
*/
|
|
|
|
template<typename Context>
|
|
|
|
std::vector<attributes::function_def> get_all_registerable_methods(attributes::klass_def const& cls, Context const& context)
|
|
|
|
{
|
|
|
|
std::vector<attributes::function_def> ret;
|
|
|
|
|
|
|
|
auto implementable_methods = get_all_implementable_methods(cls, context);
|
|
|
|
|
|
|
|
std::copy_if(implementable_methods.cbegin(), implementable_methods.cend(), std::back_inserter(ret)
|
|
|
|
, [&cls](attributes::function_def const & func) {
|
|
|
|
|
|
|
|
if (cls == func.klass)
|
|
|
|
return true;
|
|
|
|
|
2019-09-10 15:47:47 -07:00
|
|
|
if (is_managed_interface(func.klass) && func.is_static)
|
|
|
|
return true;
|
|
|
|
|
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
|
|
|
if (!is_managed_interface(func.klass) || func.scope != attributes::member_scope::scope_public)
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2020-01-30 11:49:04 -08:00
|
|
|
bool is_function_registerable (attributes::function_def func, attributes::klass_def const& cls)
|
|
|
|
{
|
|
|
|
if (cls == func.klass)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (is_managed_interface(func.klass) && func.is_static)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (!is_managed_interface(func.klass) || func.scope != attributes::member_scope::scope_public)
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// /*
|
|
|
|
// * Gets all methods that this class should register (i.e. that comes from it and non-public interface methods
|
|
|
|
// * that this class is the first one implementing)
|
|
|
|
// */
|
|
|
|
// template<typename Context>
|
|
|
|
// std::vector<attributes::property_def> get_all_registerable_properties(attributes::klass_def const& cls, Context const& context)
|
|
|
|
// {
|
|
|
|
// std::vector<attributes::property_def> ret;
|
|
|
|
|
|
|
|
// auto implementable_properties = get_all_implementable_properties(cls, context);
|
|
|
|
|
|
|
|
// std::copy_if(implementable_properties.cbegin(), implementable_properties.cend(), std::back_inserter(ret)
|
|
|
|
// , [&cls](attributes::property_def const & property) {
|
|
|
|
// auto klass = property.getter ? property.getter->klass
|
|
|
|
// : property.setter->klass;
|
|
|
|
|
|
|
|
// if (cls == klass)
|
|
|
|
// return true;
|
|
|
|
|
|
|
|
// if (is_managed_interface(klass) && ((property.getter && property.getter->is_static)
|
|
|
|
// || (property.setter && property.setter->is_static)))
|
|
|
|
// return true;
|
|
|
|
|
|
|
|
// if (!is_managed_interface(klass) || ((property.getter && property.getter->scope != attributes::member_scope::scope_public)
|
|
|
|
// || (property.setter && property.setter->scope != attributes::member_scope::scope_public)))
|
|
|
|
// return true;
|
|
|
|
// return false;
|
|
|
|
// });
|
|
|
|
|
|
|
|
// return ret;
|
|
|
|
// }
|
|
|
|
|
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
|
|
|
/*
|
|
|
|
* Checks whether the given is unique going up the inheritance tree from leaf_klass
|
|
|
|
*/
|
|
|
|
inline bool is_unique_event(attributes::event_def const& evt
|
|
|
|
, attributes::klass_def const& leaf_klass)
|
|
|
|
{
|
|
|
|
auto events = leaf_klass.get_all_events();
|
|
|
|
int i = 1;
|
|
|
|
return !std::any_of(events.cbegin(), events.cend(),
|
|
|
|
[&evt, &i](const attributes::event_def &other) {
|
|
|
|
return evt.name == other.name && i++ == 2;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-02-01 11:03:02 -08:00
|
|
|
inline std::vector<attributes::constructor_def> reorder_constructors(std::vector<attributes::constructor_def> constructors)
|
|
|
|
{
|
|
|
|
auto is_required = [](attributes::constructor_def const& ctr) { return !ctr.is_optional; };
|
2020-06-08 14:32:22 -07:00
|
|
|
auto is_object_parent = [](attributes::constructor_def const& ctr)
|
|
|
|
{
|
|
|
|
return (ctr.klass.namespaces.size() == 1
|
|
|
|
&& ctr.klass.namespaces[0] == "Efl"
|
|
|
|
&& ctr.klass.eolian_name == "Object"
|
|
|
|
&& ctr.name == "Efl.Object.parent");
|
|
|
|
};
|
2019-02-01 11:03:02 -08:00
|
|
|
std::stable_partition(constructors.begin(), constructors.end(), is_required);
|
2020-06-08 14:32:22 -07:00
|
|
|
constructors.erase (std::remove_if (constructors.begin(), constructors.end(), is_object_parent), constructors.end());
|
2019-02-01 11:03:02 -08:00
|
|
|
return constructors;
|
|
|
|
}
|
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
|
|
|
|
2018-04-10 18:50:05 -07:00
|
|
|
} // namespace helpers
|
|
|
|
|
|
|
|
} // namespace eolian_mono
|
2017-12-12 06:06:46 -08:00
|
|
|
|
|
|
|
#endif
|