2019-10-24 06:01:50 -07:00
|
|
|
/*
|
|
|
|
* Copyright 2019 by its authors. See AUTHORS.
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
2017-12-06 16:03:55 -08:00
|
|
|
#pragma warning disable 1591
|
|
|
|
|
2017-11-23 16:49:22 -08:00
|
|
|
using System;
|
2018-05-02 15:49:37 -07:00
|
|
|
using System.Linq;
|
2017-11-23 16:49:22 -08:00
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
using System.Collections.Generic;
|
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
|
|
|
using System.Reflection;
|
2019-10-14 07:57:01 -07:00
|
|
|
using System.ComponentModel;
|
2019-11-07 18:33:09 -08:00
|
|
|
using System.Globalization;
|
2017-11-23 16:49:22 -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
|
|
|
using Eina.Callbacks;
|
|
|
|
using static Eina.HashNativeFunctions;
|
|
|
|
using static Eina.InarrayNativeFunctions;
|
|
|
|
using static Eina.InlistNativeFunctions;
|
|
|
|
using static Eina.NativeCustomExportFunctions;
|
2017-11-23 16:49:22 -08:00
|
|
|
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
namespace Eina
|
|
|
|
{
|
2017-11-23 16:49:22 -08:00
|
|
|
|
2019-10-14 07:57:01 -07:00
|
|
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
public enum ElementType
|
|
|
|
{
|
|
|
|
NumericType,
|
|
|
|
StringType,
|
2019-06-28 06:40:52 -07:00
|
|
|
StringshareType,
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
ObjectType
|
|
|
|
};
|
2017-11-23 16:49:22 -08:00
|
|
|
|
2019-10-14 07:57:01 -07:00
|
|
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
2017-11-23 16:49:22 -08:00
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
2019-11-14 11:27:14 -08:00
|
|
|
public struct InlistMem : IEquatable<InlistMem>
|
2017-11-23 16:49:22 -08:00
|
|
|
{
|
|
|
|
public IntPtr next {get;set;}
|
|
|
|
public IntPtr prev {get;set;}
|
|
|
|
public IntPtr last {get;set;}
|
2019-11-14 11:27:14 -08:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets a hash for <see cref="InlistMem" />.
|
|
|
|
/// <para>Since EFL 1.24.</para>
|
|
|
|
/// </summary>
|
|
|
|
/// <returns>A hash code.</returns>
|
|
|
|
public override int GetHashCode()
|
|
|
|
=> next.GetHashCode() ^ prev.GetHashCode() ^ last.GetHashCode();
|
|
|
|
|
|
|
|
/// <summary>Returns whether this <see cref="InlistMem" />
|
|
|
|
/// is equal to the given <see cref="object" />.
|
|
|
|
/// <para>Since EFL 1.24.</para>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="other">The <see cref="object" /> to be compared to.</param>
|
|
|
|
/// <returns><c>true</c> if is equal to <c>other</c>.</returns>
|
|
|
|
public override bool Equals(object other)
|
|
|
|
=> (!(other is InlistMem)) ? false : Equals((InlistMem)other);
|
|
|
|
|
|
|
|
/// <summary>Returns whether this <see cref="InlistMem" /> is equal
|
|
|
|
/// to the given <see cref="InlistMem" />.
|
|
|
|
/// <para>Since EFL 1.24.</para>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="other">The <see cref="InlistMem" /> to be compared to.</param>
|
|
|
|
/// <returns><c>true</c> if is equal to <c>other</c>.</returns>
|
|
|
|
public bool Equals(InlistMem other)
|
|
|
|
=> (next == other.next) && (prev == other.prev)
|
|
|
|
&& (last == other.last);
|
|
|
|
|
|
|
|
/// <summary>Returns whether <c>lhs</c> is equal to <c>rhs</c>.
|
|
|
|
/// <para>Since EFL 1.24.</para>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="lhs">The left hand side of the operator.</param>
|
|
|
|
/// <param name="rhs">The right hand side of the operator.</param>
|
|
|
|
/// <returns><c>true</c> if <c>lhs</c> is equal
|
|
|
|
/// to <c>rhs</c>.</returns>
|
|
|
|
public static bool operator==(InlistMem lhs, InlistMem rhs)
|
|
|
|
=> lhs.Equals(rhs);
|
|
|
|
|
|
|
|
/// <summary>Returns whether <c>lhs</c> is not equal to <c>rhs</c>.
|
|
|
|
/// <para>Since EFL 1.24.</para>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="lhs">The left hand side of the operator.</param>
|
|
|
|
/// <param name="rhs">The right hand side of the operator.</param>
|
|
|
|
/// <returns><c>true</c> if <c>lhs</c> is not equal
|
|
|
|
/// to <c>rhs</c>.</returns>
|
|
|
|
public static bool operator!=(InlistMem lhs, InlistMem rhs) => !(lhs == rhs);
|
2017-11-23 16:49:22 -08:00
|
|
|
}
|
|
|
|
|
2019-10-14 07:57:01 -07:00
|
|
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
2017-11-23 16:49:22 -08:00
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
2019-11-14 11:27:14 -08:00
|
|
|
public struct InlistNode<T> : IEquatable<InlistNode<T>>
|
2017-11-23 16:49:22 -08:00
|
|
|
{
|
|
|
|
public InlistMem __in_list {get;set;}
|
|
|
|
public T Val {get;set;}
|
2019-11-14 11:27:14 -08:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets a hash for <see cref="InlistNode{T}" />.
|
|
|
|
/// <para>Since EFL 1.24.</para>
|
|
|
|
/// </summary>
|
|
|
|
/// <returns>A hash code.</returns>
|
|
|
|
public override int GetHashCode()
|
|
|
|
=> __in_list.GetHashCode() ^ Val.GetHashCode();
|
|
|
|
|
|
|
|
/// <summary>Returns whether this <see cref="InlistNode{T}" />
|
|
|
|
/// is equal to the given <see cref="object" />.
|
|
|
|
/// <para>Since EFL 1.24.</para>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="other">The <see cref="object" /> to be compared to.</param>
|
|
|
|
/// <returns><c>true</c> if is equal to <c>other</c>.</returns>
|
|
|
|
public override bool Equals(object other)
|
|
|
|
=> (!(other is InlistNode<T>)) ? false : Equals((InlistNode<T>)other);
|
|
|
|
|
|
|
|
/// <summary>Returns whether this <see cref="InlistNode{T}" /> is equal
|
|
|
|
/// to the given <see cref="InlistNode{T}" />.
|
|
|
|
/// <para>Since EFL 1.24.</para>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="other">The <see cref="InlistNode{T}" /> to be compared to.</param>
|
|
|
|
/// <returns><c>true</c> if is equal to <c>other</c>.</returns>
|
|
|
|
public bool Equals(InlistNode<T> other)
|
|
|
|
=> (__in_list == other.__in_list) && (Val.Equals(other.Val));
|
|
|
|
|
|
|
|
/// <summary>Returns whether <c>lhs</c> is equal to <c>rhs</c>.
|
|
|
|
/// <para>Since EFL 1.24.</para>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="lhs">The left hand side of the operator.</param>
|
|
|
|
/// <param name="rhs">The right hand side of the operator.</param>
|
|
|
|
/// <returns><c>true</c> if <c>lhs</c> is equal
|
|
|
|
/// to <c>rhs</c>.</returns>
|
|
|
|
public static bool operator==(InlistNode<T> lhs, InlistNode<T> rhs)
|
|
|
|
=> lhs.Equals(rhs);
|
|
|
|
|
|
|
|
/// <summary>Returns whether <c>lhs</c> is not equal to <c>rhs</c>.
|
|
|
|
/// <para>Since EFL 1.24.</para>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="lhs">The left hand side of the operator.</param>
|
|
|
|
/// <param name="rhs">The right hand side of the operator.</param>
|
|
|
|
/// <returns><c>true</c> if <c>lhs</c> is not equal
|
|
|
|
/// to <c>rhs</c>.</returns>
|
|
|
|
public static bool operator!=(InlistNode<T> lhs, InlistNode<T> rhs)
|
|
|
|
=> !(lhs == rhs);
|
2017-11-23 16:49:22 -08:00
|
|
|
}
|
|
|
|
|
2019-10-14 07:57:01 -07:00
|
|
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
2017-11-23 16:49:22 -08:00
|
|
|
public interface IBaseElementTraits<T>
|
|
|
|
{
|
|
|
|
IntPtr ManagedToNativeAlloc(T man);
|
|
|
|
IntPtr ManagedToNativeAllocInlistNode(T man);
|
2019-01-15 23:29:56 -08:00
|
|
|
void ManagedToNativeCopyTo(T man, IntPtr mem);
|
2017-11-23 16:49:22 -08:00
|
|
|
void NativeFree(IntPtr nat);
|
|
|
|
void NativeFreeInlistNodeElement(IntPtr nat);
|
|
|
|
void NativeFreeInlistNode(IntPtr nat, bool freeElement);
|
|
|
|
void NativeFreeInplace(IntPtr nat);
|
|
|
|
void ResidueFreeInplace(IntPtr nat);
|
|
|
|
T NativeToManaged(IntPtr nat);
|
|
|
|
T NativeToManagedInlistNode(IntPtr nat);
|
|
|
|
T NativeToManagedInplace(IntPtr nat);
|
|
|
|
IntPtr EinaCompareCb();
|
|
|
|
IntPtr EinaFreeCb();
|
|
|
|
IntPtr EinaHashNew();
|
|
|
|
IntPtr EinaInarrayNew(uint step);
|
|
|
|
IntPtr EinaHashIteratorKeyNew(IntPtr hash);
|
|
|
|
}
|
|
|
|
|
2019-10-14 07:57:01 -07:00
|
|
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
2019-01-15 23:29:56 -08:00
|
|
|
public class StringElementTraits : IBaseElementTraits<string>
|
2017-11-23 16:49:22 -08:00
|
|
|
{
|
|
|
|
public StringElementTraits()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-01-15 23:29:56 -08:00
|
|
|
public IntPtr ManagedToNativeAlloc(string man)
|
2017-11-23 16:49:22 -08:00
|
|
|
{
|
2019-01-15 23:29:56 -08:00
|
|
|
IntPtr newstring = MemoryNative.StrDup(man);
|
|
|
|
return newstring;
|
2017-11-23 16:49:22 -08:00
|
|
|
}
|
|
|
|
|
2019-01-15 23:29:56 -08:00
|
|
|
public IntPtr ManagedToNativeAllocInlistNode(string man)
|
2017-11-23 16:49:22 -08:00
|
|
|
{
|
|
|
|
var node = new InlistNode<IntPtr>();
|
|
|
|
node.Val = ManagedToNativeAlloc(man);
|
|
|
|
GCHandle pinnedData = GCHandle.Alloc(node, GCHandleType.Pinned);
|
|
|
|
IntPtr ptr = pinnedData.AddrOfPinnedObject();
|
2019-01-15 23:29:56 -08:00
|
|
|
IntPtr nat = MemoryNative.AllocCopy(ptr, Marshal.SizeOf<InlistMem>() + Marshal.SizeOf<IntPtr>());
|
2017-11-23 16:49:22 -08:00
|
|
|
pinnedData.Free();
|
|
|
|
return nat;
|
|
|
|
}
|
|
|
|
|
2019-01-15 23:29:56 -08:00
|
|
|
public void ManagedToNativeCopyTo(string man, IntPtr mem)
|
2017-11-23 16:49:22 -08:00
|
|
|
{
|
2019-01-15 23:29:56 -08:00
|
|
|
IntPtr stringptr = ManagedToNativeAlloc(man);
|
|
|
|
Marshal.WriteIntPtr(mem, stringptr);
|
2017-11-23 16:49:22 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
public void NativeFree(IntPtr nat)
|
|
|
|
{
|
|
|
|
if (nat != IntPtr.Zero)
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
{
|
2017-11-23 16:49:22 -08:00
|
|
|
MemoryNative.Free(nat);
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
}
|
2017-11-23 16:49:22 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
public void NativeFreeInlistNodeElement(IntPtr nat)
|
|
|
|
{
|
|
|
|
if (nat == IntPtr.Zero)
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
{
|
2017-11-23 16:49:22 -08:00
|
|
|
return;
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
}
|
|
|
|
|
2019-01-15 23:29:56 -08:00
|
|
|
var val = Marshal.PtrToStructure<IntPtr>
|
|
|
|
(nat + Marshal.SizeOf<InlistMem>());
|
|
|
|
NativeFree(val);
|
2017-11-23 16:49:22 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
public void NativeFreeInlistNode(IntPtr nat, bool freeElement)
|
|
|
|
{
|
|
|
|
if (nat == IntPtr.Zero)
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
{
|
2017-11-23 16:49:22 -08:00
|
|
|
return;
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
}
|
|
|
|
|
2017-11-23 16:49:22 -08:00
|
|
|
if (freeElement)
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
{
|
2017-11-23 16:49:22 -08:00
|
|
|
NativeFreeInlistNodeElement(nat);
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
}
|
|
|
|
|
2017-11-23 16:49:22 -08:00
|
|
|
MemoryNative.Free(nat);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void NativeFreeInplace(IntPtr nat)
|
|
|
|
{
|
|
|
|
MemoryNative.FreeRef(nat);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void ResidueFreeInplace(IntPtr nat)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-01-15 23:29:56 -08:00
|
|
|
public string NativeToManaged(IntPtr nat)
|
2017-11-23 16:49:22 -08:00
|
|
|
{
|
|
|
|
if (nat == IntPtr.Zero)
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
{
|
2019-01-15 23:29:56 -08:00
|
|
|
return default(string);
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
}
|
|
|
|
|
2019-01-15 23:29:56 -08:00
|
|
|
return StringConversion.NativeUtf8ToManagedString(nat);
|
2017-11-23 16:49:22 -08:00
|
|
|
}
|
|
|
|
|
2019-01-15 23:29:56 -08:00
|
|
|
public string NativeToManagedInlistNode(IntPtr nat)
|
2017-11-23 16:49:22 -08:00
|
|
|
{
|
|
|
|
if (nat == IntPtr.Zero)
|
|
|
|
{
|
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
|
|
|
Eina.Log.Error("Null pointer for Inlist node.");
|
2019-01-15 23:29:56 -08:00
|
|
|
return default(string);
|
2017-11-23 16:49:22 -08:00
|
|
|
}
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
|
2019-01-15 23:29:56 -08:00
|
|
|
IntPtr ptr_location = nat + Marshal.SizeOf<InlistMem>();
|
|
|
|
return NativeToManaged(Marshal.ReadIntPtr(ptr_location));
|
2017-11-23 16:49:22 -08:00
|
|
|
}
|
|
|
|
|
2019-01-15 23:29:56 -08:00
|
|
|
// Strings inplaced are always a pointer, because they are variable-sized
|
|
|
|
public string NativeToManagedInplace(IntPtr nat)
|
2017-11-23 16:49:22 -08:00
|
|
|
{
|
|
|
|
if (nat == IntPtr.Zero)
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
{
|
2019-01-15 23:29:56 -08:00
|
|
|
return default(string);
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
}
|
|
|
|
|
2019-01-15 23:29:56 -08:00
|
|
|
nat = Marshal.ReadIntPtr(nat);
|
|
|
|
if (nat == IntPtr.Zero)
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
{
|
2019-01-15 23:29:56 -08:00
|
|
|
return default(string);
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
}
|
|
|
|
|
2019-01-15 23:29:56 -08:00
|
|
|
return NativeToManaged(nat);
|
2017-11-23 16:49:22 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
public IntPtr EinaCompareCb()
|
|
|
|
{
|
|
|
|
return MemoryNative.StrCompareFuncPtrGet();
|
|
|
|
}
|
|
|
|
|
|
|
|
public IntPtr EinaFreeCb()
|
|
|
|
{
|
|
|
|
return MemoryNative.FreeFuncPtrGet();
|
|
|
|
}
|
|
|
|
|
|
|
|
public IntPtr EinaHashNew()
|
|
|
|
{
|
|
|
|
return eina_hash_string_superfast_new(IntPtr.Zero);
|
|
|
|
}
|
|
|
|
|
|
|
|
public IntPtr EinaInarrayNew(uint step)
|
|
|
|
{
|
|
|
|
return eina_inarray_new((uint)Marshal.SizeOf<IntPtr>(), step);
|
|
|
|
}
|
|
|
|
|
|
|
|
public IntPtr EinaHashIteratorKeyNew(IntPtr hash)
|
|
|
|
{
|
|
|
|
return eina_hash_iterator_key_new(hash);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-14 07:57:01 -07:00
|
|
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
2019-06-28 06:40:52 -07:00
|
|
|
public class StringshareElementTraits : IBaseElementTraits<Eina.Stringshare>
|
|
|
|
{
|
|
|
|
public StringshareElementTraits()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public IntPtr ManagedToNativeAlloc(Eina.Stringshare man)
|
|
|
|
{
|
|
|
|
var strShare = MemoryNative.AddStringshare(man);
|
|
|
|
return strShare;
|
|
|
|
}
|
|
|
|
|
|
|
|
public IntPtr ManagedToNativeAllocInlistNode(Eina.Stringshare man)
|
|
|
|
{
|
|
|
|
var node = new InlistNode<IntPtr>();
|
|
|
|
node.Val = ManagedToNativeAlloc(man);
|
|
|
|
GCHandle pinnedData = GCHandle.Alloc(node, GCHandleType.Pinned);
|
|
|
|
IntPtr ptr = pinnedData.AddrOfPinnedObject();
|
|
|
|
IntPtr nat = MemoryNative.AllocCopy
|
|
|
|
(ptr, Marshal.SizeOf<InlistMem>() + Marshal.SizeOf<IntPtr>());
|
|
|
|
pinnedData.Free();
|
|
|
|
return nat;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void ManagedToNativeCopyTo(Eina.Stringshare man, IntPtr mem)
|
|
|
|
{
|
|
|
|
IntPtr stringptr = ManagedToNativeAlloc(man);
|
|
|
|
Marshal.WriteIntPtr(mem, stringptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void NativeFree(IntPtr nat)
|
|
|
|
{
|
|
|
|
if (nat != IntPtr.Zero)
|
|
|
|
{
|
|
|
|
MemoryNative.DelStringshare(nat);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void NativeFreeInlistNodeElement(IntPtr nat)
|
|
|
|
{
|
|
|
|
if (nat == IntPtr.Zero)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var val = Marshal.PtrToStructure<IntPtr>
|
|
|
|
(nat + Marshal.SizeOf<InlistMem>());
|
|
|
|
NativeFree(val);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void NativeFreeInlistNode(IntPtr nat, bool freeElement)
|
|
|
|
{
|
|
|
|
if (nat == IntPtr.Zero)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (freeElement)
|
|
|
|
{
|
|
|
|
NativeFreeInlistNodeElement(nat);
|
|
|
|
}
|
|
|
|
|
|
|
|
MemoryNative.Free(nat);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void NativeFreeInplace(IntPtr nat)
|
|
|
|
{
|
|
|
|
MemoryNative.DelStringshareRef(nat);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void ResidueFreeInplace(IntPtr nat)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public Eina.Stringshare NativeToManaged(IntPtr nat)
|
|
|
|
{
|
|
|
|
if (nat == IntPtr.Zero)
|
|
|
|
{
|
|
|
|
return default(Eina.Stringshare);
|
|
|
|
}
|
|
|
|
|
|
|
|
return StringConversion.NativeUtf8ToManagedString(nat);
|
|
|
|
}
|
|
|
|
|
|
|
|
public Eina.Stringshare NativeToManagedInlistNode(IntPtr nat)
|
|
|
|
{
|
|
|
|
if (nat == IntPtr.Zero)
|
|
|
|
{
|
|
|
|
Eina.Log.Error("Null pointer for Inlist node.");
|
|
|
|
return default(Eina.Stringshare);
|
|
|
|
}
|
|
|
|
|
|
|
|
IntPtr ptr_location = nat + Marshal.SizeOf<InlistMem>();
|
|
|
|
return NativeToManaged(Marshal.ReadIntPtr(ptr_location));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Strings inplaced are always a pointer, because they are variable-sized
|
|
|
|
public Eina.Stringshare NativeToManagedInplace(IntPtr nat)
|
|
|
|
{
|
|
|
|
if (nat == IntPtr.Zero)
|
|
|
|
{
|
|
|
|
return default(Eina.Stringshare);
|
|
|
|
}
|
|
|
|
|
|
|
|
nat = Marshal.ReadIntPtr(nat);
|
|
|
|
if (nat == IntPtr.Zero)
|
|
|
|
{
|
|
|
|
return default(Eina.Stringshare);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NativeToManaged(nat);
|
|
|
|
}
|
|
|
|
|
|
|
|
public IntPtr EinaCompareCb()
|
|
|
|
{
|
|
|
|
return MemoryNative.StrCompareFuncPtrGet();
|
|
|
|
}
|
|
|
|
|
|
|
|
public IntPtr EinaFreeCb()
|
|
|
|
{
|
|
|
|
return MemoryNative.StringshareDelFuncPtrGet();
|
|
|
|
}
|
|
|
|
|
|
|
|
public IntPtr EinaHashNew()
|
|
|
|
{
|
|
|
|
return eina_hash_stringshared_new(MemoryNative.StringshareDelFuncPtrGet());
|
|
|
|
}
|
|
|
|
|
|
|
|
public IntPtr EinaInarrayNew(uint step)
|
|
|
|
{
|
|
|
|
return eina_inarray_new((uint)Marshal.SizeOf<IntPtr>(), step);
|
|
|
|
}
|
|
|
|
|
|
|
|
public IntPtr EinaHashIteratorKeyNew(IntPtr hash)
|
|
|
|
{
|
|
|
|
return eina_hash_iterator_key_new(hash);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-14 07:57:01 -07:00
|
|
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
2017-11-23 16:49:22 -08:00
|
|
|
public class EflObjectElementTraits<T> : IBaseElementTraits<T>
|
|
|
|
{
|
|
|
|
public IntPtr ManagedToNativeAlloc(T man)
|
|
|
|
{
|
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
|
|
|
IntPtr h = ((Efl.Eo.IWrapper)man).NativeHandle;
|
2017-11-23 16:49:22 -08:00
|
|
|
if (h == IntPtr.Zero)
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
{
|
2017-11-23 16:49:22 -08:00
|
|
|
return h;
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -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
|
|
|
return Efl.Eo.Globals.efl_ref(h);
|
2017-11-23 16:49:22 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
public IntPtr ManagedToNativeAllocInlistNode(T man)
|
|
|
|
{
|
|
|
|
var node = new InlistNode<IntPtr>();
|
|
|
|
node.Val = ManagedToNativeAlloc(man);
|
|
|
|
GCHandle pinnedData = GCHandle.Alloc(node, GCHandleType.Pinned);
|
|
|
|
IntPtr ptr = pinnedData.AddrOfPinnedObject();
|
2019-01-15 23:29:56 -08:00
|
|
|
IntPtr nat = MemoryNative.AllocCopy(ptr, Marshal.SizeOf<InlistMem>() + Marshal.SizeOf<IntPtr>());
|
2017-11-23 16:49:22 -08:00
|
|
|
pinnedData.Free();
|
|
|
|
return nat;
|
|
|
|
}
|
|
|
|
|
2019-01-15 23:29:56 -08:00
|
|
|
public void ManagedToNativeCopyTo(T man, IntPtr mem)
|
2017-11-23 16:49:22 -08:00
|
|
|
{
|
2019-01-15 23:29:56 -08:00
|
|
|
IntPtr v = ManagedToNativeAlloc(man);
|
|
|
|
Marshal.WriteIntPtr(mem, v);
|
2017-11-23 16:49:22 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
public void NativeFree(IntPtr nat)
|
|
|
|
{
|
|
|
|
if (nat != IntPtr.Zero)
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
{
|
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
|
|
|
Efl.Eo.Globals.efl_mono_thread_safe_efl_unref(nat);
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
}
|
2017-11-23 16:49:22 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
public void NativeFreeRef(IntPtr nat, bool unrefs)
|
|
|
|
{
|
|
|
|
if (unrefs)
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
{
|
2019-01-15 23:29:56 -08:00
|
|
|
NativeFree(nat);
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
}
|
2017-11-23 16:49:22 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
public void NativeFreeInlistNodeElement(IntPtr nat)
|
|
|
|
{
|
|
|
|
if (nat == IntPtr.Zero)
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
{
|
2017-11-23 16:49:22 -08:00
|
|
|
return;
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
}
|
|
|
|
|
2019-01-15 23:29:56 -08:00
|
|
|
var val = Marshal.PtrToStructure<IntPtr>
|
|
|
|
(nat + Marshal.SizeOf<InlistMem>());
|
|
|
|
NativeFree(val);
|
2017-11-23 16:49:22 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
public void NativeFreeInlistNode(IntPtr nat, bool freeElement)
|
|
|
|
{
|
|
|
|
if (nat == IntPtr.Zero)
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
{
|
2017-11-23 16:49:22 -08:00
|
|
|
return;
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
}
|
|
|
|
|
2017-11-23 16:49:22 -08:00
|
|
|
if (freeElement)
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
{
|
2017-11-23 16:49:22 -08:00
|
|
|
NativeFreeInlistNodeElement(nat);
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
}
|
|
|
|
|
2017-11-23 16:49:22 -08:00
|
|
|
MemoryNative.Free(nat);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void NativeFreeInplace(IntPtr nat)
|
|
|
|
{
|
2019-01-15 23:29:56 -08:00
|
|
|
NativeFree(nat);
|
2017-11-23 16:49:22 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
public void ResidueFreeInplace(IntPtr nat)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public T NativeToManaged(IntPtr nat)
|
|
|
|
{
|
|
|
|
if (nat == IntPtr.Zero)
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
{
|
2017-11-23 16:49:22 -08:00
|
|
|
return default(T);
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
}
|
|
|
|
|
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
|
|
|
return (T) Efl.Eo.Globals.CreateWrapperFor(nat, shouldIncRef: true);
|
2017-11-23 16:49:22 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
public T NativeToManagedRef(IntPtr nat)
|
|
|
|
{
|
|
|
|
if (nat == IntPtr.Zero)
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
{
|
2017-11-23 16:49:22 -08:00
|
|
|
return default(T);
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
}
|
|
|
|
|
2019-01-15 23:29:56 -08:00
|
|
|
return NativeToManaged(nat);
|
2017-11-23 16:49:22 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
public T NativeToManagedInlistNode(IntPtr nat)
|
|
|
|
{
|
|
|
|
if (nat == IntPtr.Zero)
|
|
|
|
{
|
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
|
|
|
Eina.Log.Error("Null pointer for Inlist node.");
|
2017-11-23 16:49:22 -08:00
|
|
|
return default(T);
|
|
|
|
}
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
|
2019-01-15 23:29:56 -08:00
|
|
|
IntPtr ptr_location = nat + Marshal.SizeOf<InlistMem>();
|
|
|
|
return NativeToManaged(Marshal.ReadIntPtr(ptr_location));
|
2017-11-23 16:49:22 -08:00
|
|
|
}
|
|
|
|
|
2019-01-15 23:29:56 -08:00
|
|
|
// EFL objects inplaced are always a pointer, because they are variable-sized
|
2017-11-23 16:49:22 -08:00
|
|
|
public T NativeToManagedInplace(IntPtr nat)
|
|
|
|
{
|
|
|
|
if (nat == IntPtr.Zero)
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
{
|
2017-11-23 16:49:22 -08:00
|
|
|
return default(T);
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
}
|
|
|
|
|
2019-01-15 23:29:56 -08:00
|
|
|
nat = Marshal.ReadIntPtr(nat);
|
|
|
|
if (nat == IntPtr.Zero)
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
{
|
2019-01-15 23:29:56 -08:00
|
|
|
return default(T);
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
}
|
|
|
|
|
2019-01-15 23:29:56 -08:00
|
|
|
return NativeToManaged(nat);
|
2017-11-23 16:49:22 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
public IntPtr EinaCompareCb()
|
|
|
|
{
|
|
|
|
return MemoryNative.PtrCompareFuncPtrGet();
|
|
|
|
}
|
|
|
|
|
|
|
|
public IntPtr EinaFreeCb()
|
|
|
|
{
|
|
|
|
return MemoryNative.EflUnrefFuncPtrGet();
|
|
|
|
}
|
|
|
|
|
|
|
|
public IntPtr EinaHashNew()
|
|
|
|
{
|
|
|
|
return eina_hash_pointer_new(IntPtr.Zero);
|
|
|
|
}
|
|
|
|
|
|
|
|
public IntPtr EinaInarrayNew(uint step)
|
|
|
|
{
|
|
|
|
return eina_inarray_new((uint)Marshal.SizeOf<IntPtr>(), step);
|
|
|
|
}
|
|
|
|
|
|
|
|
public IntPtr EinaHashIteratorKeyNew(IntPtr hash)
|
|
|
|
{
|
|
|
|
return eina_hash_iterator_ptr_key_wrapper_new_custom_export_mono(hash);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-14 07:57:01 -07:00
|
|
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
2017-11-23 16:49:22 -08:00
|
|
|
public abstract class PrimitiveElementTraits<T>
|
|
|
|
{
|
2019-09-30 19:08:44 -07:00
|
|
|
private Eina.Callbacks.EinaCompareCb dlgt = null;
|
2017-11-23 16:49:22 -08:00
|
|
|
|
|
|
|
public IntPtr ManagedToNativeAlloc(T man)
|
|
|
|
{
|
2017-12-15 16:15:00 -08:00
|
|
|
return PrimitiveConversion.ManagedToPointerAlloc(man);
|
2017-11-23 16:49:22 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
public IntPtr ManagedToNativeAllocInlistNode(T man)
|
|
|
|
{
|
|
|
|
var node = new InlistNode<T>();
|
|
|
|
node.Val = man;
|
|
|
|
GCHandle pinnedData = GCHandle.Alloc(node, GCHandleType.Pinned);
|
|
|
|
IntPtr ptr = pinnedData.AddrOfPinnedObject();
|
2019-01-15 23:29:56 -08:00
|
|
|
int Tsize = Marshal.SizeOf<T>() < Marshal.SizeOf<IntPtr>() ? Marshal.SizeOf<IntPtr>() : Marshal.SizeOf<T>();
|
|
|
|
IntPtr nat = MemoryNative.AllocCopy(ptr, Marshal.SizeOf<InlistMem>() + Tsize);
|
2017-11-23 16:49:22 -08:00
|
|
|
pinnedData.Free();
|
|
|
|
return nat;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void NativeFree(IntPtr nat)
|
|
|
|
{
|
|
|
|
MemoryNative.Free(nat);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void NativeFreeInlistNodeElement(IntPtr nat)
|
|
|
|
{
|
|
|
|
// Do nothing
|
|
|
|
}
|
|
|
|
|
|
|
|
public void NativeFreeInlistNode(IntPtr nat, bool freeElement)
|
|
|
|
{
|
|
|
|
MemoryNative.Free(nat);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void NativeFreeInplace(IntPtr nat)
|
|
|
|
{
|
|
|
|
// Do nothing
|
|
|
|
}
|
|
|
|
|
|
|
|
public void ResidueFreeInplace(IntPtr nat)
|
|
|
|
{
|
|
|
|
NativeFree(nat);
|
|
|
|
}
|
|
|
|
|
|
|
|
public T NativeToManaged(IntPtr nat)
|
|
|
|
{
|
|
|
|
if (nat == IntPtr.Zero)
|
|
|
|
{
|
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
|
|
|
Eina.Log.Error("Null pointer on primitive/struct container.");
|
2017-11-23 16:49:22 -08:00
|
|
|
return default(T);
|
|
|
|
}
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
|
2017-12-15 16:15:00 -08:00
|
|
|
return PrimitiveConversion.PointerToManaged<T>(nat);
|
2017-11-23 16:49:22 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
public T NativeToManagedRef(IntPtr nat)
|
|
|
|
{
|
|
|
|
return NativeToManaged(nat);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public T NativeToManagedInplace(IntPtr nat)
|
|
|
|
{
|
|
|
|
return NativeToManaged(nat);
|
|
|
|
}
|
|
|
|
|
|
|
|
private int PrimitiveCompareCb(IntPtr ptr1, IntPtr ptr2)
|
|
|
|
{
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
var m1 = (IComparable)NativeToManaged(ptr1);
|
2017-11-23 16:49:22 -08:00
|
|
|
var m2 = NativeToManaged(ptr2);
|
|
|
|
return m1.CompareTo(m2);
|
|
|
|
}
|
|
|
|
|
|
|
|
public IntPtr EinaCompareCb()
|
|
|
|
{
|
|
|
|
if (dlgt == null)
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
{
|
2019-09-30 19:08:44 -07:00
|
|
|
dlgt = new Eina.Callbacks.EinaCompareCb(PrimitiveCompareCb);
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
}
|
|
|
|
|
2017-11-23 16:49:22 -08:00
|
|
|
return Marshal.GetFunctionPointerForDelegate(dlgt);
|
|
|
|
}
|
|
|
|
|
|
|
|
public IntPtr EinaFreeCb()
|
|
|
|
{
|
|
|
|
return MemoryNative.FreeFuncPtrGet();
|
|
|
|
}
|
|
|
|
|
|
|
|
public IntPtr EinaInarrayNew(uint step)
|
|
|
|
{
|
|
|
|
return eina_inarray_new((uint)Marshal.SizeOf<T>(), step);
|
|
|
|
}
|
|
|
|
|
|
|
|
public IntPtr EinaHashIteratorKeyNew(IntPtr hash)
|
|
|
|
{
|
|
|
|
return eina_hash_iterator_key_new(hash);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-14 07:57:01 -07:00
|
|
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
2019-01-15 23:29:56 -08:00
|
|
|
abstract public class Primitive32ElementTraits<T> : PrimitiveElementTraits<T>, IBaseElementTraits<T>
|
2017-11-23 16:49:22 -08:00
|
|
|
{
|
|
|
|
private static IBaseElementTraits<Int32> int32Traits = null;
|
|
|
|
|
|
|
|
public Primitive32ElementTraits()
|
|
|
|
{
|
|
|
|
if (int32Traits == null)
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
{
|
2017-11-23 16:49:22 -08:00
|
|
|
if (typeof(T) == typeof(Int32)) // avoid infinite recursion
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
{
|
2017-11-23 16:49:22 -08:00
|
|
|
int32Traits = (IBaseElementTraits<Int32>)this;
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
}
|
2017-11-23 16:49:22 -08:00
|
|
|
else
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
{
|
2017-11-23 16:49:22 -08:00
|
|
|
int32Traits = TraitFunctions.GetTypeTraits<Int32>();
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
}
|
|
|
|
}
|
2017-11-23 16:49:22 -08:00
|
|
|
}
|
|
|
|
|
2019-01-15 23:29:56 -08:00
|
|
|
public abstract void ManagedToNativeCopyTo(T man, IntPtr mem);
|
|
|
|
public abstract T NativeToManagedInlistNode(IntPtr nat);
|
|
|
|
|
2017-11-23 16:49:22 -08:00
|
|
|
public IntPtr ManagedToNativeAllocRef(T man, bool refs)
|
|
|
|
{
|
2019-11-07 18:33:09 -08:00
|
|
|
return int32Traits.ManagedToNativeAlloc(Convert.ToInt32((object)man, CultureInfo.CurrentCulture));
|
2017-11-23 16:49:22 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
public void NativeFreeRef(IntPtr nat, bool unrefs)
|
|
|
|
{
|
|
|
|
int32Traits.NativeFree(nat);
|
|
|
|
}
|
|
|
|
|
|
|
|
public IntPtr EinaHashNew()
|
|
|
|
{
|
|
|
|
return eina_hash_int32_new(IntPtr.Zero);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-14 07:57:01 -07:00
|
|
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
2019-01-15 23:29:56 -08:00
|
|
|
abstract public class Primitive64ElementTraits<T> : PrimitiveElementTraits<T>, IBaseElementTraits<T>
|
2017-11-23 16:49:22 -08:00
|
|
|
{
|
|
|
|
private static IBaseElementTraits<Int64> int64Traits = null;
|
|
|
|
|
|
|
|
public Primitive64ElementTraits()
|
|
|
|
{
|
|
|
|
if (int64Traits == null)
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
{
|
2017-11-23 16:49:22 -08:00
|
|
|
if (typeof(T) == typeof(Int64)) // avoid infinite recursion
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
{
|
2017-11-23 16:49:22 -08:00
|
|
|
int64Traits = (IBaseElementTraits<Int64>)this;
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
}
|
2017-11-23 16:49:22 -08:00
|
|
|
else
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
{
|
2017-11-23 16:49:22 -08:00
|
|
|
int64Traits = TraitFunctions.GetTypeTraits<Int64>();
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
}
|
|
|
|
}
|
2017-11-23 16:49:22 -08:00
|
|
|
}
|
|
|
|
|
2019-01-15 23:29:56 -08:00
|
|
|
public abstract void ManagedToNativeCopyTo(T man, IntPtr mem);
|
|
|
|
public abstract T NativeToManagedInlistNode(IntPtr nat);
|
|
|
|
|
2017-11-23 16:49:22 -08:00
|
|
|
public IntPtr ManagedToNativeAllocRef(T man, bool refs)
|
|
|
|
{
|
2019-11-07 18:33:09 -08:00
|
|
|
return int64Traits.ManagedToNativeAlloc(Convert.ToInt64((object)man, CultureInfo.CurrentCulture));
|
2017-11-23 16:49:22 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
public void NativeFreeRef(IntPtr nat, bool unrefs)
|
|
|
|
{
|
|
|
|
int64Traits.NativeFree(nat);
|
|
|
|
}
|
|
|
|
|
|
|
|
public IntPtr EinaHashNew()
|
|
|
|
{
|
|
|
|
return eina_hash_int64_new(IntPtr.Zero);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-14 07:57:01 -07:00
|
|
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
2019-01-15 23:29:56 -08:00
|
|
|
public class IntElementTraits : Primitive32ElementTraits<int>, IBaseElementTraits<int>
|
|
|
|
{
|
|
|
|
override public void ManagedToNativeCopyTo(int man, IntPtr mem)
|
|
|
|
{
|
|
|
|
var arr = new int[1];
|
|
|
|
arr[0] = man;
|
|
|
|
Marshal.Copy(arr, 0, mem, 1);
|
|
|
|
}
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
|
2019-01-15 23:29:56 -08:00
|
|
|
override public int NativeToManagedInlistNode(IntPtr nat)
|
|
|
|
{
|
|
|
|
if (nat == IntPtr.Zero)
|
|
|
|
{
|
|
|
|
Eina.Log.Error("Null pointer for Inlist node.");
|
|
|
|
return default(int);
|
|
|
|
}
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
|
2019-01-15 23:29:56 -08:00
|
|
|
IntPtr loc = nat + Marshal.SizeOf<InlistMem>();
|
|
|
|
var v = new int[1];
|
|
|
|
Marshal.Copy(loc, v, 0, 1);
|
|
|
|
return v[0];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-14 07:57:01 -07:00
|
|
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
2019-01-15 23:29:56 -08:00
|
|
|
public class CharElementTraits : Primitive32ElementTraits<char>, IBaseElementTraits<char>
|
|
|
|
{
|
|
|
|
override public void ManagedToNativeCopyTo(char man, IntPtr mem)
|
|
|
|
{
|
|
|
|
var arr = new char[1];
|
|
|
|
arr[0] = man;
|
|
|
|
Marshal.Copy(arr, 0, mem, 1);
|
|
|
|
}
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
|
2019-01-15 23:29:56 -08:00
|
|
|
override public char NativeToManagedInlistNode(IntPtr nat)
|
|
|
|
{
|
|
|
|
if (nat == IntPtr.Zero)
|
|
|
|
{
|
|
|
|
Eina.Log.Error("Null pointer for Inlist node.");
|
|
|
|
return default(char);
|
|
|
|
}
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
|
2019-01-15 23:29:56 -08:00
|
|
|
IntPtr loc = nat + Marshal.SizeOf<InlistMem>();
|
|
|
|
var v = new char[1];
|
|
|
|
Marshal.Copy(loc, v, 0, 1);
|
|
|
|
return v[0];
|
|
|
|
}
|
|
|
|
}
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
|
2019-10-14 07:57:01 -07:00
|
|
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
2019-01-15 23:29:56 -08:00
|
|
|
public class LongElementTraits : Primitive64ElementTraits<long>, IBaseElementTraits<long>
|
|
|
|
{
|
|
|
|
override public void ManagedToNativeCopyTo(long man, IntPtr mem)
|
|
|
|
{
|
|
|
|
var arr = new long[1];
|
|
|
|
arr[0] = man;
|
|
|
|
Marshal.Copy(arr, 0, mem, 1);
|
|
|
|
}
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
|
2019-01-15 23:29:56 -08:00
|
|
|
override public long NativeToManagedInlistNode(IntPtr nat)
|
|
|
|
{
|
|
|
|
if (nat == IntPtr.Zero)
|
|
|
|
{
|
|
|
|
Eina.Log.Error("Null pointer for Inlist node.");
|
|
|
|
return default(long);
|
|
|
|
}
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
|
2019-01-15 23:29:56 -08:00
|
|
|
IntPtr loc = nat + Marshal.SizeOf<InlistMem>();
|
|
|
|
var v = new long[1];
|
|
|
|
Marshal.Copy(loc, v, 0, 1);
|
|
|
|
return v[0];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-14 07:57:01 -07:00
|
|
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
2019-01-15 23:29:56 -08:00
|
|
|
public class ShortElementTraits : Primitive32ElementTraits<short>, IBaseElementTraits<short>
|
|
|
|
{
|
|
|
|
override public void ManagedToNativeCopyTo(short man, IntPtr mem)
|
|
|
|
{
|
|
|
|
var arr = new short[1];
|
|
|
|
arr[0] = man;
|
|
|
|
Marshal.Copy(arr, 0, mem, 1);
|
|
|
|
}
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
|
2019-01-15 23:29:56 -08:00
|
|
|
override public short NativeToManagedInlistNode(IntPtr nat)
|
|
|
|
{
|
|
|
|
if (nat == IntPtr.Zero)
|
|
|
|
{
|
|
|
|
Eina.Log.Error("Null pointer for Inlist node.");
|
|
|
|
return default(short);
|
|
|
|
}
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
|
2019-01-15 23:29:56 -08:00
|
|
|
IntPtr loc = nat + Marshal.SizeOf<InlistMem>();
|
|
|
|
var v = new short[1];
|
|
|
|
Marshal.Copy(loc, v, 0, 1);
|
|
|
|
return v[0];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-14 07:57:01 -07:00
|
|
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
2019-01-15 23:29:56 -08:00
|
|
|
public class FloatElementTraits : Primitive32ElementTraits<float>, IBaseElementTraits<float>
|
|
|
|
{
|
|
|
|
override public void ManagedToNativeCopyTo(float man, IntPtr mem)
|
|
|
|
{
|
|
|
|
var arr = new float[1];
|
|
|
|
arr[0] = man;
|
|
|
|
Marshal.Copy(arr, 0, mem, 1);
|
|
|
|
}
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
|
2019-01-15 23:29:56 -08:00
|
|
|
override public float NativeToManagedInlistNode(IntPtr nat)
|
|
|
|
{
|
|
|
|
if (nat == IntPtr.Zero)
|
|
|
|
{
|
|
|
|
Eina.Log.Error("Null pointer for Inlist node.");
|
|
|
|
return default(float);
|
|
|
|
}
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
|
2019-01-15 23:29:56 -08:00
|
|
|
IntPtr loc = nat + Marshal.SizeOf<InlistMem>();
|
|
|
|
var v = new float[1];
|
|
|
|
Marshal.Copy(loc, v, 0, 1);
|
|
|
|
return v[0];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-14 07:57:01 -07:00
|
|
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
2019-01-15 23:29:56 -08:00
|
|
|
public class DoubleElementTraits : Primitive64ElementTraits<double>, IBaseElementTraits<double>
|
|
|
|
{
|
|
|
|
override public void ManagedToNativeCopyTo(double man, IntPtr mem)
|
|
|
|
{
|
|
|
|
var arr = new double[1];
|
|
|
|
arr[0] = man;
|
|
|
|
Marshal.Copy(arr, 0, mem, 1);
|
|
|
|
}
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
|
2019-01-15 23:29:56 -08:00
|
|
|
override public double NativeToManagedInlistNode(IntPtr nat)
|
|
|
|
{
|
|
|
|
if (nat == IntPtr.Zero)
|
|
|
|
{
|
|
|
|
Eina.Log.Error("Null pointer for Inlist node.");
|
|
|
|
return default(double);
|
|
|
|
}
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
|
2019-01-15 23:29:56 -08:00
|
|
|
IntPtr loc = nat + Marshal.SizeOf<InlistMem>();
|
|
|
|
var v = new double[1];
|
|
|
|
Marshal.Copy(loc, v, 0, 1);
|
|
|
|
return v[0];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-14 07:57:01 -07:00
|
|
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
2019-01-15 23:29:56 -08:00
|
|
|
public class ByteElementTraits : Primitive32ElementTraits<byte>, IBaseElementTraits<byte>
|
|
|
|
{
|
|
|
|
override public void ManagedToNativeCopyTo(byte man, IntPtr mem)
|
|
|
|
{
|
|
|
|
var arr = new byte[1];
|
|
|
|
arr[0] = man;
|
|
|
|
Marshal.Copy(arr, 0, mem, 1);
|
|
|
|
}
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
|
2019-01-15 23:29:56 -08:00
|
|
|
override public byte NativeToManagedInlistNode(IntPtr nat)
|
|
|
|
{
|
|
|
|
if (nat == IntPtr.Zero)
|
|
|
|
{
|
|
|
|
Eina.Log.Error("Null pointer for Inlist node.");
|
|
|
|
return default(byte);
|
|
|
|
}
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
|
2019-01-15 23:29:56 -08:00
|
|
|
IntPtr loc = nat + Marshal.SizeOf<InlistMem>();
|
|
|
|
var v = new byte[1];
|
|
|
|
Marshal.Copy(loc, v, 0, 1);
|
|
|
|
return v[0];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-14 07:57:01 -07:00
|
|
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
2017-11-23 16:49:22 -08:00
|
|
|
public static class TraitFunctions
|
|
|
|
{
|
|
|
|
public static bool IsEflObject(System.Type type)
|
|
|
|
{
|
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 typeof(Efl.Eo.IWrapper).IsAssignableFrom(type);
|
2017-11-23 16:49:22 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
public static bool IsString(System.Type type)
|
|
|
|
{
|
|
|
|
return type == typeof(string);
|
|
|
|
}
|
|
|
|
|
2019-06-28 06:40:52 -07:00
|
|
|
public static bool IsStringshare(System.Type type)
|
|
|
|
{
|
|
|
|
return type == typeof(Eina.Stringshare);
|
|
|
|
}
|
|
|
|
|
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 static Eina.ElementType GetElementTypeCode(System.Type type)
|
2017-11-23 16:49:22 -08:00
|
|
|
{
|
|
|
|
if (IsEflObject(type))
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
{
|
2017-11-23 16:49:22 -08:00
|
|
|
return ElementType.ObjectType;
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
}
|
2017-11-23 16:49:22 -08:00
|
|
|
else if (IsString(type))
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
{
|
2017-11-23 16:49:22 -08:00
|
|
|
return ElementType.StringType;
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
}
|
2019-06-28 06:40:52 -07:00
|
|
|
else if (IsStringshare(type))
|
|
|
|
{
|
|
|
|
return ElementType.StringshareType;
|
|
|
|
}
|
2017-11-23 16:49:22 -08:00
|
|
|
else
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
{
|
2017-11-23 16:49:22 -08:00
|
|
|
return ElementType.NumericType;
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
}
|
2017-11-23 16:49:22 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
private static IDictionary<System.Type, object> register = new Dictionary<System.Type, object>();
|
|
|
|
|
2018-05-02 15:49:37 -07:00
|
|
|
private static System.Type AsEflInstantiableType(System.Type type)
|
|
|
|
{
|
|
|
|
if (!IsEflObject(type))
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
{
|
2018-05-02 15:49:37 -07:00
|
|
|
return null;
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
}
|
2018-05-02 15:49:37 -07:00
|
|
|
|
|
|
|
if (type.IsInterface)
|
|
|
|
{
|
2019-02-06 11:50:28 -08:00
|
|
|
string fullName = type.FullName + "Concrete";
|
2018-05-02 15:49:37 -07:00
|
|
|
return type.Assembly.GetType(fullName); // That was our best guess...
|
|
|
|
}
|
|
|
|
|
2019-02-06 11:50:28 -08:00
|
|
|
return type; // Not interface, so it should be a concrete.
|
2018-05-02 15:49:37 -07:00
|
|
|
}
|
|
|
|
|
2017-11-23 16:49:22 -08:00
|
|
|
public static object RegisterTypeTraits<T>()
|
|
|
|
{
|
2019-01-15 23:29:56 -08:00
|
|
|
Eina.Log.Debug($"Finding TypeTraits for {typeof(T).Name}");
|
2017-11-23 16:49:22 -08:00
|
|
|
object traits;
|
|
|
|
var type = typeof(T);
|
|
|
|
if (IsEflObject(type))
|
|
|
|
{
|
2018-05-02 15:49:37 -07:00
|
|
|
System.Type concrete = AsEflInstantiableType(type);
|
|
|
|
if (concrete == null || !type.IsAssignableFrom(concrete))
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
{
|
2018-05-02 15:49:37 -07:00
|
|
|
throw new Exception("Failed to get a suitable concrete class for this type.");
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
}
|
|
|
|
|
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
|
|
|
// No need to pass concrete as the traits class will use reflection to get the actually most
|
|
|
|
// derived type returned.
|
|
|
|
traits = new EflObjectElementTraits<T>();
|
2017-11-23 16:49:22 -08:00
|
|
|
}
|
|
|
|
else if (IsString(type))
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
{
|
2019-01-15 23:29:56 -08:00
|
|
|
traits = new StringElementTraits();
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
}
|
2019-06-28 06:40:52 -07:00
|
|
|
else if (IsStringshare(type))
|
|
|
|
{
|
|
|
|
traits = new StringshareElementTraits();
|
|
|
|
}
|
2017-11-23 16:49:22 -08:00
|
|
|
else if (type.IsValueType)
|
|
|
|
{
|
2019-01-15 23:29:56 -08:00
|
|
|
if (type == typeof(int))
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
{
|
2019-01-15 23:29:56 -08:00
|
|
|
traits = new IntElementTraits();
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
}
|
2019-01-15 23:29:56 -08:00
|
|
|
else if (type == typeof(char))
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
{
|
2019-01-15 23:29:56 -08:00
|
|
|
traits = new CharElementTraits();
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
}
|
2019-01-15 23:29:56 -08:00
|
|
|
else if (type == typeof(long))
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
{
|
2019-01-15 23:29:56 -08:00
|
|
|
traits = new LongElementTraits();
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
}
|
2019-01-15 23:29:56 -08:00
|
|
|
else if (type == typeof(short))
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
{
|
2019-01-15 23:29:56 -08:00
|
|
|
traits = new ShortElementTraits();
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
}
|
2019-01-15 23:29:56 -08:00
|
|
|
else if (type == typeof(float))
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
{
|
2019-01-15 23:29:56 -08:00
|
|
|
traits = new FloatElementTraits();
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
}
|
2019-01-15 23:29:56 -08:00
|
|
|
else if (type == typeof(double))
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
{
|
2019-01-15 23:29:56 -08:00
|
|
|
traits = new DoubleElementTraits();
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
}
|
2019-01-15 23:29:56 -08:00
|
|
|
else if (type == typeof(byte))
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
{
|
2019-01-15 23:29:56 -08:00
|
|
|
traits = new ByteElementTraits();
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
}
|
2017-11-23 16:49:22 -08:00
|
|
|
else
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
{
|
2019-01-15 23:29:56 -08:00
|
|
|
throw new Exception("No traits registered for this type");
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
}
|
2017-11-23 16:49:22 -08:00
|
|
|
}
|
|
|
|
else
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
{
|
2017-11-23 16:49:22 -08:00
|
|
|
throw new Exception("No traits registered for this type");
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
}
|
2017-11-23 16:49:22 -08:00
|
|
|
|
|
|
|
register[type] = traits;
|
|
|
|
return traits;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static object RegisterTypeTraits<T>(IBaseElementTraits<T> traits)
|
|
|
|
{
|
|
|
|
register[typeof(T)] = traits;
|
|
|
|
return traits;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static IBaseElementTraits<T> GetTypeTraits<T>()
|
|
|
|
{
|
|
|
|
object traits;
|
|
|
|
if (!register.TryGetValue(typeof(T), out traits))
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
{
|
2017-11-23 16:49:22 -08:00
|
|
|
traits = RegisterTypeTraits<T>();
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return (IBaseElementTraits<T>)traits;
|
2017-11-23 16:49:22 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
// //
|
|
|
|
// Traits functions //
|
|
|
|
// //
|
|
|
|
|
|
|
|
// Convertion functions //
|
|
|
|
|
|
|
|
public static IntPtr ManagedToNativeAlloc<T>(T man)
|
|
|
|
{
|
|
|
|
return GetTypeTraits<T>().ManagedToNativeAlloc(man);
|
|
|
|
}
|
|
|
|
|
2019-01-15 23:29:56 -08:00
|
|
|
public static void ManagedToNativeCopyTo<T>(T man, IntPtr mem)
|
2017-11-23 16:49:22 -08:00
|
|
|
{
|
2019-01-15 23:29:56 -08:00
|
|
|
GetTypeTraits<T>().ManagedToNativeCopyTo(man, mem);
|
2017-11-23 16:49:22 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
public static IntPtr ManagedToNativeAllocInlistNode<T>(T man)
|
|
|
|
{
|
|
|
|
return GetTypeTraits<T>().ManagedToNativeAllocInlistNode(man);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void NativeFree<T>(IntPtr nat)
|
|
|
|
{
|
|
|
|
GetTypeTraits<T>().NativeFree(nat);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void NativeFreeInlistNodeElement<T>(IntPtr nat)
|
|
|
|
{
|
|
|
|
GetTypeTraits<T>().NativeFreeInlistNodeElement(nat);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void NativeFreeInlistNode<T>(IntPtr nat, bool freeElement = true)
|
|
|
|
{
|
|
|
|
GetTypeTraits<T>().NativeFreeInlistNode(nat, freeElement);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void NativeFreeInplace<T>(IntPtr nat)
|
|
|
|
{
|
|
|
|
GetTypeTraits<T>().NativeFreeInplace(nat);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void ResidueFreeInplace<T>(IntPtr nat)
|
|
|
|
{
|
|
|
|
GetTypeTraits<T>().ResidueFreeInplace(nat);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static T NativeToManaged<T>(IntPtr nat)
|
|
|
|
{
|
|
|
|
return GetTypeTraits<T>().NativeToManaged(nat);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static T NativeToManagedInlistNode<T>(IntPtr nat)
|
|
|
|
{
|
|
|
|
return GetTypeTraits<T>().NativeToManagedInlistNode(nat);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static T NativeToManagedInplace<T>(IntPtr nat)
|
|
|
|
{
|
|
|
|
return GetTypeTraits<T>().NativeToManagedInplace(nat);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Misc //
|
|
|
|
|
|
|
|
public static IntPtr EinaCompareCb<T>()
|
|
|
|
{
|
|
|
|
return GetTypeTraits<T>().EinaCompareCb();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static IntPtr EinaFreeCb<T>()
|
|
|
|
{
|
|
|
|
return GetTypeTraits<T>().EinaFreeCb();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static IntPtr EinaHashNew<TKey>()
|
|
|
|
{
|
|
|
|
return GetTypeTraits<TKey>().EinaHashNew();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static IntPtr EinaInarrayNew<T>(uint step)
|
|
|
|
{
|
|
|
|
return GetTypeTraits<T>().EinaInarrayNew(step);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static IntPtr EinaHashIteratorKeyNew<T>(IntPtr hash)
|
|
|
|
{
|
|
|
|
return GetTypeTraits<T>().EinaHashIteratorKeyNew(hash);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|