path: root/src/bindings (follow)
AgeCommit message (Collapse)Author
2019-08-05csharp: fix ownership of value types in arrays and listsVitor Sousa
Summary: `eolian_mono` now considers the implicit ownership of value types in arrays and lists when generating ownership flags. Also, update manual bindings for arrays and lists to no longer free elements in the `Dispose` method when the container has ownership of the elements but C# itself does not have ownership of the container; the elements will be freed by whoever owns the container. Modifying and removing elements will still free them though. Re-enabled unit tests that required ownership of value type elements. Reviewers: felipealmeida, q66, vitor.sousa Reviewed By: felipealmeida Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision:
2019-08-05efl-mono: Add Model manual implementation to C# and MVVM factoriesLauro Moura
Summary: Depends on D9273, D9270 Test Plan: Run added testcases. Reviewers: cedric, bu5hm4n, zmike, SanghyeonLee, felipealmeida, segfaultxavi Reviewed By: cedric Subscribers: cedric Tags: #expertise_solutions, #efl_language_bindings Differential Revision:
2019-08-01eolian: remove __builtin_free_cbDaniel Kolesa
This has long been unused. If we need to replace this eventually, it should be done correctly.
2019-07-31eolian-cxx: Generate eot filesFelipe Magno de Almeida
Summary: Eolian Type files were not being generated, which made some template specialization to not be defined, for example for function_wrappers. Reviewers: bu5hm4n, woohyun, lauromoura Reviewed By: lauromoura Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision:
2019-07-30csharp: Add marshal support for Eina.ValueTypeLauro Moura
Summary: It uses a custom marshaler and a helper boxing class to convert between the managed enum values and the native Eina_Value_Type pointers. To be used by future MVVM machinery. Reviewers: vitor.sousa, felipealmeida Reviewed By: vitor.sousa Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision:
2019-07-26efl_mono: update docs of CreateWrapperForYeongjong Lee
Reviewers: lauromoura, felipealmeida, segfaultxavi, vitor.sousa Reviewed By: lauromoura Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision:
2019-07-26csharp: fix EFL# by updating it to reflect the newest changes in EolianVitor Sousa
Summary: `Efl.Event` became a builtin type that is no longer declared in `efl_object.eo`, and therefore it is no longer automatically generated in EFL#. Given that, we define a struct manually to reflect the memory layout of the native struct. Containers of value types are now allowed in eolian, so tests that were disabled because of the restriction on `ptr` were re-enabled using the plain type. But since these containers have just arrived, handling of ownership for value types is currently undefined in bindings. Hence, tests that used `ptr(int) @owned` as elements were left disable. This will be solved in a future patch. `void_pr` is now deprecated, so we remove it from tests also. Reviewers: q66, segfaultxavi, lauromoura, felipealmeida Reviewed By: lauromoura Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision:
2019-07-17cxx: remove a compilation warning for g++ 7.xVitor Sousa
Remove a compilation warning about an unsupported warning category for g++ 7.x. A `#pragma` directive was used to suppress a `-Wcast-function-type` warning in g++. Versions older than 8.x do not have this warning category and raises a warning because of this directive. Now this directive is only enabled for g++ version 8.x or newer.
2019-07-17eolian: add builtin binbuf and event typesDaniel Kolesa
Binbuf is like strbuf and allows not using the Eina opaque wrapper now, which will remove some ptr(). And event translates to Efl.Event because otherwise there would be no way to get rid of void_ptr.
2019-07-12cxx: remove compilation warnings in C++ code, from both gcc and clangVitor Sousa
Summary: Remove almost all the compilation warnings from C++ code. Only explicit warnings using the `#warning` preprocessor directive remain. Some warnings had to be suppressed with `#pragma` directives because the behavior they were warning about is intended in some specific places. Code comments were added in such situations. Added a generator that creates `#pragma` directives in order to suppress warnings in all generated C++ headers. Currently `-Wignored-qualifiers` is the only warning category being suppressed. The innocuous const qualifiers that it points are inoffensive and have no effect in compilation at all. They are also hard to track in generation since they can emerge from different types in many places. To ease the generation of the warning suppressors an utility constructor was added to `efl::eolian::grammar::attributes::unused_type`. Add constructors to `eolian_mono::class_context` to default initialize its internal string and avoid field initialization warnings. Test Plan: `meson test` Reviewers: lauromoura, felipealmeida, zmike, segfaultxavi Reviewed By: zmike Subscribers: cedric, #reviewers, #committers Tags: #efl_language_bindings Differential Revision:
2019-07-11csharp: Enable conversion of container Eina.ValuesLauro Moura
Summary: When creating a new Value with any IEnumerable of a supported type, the IEnumerable will be copied into an Eina.Value of type EINA_VALUE_ARRAY_TYPE. Similarly, `Unwrap()` on a Eina.Value container will create a new System.Collections.List<T> and return it. Depends on D9272 Reviewers: felipealmeida, vitor.sousa, segfaultxavi Reviewed By: vitor.sousa Subscribers: cedric, #reviewers, #committers Tags: #efl, #expertise_solutions Differential Revision:
2019-07-11csharp: Add helpers to get/set Values from ObjectsLauro Moura
Summary: The user can construct an `Eina.Value` from a plain C# `object`, using reflection to get the correct type of object and construct the correct underlying C value. Also added the `Unwrap()` method to return a C# object representing the wrapped value. Both operations are useful when using `Eina.Value` to Get/Set values from `PropertyInfo` targets as in ``` var v = new Eina.Value(propInfo.GetValue(sourceObj)); ... propInfo.SetValue(targetObj, v.Unwrap()); ``` Currently, containers are not supported. It will be added in a following commit. Depends on D9270 Reviewers: felipealmeida, vitor.sousa, segfaultxavi Reviewed By: vitor.sousa Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision:
2019-07-11csharp: Tag exported API items.Lauro Moura
Summary: Attributes to be used by the API export tool. For end users, no changes in the public API (except for a new attribute in generated classes). Also simplifies constructor forwarding by not needing to pass the type of the first "generated" class to compare. Currently only automatically generated items are tagged. Depends: D9259 Reviewers: vitor.sousa, felipealmeida Reviewed By: vitor.sousa Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision:
2019-07-09efl-mono: Treat Warnings as ErrorsXavi Artigas
Now that there are 0 documentation warnings, let's make sure we stay this way.
2019-07-08csharp: fix some build warnings related with incorrect and missing documentationVitor Sousa
Summary: Some parameter names, tag names and cref identifiers in the documentation were incorrect and causing warnings during compilation. There were also warnings related with missing documentation in publicly visible elements in the manual binding. This commit fixes these incorrections and adds documentation to the manual binding in order to solve these compilation warnings. Warnings related with missing documentation in `.eo` files are still present. Test Plan: Just compile with mono binding. Reviewers: lauromoura, felipealmeida, segfaultxavi Reviewed By: segfaultxavi Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision:
2019-07-08eolian: remove API to get freefunc of typeDaniel Kolesa
This is not supported anymore. For now, the syntax is kept around because of broken C++ tests, but afterwards it will also be removed.
2019-07-08elua: add error api into eolian bindingsDaniel Kolesa
2019-07-05csharp: Fix Future callback lifetimeLauro Moura
Assigning a method directly to a field expecting a delegate creates a delegate on the fly. This delegate can be collected normally as any collectable object. In dotnet the GC is more aggressive, causing this delegate to be collected and C trying to call an invalid function. To avoid this, we create a static delegate that will be passed to C. Its lifetime will be tied to the static method it wraps.
2019-07-05csharp: encapsulate some internal code of EoWrapperVitor Sousa
Summary: Encapsulate some parts of EoWrapper making them less accessible to lib users. This can avoid unnecessary and risky usage of code that is only intended for internal usage. `inherited` field was made private and renamed to `generated`. Now its value can only be obtained through the `IsGeneratedBindingClass` property. `handle` field was made private. `eventLock` was renamed to `eflBindingEventLock` `ConstructingHandle` property set was made private. Constructors that are used to create new EFL# managed objects by wrapping a preexisting eo handle now receive a specific struct wrapping the handle pointer. This can avoid faulty interactions with the Reflection engine used only for generated classes that implement this constructor. Test Plan: meson test Reviewers: lauromoura, felipealmeida, YOhoho Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision:
2019-06-28csharp: fix some compilation warningsVitor Sousa
Fix unused variable warnings in eina_mono and unit test files.
2019-06-28csharp: fix Eina_Stringshare support in containers for manual and generated APIVitor Sousa
Summary: Both C strings and eina stringshares are bound as regular strings in EFL#, as working directly with these types would demand unnecessary hassle from the user viewpoint. But for eina containers this distinction is important, and since C# generics do not provide a convenient way of dealing with the same type requiring a different management based on some other condition (at least not without compromising the usability for other types), we added a simple `System.String` wrapper named `Eina.Stringshare` that works as a placeholder for signaling this distinction. Working with this class should be transparent in most use cases because it converts to and from `System.String` implicitly. It also implements equality/inequality methods for easier comparison with strings and other stringshare objects. Add new methods and a new container element trait for dealing specifically with `Eina_Stringshare` elements. Adapt eolian_mono to identify and generate the proper placeholder in methods that require stringshare containers. Remove some direct uses of DllImport-ed functions in favor of more flexible manual binding methods. Move `Eina.Stringshare` DllImport directives to a static class named `NativeMethods`, in accordance with the code design warning CA1060. Also add a TODO comment to move all other DllImport directives to this class. Change parameter of the method `Efl.Csharp.Application.OnInitialize` from `Eina.Array<System.String>` to `string[]`. This will make this API more similar with the default C# way of receiving command line arguments. Add tests for containers storing stringshare elements. Reviewers: felipealmeida, lauromoura, segfaultxavi, bu5hm4n Reviewed By: lauromoura Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision:
2019-06-28csharp: make inherited C# classes constructible from native CVitor Sousa
Summary: With this commit it is now possible for a class that inherits from a C# binding class to be instantiated from native C code. It only has to provide a constructor that receives an `Efl.Eo.EoWrapper.ConstructingHandle` struct, and which calls the base binding constructor passing it. For example: `private Type(ConstructingHandle ch) : base(ch) {}`. Add some test files to validate the proper behavior of this feature. Add some small fixes in generation contexts in order to properly generate base constructors. Depends on D9070 Test Plan: `meson test` and `make check` Reviewers: lauromoura, felipealmeida, segfaultxavi, woohyun, YOhoho Reviewed By: YOhoho Subscribers: YOhoho, cedric, #reviewers, #committers Tags: #efl Differential Revision:
2019-06-27efl-mono: Fix value forwarding in promises/asyncLauro Moura
Summary: Values returned from C# Then callbacks must release ownership of the underlying native value, so Eina code can clean it up nicely and avoid the Wrapper flushing it early. The same issue applied to the Async wrappers. In this case the value passed as the Task parameter could be released by an `using` block awaiting the value. Also Future creation was then-ing the wrong handle. Also add better exception messages. Reviewers: vitor.sousa, felipealmeida Reviewed By: vitor.sousa Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision:
2019-06-27csharp: Add missing prefix to enable interpolationLauro Moura
Reviewers: vitor.sousa Reviewed By: vitor.sousa Subscribers: cedric, #reviewers, #committers Tags: #efl, #expertise_solutions Differential Revision:
2019-06-27csharp: Update after iterator changesLauro Moura
Summary: Iterator and Accessors are views only, not owning the data they point to. Also updated the tests by handling some test data that were leaking. Fixes T8036 Reviewers: vitor.sousa, felipealmeida Reviewed By: vitor.sousa Subscribers: cedric, #reviewers, #committers, segfaultxavi, q66 Tags: #efl Maniphest Tasks: T8036 Differential Revision:
2019-06-25efl-mono: Add object type support for Eina.ValueFelipe Magno de Almeida
Summary: C# `Eina.Value` now has builtin support for `EINA_VALUE_TYPE_OBJECT`. To avoid ambiguity with the `Set` method overloads, explicit casting operators were used for wrapping/unwrapping `Efl.Object` instead of implicit ones like for other value types. Thus, to initialize an `Eina.Value` from an object, you can use the following: `var v = (Eina.Value)myObj;` Reviewers: felipealmeida, vitor.sousa, segfaultxavi, Jaehyun_Cho Reviewed By: Jaehyun_Cho Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision:
2019-06-19efl_mono: support multilevel inheritance of NativeClassYeongjong Lee
Summary: When it creates multilevel class of NativeClass, internal c function is not called because eo vtables aren't created Test Plan: Check "MyBox2 UpdateLayout" printed. ``` //mcs test_box.cs -out:test_box.exe `pkg-config --libs efl-mono` //mono test_box.exe using System; public class MyBox2 : MyBox { public MyBox2(Efl.Object parent, string style = null) : base(parent, style) { } public override void UpdateLayout() { Eina.Log.Error("MyBox2 UpdateLayout"); base.UpdateLayout(); } } public class MyBox : Efl.Ui.Box { public MyBox(Efl.Object parent, string style = null) : base(parent, style) { } public override void UpdateLayout() { Eina.Log.Error("MyBox UpdateLayout"); base.UpdateLayout(); } } public class Example : Efl.Csharp.Application { protected override void OnInitialize(Eina.Array<System.String> args) { Efl.Ui.Win win = new Efl.Ui.Win(Efl.App.AppMain); var box = new MyBox(win); box.SetHintSizeMin(new Eina.Size2D(360, 240)); win.SetContent(box); var box2 = new MyBox2(win); box2.SetHintSizeMin(new Eina.Size2D(360, 240)); box2.Pack(box); var button = new Efl.Ui.Button(box); button.SetText("Click"); button.ClickedEvt += (object sender, Efl.Ui.IClickableClickedEvt_Args e) => { box.CalculateGroup(); box2.CalculateGroup(); }; box.Pack(button); } public static void Main() { var example = new Example(); example.Launch(); } } ``` Reviewers: segfaultxavi, vitor.sousa, felipealmeida, lauromoura, woohyun, Jaehyun_Cho Reviewed By: Jaehyun_Cho Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision:
2019-05-31csharp: Do some iterations on exit.Lauro Moura
So we can kinda properly clean up things before shutting down.
2019-05-31csharp: Refactor wrapper lifetime.Vitor Sousa
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:
2019-05-26eolian: add runtime API to get file format versionDaniel Kolesa
This is useful for FFI based bindings (like the Lua or Python ones) and so on.
2019-05-26elua: add version_get API for units in eolian bindingsDaniel Kolesa
2019-05-26eolian: rename @warn_unused and its associated APIDaniel Kolesa
@warn_unused in syntax is now called @no_unused - this is because "warning about unused" is a C thing (or rather, an extension to C) and various languages might want to use stricter behavior for this. Its associated API does the reverse now - it lets you query whether being unused is allowed at all. This is to match future behavior of Eolian (once it supports versioning) that will likely reverse it. @feature
2019-05-26eolian: remove param @nonullDaniel Kolesa
This has been deprecated for a while and is not strictly necessary - as a part of an effort to stabilize Eolian, remove this. Eolian will eventually gain support for versioning and use a reversed behavior (i.e. no NULL by default), but the API it wlll use for that will be very different. Features can always be added, it's much harder to drop them. @feature
2019-05-21eolian: remove @nullable keywordDaniel Kolesa
This was an experiment that never properly took off and was never used by any generator. Its use was highly variable, so it could not be relied upon. We will still want to reverse the current behavior eventually (no null by default), but that will be done with eo file versioning in the future. @feature
2019-05-17efl_mono: generate efl_canvas_text.eo.csJaehyun Cho
To use canvas text in efl csharp bindings, it is permitted to generate efl_canvas_text.eo.cs.
2019-05-16eolian: rename eolian_event_c_name_getDaniel Kolesa
This is for consistency with the new eolian_class_c_macro_get as well as for better clarity, as c_name_get is already provided by Object and refers to something else.
2019-05-16eolian: rename eolian_typedecl_enum_field_c_name_getDaniel Kolesa
This is to allow for better object oriented APIs, as the `c_name` field would be inherited from Object. This also makes it more clear in C.
2019-05-16eolian: add API to retrieve the C name of an objectDaniel Kolesa
This is to prepare for type/class renaming support. This adds the necessary API to retrieve C-specific names. Other refactoring is necessary elsewhere for now. This also renames the old API eolian_class_c_name_get to eolian_class_c_macro_get to avoid conflict as well as clarify the intention.
2019-05-14efl-mono: Use Efl.Ui.Win API instead of Elm.PolicyXavi Artigas
Summary: This removes another bit of legacy API from the C# bindings. This also reverts "elm: Put back Policy and Policy_Quit in EO files" (a9132a9a66955608e913bb1228e4adb371310b09) so that these two Elm enums are definitely out of the EO files. Test Plan: Everything, including mono bindings, continue to build. At runtime, C# apps still exit when all windows are closed. Reviewers: lauromoura, vitor.sousa, q66 Reviewed By: q66 Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision:
2019-05-13efl_mono: generate efl_canvas_vg_object.eo.cs by mesonJaehyun Cho
This commit is the same as 0e8f289d7dfb4c5877559917a57a3ac08545fb86 but this commit is for meson. To use vector graphics in efl csharp bindings, it is permitted to generate efl_canvas_vg_object.eo.cs. Other efl_canvas_vg .eo.cs files have already been generated because the file names were changed from efl_vg to efl_canvas_vg.
2019-05-13efl_mono: move to lib with versions by mesonJaehyun Cho
meson generates to lib/efl-mono-1/ directory unlike other so files. Moreover, the so file does not have versions in the file name unlike other so files. Like other so files, is moved to lib directory with versions in the file name.
2019-05-03eolian: refactor parsing API and path handlingDaniel Kolesa
This splits the eolian_file_parse API into two, one for parsing files already present in the database (always by filename) and one for parsing paths. It fixes several bugs/leaks on the way (incorrect use of stringshare etc.) as well as adds checking for whether there are no conflicting filenames at scan time, for free. That means it is now no longer possible to scan two paths which have an eo or eot file of the same name in them. It should also be faster now. It also fixes T7820. @fix
2019-05-03efl_mono: fix to load based on efl.Libs.EvasJaehyun Cho is loaded based on efl.Libs.Evas in efl_libs.cs. Therefore, the hard coded string "evas" is replaced with efl.Libs.Evas.
2019-05-02cxx: Rename Elementary.hh into Efl_Ui.hhLauro Moura
Also include Efl_Ui.h alongside Elementary.h (the latter is still needed by some widgets).
2019-04-18meson: unbreak cxx header installationMarcel Hollerbach
Summary: before we had *correct* fileds in the subdir: keyword. However, install_dir: was wrong, so *this* time, this seems right. Reviewers: cedric, zmike, segfaultxavi, raster Reviewed By: zmike Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision:
2019-04-15cxx: Fix eldbus meta include nameLauro Moura
Summary: It should not conflict with Eldbus_Model header Fixes T7805 Reviewers: vtorri Reviewed By: vtorri Subscribers: cedric, #reviewers, #committers Tags: #efl Maniphest Tasks: T7805 Differential Revision:
2019-04-15csharp: Rename MarshalTest to MarshalEoLauro Moura
Summary: To better reflect its intent Reviewers: segfaultxavi, vitor.sousa, felipealmeida Reviewed By: vitor.sousa Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision:
2019-04-15csharp: Fix free_cb calling under dotnet.Lauro Moura
Summary: dotnet's GC seems to be more agressive, showing some issues that usually do not appear when running under Mono's. This commit uses for free_cb's the same scheme we already use for regular Eo refs, using a GC handle to keep the cleaning callback alive. Reviewers: vitor.sousa, felipealmeida, woohyun Reviewed By: vitor.sousa Subscribers: segfaultxavi, cedric, #reviewers, #committers Tags: #efl Differential Revision:
2019-04-12elua: add all missing eolian api bindingsDaniel Kolesa
2019-04-11mono-docs: Allow embedding external examplesXavi Artigas
Summary: New option added to eolian_gen: -e <dir> This specifies a directory to search for examples. If a file is found with the same name as an EFL C# class (e.g. Efl.Ui.Button.cs) or as an EFL C# method or property (e.g. Efl.IText.Text.cs, Efl.IText.SetText.cs) its full contents will be embedded in the documentation for that class or method within <example> and <code> tags. This is, in turn, is parsed by DocFX and shown in Example boxes in the generated pages. If an example file is not found, no examples are embedded for that object. If -e is not used, no examples are embedded for any object. New option added to meson: mono-examples-dir to point to the examples directory. This directory is then passed to eolian_mono through -e. Do not use it (or define it to nothing) to disable example embedding. No performance drop has been observed because of these extra tests. Right now examples can only be given for base classes, not for derived ones (i.e. Efl.IText.Text but not Efl.Ui.Button.Text). This will be addressed in a later commit. Feature Depends on D8587 Test Plan: Create an examples folder and put some files in it: ``` mkdir /tmp/examples echo 'var button = new Efl.Ui.Button();' > /tmp/examples/Efl.Ui.Button.cs echo 'button.AutoRepeatEnabled = true;' > /tmp/examples/Efl.Ui.IAutorepeat.AutorepeatEnabled.cs echo 'button.SetAutoRepeatEnabled(true);' > /tmp/examples/Efl.Ui.IAutorepeat.SetAutorepeatEnabled.cs ``` Configure meson to embed examples and build: ``` meson configure -Dmono-examples-dir=/tmp/examples ninja ``` Examine the generated efl_ui_button.eo.cs file to see embedded <example> tags, or run DocFX and bask in the glory of documentation pages with examples: ``` cd doc/docfx ./ ``` Reviewers: lauromoura, felipealmeida, vitor.sousa, zmike, bu5hm4n Reviewed By: vitor.sousa Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: