2017-12-06 16:03:55 -08:00
|
|
|
|
#pragma warning disable 1591
|
|
|
|
|
|
2017-11-23 16:49:22 -08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
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 static Eina.TraitFunctions;
|
|
|
|
|
using static Eina.IteratorNativeFunctions;
|
|
|
|
|
using static Eina.HashNativeFunctions;
|
|
|
|
|
using Eina.Callbacks;
|
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
|
|
|
|
namespace Eina
|
2017-11-23 16:49:22 -08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
|
|
|
|
public struct HashTupleNative
|
|
|
|
|
{
|
|
|
|
|
public IntPtr key;
|
|
|
|
|
public IntPtr data;
|
|
|
|
|
public uint key_length;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static class HashNativeFunctions
|
|
|
|
|
{
|
|
|
|
|
[DllImport(efl.Libs.Eina)] public static extern IntPtr
|
|
|
|
|
eina_hash_new(IntPtr key_length_cb, IntPtr key_cmp_cb, IntPtr key_hash_cb, IntPtr data_free_cb, int buckets_power_size);
|
|
|
|
|
|
|
|
|
|
[DllImport(efl.Libs.Eina)] public static extern void
|
|
|
|
|
eina_hash_free_cb_set(IntPtr hash, IntPtr data_free_cb);
|
|
|
|
|
|
|
|
|
|
[DllImport(efl.Libs.Eina)] public static extern IntPtr
|
|
|
|
|
eina_hash_string_djb2_new(IntPtr data_free_cb);
|
|
|
|
|
|
|
|
|
|
[DllImport(efl.Libs.Eina)] public static extern IntPtr
|
|
|
|
|
eina_hash_string_superfast_new(IntPtr data_free_cb);
|
|
|
|
|
|
|
|
|
|
[DllImport(efl.Libs.Eina)] public static extern IntPtr
|
|
|
|
|
eina_hash_string_small_new(IntPtr data_free_cb);
|
|
|
|
|
|
|
|
|
|
[DllImport(efl.Libs.Eina)] public static extern IntPtr
|
|
|
|
|
eina_hash_int32_new(IntPtr data_free_cb);
|
|
|
|
|
|
|
|
|
|
[DllImport(efl.Libs.Eina)] public static extern IntPtr
|
|
|
|
|
eina_hash_int64_new(IntPtr data_free_cb);
|
|
|
|
|
|
|
|
|
|
[DllImport(efl.Libs.Eina)] public static extern IntPtr
|
|
|
|
|
eina_hash_pointer_new(IntPtr data_free_cb);
|
|
|
|
|
|
|
|
|
|
[DllImport(efl.Libs.Eina)] public static extern IntPtr
|
|
|
|
|
eina_hash_stringshared_new(IntPtr data_free_cb);
|
|
|
|
|
|
|
|
|
|
[DllImport(efl.Libs.Eina)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool
|
|
|
|
|
eina_hash_add(IntPtr hash, IntPtr key, IntPtr data);
|
|
|
|
|
|
|
|
|
|
[DllImport(efl.Libs.Eina)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool
|
|
|
|
|
eina_hash_direct_add(IntPtr hash, IntPtr key, IntPtr data);
|
|
|
|
|
|
|
|
|
|
[DllImport(efl.Libs.Eina)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool
|
|
|
|
|
eina_hash_del(IntPtr hash, IntPtr key, IntPtr data);
|
|
|
|
|
|
|
|
|
|
[DllImport(efl.Libs.Eina)] public static extern IntPtr
|
|
|
|
|
eina_hash_find(IntPtr hash, IntPtr key);
|
|
|
|
|
|
|
|
|
|
[DllImport(efl.Libs.Eina)] public static extern IntPtr
|
|
|
|
|
eina_hash_modify(IntPtr hash, IntPtr key, IntPtr data);
|
|
|
|
|
|
|
|
|
|
[DllImport(efl.Libs.Eina)] public static extern IntPtr
|
|
|
|
|
eina_hash_set(IntPtr hash, IntPtr key, IntPtr data);
|
|
|
|
|
|
|
|
|
|
[DllImport(efl.Libs.Eina)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool
|
|
|
|
|
eina_hash_move(IntPtr hash, IntPtr old_key, IntPtr new_key);
|
|
|
|
|
|
|
|
|
|
[DllImport(efl.Libs.Eina)] public static extern void
|
|
|
|
|
eina_hash_free(IntPtr hash);
|
|
|
|
|
|
|
|
|
|
[DllImport(efl.Libs.Eina)] public static extern void
|
|
|
|
|
eina_hash_free_buckets(IntPtr hash);
|
|
|
|
|
|
|
|
|
|
[DllImport(efl.Libs.Eina)] public static extern int
|
|
|
|
|
eina_hash_population(IntPtr hash);
|
|
|
|
|
|
|
|
|
|
[DllImport(efl.Libs.Eina)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool
|
|
|
|
|
eina_hash_add_by_hash(IntPtr hash, IntPtr key, int key_length, int key_hash, IntPtr data);
|
|
|
|
|
|
|
|
|
|
[DllImport(efl.Libs.Eina)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool
|
|
|
|
|
eina_hash_direct_add_by_hash(IntPtr hash, IntPtr key, int key_length, int key_hash, IntPtr data);
|
|
|
|
|
|
|
|
|
|
[DllImport(efl.Libs.Eina)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool
|
|
|
|
|
eina_hash_del_by_key_hash(IntPtr hash, IntPtr key, int key_length, int key_hash);
|
|
|
|
|
|
|
|
|
|
[DllImport(efl.Libs.Eina)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool
|
|
|
|
|
eina_hash_del_by_key(IntPtr hash, IntPtr key);
|
|
|
|
|
|
|
|
|
|
[DllImport(efl.Libs.Eina)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool
|
|
|
|
|
eina_hash_del_by_data(IntPtr hash, IntPtr data);
|
|
|
|
|
|
|
|
|
|
[DllImport(efl.Libs.Eina)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool
|
|
|
|
|
eina_hash_del_by_hash(IntPtr hash, IntPtr key, int key_length, int key_hash, IntPtr data);
|
|
|
|
|
|
|
|
|
|
[DllImport(efl.Libs.Eina)] public static extern IntPtr
|
|
|
|
|
eina_hash_find_by_hash(IntPtr hash, IntPtr key, int key_length, int key_hash);
|
|
|
|
|
|
|
|
|
|
[DllImport(efl.Libs.Eina)] public static extern IntPtr
|
|
|
|
|
eina_hash_modify_by_hash(IntPtr hash, IntPtr key, int key_length, int key_hash, IntPtr data);
|
|
|
|
|
|
|
|
|
|
[DllImport(efl.Libs.Eina)] public static extern IntPtr
|
|
|
|
|
eina_hash_iterator_key_new(IntPtr hash);
|
|
|
|
|
|
|
|
|
|
[DllImport(efl.Libs.Eina)] public static extern IntPtr
|
|
|
|
|
eina_hash_iterator_data_new(IntPtr hash);
|
|
|
|
|
|
|
|
|
|
[DllImport(efl.Libs.Eina)] public static extern IntPtr
|
|
|
|
|
eina_hash_iterator_tuple_new(IntPtr hash);
|
|
|
|
|
|
|
|
|
|
[DllImport(efl.Libs.Eina)] public static extern void
|
|
|
|
|
eina_hash_foreach(IntPtr hash, IntPtr func, IntPtr fdata);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(efl.Libs.Eina)] public static extern void
|
|
|
|
|
eina_hash_list_append(IntPtr hash, IntPtr key, IntPtr data);
|
|
|
|
|
[DllImport(efl.Libs.Eina)] public static extern void
|
|
|
|
|
eina_hash_list_prepend(IntPtr hash, IntPtr key, IntPtr data);
|
|
|
|
|
[DllImport(efl.Libs.Eina)] public static extern void
|
|
|
|
|
eina_hash_list_remove(IntPtr hash, IntPtr key, IntPtr data);
|
|
|
|
|
|
|
|
|
|
[DllImport(efl.Libs.Eina)] public static extern int
|
|
|
|
|
eina_hash_superfast(string key, int len);
|
|
|
|
|
|
|
|
|
|
[DllImport(efl.Libs.CustomExports)] public static extern IntPtr
|
|
|
|
|
eina_hash_iterator_ptr_key_wrapper_new_custom_export_mono(IntPtr hash);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class Hash<TKey, TValue> : IEnumerable<KeyValuePair<TKey, TValue>>, IDisposable
|
|
|
|
|
{
|
|
|
|
|
public IntPtr Handle {get; set;} = IntPtr.Zero;
|
|
|
|
|
public bool Own {get; set;}
|
|
|
|
|
public bool OwnKey {get; set;}
|
|
|
|
|
public bool OwnValue {get; set;}
|
|
|
|
|
|
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 int Count
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2017-11-23 16:49:22 -08:00
|
|
|
|
return Population();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void InitNew()
|
|
|
|
|
{
|
|
|
|
|
Handle = EinaHashNew<TKey>();
|
|
|
|
|
SetOwn(true);
|
|
|
|
|
SetOwnKey(true);
|
|
|
|
|
SetOwnValue(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Hash()
|
|
|
|
|
{
|
|
|
|
|
InitNew();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Hash(IntPtr handle, bool own)
|
|
|
|
|
{
|
|
|
|
|
Handle = handle;
|
|
|
|
|
SetOwnership(own);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Hash(IntPtr handle, bool own, bool ownKey, bool ownValue)
|
|
|
|
|
{
|
|
|
|
|
Handle = handle;
|
|
|
|
|
SetOwnership(own, ownKey, ownValue);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
~Hash()
|
|
|
|
|
{
|
|
|
|
|
Dispose(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected virtual void Dispose(bool disposing)
|
|
|
|
|
{
|
|
|
|
|
IntPtr h = Handle;
|
|
|
|
|
Handle = IntPtr.Zero;
|
|
|
|
|
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;
|
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 (Own)
|
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-04-05 15:57:29 -07:00
|
|
|
|
if (disposing)
|
|
|
|
|
{
|
|
|
|
|
eina_hash_free(h);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Efl.Eo.Globals.efl_mono_thread_safe_free_cb_exec(eina_hash_free, 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
|
|
|
|
}
|
2017-11-23 16:49:22 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
|
{
|
|
|
|
|
Dispose(true);
|
|
|
|
|
GC.SuppressFinalize(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Free()
|
|
|
|
|
{
|
|
|
|
|
Dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IntPtr Release()
|
|
|
|
|
{
|
|
|
|
|
IntPtr h = Handle;
|
|
|
|
|
Handle = IntPtr.Zero;
|
|
|
|
|
return h;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetOwn(bool own)
|
|
|
|
|
{
|
|
|
|
|
Own = own;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetOwnKey(bool ownKey)
|
|
|
|
|
{
|
|
|
|
|
OwnKey = ownKey;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetOwnValue(bool ownValue)
|
|
|
|
|
{
|
|
|
|
|
OwnValue = ownValue;
|
|
|
|
|
|
|
|
|
|
if (ownValue)
|
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
|
|
|
|
eina_hash_free_cb_set(Handle, EinaFreeCb<TValue>());
|
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 SetOwnership(bool ownAll)
|
|
|
|
|
{
|
|
|
|
|
SetOwn(ownAll);
|
|
|
|
|
SetOwnKey(ownAll);
|
|
|
|
|
SetOwnValue(ownAll);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetOwnership(bool own, bool ownKey, bool ownValue)
|
|
|
|
|
{
|
|
|
|
|
SetOwn(own);
|
|
|
|
|
SetOwnKey(ownKey);
|
|
|
|
|
SetOwnValue(ownValue);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void UnSetFreeCb()
|
|
|
|
|
{
|
|
|
|
|
eina_hash_free_cb_set(Handle, IntPtr.Zero);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool AddNew(TKey key, TValue val)
|
|
|
|
|
{
|
2019-01-15 23:29:56 -08:00
|
|
|
|
IntPtr gchnk = CopyNativeObject(key, ForceRefKey<TKey>());
|
|
|
|
|
IntPtr nk = GetNativePtr<TKey>(gchnk, ForceRefKey<TKey>());
|
|
|
|
|
IntPtr gchnv = CopyNativeObject(val, false);
|
|
|
|
|
IntPtr nv = GetNativePtr<TValue>(gchnv, false);
|
2017-11-23 16:49:22 -08:00
|
|
|
|
var r = eina_hash_add(Handle, nk, nv);
|
2019-01-15 23:29:56 -08:00
|
|
|
|
FreeNativeIndirection<TKey>(gchnk, ForceRefKey<TKey>());
|
|
|
|
|
FreeNativeIndirection<TValue>(gchnv, false);
|
2017-11-23 16:49:22 -08:00
|
|
|
|
return r;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Add(TKey key, TValue val)
|
|
|
|
|
{
|
|
|
|
|
Set(key, val);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool DelByKey(TKey key)
|
|
|
|
|
{
|
2019-01-15 23:29:56 -08:00
|
|
|
|
IntPtr gchnk = CopyNativeObject(key, ForceRefKey<TKey>());
|
|
|
|
|
IntPtr nk = GetNativePtr<TKey>(gchnk, ForceRefKey<TKey>());
|
2017-11-23 16:49:22 -08:00
|
|
|
|
var r = eina_hash_del_by_key(Handle, nk);
|
2019-01-15 23:29:56 -08:00
|
|
|
|
FreeNativeIndirection<TKey>(gchnk, ForceRefKey<TKey>());
|
|
|
|
|
// NativeFreeRef<TKey>(nk, OwnKey && r);
|
2017-11-23 16:49:22 -08:00
|
|
|
|
return r;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool DelByValue(TValue val)
|
|
|
|
|
{
|
2019-01-15 23:29:56 -08:00
|
|
|
|
IntPtr gchnv = CopyNativeObject(val, false);
|
|
|
|
|
IntPtr nv = GetNativePtr<TValue>(gchnv, false);
|
2017-11-23 16:49:22 -08:00
|
|
|
|
var r = eina_hash_del_by_data(Handle, nv);
|
2019-01-15 23:29:56 -08:00
|
|
|
|
FreeNativeIndirection<TValue>(gchnv, false);
|
2017-11-23 16:49:22 -08:00
|
|
|
|
return r;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Remove(TKey key)
|
|
|
|
|
{
|
|
|
|
|
DelByKey(key);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public TValue Find(TKey key)
|
|
|
|
|
{
|
2019-01-15 23:29:56 -08:00
|
|
|
|
var gchnk = CopyNativeObject<TKey>(key, ForceRefKey<TKey>());
|
|
|
|
|
var nk = GetNativePtr<TKey>(gchnk, ForceRefKey<TKey>());
|
2017-11-23 16:49:22 -08:00
|
|
|
|
var found = eina_hash_find(Handle, nk);
|
2019-01-15 23:29:56 -08:00
|
|
|
|
//NativeFreeRef<TKey>(nk);
|
|
|
|
|
FreeNativeIndirection<TKey>(gchnk, ForceRefKey<TKey>());
|
2017-11-23 16:49:22 -08:00
|
|
|
|
if (found == 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
|
|
|
|
throw new KeyNotFoundException();
|
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<TValue>(IndirectNative<TValue>(found, false));
|
2017-11-23 16:49:22 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool TryGetValue(TKey key, out TValue val)
|
|
|
|
|
{
|
2019-01-15 23:29:56 -08:00
|
|
|
|
var gchnk = CopyNativeObject<TKey>(key, ForceRefKey<TKey>());
|
|
|
|
|
var nk = GetNativePtr<TKey>(gchnk, ForceRefKey<TKey>());
|
2017-11-23 16:49:22 -08:00
|
|
|
|
var found = eina_hash_find(Handle, nk);
|
2019-01-15 23:29:56 -08:00
|
|
|
|
FreeNativeIndirection<TKey>(gchnk, ForceRefKey<TKey>());
|
2017-11-23 16:49:22 -08:00
|
|
|
|
if (found == IntPtr.Zero)
|
|
|
|
|
{
|
|
|
|
|
val = default(TValue);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
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
|
|
|
|
val = NativeToManaged<TValue>(IndirectNative<TValue>(found, false));
|
2017-11-23 16:49:22 -08:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool ContainsKey(TKey key)
|
|
|
|
|
{
|
2019-01-15 23:29:56 -08:00
|
|
|
|
var gchnk = CopyNativeObject<TKey>(key, ForceRefKey<TKey>());
|
|
|
|
|
var nk = GetNativePtr<TKey>(gchnk, ForceRefKey<TKey>());
|
|
|
|
|
// var nk = ManagedToNativeAllocRef(key);
|
2017-11-23 16:49:22 -08:00
|
|
|
|
var found = eina_hash_find(Handle, nk);
|
2019-01-15 23:29:56 -08:00
|
|
|
|
// NativeFreeRef<TKey>(nk);
|
|
|
|
|
FreeNativeIndirection<TKey>(gchnk, ForceRefKey<TKey>());
|
2017-11-23 16:49:22 -08:00
|
|
|
|
return found != IntPtr.Zero;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool Modify(TKey key, TValue val)
|
|
|
|
|
{
|
2019-01-15 23:29:56 -08:00
|
|
|
|
var gchnk = CopyNativeObject<TKey>(key, ForceRefKey<TKey>());
|
|
|
|
|
var nk = GetNativePtr<TKey>(gchnk, ForceRefKey<TKey>());
|
|
|
|
|
var gchnv = CopyNativeObject<TValue>(val, false);
|
|
|
|
|
var nv = GetNativePtr<TValue>(gchnv, false);
|
2017-11-23 16:49:22 -08:00
|
|
|
|
var old = eina_hash_modify(Handle, nk, nv);
|
2019-01-15 23:29:56 -08:00
|
|
|
|
FreeNativeIndirection<TKey>(gchnk, ForceRefKey<TKey>());
|
|
|
|
|
// NativeFreeRef<TKey>(nk);
|
2017-11-23 16:49:22 -08:00
|
|
|
|
if (old == IntPtr.Zero)
|
|
|
|
|
{
|
|
|
|
|
NativeFree<TValue>(nv);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
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 (OwnValue)
|
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
|
|
|
|
NativeFree<TValue>(old);
|
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 true;
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-15 23:29:56 -08:00
|
|
|
|
private static bool ForceRefKey<T>()
|
|
|
|
|
{
|
|
|
|
|
return (!typeof(T).IsValueType) && (typeof(T) != typeof(string));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static IntPtr CopyNativeObject<T>(T value, bool forceRef)
|
|
|
|
|
{
|
|
|
|
|
if (!IsEflObject(typeof(T)) && forceRef)
|
|
|
|
|
{
|
|
|
|
|
GCHandle gch = GCHandle.Alloc(new byte[Marshal.SizeOf<T>()], GCHandleType.Pinned);
|
|
|
|
|
IntPtr pin = gch.AddrOfPinnedObject();
|
|
|
|
|
|
|
|
|
|
ManagedToNativeCopyTo(value, pin);
|
|
|
|
|
|
|
|
|
|
return GCHandle.ToIntPtr(gch);
|
|
|
|
|
}
|
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
|
|
|
|
else if (IsEflObject(typeof(T)) && forceRef)
|
2019-01-15 23:29:56 -08:00
|
|
|
|
{
|
|
|
|
|
GCHandle gch = GCHandle.Alloc(new byte[Marshal.SizeOf<IntPtr>()], GCHandleType.Pinned);
|
|
|
|
|
IntPtr pin = gch.AddrOfPinnedObject();
|
|
|
|
|
|
|
|
|
|
ManagedToNativeCopyTo(value, pin);
|
|
|
|
|
|
|
|
|
|
return GCHandle.ToIntPtr(gch);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return ManagedToNativeAlloc(value);
|
|
|
|
|
}
|
|
|
|
|
}
|
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
|
|
|
|
private static IntPtr GetNativePtr<T>(IntPtr gchptr, bool forceRef)
|
|
|
|
|
{
|
|
|
|
|
if (forceRef)
|
|
|
|
|
{
|
|
|
|
|
GCHandle gch = GCHandle.FromIntPtr(gchptr);
|
|
|
|
|
IntPtr pin = gch.AddrOfPinnedObject();
|
|
|
|
|
|
|
|
|
|
return pin;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return gchptr;
|
|
|
|
|
}
|
|
|
|
|
}
|
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
|
|
|
|
private static void FreeNativeIndirection<T>(IntPtr gchptr, bool forceRef)
|
|
|
|
|
{
|
|
|
|
|
if (forceRef)
|
|
|
|
|
{
|
|
|
|
|
GCHandle gch = GCHandle.FromIntPtr(gchptr);
|
|
|
|
|
gch.Free();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static IntPtr IndirectNative<T>(IntPtr ptr, bool forceRef)
|
|
|
|
|
{
|
|
|
|
|
if (forceRef)
|
|
|
|
|
{
|
|
|
|
|
IntPtr val = Marshal.ReadIntPtr(ptr);
|
|
|
|
|
return val;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return ptr;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-23 16:49:22 -08:00
|
|
|
|
public void Set(TKey key, TValue val)
|
|
|
|
|
{
|
2019-01-15 23:29:56 -08:00
|
|
|
|
IntPtr gchnk = CopyNativeObject(key, ForceRefKey<TKey>());
|
|
|
|
|
IntPtr nk = GetNativePtr<TKey>(gchnk, ForceRefKey<TKey>());
|
|
|
|
|
|
|
|
|
|
IntPtr gchnv = CopyNativeObject(val, false);
|
|
|
|
|
IntPtr nv = GetNativePtr<TValue>(gchnv, false);
|
|
|
|
|
IntPtr old = eina_hash_set(Handle, nk, nv);
|
|
|
|
|
FreeNativeIndirection<TKey>(gchnk, ForceRefKey<TKey>());
|
|
|
|
|
FreeNativeIndirection<TValue>(gchnv, false);
|
2019-03-07 08:58:26 -08:00
|
|
|
|
if (OwnValue || old != 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-03-07 08:58:26 -08:00
|
|
|
|
NativeFree<TValue>(old);
|
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 TValue this[TKey key]
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return Find(key);
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
Set(key, value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool Move(TKey key_old, TKey key_new)
|
|
|
|
|
{
|
2019-01-15 23:29:56 -08:00
|
|
|
|
IntPtr gchnko = CopyNativeObject(key_old, ForceRefKey<TKey>());
|
|
|
|
|
IntPtr nko = GetNativePtr<TKey>(gchnko, ForceRefKey<TKey>());
|
|
|
|
|
IntPtr gchnk = CopyNativeObject(key_new, ForceRefKey<TKey>());
|
|
|
|
|
IntPtr nk = GetNativePtr<TKey>(gchnk, ForceRefKey<TKey>());
|
|
|
|
|
// var nk_old = ManagedToNativeAllocRef(key_old);
|
|
|
|
|
// var nk_new = ManagedToNativeAllocRef(key_new, true);
|
|
|
|
|
var r = eina_hash_move(Handle, nko, nk);
|
|
|
|
|
FreeNativeIndirection<TKey>(gchnko, ForceRefKey<TKey>());
|
|
|
|
|
FreeNativeIndirection<TKey>(gchnk, ForceRefKey<TKey>());
|
|
|
|
|
// NativeFreeRef<TKey>(nk_old, OwnKey && r);
|
|
|
|
|
// NativeFreeRef<TKey>(nk_new, !r);
|
2017-11-23 16:49:22 -08:00
|
|
|
|
return r;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void FreeBuckets()
|
|
|
|
|
{
|
|
|
|
|
eina_hash_free_buckets(Handle);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int Population()
|
|
|
|
|
{
|
|
|
|
|
return eina_hash_population(Handle);
|
|
|
|
|
}
|
|
|
|
|
|
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 Eina.Iterator<TKey> Keys()
|
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
|
|
|
|
return new Eina.Iterator<TKey>(EinaHashIteratorKeyNew<TKey>(Handle), true, false);
|
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
|
|
|
|
public Eina.Iterator<TValue> Values()
|
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
|
|
|
|
return new Eina.Iterator<TValue>(eina_hash_iterator_data_new(Handle), true, false);
|
2017-11-23 16:49:22 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()
|
|
|
|
|
{
|
|
|
|
|
IntPtr itr = eina_hash_iterator_tuple_new(Handle);
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
for (IntPtr tuplePtr; eina_iterator_next(itr, out tuplePtr);)
|
|
|
|
|
{
|
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
|
|
|
|
var tuple = Marshal.PtrToStructure<Eina.HashTupleNative>(tuplePtr);
|
2019-01-15 23:29:56 -08:00
|
|
|
|
IntPtr ikey = IndirectNative<TKey>(tuple.key, ForceRefKey<TKey>());
|
|
|
|
|
var key = NativeToManaged<TKey>(ikey);
|
2017-11-23 16:49:22 -08:00
|
|
|
|
var val = NativeToManaged<TValue>(tuple.data);
|
|
|
|
|
yield return new KeyValuePair<TKey, TValue>(key, val);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
eina_iterator_free(itr);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
|
|
|
|
|
{
|
|
|
|
|
return this.GetEnumerator();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|