2017-11-23 16:50:16 -08:00
|
|
|
#ifndef EOLIAN_MONO_FUNCTION_POINTER_HPP
|
|
|
|
#define EOLIAN_MONO_FUNCTION_POINTER_HPP
|
|
|
|
|
|
|
|
#include <Eolian.h>
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
|
|
|
|
2018-03-21 18:39:17 -07:00
|
|
|
#include "function_helpers.hh"
|
2017-12-06 16:03:55 -08:00
|
|
|
#include "documentation.hh"
|
2018-03-21 18:39:17 -07:00
|
|
|
#include "generation_contexts.hh"
|
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
|
|
|
#include "blacklist.hh"
|
2017-12-06 16:03:55 -08:00
|
|
|
|
2017-11-23 16:50:16 -08:00
|
|
|
namespace eolian_mono {
|
|
|
|
|
|
|
|
// Blacklist structs that require some kind of manual binding.
|
efl-csharp: Respect beta for classes and other stuff.
Summary:
In order to work around an issue with Efl.App, which is stable but
inherits from Efl.Core.Command_Line, @beta interfaces/mixins in the
inheritance chain are simply skipped.
Also changed the class used int test for inheritance from C#
Efl.Loop is stable but internally it uses a @beta class as argument to
its Register() method in the constructor. When instantiating a
user-defined C# subclass, the binding calls the C# override in the
NativeInherit class and the marshalling fails as no code is generated
for the beta class.
Also moved Efl.Part test to a beta class. Efl.Part is still beta.
Regarding parts, they are skipped if its class is @beta too.
Also rejected all elm_* files in elm public eo files. They should get
back in as they are converted to Efl.Ui.* api. An exception is
elm_interface_scrollable.eo, as efl_ui_panel depends on it.
Fixes T7730
Test Plan: Run tests
Reviewers: vitor.sousa, segfaultxavi, felipealmeida, cedric, bu5hm4n, zmike
Reviewed By: vitor.sousa
Subscribers: #reviewers, #committers
Tags: #efl
Maniphest Tasks: T7730
Differential Revision: https://phab.enlightenment.org/D8268
2019-03-11 11:46:12 -07:00
|
|
|
template <typename Context>
|
2019-03-22 14:37:50 -07:00
|
|
|
static bool is_function_ptr_blacklisted(attributes::function_def const& func, Context const& context)
|
2017-11-23 16:50:16 -08:00
|
|
|
{
|
2018-04-27 14:08:25 -07:00
|
|
|
std::string name = name_helpers::function_ptr_full_eolian_name(func);
|
2017-11-23 16:50:16 -08:00
|
|
|
|
efl-csharp: Respect beta for classes and other stuff.
Summary:
In order to work around an issue with Efl.App, which is stable but
inherits from Efl.Core.Command_Line, @beta interfaces/mixins in the
inheritance chain are simply skipped.
Also changed the class used int test for inheritance from C#
Efl.Loop is stable but internally it uses a @beta class as argument to
its Register() method in the constructor. When instantiating a
user-defined C# subclass, the binding calls the C# override in the
NativeInherit class and the marshalling fails as no code is generated
for the beta class.
Also moved Efl.Part test to a beta class. Efl.Part is still beta.
Regarding parts, they are skipped if its class is @beta too.
Also rejected all elm_* files in elm public eo files. They should get
back in as they are converted to Efl.Ui.* api. An exception is
elm_interface_scrollable.eo, as efl_ui_panel depends on it.
Fixes T7730
Test Plan: Run tests
Reviewers: vitor.sousa, segfaultxavi, felipealmeida, cedric, bu5hm4n, zmike
Reviewed By: vitor.sousa
Subscribers: #reviewers, #committers
Tags: #efl
Maniphest Tasks: T7730
Differential Revision: https://phab.enlightenment.org/D8268
2019-03-11 11:46:12 -07:00
|
|
|
return blacklist::is_function_blacklisted(func, context);
|
2017-11-23 16:50:16 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
struct function_pointer {
|
|
|
|
template <typename OutputIterator, typename Context>
|
2018-04-27 14:08:25 -07:00
|
|
|
bool generate(OutputIterator sink, attributes::function_def const& f, Context const& context) const
|
2017-11-23 16:50:16 -08:00
|
|
|
{
|
2018-04-27 14:08:25 -07:00
|
|
|
EINA_CXX_DOM_LOG_DBG(eolian_mono::domain) << "function_pointer_generator: " << f.name << std::endl;
|
2017-11-23 16:50:16 -08:00
|
|
|
// FIXME export Typedecl in eolian_cxx API
|
2018-03-21 18:39:17 -07:00
|
|
|
auto funcptr_ctx = context_add_tag(class_context{class_context::function_ptr}, 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 (is_function_ptr_blacklisted(f, context))
|
|
|
|
return true;
|
|
|
|
|
2018-03-21 18:39:17 -07:00
|
|
|
std::string return_type;
|
|
|
|
if(!as_generator(eolian_mono::type(true)).generate(std::back_inserter(return_type), f.return_type, context))
|
|
|
|
return false;
|
2017-11-23 16:50:16 -08:00
|
|
|
|
2018-04-27 14:08:25 -07:00
|
|
|
if (!name_helpers::open_namespaces(sink, f.namespaces, funcptr_ctx))
|
|
|
|
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
|
|
|
std::string f_name = name_helpers::typedecl_managed_name(f);
|
|
|
|
|
2017-11-23 16:50:16 -08:00
|
|
|
// C# visible delegate
|
2017-12-06 16:03:55 -08:00
|
|
|
if (!as_generator(documentation
|
|
|
|
<< "public delegate " << type << " " << string
|
2017-11-23 16:50:16 -08:00
|
|
|
<< "(" << (parameter % ", ") << ");\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(f, f.return_type, f_name, f.parameters), funcptr_ctx))
|
2017-11-23 16:50:16 -08:00
|
|
|
return false;
|
|
|
|
// "Internal" delegate, 1-to-1 with the Unamaged function type
|
2019-01-15 23:29:56 -08:00
|
|
|
if (!as_generator(marshall_annotation(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
|
|
|
<< "public delegate " << marshall_type(true) << " " << string // public?
|
2019-01-15 23:29:56 -08:00
|
|
|
<< "Internal(IntPtr data" << *grammar::attribute_reorder<-1, -1>((", " << marshall_annotation << " " << marshall_parameter)) << ");\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(f.return_type, f.return_type, f_name, f.parameters), funcptr_ctx))
|
2017-11-23 16:50:16 -08:00
|
|
|
return false;
|
|
|
|
|
|
|
|
// Wrapper type, with callback matching the Unamanaged one
|
2019-04-05 15:57:29 -07:00
|
|
|
if (!as_generator("internal class " << f_name << "Wrapper : IDisposable\n"
|
2017-11-23 16:50:16 -08:00
|
|
|
<< "{\n\n"
|
|
|
|
<< scope_tab << "private " << f_name << "Internal _cb;\n"
|
|
|
|
<< scope_tab << "private IntPtr _cb_data;\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
|
|
|
<< scope_tab << "private EinaFreeCb _cb_free_cb;\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
|
|
|
<< scope_tab << "internal " << f_name << "Wrapper (" << f_name << "Internal _cb, IntPtr _cb_data, EinaFreeCb _cb_free_cb)\n"
|
2017-11-23 16:50:16 -08:00
|
|
|
<< scope_tab << "{\n"
|
|
|
|
<< scope_tab << scope_tab << "this._cb = _cb;\n"
|
|
|
|
<< scope_tab << scope_tab << "this._cb_data = _cb_data;\n"
|
|
|
|
<< scope_tab << scope_tab << "this._cb_free_cb = _cb_free_cb;\n"
|
|
|
|
<< scope_tab << "}\n\n"
|
|
|
|
|
|
|
|
<< scope_tab << "~" << f_name << "Wrapper()\n"
|
|
|
|
<< scope_tab << "{\n"
|
2019-04-05 15:57:29 -07:00
|
|
|
<< scope_tab << scope_tab << "Dispose(false);\n"
|
|
|
|
<< scope_tab << "}\n\n"
|
|
|
|
|
|
|
|
<< scope_tab << "protected virtual void Dispose(bool disposing)\n"
|
|
|
|
<< scope_tab << "{\n"
|
2017-11-23 16:50:16 -08:00
|
|
|
<< scope_tab << scope_tab << "if (this._cb_free_cb != null)\n"
|
2019-04-05 15:57:29 -07:00
|
|
|
<< scope_tab << scope_tab << "{\n"
|
|
|
|
<< scope_tab << scope_tab << scope_tab << "if (disposing)\n"
|
|
|
|
<< scope_tab << scope_tab << scope_tab << "{\n"
|
|
|
|
<< scope_tab << scope_tab << scope_tab << scope_tab << "this._cb_free_cb(this._cb_data);\n"
|
|
|
|
<< scope_tab << scope_tab << scope_tab << "}\n"
|
|
|
|
<< scope_tab << scope_tab << scope_tab << "else\n"
|
|
|
|
<< scope_tab << scope_tab << scope_tab << "{\n"
|
|
|
|
<< scope_tab << scope_tab << scope_tab << scope_tab << "Efl.Eo.Globals.efl_mono_thread_safe_free_cb_exec(this._cb_free_cb, this._cb_data);\n"
|
|
|
|
<< scope_tab << scope_tab << scope_tab << "}\n"
|
|
|
|
<< scope_tab << scope_tab << scope_tab << "this._cb_free_cb = null;\n"
|
|
|
|
<< scope_tab << scope_tab << scope_tab << "this._cb_data = IntPtr.Zero;\n"
|
|
|
|
<< scope_tab << scope_tab << scope_tab << "this._cb = null;\n"
|
|
|
|
<< scope_tab << scope_tab << "}\n"
|
|
|
|
<< scope_tab << "}\n\n"
|
|
|
|
|
|
|
|
<< scope_tab << "public void Dispose()\n"
|
|
|
|
<< scope_tab << "{\n"
|
|
|
|
<< scope_tab << scope_tab << "Dispose(true);\n"
|
|
|
|
<< scope_tab << scope_tab << "GC.SuppressFinalize(this);\n"
|
2017-11-23 16:50:16 -08:00
|
|
|
<< scope_tab << "}\n\n"
|
|
|
|
|
2017-12-06 16:03:55 -08:00
|
|
|
<< scope_tab << "internal " << type << " ManagedCb(" << (parameter % ",") << ")\n"
|
2017-11-23 16:50:16 -08:00
|
|
|
<< scope_tab << "{\n"
|
2018-03-21 18:39:17 -07:00
|
|
|
<< function_definition_preamble << "_cb(_cb_data, " << (argument_invocation % ", ") << ");\n"
|
|
|
|
<< function_definition_epilogue
|
2017-11-23 16:50:16 -08:00
|
|
|
<< scope_tab << "}\n\n"
|
|
|
|
|
2018-03-21 18:39:17 -07:00
|
|
|
|
2019-01-15 23:29:56 -08:00
|
|
|
<< scope_tab << marshall_annotation(true)
|
|
|
|
<< scope_tab << "internal static " << marshall_type(true) << " Cb(IntPtr cb_data" << *grammar::attribute_reorder<-1, -1>((", " << marshall_annotation << " " << marshall_parameter)) << ")\n"
|
2017-11-23 16:50:16 -08:00
|
|
|
<< scope_tab << "{\n"
|
|
|
|
<< scope_tab << scope_tab << "GCHandle handle = GCHandle.FromIntPtr(cb_data);\n"
|
|
|
|
<< scope_tab << scope_tab << string << " cb = (" << string << ")handle.Target;\n"
|
2018-03-21 18:39:17 -07:00
|
|
|
<< native_function_definition_preamble
|
|
|
|
<< scope_tab << scope_tab << "try {\n"
|
2019-03-26 10:45:18 -07:00
|
|
|
<< scope_tab << scope_tab << scope_tab << (return_type != "void" ? "_ret_var = " : "") << "cb(" << (native_argument_invocation % ", ") << ");\n"
|
2018-03-21 18:39:17 -07:00
|
|
|
<< scope_tab << scope_tab << "} catch (Exception e) {\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
|
|
|
<< scope_tab << scope_tab << scope_tab << "Eina.Log.Warning($\"Callback error: {e.ToString()}\");\n"
|
2019-01-15 00:51:20 -08:00
|
|
|
<< scope_tab << scope_tab << scope_tab << "Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);\n"
|
2018-03-21 18:39:17 -07:00
|
|
|
<< scope_tab << scope_tab << "}\n"
|
|
|
|
<< native_function_definition_epilogue(nullptr)
|
2017-11-23 16:50:16 -08:00
|
|
|
<< scope_tab << "}\n"
|
|
|
|
<< "}\n"
|
2018-03-21 18:39:17 -07:00
|
|
|
).generate(sink, std::make_tuple(f.return_type, f.parameters, f, f.parameters, f, f.return_type, f.return_type, f.parameters, f_name, f_name, f, f.parameters, f), funcptr_ctx))
|
2017-11-23 16:50:16 -08:00
|
|
|
return false;
|
|
|
|
|
2018-04-27 14:08:25 -07:00
|
|
|
if (!name_helpers::close_namespaces(sink, f.namespaces, funcptr_ctx))
|
|
|
|
return false;
|
2017-11-23 16:50:16 -08:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct function_pointer const function_pointer = {};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|