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_CLASS_DEFINITION_HPP
# define EOLIAN_MONO_CLASS_DEFINITION_HPP
# include "grammar/integral.hpp"
# include "grammar/generator.hpp"
# include "grammar/klass_def.hpp"
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
# include "grammar/attribute_conditional.hpp"
2018-04-16 12:26:13 -07:00
# include "blacklist.hh"
2017-11-23 16:50:16 -08:00
# include "grammar/indentation.hpp"
# include "grammar/list.hpp"
# include "grammar/alternative.hpp"
# include "type.hh"
2018-04-16 17:44:27 -07:00
# include "name_helpers.hh"
2018-05-07 15:22:59 -07:00
# include "async_function_definition.hh"
2017-11-23 16:50:16 -08:00
# include "function_definition.hh"
# include "function_registration.hh"
# include "function_declaration.hh"
2017-12-06 16:03:55 -08:00
# include "documentation.hh"
2018-03-19 16:35:36 -07:00
# include "part_definition.hh"
2018-04-16 17:44:27 -07:00
# include "events.hh"
2017-11-23 16:50:16 -08:00
# include "grammar/string.hpp"
# include "grammar/attribute_replace.hpp"
# include "grammar/integral.hpp"
# include "grammar/case.hpp"
# include "using_decl.hh"
# include "utils.hh"
# include <string>
# include <algorithm>
namespace eolian_mono {
2018-01-19 05:30:00 -08:00
template < typename Context >
static bool
is_inherit_context ( Context const & context )
{
return context_find_tag < class_context > ( context ) . current_wrapper_kind = = class_context : : inherit ;
}
2019-08-23 10:27:28 -07:00
enum partial_class
{
class_partial = 1
} ;
2017-11-23 16:50:16 -08:00
struct klass
{
template < typename OutputIterator , typename Context >
bool generate ( OutputIterator sink , attributes : : klass_def const & cls , Context const & context ) const
{
2018-04-27 14:08:25 -07:00
EINA_CXX_DOM_LOG_DBG ( eolian_mono : : domain ) < < " klass_generator: " < < cls . eolian_name < < std : : endl ;
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
2019-04-23 02:48:03 -07:00
auto const & indent = current_indentation ( context ) ;
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 ( blacklist : : is_class_blacklisted ( cls , context ) )
{
EINA_CXX_DOM_LOG_DBG ( eolian_mono : : domain ) < < " class " < < cls . eolian_name < < " is blacklisted. Skipping. " < < std : : endl ;
return true ;
}
2017-11-23 16:50:16 -08:00
std : : string suffix , class_type ;
switch ( cls . type )
{
case attributes : : class_type : : regular :
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
class_type = " class " ;
suffix = " CLASS " ;
break ;
2017-11-23 16:50:16 -08:00
case attributes : : class_type : : abstract_ :
csharp: Make classes abstract and rework casting
Summary:
Abstract Eo classes are now proper C# abstract classes.
As a side effect, returning Eo instances from native code was reworked
to return instances of their actual Eo classes instead of previous
behavior of returning a generic Efl.Object and using static_cast.
Instead of `var window = Efl.Ui.Win.static_cast(widget.GetParent());`
Use `var window = widget.GetParent() as Efl.Ui.Win;`
Another side effect was that `efl_constructor` was removed from the list
of supported `Efl.Object` overrides. It is invoked inside
`efl_add_internal_start`, before the bindings makes the association of
the newly created EoId with the C# instance that created it, making the
managed delegate meaningless. C# users then can use regular C#
constructors to initialize fields.
Also changed to set the private data of C#-inherited classes before the
call to constructing methods (aka constructor parameters) so C# classes
can override them correctly.
Fixes T7778
Fixes T7757
Reviewers: vitor.sousa, felipealmeida, segfaultxavi
Reviewed By: vitor.sousa, segfaultxavi
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Maniphest Tasks: T7778, T7757, T7702
Differential Revision: https://phab.enlightenment.org/D8550
2019-04-05 15:53:37 -07:00
class_type = " abstract class " ;
2017-11-23 16:50:16 -08:00
suffix = " CLASS " ;
break ;
case attributes : : class_type : : mixin :
class_type = " interface " ;
suffix = " MIXIN " ;
break ;
case attributes : : class_type : : interface_ :
class_type = " interface " ;
suffix = " INTERFACE " ;
break ;
}
2018-04-27 14:08:25 -07:00
if ( ! name_helpers : : open_namespaces ( sink , cls . namespaces , context ) )
return false ;
2017-11-23 16:50:16 -08:00
auto methods = cls . get_all_methods ( ) ;
// Interface class
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 ( class_type = = " interface " )
2017-11-23 16:50:16 -08:00
{
2019-04-11 03:40:21 -07:00
auto iface_cxt = context_add_tag ( class_context { class_context : : interface ,
name_helpers : : klass_full_concrete_or_interface_name ( cls ) } ,
context ) ;
2017-12-06 16:03:55 -08:00
2020-01-12 16:45:16 -08:00
if ( ! as_generator ( documentation ( 1 ) ) . generate ( sink , cls , iface_cxt ) )
2019-01-17 04:33:09 -08:00
return false ;
2017-12-06 16:03:55 -08:00
2019-01-17 04:33:09 -08:00
// Mark the interface with the proper native Efl_Class* getter
2020-01-12 16:45:16 -08:00
if ( ! as_generator ( scope_tab < < lit ( " [ " ) < < name_helpers : : klass_full_native_inherit_name ( cls ) < < " ] \n " )
2019-01-17 04:33:09 -08:00
. generate ( sink , attributes : : unused , iface_cxt ) )
return false ;
2018-12-14 09:06:12 -08:00
2020-01-12 16:45:16 -08:00
if ( ! as_generator ( scope_tab < < " [Efl.Eo.BindingEntity] \n " ) . generate ( sink , attributes : : unused , iface_cxt ) )
2019-07-11 11:50:33 -07:00
return false ;
2019-08-23 10:27:28 -07:00
using efl : : eolian : : grammar : : lit ;
2019-01-17 04:33:09 -08:00
if ( ! as_generator
2017-11-23 16:50:16 -08:00
(
2020-01-12 16:45:16 -08:00
scope_tab < < lit ( " public " ) < < ( is_partial ? " partial " : " " )
2019-08-23 10:27:28 -07:00
/*<< class_type*/ < < " interface " /*<<*/ " " < < string < < " : "
2017-11-23 16:50:16 -08:00
)
2018-05-02 15:49:37 -07:00
. generate ( sink , name_helpers : : klass_interface_name ( cls ) , iface_cxt ) )
2019-01-17 04:33:09 -08:00
return false ;
for ( auto first = std : : begin ( cls . immediate_inherits )
, last = std : : end ( cls . immediate_inherits ) ; first ! = last ; + + first )
{
2019-07-11 07:06:17 -07:00
if ( ! context_find_tag < options_context > ( iface_cxt ) . want_beta & & first - > is_beta )
continue ;
2019-01-17 04:33:09 -08:00
if ( first - > type ! = attributes : : class_type : : regular & & first - > type ! = attributes : : class_type : : abstract_ )
2019-11-06 18:34:18 -08:00
if ( ! as_generator ( " \n " < < scope_tab < < string < < " , " ) . generate ( sink , name_helpers : : klass_full_interface_name ( * first ) , iface_cxt ) )
2019-01-17 04:33:09 -08:00
return false ;
}
2017-11-23 16:50:16 -08:00
2020-01-12 16:45:16 -08:00
if ( ! as_generator ( " \n " < < scope_tab ( 2 ) < < " Efl.Eo.IWrapper, IDisposable " ) . generate ( sink , attributes : : unused , iface_cxt ) )
2019-01-17 04:33:09 -08:00
return false ;
2018-04-27 14:08:25 -07:00
2020-01-12 16:45:16 -08:00
if ( ! as_generator ( " \n " < < scope_tab < < " { \n " ) . generate ( sink , attributes : : unused , iface_cxt ) )
2019-01-17 04:33:09 -08:00
return false ;
2018-04-27 14:08:25 -07:00
2019-09-23 16:50:27 -07:00
if ( ! as_generator ( * ( function_declaration ) ) . generate ( sink , cls . functions , iface_cxt ) )
2019-01-17 04:33:09 -08:00
return false ;
2018-04-27 14:08:25 -07:00
2019-09-23 16:50:27 -07:00
if ( ! as_generator ( * ( async_function_declaration ) ) . generate ( sink , cls . functions , iface_cxt ) )
2019-01-17 04:33:09 -08:00
return false ;
2018-05-07 15:22:59 -07:00
2019-01-17 04:33:09 -08:00
if ( ! as_generator ( * ( event_declaration ) ) . generate ( sink , cls . events , iface_cxt ) )
return false ;
2017-11-23 16:50:16 -08:00
2019-01-17 04:33:09 -08:00
for ( auto & & p : cls . parts )
if ( ! as_generator (
2020-01-12 16:45:16 -08:00
documentation ( 2 )
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
< < name_helpers : : klass_full_concrete_or_interface_name ( p . klass ) < < " " < < utils : : capitalize ( p . name ) < < " { get;} \n "
2018-04-25 07:36:24 -07:00
) . generate ( sink , p , iface_cxt ) )
2019-01-17 04:33:09 -08:00
return false ;
2018-12-14 12:17:23 -08:00
2020-01-20 14:00:44 -08:00
if ( ! as_generator ( * ( property_wrapper_definition ( cls ) ) ) . generate ( sink , cls . properties , iface_cxt ) )
2019-01-17 04:33:09 -08:00
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
2019-01-17 04:33:09 -08:00
// End of interface declaration
2020-01-12 16:45:16 -08:00
if ( ! as_generator ( scope_tab < < " } \n \n " ) . generate ( sink , attributes : : unused , iface_cxt ) ) return false ;
2017-11-23 16:50:16 -08:00
}
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
// Events arguments go in the top namespace to avoid the Concrete suffix clutter in interface events.
// Regular/abstract class events go here too for consistency.
if ( ! as_generator ( * ( event_argument_wrapper ) ) . generate ( sink , cls . events , context ) )
return false ;
bool root = ! helpers : : has_regular_ancestor ( cls ) ;
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
std : : set < attributes : : klass_name , attributes : : compare_klass_name_by_name > inherit_interfaces = helpers : : non_implemented_interfaces ( cls , 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 : : vector < attributes : : klass_name > inherit_classes ;
std : : copy_if ( cls . immediate_inherits . begin ( ) , cls . immediate_inherits . end ( )
, std : : back_inserter ( inherit_classes )
, [ ] ( attributes : : klass_name const & klass )
{
switch ( klass . type )
{
case attributes : : class_type : : regular :
case attributes : : class_type : : abstract_ :
return true ;
default :
return false ;
} ;
} ) ;
// Concrete class for interfaces, mixins, etc.
csharp: Make classes abstract and rework casting
Summary:
Abstract Eo classes are now proper C# abstract classes.
As a side effect, returning Eo instances from native code was reworked
to return instances of their actual Eo classes instead of previous
behavior of returning a generic Efl.Object and using static_cast.
Instead of `var window = Efl.Ui.Win.static_cast(widget.GetParent());`
Use `var window = widget.GetParent() as Efl.Ui.Win;`
Another side effect was that `efl_constructor` was removed from the list
of supported `Efl.Object` overrides. It is invoked inside
`efl_add_internal_start`, before the bindings makes the association of
the newly created EoId with the C# instance that created it, making the
managed delegate meaningless. C# users then can use regular C#
constructors to initialize fields.
Also changed to set the private data of C#-inherited classes before the
call to constructing methods (aka constructor parameters) so C# classes
can override them correctly.
Fixes T7778
Fixes T7757
Reviewers: vitor.sousa, felipealmeida, segfaultxavi
Reviewed By: vitor.sousa, segfaultxavi
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Maniphest Tasks: T7778, T7757, T7702
Differential Revision: https://phab.enlightenment.org/D8550
2019-04-05 15:53:37 -07:00
if ( class_type ! = " class " & & class_type ! = " abstract class " )
2017-11-23 16:50:16 -08:00
{
2019-04-11 03:40:21 -07:00
auto concrete_cxt = context_add_tag ( class_context { class_context : : concrete ,
name_helpers : : klass_full_concrete_or_interface_name ( cls ) } ,
context ) ;
2018-04-27 14:08:25 -07:00
auto concrete_name = name_helpers : : klass_concrete_name ( cls ) ;
auto interface_name = name_helpers : : klass_interface_name ( cls ) ;
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-04-23 02:48:03 -07:00
// We can't make these internal yet as they have methods that are used by
// other classes that implement the interface.
2017-11-23 16:50:16 -08:00
if ( ! as_generator
(
2020-01-12 16:45:16 -08:00
documentation ( 1 )
< < scope_tab < < " public sealed " < < ( is_partial ? " partial " : " " ) < < " class " < < concrete_name < < " : \n "
< < scope_tab ( 2 ) < < ( root ? " Efl.Eo.EoWrapper " : " " ) < < ( klass_full_concrete_or_interface_name % " " )
< < " , \n " < < scope_tab ( 2 ) < < interface_name
< < * ( " , \n " < < scope_tab ( 2 ) < < name_helpers : : klass_full_concrete_or_interface_name ) < < " \n "
< < scope_tab < < " { \n "
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
) . generate ( sink , std : : make_tuple ( cls , inherit_classes , inherit_interfaces ) , concrete_cxt ) )
return false ;
if ( ! generate_fields ( sink , cls , concrete_cxt ) )
return false ;
2019-06-28 06:29:01 -07:00
if ( ! as_generator
(
2020-01-12 16:45:16 -08:00
scope_tab ( 2 ) < < " /// <summary>Subclasses should override this constructor if they are expected to be instantiated from native code. \n "
< < scope_tab ( 2 ) < < " /// Do not call this constructor directly.</summary> \n "
< < scope_tab ( 2 ) < < " /// <param name= \" ch \" >Tag struct storing the native handle of the object being constructed.</param> \n "
< < scope_tab ( 2 ) < < " private " < < concrete_name < < " (ConstructingHandle ch) : base(ch) \n "
< < scope_tab ( 2 ) < < " { \n "
< < scope_tab ( 2 ) < < " } \n \n "
2019-06-28 06:29:01 -07:00
)
. generate ( sink , attributes : : unused , concrete_cxt ) )
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
if ( ! as_generator
(
2020-01-12 16:45:16 -08:00
scope_tab ( 2 ) < < " [System.Runtime.InteropServices.DllImport( " < < context_find_tag < library_context > ( concrete_cxt ) . actual_library_name ( cls . filename )
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
< < " )] internal static extern System.IntPtr \n "
2020-01-12 16:45:16 -08:00
< < scope_tab ( 2 ) < < scope_tab < < name_helpers : : klass_get_name ( cls ) < < " (); \n \n "
< < scope_tab ( 2 ) < < " /// <summary>Initializes a new instance of the <see cref= \" " < < interface_name < < " \" /> class. \n "
< < scope_tab ( 2 ) < < " /// Internal usage: This is used when interacting with C code and should not be used directly.</summary> \n "
< < scope_tab ( 2 ) < < " /// <param name= \" wh \" >The native pointer to be wrapped.</param> \n "
< < scope_tab ( 2 ) < < " private " < < concrete_name < < " (Efl.Eo.WrappingHandle wh) : base(wh) \n "
< < scope_tab ( 2 ) < < " { \n "
< < scope_tab ( 2 ) < < " } \n \n "
2017-11-23 16:50:16 -08:00
)
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
. generate ( sink , attributes : : unused , concrete_cxt ) )
return false ;
2017-11-23 16:50:16 -08:00
if ( ! generate_events ( sink , cls , concrete_cxt ) )
return false ;
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 ( ! as_generator ( lit ( " #pragma warning disable CS0628 \n " ) ) . generate ( sink , attributes : : unused , concrete_cxt ) )
return false ;
2018-03-19 16:35:36 -07:00
// Parts
if ( ! as_generator ( * ( part_definition ) )
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
. generate ( sink , cls . parts , concrete_cxt ) ) return false ;
2018-03-19 16:35:36 -07:00
2017-11-23 16:50:16 -08:00
// Concrete function definitions
2019-07-11 01:19:53 -07:00
auto implemented_methods = helpers : : get_all_implementable_methods ( cls , concrete_cxt ) ;
2017-11-23 16:50:16 -08:00
if ( ! as_generator ( * ( function_definition ) )
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
. generate ( sink , implemented_methods , concrete_cxt ) ) return false ;
2017-11-23 16:50:16 -08:00
2018-05-07 15:22:59 -07:00
// Async wrappers
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 ( ! as_generator ( * ( async_function_definition ) ) . generate ( sink , implemented_methods , concrete_cxt ) )
2018-04-16 17:44:27 -07:00
return false ;
2018-12-14 12:17:23 -08:00
// Property wrappers
2020-01-20 14:00:44 -08:00
if ( ! as_generator ( * ( property_wrapper_definition ( cls ) ) ) . generate ( sink , cls . properties , concrete_cxt ) )
2018-12-14 12:17:23 -08:00
return false ;
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
for ( auto & & klass : helpers : : non_implemented_interfaces ( cls , concrete_cxt ) )
2018-12-14 12:17:23 -08:00
{
attributes : : klass_def c ( get_klass ( klass , cls . unit ) , cls . unit ) ;
2020-01-20 14:00:44 -08:00
if ( ! as_generator ( * ( property_wrapper_definition ( cls ) ) ) . generate ( sink , c . properties , concrete_cxt ) )
2018-12-14 12:17:23 -08:00
return false ;
}
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 ( ! as_generator ( lit ( " #pragma warning restore CS0628 \n " ) ) . generate ( sink , attributes : : unused , concrete_cxt ) )
return false ;
2019-03-15 07:30:24 -07:00
// Copied from nativeinherit class, used when setting up providers.
if ( ! as_generator (
2020-01-12 16:45:16 -08:00
scope_tab ( 2 ) < < " private static IntPtr GetEflClassStatic() \n "
< < scope_tab ( 2 ) < < " { \n "
< < scope_tab ( 2 ) < < scope_tab < < " return " < < name_helpers : : klass_get_full_name ( cls ) < < " (); \n "
< < scope_tab ( 2 ) < < " } \n \n "
2019-03-15 07:30:24 -07:00
) . generate ( sink , attributes : : unused , concrete_cxt ) )
return false ;
2019-06-28 06:29:01 -07:00
if ( ! generate_native_inherit_class ( sink , cls , change_indentation ( indent . inc ( ) , concrete_cxt ) ) )
2019-04-23 02:48:03 -07:00
return true ;
2018-12-14 12:17:23 -08:00
2020-01-12 16:45:16 -08:00
if ( ! as_generator ( scope_tab < < " } \n " ) . generate ( sink , attributes : : unused , concrete_cxt ) ) return false ;
2017-11-23 16:50:16 -08:00
}
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
// Inheritable class
csharp: Make classes abstract and rework casting
Summary:
Abstract Eo classes are now proper C# abstract classes.
As a side effect, returning Eo instances from native code was reworked
to return instances of their actual Eo classes instead of previous
behavior of returning a generic Efl.Object and using static_cast.
Instead of `var window = Efl.Ui.Win.static_cast(widget.GetParent());`
Use `var window = widget.GetParent() as Efl.Ui.Win;`
Another side effect was that `efl_constructor` was removed from the list
of supported `Efl.Object` overrides. It is invoked inside
`efl_add_internal_start`, before the bindings makes the association of
the newly created EoId with the C# instance that created it, making the
managed delegate meaningless. C# users then can use regular C#
constructors to initialize fields.
Also changed to set the private data of C#-inherited classes before the
call to constructing methods (aka constructor parameters) so C# classes
can override them correctly.
Fixes T7778
Fixes T7757
Reviewers: vitor.sousa, felipealmeida, segfaultxavi
Reviewed By: vitor.sousa, segfaultxavi
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Maniphest Tasks: T7778, T7757, T7702
Differential Revision: https://phab.enlightenment.org/D8550
2019-04-05 15:53:37 -07:00
if ( class_type = = " class " | | class_type = = " abstract class " )
2017-11-23 16:50:16 -08:00
{
2019-04-11 03:40:21 -07:00
auto inherit_cxt = context_add_tag ( class_context { class_context : : inherit ,
name_helpers : : klass_full_concrete_or_interface_name ( cls ) } ,
context ) ;
2018-04-27 14:08:25 -07:00
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
// Class header
if ( ! as_generator
2017-11-23 16:50:16 -08:00
(
2020-01-12 16:45:16 -08:00
documentation ( 1 )
< < scope_tab < < " [ " < < name_helpers : : klass_full_native_inherit_name ( cls ) < < " ] \n "
< < scope_tab < < " [Efl.Eo.BindingEntity] \n "
< < scope_tab < < " [SuppressMessage( \" Microsoft.Naming \" , \" CA1724:TypeNamesShouldNotMatchNamespaces \" )] \n "
< < scope_tab < < " public "
2019-08-23 10:27:28 -07:00
< < ( is_partial
? class_type = = " class "
? " partial class "
: " abstract partial class "
: class_type
)
< < " " < < name_helpers : : klass_concrete_name ( cls ) < < " : "
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
< < ( klass_full_concrete_or_interface_name % " , " ) // classes
csharp: Refactor wrapper lifetime.
Summary:
This commit makes use of the `ownership,shared` and `ownership,unique`
events from Efl.Object in order to avoid the C# wrapper from being
collected while C code holds a reference to the object.
For example, creating a list of items in a for loop and attaching events to
them would fails without this commit, as the C# GC may collect the wrapper.
The basic idea is that we use a `WrapperSupervisor`, which is stored in
the Eo data storage, with a GCHandle allocated for the lifetime of the
underlying Eo object. This supervisor takes care of holding either a
weak C# reference (when in unique mode, allowing the wrapper to be GC'd)
or a hard C# reference (when in shared mode, making the wrapper
non-collectable while the Eo has extra references).
One limitation is that object graphs can leak if a shared object in the
graph - an Eo child for example - stores a hard reference to another
object in the graph as a C# field. In this example, this causes the
parent to always have a hard C# reference (from the child) as the child
is non-collectable due to the parent holding an Eo reference to it.
Depends on D8678
Test Plan: `ninja test` and `make test`
Reviewers: lauromoura, felipealmeida, woohyun, segfaultxavi
Reviewed By: lauromoura
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D9014
2019-05-31 13:43:11 -07:00
< < ( root ? " Efl.Eo.EoWrapper " : " " ) // ... or root
< < ( inherit_interfaces . empty ( ) ? " " : " , " )
< < ( klass_full_concrete_or_interface_name % " , " ) // interfaces
2020-01-12 16:45:16 -08:00
< < " \n " < < scope_tab < < " { \n "
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
)
. generate ( sink , std : : make_tuple ( cls , inherit_classes , inherit_interfaces ) , inherit_cxt ) )
return false ;
// Class body
if ( ! generate_fields ( sink , cls , inherit_cxt ) )
return false ;
if ( ! generate_constructors ( sink , cls , inherit_cxt ) )
return false ;
2017-11-23 16:50:16 -08:00
if ( ! generate_events ( sink , cls , inherit_cxt ) )
return false ;
2018-03-19 16:35:36 -07:00
// Parts
if ( ! as_generator ( * ( part_definition ) )
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
. generate ( sink , cls . parts , inherit_cxt ) ) return false ;
2018-03-19 16:35:36 -07:00
2017-11-23 16:50:16 -08:00
// Inherit function definitions
2019-07-11 01:19:53 -07:00
auto implemented_methods = helpers : : get_all_implementable_methods ( cls , inherit_cxt ) ;
2017-11-23 16:50:16 -08:00
if ( ! as_generator ( * ( function_definition ( 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
. generate ( sink , implemented_methods , inherit_cxt ) ) return false ;
2017-11-23 16:50:16 -08:00
2018-05-07 15:22:59 -07:00
// Async wrappers
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 ( ! as_generator ( * ( async_function_definition ( true ) ) ) . generate ( sink , implemented_methods , inherit_cxt ) )
2018-05-07 15:22:59 -07:00
return false ;
2018-12-14 12:17:23 -08:00
// Property wrappers
2020-01-20 14:00:44 -08:00
if ( ! as_generator ( * ( property_wrapper_definition ( cls ) ) ) . generate ( sink , cls . properties , inherit_cxt ) )
2018-12-14 12:17:23 -08:00
return false ;
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
for ( auto & & klass : helpers : : non_implemented_interfaces ( cls , inherit_cxt ) )
2018-12-14 12:17:23 -08:00
{
attributes : : klass_def c ( get_klass ( klass , cls . unit ) , cls . unit ) ;
2020-01-20 14:00:44 -08:00
if ( ! as_generator ( * ( property_wrapper_definition ( cls ) ) ) . generate ( sink , c . properties , inherit_cxt ) )
2018-12-14 12:17:23 -08:00
return false ;
}
2019-02-06 11:50:28 -08:00
// Copied from nativeinherit class, used when setting up providers.
if ( ! as_generator (
2020-01-12 16:45:16 -08:00
scope_tab ( 2 ) < < " private static IntPtr GetEflClassStatic() \n "
< < scope_tab ( 2 ) < < " { \n "
< < scope_tab ( 2 ) < < scope_tab < < " return " < < name_helpers : : klass_get_full_name ( cls ) < < " (); \n "
< < scope_tab ( 2 ) < < " } \n \n "
2019-02-06 11:50:28 -08:00
) . generate ( sink , attributes : : unused , inherit_cxt ) )
return false ;
2019-06-28 06:29:01 -07:00
if ( ! generate_native_inherit_class ( sink , cls , change_indentation ( indent . inc ( ) , inherit_cxt ) ) )
2019-04-23 02:48:03 -07:00
return true ;
2020-01-12 16:45:16 -08:00
if ( ! as_generator ( scope_tab < < " } \n " ) . generate ( sink , attributes : : unused , inherit_cxt ) ) return false ;
2017-11-23 16:50:16 -08:00
}
2019-04-23 02:48:03 -07:00
if ( ! name_helpers : : close_namespaces ( sink , cls . namespaces , context ) )
return false ;
2019-08-19 17:31:20 -07:00
std : : vector < attributes : : property_def > implementable_properties ;
std : : copy ( cls . properties . begin ( ) , cls . properties . end ( ) , std : : back_inserter ( implementable_properties ) ) ;
for ( auto & & klass : helpers : : non_implemented_interfaces ( cls , context ) )
{
attributes : : klass_def c ( get_klass ( klass , cls . unit ) , cls . unit ) ;
std : : copy ( c . properties . begin ( ) , c . properties . end ( ) , std : : back_inserter ( implementable_properties ) ) ;
}
2019-12-23 00:18:02 -08:00
std : : stringstream extension_method_stream ;
std : : ostream_iterator < char > extension_method_iterator ( extension_method_stream ) ;
if ( ! as_generator
( * property_extension_method_definition ( cls )
< < * part_extension_method_definition ( cls ) )
. generate ( extension_method_iterator , std : : make_tuple ( implementable_properties , cls . parts ) , context ) )
return false ;
if ( extension_method_stream . tellp ( ) < = 0 )
2019-12-18 23:30:48 -08:00
return true ;
2020-01-06 02:07:28 -08:00
if ( ! name_helpers : : open_namespaces ( sink , cls . namespaces , context ) )
return false ;
2019-08-05 07:17:52 -07:00
if ( ! as_generator
2019-08-23 10:18:42 -07:00
( lit ( " #if EFL_BETA \n " )
< < " #pragma warning disable CS1591 \n " // Disabling warnings as DocFx will hide these classes
2020-01-12 16:45:16 -08:00
< < scope_tab < < " public static class " < < name_helpers : : klass_concrete_name ( cls )
2020-01-06 02:08:44 -08:00
< < " Extensions { \n "
2019-12-23 00:18:02 -08:00
< < extension_method_stream . str ( )
2020-01-12 16:45:16 -08:00
< < scope_tab < < " } \n "
2019-08-23 10:18:42 -07:00
< < " #pragma warning restore CS1591 \n "
< < " #endif \n " )
2019-12-23 00:18:02 -08:00
. generate ( sink , cls . namespaces , context ) )
2019-08-05 07:17:52 -07:00
return false ;
2020-01-06 02:07:28 -08:00
if ( ! name_helpers : : close_namespaces ( sink , cls . namespaces , context ) )
return false ;
2019-04-23 02:48:03 -07:00
return true ;
}
// NativeInherit class. Contains function pointers for the native Eo methods and delegates that are registered in Eo as virtual method implementations
// These delegates are called from C to C#, checking whether the C# subclass reimplemented it.
template < typename OutputIterator , typename Context >
bool generate_native_inherit_class ( OutputIterator sink , attributes : : klass_def const & cls , Context const & context ) const
{
2017-11-23 16:50:16 -08:00
{
2019-04-11 03:40:21 -07:00
auto inative_cxt = context_add_tag ( class_context { class_context : : inherit_native ,
name_helpers : : klass_full_concrete_or_interface_name ( cls ) } ,
context ) ;
2018-04-27 14:08:25 -07:00
auto native_inherit_name = name_helpers : : klass_native_inherit_name ( cls ) ;
2018-12-14 14:39:09 -08:00
auto inherit_name = name_helpers : : klass_inherit_name ( cls ) ;
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
auto implementable_methods = helpers : : get_all_registerable_methods ( cls , context ) ;
2019-04-23 02:48:03 -07:00
bool root = ! helpers : : has_regular_ancestor ( cls ) ;
2020-01-12 16:45:16 -08:00
auto const & indent = current_indentation ( inative_cxt ) . inc ( ) ;
2019-11-26 06:13:47 -08:00
std : : string klass_since ;
if ( ! documentation_helpers : : generate_since_tag_line ( std : : back_inserter ( klass_since ) , cls . documentation , indent , context ) )
return false ;
2019-04-23 02:48:03 -07:00
2018-12-14 14:39:09 -08:00
std : : string base_name ;
if ( ! root )
{
attributes : : klass_def parent_klass ( get_klass ( * cls . parent , cls . unit ) , cls . unit ) ;
base_name = name_helpers : : klass_full_native_inherit_name ( parent_klass ) ;
}
2017-11-23 16:50:16 -08:00
if ( ! as_generator
(
2019-04-23 02:48:03 -07:00
indent < < lit ( " /// <summary>Wrapper for native methods and virtual method delegates. \n " )
2019-11-26 06:13:47 -08:00
< < indent < < " /// For internal use by generated code only. \n "
< < klass_since
< < indent < < " /// </summary> \n "
< < indent < < " [EditorBrowsable(EditorBrowsableState.Never)] \n "
2019-10-28 14:48:26 -07:00
< < indent < < " internal new class " < < native_inherit_name < < " : " < < ( root ? " Efl.Eo.EoWrapper.NativeMethods " : base_name ) < < " \n "
2019-04-23 02:48:03 -07:00
< < indent < < " { \n "
) . generate ( sink , attributes : : unused , inative_cxt ) )
return false ;
if ( implementable_methods . size ( ) > = 1 )
{
if ( ! as_generator (
indent < < scope_tab < < " private static Efl.Eo.NativeModule Module = new Efl.Eo.NativeModule( "
2019-09-23 16:50:27 -07:00
< < context_find_tag < library_context > ( context ) . actual_library_name ( cls . filename ) < < " ); \n \n "
2019-04-23 02:48:03 -07:00
) . generate ( sink , attributes : : unused , inative_cxt ) )
return false ;
}
if ( ! as_generator (
2019-11-26 06:13:47 -08:00
indent < < scope_tab < < " /// <summary>Gets the list of Eo operations to override. \n "
< < klass_since
< < indent < < " /// </summary> \n "
2019-04-23 02:48:03 -07:00
< < indent < < scope_tab < < " /// <returns>The list of Eo operations to be overload.</returns> \n "
2019-10-28 14:48:26 -07:00
< < indent < < scope_tab < < " internal override System.Collections.Generic.List<EflOpDescription> GetEoOps(System.Type type, bool includeInherited) \n "
2019-04-23 02:48:03 -07:00
< < indent < < scope_tab < < " { \n "
2019-10-17 09:57:22 -07:00
< < indent < < scope_tab < < scope_tab < < " var descs = new System.Collections.Generic.List<EflOpDescription>(); \n "
2017-11-23 16:50:16 -08:00
)
2019-01-17 04:33:09 -08:00
. generate ( sink , attributes : : unused , inative_cxt ) )
2017-11-23 16:50:16 -08:00
return false ;
// Native wrapper registration
2019-04-15 11:45:40 -07:00
// We write them first to a temporary function as the implementable function list may contain
// only non-registrable methods like class functions, leading to unused `methods` variable.
std : : string tmp_registration ;
2019-01-17 04:33:09 -08:00
if ( ! as_generator ( * ( function_registration ( cls ) ) )
2019-04-23 02:48:03 -07:00
. generate ( std : : back_inserter ( tmp_registration ) , implementable_methods , change_indentation ( indent . inc ( 2 ) , inative_cxt ) ) )
2019-04-15 11:45:40 -07:00
return false ;
if ( tmp_registration . find ( " methods " ) ! = std : : string : : npos )
if ( ! as_generator (
2019-04-23 02:48:03 -07:00
indent < < scope_tab < < scope_tab < < " var methods = Efl.Eo.Globals.GetUserMethods(type); \n \n "
2019-04-15 11:45:40 -07:00
< < tmp_registration
) . generate ( sink , attributes : : unused , inative_cxt ) )
return false ;
2019-09-08 18:13:40 -07:00
if ( ! as_generator (
indent < < scope_tab < < scope_tab < < " if (includeInherited) \n "
< < indent < < scope_tab ( 2 ) < < " { \n "
< < indent < < scope_tab ( 3 ) < < " var all_interfaces = type.GetInterfaces(); \n "
< < indent < < scope_tab ( 3 ) < < " foreach (var iface in all_interfaces) \n "
< < indent < < scope_tab ( 3 ) < < " { \n "
< < indent < < scope_tab ( 4 ) < < " var moredescs = ((Efl.Eo.NativeClass)iface.GetCustomAttributes(false)?.FirstOrDefault(attr => attr is Efl.Eo.NativeClass))?.GetEoOps(type, false); \n "
< < indent < < scope_tab ( 4 ) < < " if (moredescs != null) \n "
< < indent < < scope_tab ( 5 ) < < " descs.AddRange(moredescs); \n "
< < indent < < scope_tab ( 3 ) < < " } \n "
< < indent < < scope_tab ( 2 ) < < " } \n "
) . generate ( sink , attributes : : unused , inative_cxt ) )
return false ;
2019-06-28 06:29:01 -07:00
if ( ! root | | context_find_tag < class_context > ( context ) . current_wrapper_kind ! = class_context : : concrete )
2019-09-08 18:13:40 -07:00
if ( ! as_generator ( indent < < scope_tab < < scope_tab < < " descs.AddRange(base.GetEoOps(type, false)); \n " ) . generate ( sink , attributes : : unused , inative_cxt ) )
2018-12-14 14:39:09 -08:00
return false ;
if ( ! as_generator (
2019-04-23 02:48:03 -07:00
indent < < scope_tab < < scope_tab < < " return descs; \n "
2019-09-23 16:50:27 -07:00
< < indent < < scope_tab < < " } \n \n "
2018-12-14 14:39:09 -08:00
) . generate ( sink , attributes : : unused , inative_cxt ) )
return false ;
2019-11-26 06:13:47 -08:00
if ( ! klass_since . empty ( ) )
2020-01-12 16:45:16 -08:00
klass_since = static_cast < std : : string > ( scope_tab ( 2 ) ) + klass_since ;
2019-11-26 06:13:47 -08:00
2019-01-17 04:33:09 -08:00
// Attribute getter of the native 'Efl_Class *' handle (for proper inheritance from additional explicit interfaces)
if ( ! as_generator (
2019-11-26 06:13:47 -08:00
indent < < scope_tab < < " /// <summary>Returns the Eo class for the native methods of this class. \n "
< < klass_since
< < indent < < scope_tab < < " /// </summary> \n "
2019-04-23 02:48:03 -07:00
< < indent < < scope_tab < < " /// <returns>The native class pointer.</returns> \n "
2019-10-28 14:48:26 -07:00
< < indent < < scope_tab < < " internal override IntPtr GetEflClass() \n "
2019-04-23 02:48:03 -07:00
< < indent < < scope_tab < < " { \n "
< < indent < < scope_tab < < scope_tab < < " return " < < name_helpers : : klass_get_full_name ( cls ) < < " (); \n "
< < indent < < scope_tab < < " } \n \n "
2019-01-17 04:33:09 -08:00
) . generate ( sink , attributes : : unused , inative_cxt ) )
return false ;
csharp: Make classes abstract and rework casting
Summary:
Abstract Eo classes are now proper C# abstract classes.
As a side effect, returning Eo instances from native code was reworked
to return instances of their actual Eo classes instead of previous
behavior of returning a generic Efl.Object and using static_cast.
Instead of `var window = Efl.Ui.Win.static_cast(widget.GetParent());`
Use `var window = widget.GetParent() as Efl.Ui.Win;`
Another side effect was that `efl_constructor` was removed from the list
of supported `Efl.Object` overrides. It is invoked inside
`efl_add_internal_start`, before the bindings makes the association of
the newly created EoId with the C# instance that created it, making the
managed delegate meaningless. C# users then can use regular C#
constructors to initialize fields.
Also changed to set the private data of C#-inherited classes before the
call to constructing methods (aka constructor parameters) so C# classes
can override them correctly.
Fixes T7778
Fixes T7757
Reviewers: vitor.sousa, felipealmeida, segfaultxavi
Reviewed By: vitor.sousa, segfaultxavi
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Maniphest Tasks: T7778, T7757, T7702
Differential Revision: https://phab.enlightenment.org/D8550
2019-04-05 15:53:37 -07:00
2017-11-23 16:50:16 -08:00
// Native method definitions
2019-04-23 02:48:03 -07:00
if ( ! as_generator (
2019-05-03 01:09:58 -07:00
indent < < scope_tab < < " #pragma warning disable CA1707, CS1591, SA1300, SA1600 \n \n "
2019-04-23 02:48:03 -07:00
< < * ( native_function_definition ( cls ) )
2019-05-03 01:09:58 -07:00
< < indent < < scope_tab < < " #pragma warning restore CA1707, CS1591, SA1300, SA1600 \n \n " )
2019-04-23 02:48:03 -07:00
. generate ( sink , implementable_methods , change_indentation ( indent . inc ( ) , inative_cxt ) ) ) return false ;
2017-11-23 16:50:16 -08:00
2020-01-12 16:45:16 -08:00
if ( ! as_generator ( indent < < " } \n " ) . generate ( sink , attributes : : unused , inative_cxt ) ) return false ;
2017-11-23 16:50:16 -08:00
}
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
template < typename OutputIterator , typename Context >
bool generate_fields ( OutputIterator sink , attributes : : klass_def const & cls , Context const & context ) const
{
std : : string visibility = is_inherit_context ( context ) ? " protected " : " private " ;
2019-01-17 04:33:09 -08:00
std : : string class_getter = name_helpers : : klass_get_name ( cls ) + " () " ;
2018-12-14 14:39:09 -08:00
std : : string native_inherit_full_name = name_helpers : : klass_full_native_inherit_name ( cls ) ;
2019-01-17 04:33:09 -08:00
auto inherit_name = name_helpers : : klass_concrete_name ( cls ) ;
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 ( ! as_generator (
2020-01-12 16:45:16 -08:00
scope_tab ( 2 ) < < " /// <summary>Pointer to the native class description.</summary> \n "
< < scope_tab ( 2 ) < < " public override System.IntPtr NativeClass \n "
< < scope_tab ( 2 ) < < " { \n "
< < scope_tab ( 2 ) < < scope_tab < < " get \n "
< < scope_tab ( 2 ) < < scope_tab < < " { \n "
< < scope_tab ( 2 ) < < scope_tab < < scope_tab < < " if (((object)this).GetType() == typeof( " < < inherit_name < < " )) \n "
< < scope_tab ( 2 ) < < scope_tab < < scope_tab < < " { \n "
< < scope_tab ( 2 ) < < scope_tab < < scope_tab < < scope_tab < < " return GetEflClassStatic(); \n "
< < scope_tab ( 2 ) < < scope_tab < < scope_tab < < " } \n "
< < scope_tab ( 2 ) < < scope_tab < < scope_tab < < " else \n "
< < scope_tab ( 2 ) < < scope_tab < < scope_tab < < " { \n "
< < scope_tab ( 2 ) < < scope_tab < < scope_tab < < scope_tab < < " return Efl.Eo.ClassRegister.klassFromType[((object)this).GetType()]; \n "
< < scope_tab ( 2 ) < < scope_tab < < scope_tab < < " } \n "
< < scope_tab ( 2 ) < < scope_tab < < " } \n "
< < scope_tab ( 2 ) < < " } \n \n "
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
) . generate ( sink , attributes : : unused , context ) )
return false ;
csharp: Refactor wrapper lifetime.
Summary:
This commit makes use of the `ownership,shared` and `ownership,unique`
events from Efl.Object in order to avoid the C# wrapper from being
collected while C code holds a reference to the object.
For example, creating a list of items in a for loop and attaching events to
them would fails without this commit, as the C# GC may collect the wrapper.
The basic idea is that we use a `WrapperSupervisor`, which is stored in
the Eo data storage, with a GCHandle allocated for the lifetime of the
underlying Eo object. This supervisor takes care of holding either a
weak C# reference (when in unique mode, allowing the wrapper to be GC'd)
or a hard C# reference (when in shared mode, making the wrapper
non-collectable while the Eo has extra references).
One limitation is that object graphs can leak if a shared object in the
graph - an Eo child for example - stores a hard reference to another
object in the graph as a C# field. In this example, this causes the
parent to always have a hard C# reference (from the child) as the child
is non-collectable due to the parent holding an Eo reference to it.
Depends on D8678
Test Plan: `ninja test` and `make test`
Reviewers: lauromoura, felipealmeida, woohyun, segfaultxavi
Reviewed By: lauromoura
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D9014
2019-05-31 13:43:11 -07:00
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
}
template < typename OutputIterator , typename Context >
bool generate_constructors ( OutputIterator sink , attributes : : klass_def const & cls , Context const & context ) const
{
auto inherit_name = name_helpers : : klass_concrete_name ( cls ) ;
if ( ! as_generator (
2020-01-12 16:45:16 -08:00
scope_tab ( 2 ) < < " [System.Runtime.InteropServices.DllImport( " < < context_find_tag < library_context > ( context ) . actual_library_name ( cls . filename )
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
< < " )] internal static extern System.IntPtr \n "
2020-01-12 16:45:16 -08:00
< < scope_tab ( 2 ) < < scope_tab < < name_helpers : : klass_get_name ( cls ) < < " (); \n \n "
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
) . generate ( sink , attributes : : unused , context ) )
return false ;
2019-03-07 01:54:35 -08:00
auto all_constructors = helpers : : reorder_constructors ( cls . get_all_constructors ( ) ) ;
decltype ( all_constructors ) constructors ;
std : : copy_if ( all_constructors . cbegin ( ) , all_constructors . cend ( ) , std : : back_inserter ( constructors ) , [ & context ] ( attributes : : constructor_def const & ctor ) {
return ! blacklist : : is_function_blacklisted ( ctor . function , 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-11-26 06:13:47 -08:00
std : : string klass_since ;
2020-01-12 16:45:16 -08:00
if ( ! documentation_helpers : : generate_since_tag_line ( std : : back_inserter ( klass_since ) , cls . documentation , scope_tab ( 2 ) , context ) )
2019-11-26 06:13:47 -08:00
return false ;
2019-02-01 11:03:02 -08:00
// Public (API) constructors
if ( ! as_generator (
2020-01-12 16:45:16 -08:00
scope_tab ( 2 ) < < " /// <summary>Initializes a new instance of the <see cref= \" " < < inherit_name < < " \" /> class. \n "
2019-11-26 06:13:47 -08:00
< < klass_since
2020-01-12 16:45:16 -08:00
< < scope_tab ( 2 ) < < " /// </summary> \n "
< < scope_tab ( 2 ) < < " /// <param name= \" parent \" >Parent instance.</param> \n "
< < * ( documentation ( 1 ) )
2019-02-01 11:03:02 -08:00
// For constructors with arguments, the parent is also required, as optional parameters can't come before non-optional paramenters.
2020-01-12 16:45:16 -08:00
< < scope_tab ( 2 ) < < " public " < < inherit_name < < " (Efl.Object parent " < < ( ( constructors . size ( ) > 0 ) ? " " : " = null " )
2019-11-06 18:34:18 -08:00
< < * ( " , " < < constructor_param ) < < " ) : "
< < " base( " < < name_helpers : : klass_get_name ( cls ) < < " (), parent) \n "
2020-01-12 16:45:16 -08:00
< < scope_tab ( 2 ) < < " { \n "
2019-04-22 14:07:11 -07:00
< < ( * ( scope_tab < < scope_tab < < constructor_invocation < < " \n " ) )
2020-01-12 16:45:16 -08:00
< < scope_tab ( 2 ) < < scope_tab < < " FinishInstantiation(); \n "
< < scope_tab ( 2 ) < < " } \n \n "
< < scope_tab ( 2 ) < < " /// <summary>Subclasses should override this constructor if they are expected to be instantiated from native code. \n "
< < scope_tab ( 2 ) < < " /// Do not call this constructor directly. \n "
2019-11-26 06:13:47 -08:00
< < klass_since
2020-01-12 16:45:16 -08:00
< < scope_tab ( 2 ) < < " /// </summary> \n "
< < scope_tab ( 2 ) < < " /// <param name= \" ch \" >Tag struct storing the native handle of the object being constructed.</param> \n "
< < scope_tab ( 2 ) < < " protected " < < inherit_name < < " (ConstructingHandle ch) : base(ch) \n "
< < scope_tab ( 2 ) < < " { \n "
< < scope_tab ( 2 ) < < " } \n \n "
< < scope_tab ( 2 ) < < " /// <summary>Initializes a new instance of the <see cref= \" " < < inherit_name < < " \" /> class. \n "
< < scope_tab ( 2 ) < < " /// Internal usage: Constructs an instance from a native pointer. This is used when interacting with C code and should not be used directly. \n "
2019-11-26 06:13:47 -08:00
< < klass_since
2020-01-12 16:45:16 -08:00
< < scope_tab ( 2 ) < < " /// </summary> \n "
< < scope_tab ( 2 ) < < " /// <param name= \" wh \" >The native pointer to be wrapped.</param> \n "
< < scope_tab ( 2 ) < < " internal " < < inherit_name < < " (Efl.Eo.WrappingHandle wh) : base(wh) \n "
< < scope_tab ( 2 ) < < " { \n "
< < scope_tab ( 2 ) < < " } \n \n "
2019-02-01 11:03:02 -08:00
) . generate ( sink , std : : make_tuple ( constructors , constructors , constructors ) , context ) )
return false ;
csharp: Make classes abstract and rework casting
Summary:
Abstract Eo classes are now proper C# abstract classes.
As a side effect, returning Eo instances from native code was reworked
to return instances of their actual Eo classes instead of previous
behavior of returning a generic Efl.Object and using static_cast.
Instead of `var window = Efl.Ui.Win.static_cast(widget.GetParent());`
Use `var window = widget.GetParent() as Efl.Ui.Win;`
Another side effect was that `efl_constructor` was removed from the list
of supported `Efl.Object` overrides. It is invoked inside
`efl_add_internal_start`, before the bindings makes the association of
the newly created EoId with the C# instance that created it, making the
managed delegate meaningless. C# users then can use regular C#
constructors to initialize fields.
Also changed to set the private data of C#-inherited classes before the
call to constructing methods (aka constructor parameters) so C# classes
can override them correctly.
Fixes T7778
Fixes T7757
Reviewers: vitor.sousa, felipealmeida, segfaultxavi
Reviewed By: vitor.sousa, segfaultxavi
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Maniphest Tasks: T7778, T7757, T7702
Differential Revision: https://phab.enlightenment.org/D8550
2019-04-05 15:53:37 -07:00
// Some abstract classes (like Efl.App) have a simple regular class that is used to instantiate them
// in a controlled manner. These fake-private classes can be returned from C and we use a similarly-named
// private class to be able to instantiate them when they get to the C# world.
if ( cls . type = = attributes : : class_type : : abstract_ )
{
if ( ! as_generator (
2020-01-12 16:45:16 -08:00
scope_tab ( 2 ) < < " [Efl.Eo.PrivateNativeClass] \n "
< < scope_tab ( 2 ) < < " private class " < < inherit_name < < " Realized : " < < inherit_name < < " \n "
< < scope_tab ( 2 ) < < " { \n "
< < scope_tab ( 2 ) < < scope_tab < < " private " < < inherit_name < < " Realized(Efl.Eo.WrappingHandle wh) : base(wh) \n "
< < scope_tab ( 2 ) < < scope_tab < < " { \n "
< < scope_tab ( 2 ) < < scope_tab < < " } \n "
< < scope_tab ( 2 ) < < " } \n "
csharp: Make classes abstract and rework casting
Summary:
Abstract Eo classes are now proper C# abstract classes.
As a side effect, returning Eo instances from native code was reworked
to return instances of their actual Eo classes instead of previous
behavior of returning a generic Efl.Object and using static_cast.
Instead of `var window = Efl.Ui.Win.static_cast(widget.GetParent());`
Use `var window = widget.GetParent() as Efl.Ui.Win;`
Another side effect was that `efl_constructor` was removed from the list
of supported `Efl.Object` overrides. It is invoked inside
`efl_add_internal_start`, before the bindings makes the association of
the newly created EoId with the C# instance that created it, making the
managed delegate meaningless. C# users then can use regular C#
constructors to initialize fields.
Also changed to set the private data of C#-inherited classes before the
call to constructing methods (aka constructor parameters) so C# classes
can override them correctly.
Fixes T7778
Fixes T7757
Reviewers: vitor.sousa, felipealmeida, segfaultxavi
Reviewed By: vitor.sousa, segfaultxavi
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Maniphest Tasks: T7778, T7757, T7702
Differential Revision: https://phab.enlightenment.org/D8550
2019-04-05 15:53:37 -07:00
) . generate ( sink , attributes : : unused , context ) )
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
return as_generator (
2020-01-12 16:45:16 -08:00
scope_tab ( 2 ) < < " /// <summary>Initializes a new instance of the <see cref= \" " < < inherit_name < < " \" /> class. \n "
< < scope_tab ( 2 ) < < " /// Internal usage: Constructor to forward the wrapper initialization to the root class that interfaces with native code. Should not be used directly. \n "
2019-11-26 06:13:47 -08:00
< < klass_since
2020-01-12 16:45:16 -08:00
< < scope_tab ( 2 ) < < " /// </summary> \n "
< < scope_tab ( 2 ) < < " /// <param name= \" baseKlass \" >The pointer to the base native Eo class.</param> \n "
< < scope_tab ( 2 ) < < " /// <param name= \" parent \" >The Efl.Object parent of this instance.</param> \n "
< < scope_tab ( 2 ) < < " protected " < < inherit_name < < " (IntPtr baseKlass, Efl.Object parent) : base(baseKlass, parent) \n "
< < scope_tab ( 2 ) < < " { \n "
< < scope_tab ( 2 ) < < " } \n \n "
csharp: Refactor wrapper lifetime.
Summary:
This commit makes use of the `ownership,shared` and `ownership,unique`
events from Efl.Object in order to avoid the C# wrapper from being
collected while C code holds a reference to the object.
For example, creating a list of items in a for loop and attaching events to
them would fails without this commit, as the C# GC may collect the wrapper.
The basic idea is that we use a `WrapperSupervisor`, which is stored in
the Eo data storage, with a GCHandle allocated for the lifetime of the
underlying Eo object. This supervisor takes care of holding either a
weak C# reference (when in unique mode, allowing the wrapper to be GC'd)
or a hard C# reference (when in shared mode, making the wrapper
non-collectable while the Eo has extra references).
One limitation is that object graphs can leak if a shared object in the
graph - an Eo child for example - stores a hard reference to another
object in the graph as a C# field. In this example, this causes the
parent to always have a hard C# reference (from the child) as the child
is non-collectable due to the parent holding an Eo reference to it.
Depends on D8678
Test Plan: `ninja test` and `make test`
Reviewers: lauromoura, felipealmeida, woohyun, segfaultxavi
Reviewed By: lauromoura
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D9014
2019-05-31 13:43:11 -07:00
) . 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
}
2017-11-23 16:50:16 -08:00
template < typename OutputIterator , typename Context >
bool generate_events ( OutputIterator sink , attributes : : klass_def const & cls , Context const & context ) const
{
if ( ! has_events ( cls ) )
return true ;
// Self events
2019-09-23 16:50:27 -07:00
if ( ! as_generator ( * ( event_definition ( cls , cls ) ) < < " \n " ) . generate ( sink , cls . events , context ) )
2018-04-16 17:44:27 -07:00
return false ;
2017-11-23 16:50:16 -08:00
// Inherited events
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
// For now, as mixins can inherit from regular classes, we can't filter out inherited events.
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 inherits = helpers : : non_implemented_interfaces ( cls , 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
for ( auto & & c : inherits )
2017-11-23 16:50:16 -08:00
{
2017-12-06 08:27:27 -08:00
attributes : : klass_def klass ( get_klass ( c , cls . unit ) , cls . unit ) ;
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 ( ! as_generator ( * ( event_definition ( klass , cls ) ) ) . generate ( sink , klass . events , context ) )
2018-04-16 17:44:27 -07:00
return false ;
2017-11-23 16:50:16 -08:00
}
return true ;
}
2019-08-23 10:27:28 -07:00
bool is_partial ;
klass const operator ( ) ( partial_class ) const
{
return klass { true } ;
}
2017-11-23 16:50:16 -08:00
} ;
2019-08-23 10:27:28 -07:00
struct klass const klass = { false } ;
2017-11-23 16:50:16 -08:00
}
namespace efl { namespace eolian { namespace grammar {
template < >
struct is_eager_generator < struct : : eolian_mono : : klass > : std : : true_type { } ;
template < >
struct is_generator < struct : : eolian_mono : : klass > : std : : true_type { } ;
namespace type_traits {
template < >
struct attributes_needed < struct : : eolian_mono : : klass > : std : : integral_constant < int , 1 > { } ;
}
} } }
# endif