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;
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
using System.Collections.Generic;
|
2019-10-14 07:22:56 -07:00
|
|
|
|
using System.ComponentModel;
|
2019-12-17 05:56:42 -08:00
|
|
|
|
using System.Diagnostics.CodeAnalysis;
|
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 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)]
|
2019-10-14 07:22:56 -07:00
|
|
|
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
2019-12-18 18:46:11 -08:00
|
|
|
|
internal struct HashTupleNative : IEquatable<HashTupleNative>
|
2017-11-23 16:49:22 -08:00
|
|
|
|
{
|
|
|
|
|
public IntPtr key;
|
|
|
|
|
public IntPtr data;
|
|
|
|
|
public uint key_length;
|
2019-11-14 11:27:14 -08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets a hash for <see cref="HashTupleNative" />.
|
|
|
|
|
/// <para>Since EFL 1.24.</para>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>A hash code.</returns>
|
|
|
|
|
public override int GetHashCode()
|
|
|
|
|
=> key.GetHashCode() ^ data.GetHashCode() ^ key_length.GetHashCode();
|
|
|
|
|
|
|
|
|
|
/// <summary>Returns whether this <see cref="HashTupleNative" />
|
|
|
|
|
/// 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 HashTupleNative)) ? false : Equals((HashTupleNative)other);
|
|
|
|
|
|
|
|
|
|
/// <summary>Returns whether this <see cref="HashTupleNative" /> is equal
|
|
|
|
|
/// to the given <see cref="HashTupleNative" />.
|
|
|
|
|
/// <para>Since EFL 1.24.</para>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="other">The <see cref="HashTupleNative" /> to be compared to.</param>
|
|
|
|
|
/// <returns><c>true</c> if is equal to <c>other</c>.</returns>
|
|
|
|
|
public bool Equals(HashTupleNative other)
|
|
|
|
|
=> (key == other.key) && (data == other.data)
|
|
|
|
|
&& (key_length == other.key_length);
|
|
|
|
|
|
|
|
|
|
/// <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==(HashTupleNative lhs, HashTupleNative 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!=(HashTupleNative lhs, HashTupleNative rhs) => !(lhs == rhs);
|
2017-11-23 16:49:22 -08:00
|
|
|
|
}
|
|
|
|
|
|
2019-10-14 07:22:56 -07:00
|
|
|
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
2019-12-18 18:46:11 -08:00
|
|
|
|
internal static class HashNativeFunctions
|
2017-11-23 16:49:22 -08:00
|
|
|
|
{
|
2019-10-17 16:23:11 -07:00
|
|
|
|
[DllImport(efl.Libs.Eina)] internal static extern IntPtr
|
2017-11-23 16:49:22 -08:00
|
|
|
|
eina_hash_new(IntPtr key_length_cb, IntPtr key_cmp_cb, IntPtr key_hash_cb, IntPtr data_free_cb, int buckets_power_size);
|
|
|
|
|
|
2019-10-17 16:23:11 -07:00
|
|
|
|
[DllImport(efl.Libs.Eina)] internal static extern void
|
2017-11-23 16:49:22 -08:00
|
|
|
|
eina_hash_free_cb_set(IntPtr hash, IntPtr data_free_cb);
|
|
|
|
|
|
2019-10-17 16:23:11 -07:00
|
|
|
|
[DllImport(efl.Libs.Eina)] internal static extern IntPtr
|
2017-11-23 16:49:22 -08:00
|
|
|
|
eina_hash_string_djb2_new(IntPtr data_free_cb);
|
|
|
|
|
|
2019-10-17 16:23:11 -07:00
|
|
|
|
[DllImport(efl.Libs.Eina)] internal static extern IntPtr
|
2017-11-23 16:49:22 -08:00
|
|
|
|
eina_hash_string_superfast_new(IntPtr data_free_cb);
|
|
|
|
|
|
2019-10-17 16:23:11 -07:00
|
|
|
|
[DllImport(efl.Libs.Eina)] internal static extern IntPtr
|
2017-11-23 16:49:22 -08:00
|
|
|
|
eina_hash_string_small_new(IntPtr data_free_cb);
|
|
|
|
|
|
2019-10-17 16:23:11 -07:00
|
|
|
|
[DllImport(efl.Libs.Eina)] internal static extern IntPtr
|
2017-11-23 16:49:22 -08:00
|
|
|
|
eina_hash_int32_new(IntPtr data_free_cb);
|
|
|
|
|
|
2019-10-17 16:23:11 -07:00
|
|
|
|
[DllImport(efl.Libs.Eina)] internal static extern IntPtr
|
2017-11-23 16:49:22 -08:00
|
|
|
|
eina_hash_int64_new(IntPtr data_free_cb);
|
|
|
|
|
|
2019-10-17 16:23:11 -07:00
|
|
|
|
[DllImport(efl.Libs.Eina)] internal static extern IntPtr
|
2017-11-23 16:49:22 -08:00
|
|
|
|
eina_hash_pointer_new(IntPtr data_free_cb);
|
|
|
|
|
|
2019-10-17 16:23:11 -07:00
|
|
|
|
[DllImport(efl.Libs.Eina)] internal static extern IntPtr
|
2017-11-23 16:49:22 -08:00
|
|
|
|
eina_hash_stringshared_new(IntPtr data_free_cb);
|
|
|
|
|
|
2019-10-17 16:23:11 -07:00
|
|
|
|
[DllImport(efl.Libs.Eina)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool
|
2017-11-23 16:49:22 -08:00
|
|
|
|
eina_hash_add(IntPtr hash, IntPtr key, IntPtr data);
|
|
|
|
|
|
2019-10-17 16:23:11 -07:00
|
|
|
|
[DllImport(efl.Libs.Eina)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool
|
2017-11-23 16:49:22 -08:00
|
|
|
|
eina_hash_direct_add(IntPtr hash, IntPtr key, IntPtr data);
|
|
|
|
|
|
2019-10-17 16:23:11 -07:00
|
|
|
|
[DllImport(efl.Libs.Eina)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool
|
2017-11-23 16:49:22 -08:00
|
|
|
|
eina_hash_del(IntPtr hash, IntPtr key, IntPtr data);
|
|
|
|
|
|
2019-10-17 16:23:11 -07:00
|
|
|
|
[DllImport(efl.Libs.Eina)] internal static extern IntPtr
|
2017-11-23 16:49:22 -08:00
|
|
|
|
eina_hash_find(IntPtr hash, IntPtr key);
|
|
|
|
|
|
2019-10-17 16:23:11 -07:00
|
|
|
|
[DllImport(efl.Libs.Eina)] internal static extern IntPtr
|
2017-11-23 16:49:22 -08:00
|
|
|
|
eina_hash_modify(IntPtr hash, IntPtr key, IntPtr data);
|
|
|
|
|
|
2019-10-17 16:23:11 -07:00
|
|
|
|
[DllImport(efl.Libs.Eina)] internal static extern IntPtr
|
2017-11-23 16:49:22 -08:00
|
|
|
|
eina_hash_set(IntPtr hash, IntPtr key, IntPtr data);
|
|
|
|
|
|
2019-10-17 16:23:11 -07:00
|
|
|
|
[DllImport(efl.Libs.Eina)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool
|
2017-11-23 16:49:22 -08:00
|
|
|
|
eina_hash_move(IntPtr hash, IntPtr old_key, IntPtr new_key);
|
|
|
|
|
|
2019-10-17 16:23:11 -07:00
|
|
|
|
[DllImport(efl.Libs.Eina)] internal static extern void
|
2017-11-23 16:49:22 -08:00
|
|
|
|
eina_hash_free(IntPtr hash);
|
|
|
|
|
|
2019-10-17 16:23:11 -07:00
|
|
|
|
[DllImport(efl.Libs.Eina)] internal static extern void
|
2017-11-23 16:49:22 -08:00
|
|
|
|
eina_hash_free_buckets(IntPtr hash);
|
|
|
|
|
|
2019-10-17 16:23:11 -07:00
|
|
|
|
[DllImport(efl.Libs.Eina)] internal static extern int
|
2017-11-23 16:49:22 -08:00
|
|
|
|
eina_hash_population(IntPtr hash);
|
|
|
|
|
|
2019-10-17 16:23:11 -07:00
|
|
|
|
[DllImport(efl.Libs.Eina)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool
|
2017-11-23 16:49:22 -08:00
|
|
|
|
eina_hash_add_by_hash(IntPtr hash, IntPtr key, int key_length, int key_hash, IntPtr data);
|
|
|
|
|
|
2019-10-17 16:23:11 -07:00
|
|
|
|
[DllImport(efl.Libs.Eina)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool
|
2017-11-23 16:49:22 -08:00
|
|
|
|
eina_hash_direct_add_by_hash(IntPtr hash, IntPtr key, int key_length, int key_hash, IntPtr data);
|
|
|
|
|
|
2019-10-17 16:23:11 -07:00
|
|
|
|
[DllImport(efl.Libs.Eina)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool
|
2017-11-23 16:49:22 -08:00
|
|
|
|
eina_hash_del_by_key_hash(IntPtr hash, IntPtr key, int key_length, int key_hash);
|
|
|
|
|
|
2019-10-17 16:23:11 -07:00
|
|
|
|
[DllImport(efl.Libs.Eina)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool
|
2017-11-23 16:49:22 -08:00
|
|
|
|
eina_hash_del_by_key(IntPtr hash, IntPtr key);
|
|
|
|
|
|
2019-10-17 16:23:11 -07:00
|
|
|
|
[DllImport(efl.Libs.Eina)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool
|
2017-11-23 16:49:22 -08:00
|
|
|
|
eina_hash_del_by_data(IntPtr hash, IntPtr data);
|
|
|
|
|
|
2019-10-17 16:23:11 -07:00
|
|
|
|
[DllImport(efl.Libs.Eina)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool
|
2017-11-23 16:49:22 -08:00
|
|
|
|
eina_hash_del_by_hash(IntPtr hash, IntPtr key, int key_length, int key_hash, IntPtr data);
|
|
|
|
|
|
2019-10-17 16:23:11 -07:00
|
|
|
|
[DllImport(efl.Libs.Eina)] internal static extern IntPtr
|
2017-11-23 16:49:22 -08:00
|
|
|
|
eina_hash_find_by_hash(IntPtr hash, IntPtr key, int key_length, int key_hash);
|
|
|
|
|
|
2019-10-17 16:23:11 -07:00
|
|
|
|
[DllImport(efl.Libs.Eina)] internal static extern IntPtr
|
2017-11-23 16:49:22 -08:00
|
|
|
|
eina_hash_modify_by_hash(IntPtr hash, IntPtr key, int key_length, int key_hash, IntPtr data);
|
|
|
|
|
|
2019-10-17 16:23:11 -07:00
|
|
|
|
[DllImport(efl.Libs.Eina)] internal static extern IntPtr
|
2017-11-23 16:49:22 -08:00
|
|
|
|
eina_hash_iterator_key_new(IntPtr hash);
|
|
|
|
|
|
2019-10-17 16:23:11 -07:00
|
|
|
|
[DllImport(efl.Libs.Eina)] internal static extern IntPtr
|
2017-11-23 16:49:22 -08:00
|
|
|
|
eina_hash_iterator_data_new(IntPtr hash);
|
|
|
|
|
|
2019-10-17 16:23:11 -07:00
|
|
|
|
[DllImport(efl.Libs.Eina)] internal static extern IntPtr
|
2017-11-23 16:49:22 -08:00
|
|
|
|
eina_hash_iterator_tuple_new(IntPtr hash);
|
|
|
|
|
|
2019-10-17 16:23:11 -07:00
|
|
|
|
[DllImport(efl.Libs.Eina)] internal static extern void
|
2017-11-23 16:49:22 -08:00
|
|
|
|
eina_hash_foreach(IntPtr hash, IntPtr func, IntPtr fdata);
|
|
|
|
|
|
|
|
|
|
|
2019-10-17 16:23:11 -07:00
|
|
|
|
[DllImport(efl.Libs.Eina)] internal static extern void
|
2017-11-23 16:49:22 -08:00
|
|
|
|
eina_hash_list_append(IntPtr hash, IntPtr key, IntPtr data);
|
2019-10-17 16:23:11 -07:00
|
|
|
|
[DllImport(efl.Libs.Eina)] internal static extern void
|
2017-11-23 16:49:22 -08:00
|
|
|
|
eina_hash_list_prepend(IntPtr hash, IntPtr key, IntPtr data);
|
2019-10-17 16:23:11 -07:00
|
|
|
|
[DllImport(efl.Libs.Eina)] internal static extern void
|
2017-11-23 16:49:22 -08:00
|
|
|
|
eina_hash_list_remove(IntPtr hash, IntPtr key, IntPtr data);
|
|
|
|
|
|
2019-10-17 16:23:11 -07:00
|
|
|
|
[DllImport(efl.Libs.Eina)] internal static extern int
|
2017-11-23 16:49:22 -08:00
|
|
|
|
eina_hash_superfast(string key, int len);
|
|
|
|
|
|
2019-10-17 16:23:11 -07:00
|
|
|
|
[DllImport(efl.Libs.CustomExports)] internal static extern IntPtr
|
2017-11-23 16:49:22 -08:00
|
|
|
|
eina_hash_iterator_ptr_key_wrapper_new_custom_export_mono(IntPtr hash);
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-03 23:46:29 -07:00
|
|
|
|
/// <summary>Wrapper around native dictionary mapping keys to values.
|
|
|
|
|
///
|
2019-12-17 03:04:01 -08:00
|
|
|
|
/// <para>Since EFL 1.23.</para>
|
2019-10-03 23:46:29 -07:00
|
|
|
|
/// </summary>
|
2019-12-17 05:56:42 -08:00
|
|
|
|
[SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix",
|
|
|
|
|
Justification = "This is a generalized container mapping the native one.")]
|
2017-11-23 16:49:22 -08:00
|
|
|
|
public class Hash<TKey, TValue> : IEnumerable<KeyValuePair<TKey, TValue>>, IDisposable
|
|
|
|
|
{
|
2019-10-14 07:22:56 -07:00
|
|
|
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
2017-11-23 16:49:22 -08:00
|
|
|
|
public IntPtr Handle {get; set;} = IntPtr.Zero;
|
2019-10-14 07:22:56 -07:00
|
|
|
|
/// <summary>Whether this wrapper owns the native hash.
|
|
|
|
|
/// <para>Since EFL 1.23.</para>
|
|
|
|
|
/// </summary>
|
2017-11-23 16:49:22 -08:00
|
|
|
|
public bool Own {get; set;}
|
2019-10-14 07:22:56 -07:00
|
|
|
|
/// <summary>Whether this wrapper owns the key.
|
|
|
|
|
/// <para>Since EFL 1.23.</para>
|
|
|
|
|
/// </summary>
|
2017-11-23 16:49:22 -08:00
|
|
|
|
public bool OwnKey {get; set;}
|
2019-10-14 07:22:56 -07:00
|
|
|
|
/// <summary>Whether this wrapper owns the value.
|
|
|
|
|
/// <para>Since EFL 1.23.</para>
|
|
|
|
|
/// </summary>
|
2017-11-23 16:49:22 -08:00
|
|
|
|
public bool OwnValue {get; set;}
|
|
|
|
|
|
2019-10-14 07:22:56 -07:00
|
|
|
|
/// <summary>Quantity of elements in the hash.
|
|
|
|
|
/// <para>Since EFL 1.23.</para>
|
|
|
|
|
/// </summary>
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-14 07:22:56 -07:00
|
|
|
|
/// <summary>Default constructor.
|
|
|
|
|
/// <para>Since EFL 1.23.</para>
|
|
|
|
|
/// </summary>
|
2017-11-23 16:49:22 -08:00
|
|
|
|
public Hash()
|
|
|
|
|
{
|
|
|
|
|
InitNew();
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-14 07:22:56 -07:00
|
|
|
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
2017-11-23 16:49:22 -08:00
|
|
|
|
public Hash(IntPtr handle, bool own)
|
|
|
|
|
{
|
|
|
|
|
Handle = handle;
|
|
|
|
|
SetOwnership(own);
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-14 07:22:56 -07:00
|
|
|
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
2017-11-23 16:49:22 -08:00
|
|
|
|
public Hash(IntPtr handle, bool own, bool ownKey, bool ownValue)
|
|
|
|
|
{
|
|
|
|
|
Handle = handle;
|
|
|
|
|
SetOwnership(own, ownKey, ownValue);
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-14 07:22:56 -07:00
|
|
|
|
/// <summary>Default destructor.
|
|
|
|
|
/// <para>Since EFL 1.23.</para>
|
|
|
|
|
/// </summary>
|
2017-11-23 16:49:22 -08:00
|
|
|
|
~Hash()
|
|
|
|
|
{
|
|
|
|
|
Dispose(false);
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-14 07:22:56 -07:00
|
|
|
|
/// <summary>Disposes of this wrapper, releasing the native accessor if
|
|
|
|
|
/// owned.
|
|
|
|
|
/// <para>Since EFL 1.23.</para>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="disposing">True if this was called from <see cref="Dispose()"/> public method. False if
|
|
|
|
|
/// called from the C# finalizer.</param>
|
2017-11-23 16:49:22 -08:00
|
|
|
|
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
|
|
|
|
|
{
|
2019-04-15 10:09:49 -07:00
|
|
|
|
Efl.Eo.Globals.ThreadSafeFreeCbExec(eina_hash_free, h);
|
2019-04-05 15:57:29 -07: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
|
|
|
|
}
|
2017-11-23 16:49:22 -08:00
|
|
|
|
}
|
|
|
|
|
|
2019-10-14 07:22:56 -07:00
|
|
|
|
/// <summary>Release the native resources held by this instance.
|
|
|
|
|
/// <para>Since EFL 1.23.</para>
|
|
|
|
|
/// </summary>
|
2017-11-23 16:49:22 -08:00
|
|
|
|
public void Dispose()
|
|
|
|
|
{
|
|
|
|
|
Dispose(true);
|
|
|
|
|
GC.SuppressFinalize(this);
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-14 07:22:56 -07:00
|
|
|
|
/// <summary>Release the native resources held by this instance.
|
|
|
|
|
/// <para>Since EFL 1.23.</para>
|
|
|
|
|
/// </summary>
|
2017-11-23 16:49:22 -08:00
|
|
|
|
public void Free()
|
|
|
|
|
{
|
|
|
|
|
Dispose();
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-14 07:22:56 -07:00
|
|
|
|
/// <summary>Release the pointer.
|
|
|
|
|
/// <para>Since EFL 1.23.</para>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>The instance.</returns>
|
2017-11-23 16:49:22 -08:00
|
|
|
|
public IntPtr Release()
|
|
|
|
|
{
|
|
|
|
|
IntPtr h = Handle;
|
|
|
|
|
Handle = IntPtr.Zero;
|
|
|
|
|
return h;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-14 07:22:56 -07:00
|
|
|
|
/// <summary>Sets ownership.
|
|
|
|
|
/// <para>Since EFL 1.23.</para>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="own">If the hash own the object.</param>
|
2017-11-23 16:49:22 -08:00
|
|
|
|
public void SetOwn(bool own)
|
|
|
|
|
{
|
|
|
|
|
Own = own;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-14 07:22:56 -07:00
|
|
|
|
/// <summary>Sets key's ownership.
|
|
|
|
|
/// <para>Since EFL 1.23.</para>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="ownKey">If the hash own the key's object.</param>
|
2017-11-23 16:49:22 -08:00
|
|
|
|
public void SetOwnKey(bool ownKey)
|
|
|
|
|
{
|
|
|
|
|
OwnKey = ownKey;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-14 07:22:56 -07:00
|
|
|
|
/// <summary>Sets value's ownership.
|
|
|
|
|
/// <para>Since EFL 1.23.</para>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="ownValue">If the hash own the value's object.</param>
|
2017-11-23 16:49:22 -08:00
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
2019-10-14 07:22:56 -07:00
|
|
|
|
/// <summary>Sets all ownership.
|
|
|
|
|
/// <para>Since EFL 1.23.</para>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="ownAll">If the hash own for all ownerships.</param>
|
2017-11-23 16:49:22 -08:00
|
|
|
|
public void SetOwnership(bool ownAll)
|
|
|
|
|
{
|
|
|
|
|
SetOwn(ownAll);
|
|
|
|
|
SetOwnKey(ownAll);
|
|
|
|
|
SetOwnValue(ownAll);
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-14 07:22:56 -07:00
|
|
|
|
/// <summary>Sets own individually.
|
|
|
|
|
/// <para>Since EFL 1.23.</para>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="own">If the hash own the object.</param>
|
|
|
|
|
/// <param name="ownKey">If the hash own the key's object.</param>
|
|
|
|
|
/// <param name="ownValue">If the hash own the value's object.</param>
|
2017-11-23 16:49:22 -08:00
|
|
|
|
public void SetOwnership(bool own, bool ownKey, bool ownValue)
|
|
|
|
|
{
|
|
|
|
|
SetOwn(own);
|
|
|
|
|
SetOwnKey(ownKey);
|
|
|
|
|
SetOwnValue(ownValue);
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-14 07:22:56 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Cleanup for the hash.
|
|
|
|
|
/// <para>Since EFL 1.23.</para>
|
|
|
|
|
/// </summary>
|
2017-11-23 16:49:22 -08:00
|
|
|
|
public void UnSetFreeCb()
|
|
|
|
|
{
|
|
|
|
|
eina_hash_free_cb_set(Handle, IntPtr.Zero);
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-14 07:22:56 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Adds an entry to the hash.
|
|
|
|
|
/// <para>Since EFL 1.23.</para>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="key">A unique key.</param>
|
|
|
|
|
/// <param name="val">The value to associate with the key.</param>
|
|
|
|
|
/// <returns> false if an error occurred, true otherwise.</returns>
|
2017-11-23 16:49:22 -08:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-14 07:22:56 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Modifies the entry at the specified key.
|
|
|
|
|
/// <para>Since EFL 1.23.</para>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="key">The key of the entry to modify.</param>
|
|
|
|
|
/// <param name="val">The value to replace the previous entry.</param>
|
2017-11-23 16:49:22 -08:00
|
|
|
|
public void Add(TKey key, TValue val)
|
|
|
|
|
{
|
|
|
|
|
Set(key, val);
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-14 07:22:56 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Removes the entry identified by a key from the hash.
|
|
|
|
|
/// <para>Since EFL 1.23.</para>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="key">The key.</param>
|
2017-11-23 16:49:22 -08:00
|
|
|
|
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>());
|
2017-11-23 16:49:22 -08:00
|
|
|
|
return r;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-14 07:22:56 -07:00
|
|
|
|
/// <summary>Searches this hash for <c>val</c> and deletes it from the hash,
|
|
|
|
|
/// also deleting it.
|
|
|
|
|
/// <para>Since EFL 1.23.</para>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="val">The value to be deleted.</param>
|
2019-09-13 15:22:39 -07:00
|
|
|
|
/// <returns><c>true</c> if the value was found and deleted, false if it was <c>null</c> or not found.</returns>
|
2017-11-23 16:49:22 -08:00
|
|
|
|
public bool DelByValue(TValue val)
|
|
|
|
|
{
|
2019-09-13 15:22:39 -07:00
|
|
|
|
// We don't use the C version of `eina_hash_del_by_data` because it requires the exact pointer
|
|
|
|
|
// we passed to add(). As our hashes store the data by pointer, this makes it harder to pass the
|
|
|
|
|
// same value.
|
|
|
|
|
if (val == null)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (var pair in this)
|
|
|
|
|
{
|
|
|
|
|
if (pair.Value != null && val.Equals(pair.Value))
|
|
|
|
|
{
|
|
|
|
|
return this.DelByKey(pair.Key);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
2017-11-23 16:49:22 -08:00
|
|
|
|
}
|
|
|
|
|
|
2019-10-14 07:22:56 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Removes the entry identified by a key from the hash.
|
|
|
|
|
/// <para>Since EFL 1.23.</para>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="key">The key.</param>
|
2017-11-23 16:49:22 -08:00
|
|
|
|
public void Remove(TKey key)
|
|
|
|
|
{
|
|
|
|
|
DelByKey(key);
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-14 07:22:56 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Retrieves a specific entry in the hash.
|
|
|
|
|
/// <para>Since EFL 1.23.</para>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="key">The key of the entry to find.</param>
|
|
|
|
|
/// <returns>The value of the entry.</returns>
|
2017-11-23 16:49:22 -08:00
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
2019-10-14 07:22:56 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Check if key is present. if not, a default value is setted.
|
|
|
|
|
/// <para>Since EFL 1.23.</para>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="key">The key to be checked.</param>
|
|
|
|
|
/// <param name="val">[out] The value of the entry.</param>
|
|
|
|
|
/// <returns>true if key exists, false otherwise.</returns>
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-14 07:22:56 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Check if key is present.
|
|
|
|
|
/// <para>Since EFL 1.23.</para>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="key">The key to be checked.</param>
|
|
|
|
|
/// <returns>true if key exists, false otherwise.</returns>
|
2017-11-23 16:49:22 -08:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-14 07:22:56 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Modifies the speficied key if exists.
|
|
|
|
|
/// <para>Since EFL 1.23.</para>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="key">The key to modify.</param>
|
|
|
|
|
/// <param name="val"> The new value.</param>
|
|
|
|
|
/// <returns>False if key do not exists, true otherwise.</returns>
|
2017-11-23 16:49:22 -08:00
|
|
|
|
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>()
|
|
|
|
|
{
|
2019-06-28 06:40:52 -07:00
|
|
|
|
return (!typeof(T).IsValueType)
|
|
|
|
|
&& (typeof(T) != typeof(string))
|
|
|
|
|
&& (typeof(T) != typeof(Eina.Stringshare));
|
2019-01-15 23:29:56 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-14 07:22:56 -07:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Modifies the entry at the specified key. Adds if key is not found.
|
|
|
|
|
/// <para>Since EFL 1.23.</para>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="key">The key to modify.</param>
|
|
|
|
|
/// <param name="val">The value to replace the previous entry.</param>
|
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-06-28 06:40:52 -07: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
|
|
|
|
}
|
|
|
|
|
|
2019-10-14 07:22:56 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Accessor by key to the hash.
|
|
|
|
|
/// <para>Since EFL 1.23.</para>
|
|
|
|
|
/// </summary>
|
2017-11-23 16:49:22 -08:00
|
|
|
|
public TValue this[TKey key]
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return Find(key);
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
Set(key, value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-14 07:22:56 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Changes the keys of an entry in the hash.
|
|
|
|
|
/// <para>Since EFL 1.23.</para>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="key_old">The current key with data.</param>
|
|
|
|
|
/// <param name="key_new">The new key with data.</param>
|
|
|
|
|
/// <returns>false in any case but success, true on success.</returns>
|
2017-11-23 16:49:22 -08:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-14 07:22:56 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Frees the hash buckets.
|
|
|
|
|
/// <para>Since EFL 1.23.</para>
|
|
|
|
|
/// </summary>
|
2017-11-23 16:49:22 -08:00
|
|
|
|
public void FreeBuckets()
|
|
|
|
|
{
|
|
|
|
|
eina_hash_free_buckets(Handle);
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-14 07:22:56 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Returns the number of entries in the hash.
|
|
|
|
|
/// <para>Since EFL 1.23.</para>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>The number of entries, 0 on error.</returns>
|
2017-11-23 16:49:22 -08:00
|
|
|
|
public int Population()
|
|
|
|
|
{
|
|
|
|
|
return eina_hash_population(Handle);
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-14 07:22:56 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets an Iterator for keys.
|
|
|
|
|
/// <para>Since EFL 1.23.</para>
|
|
|
|
|
/// </summary>
|
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
|
|
|
|
{
|
2019-06-27 09:49:42 -07:00
|
|
|
|
return new Eina.Iterator<TKey>(EinaHashIteratorKeyNew<TKey>(Handle), true);
|
2017-11-23 16:49:22 -08:00
|
|
|
|
}
|
|
|
|
|
|
2019-10-14 07:22:56 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets An Iterator for values.
|
|
|
|
|
/// <para>Since EFL 1.23.</para>
|
|
|
|
|
/// </summary>
|
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
|
|
|
|
{
|
2019-06-27 09:49:42 -07:00
|
|
|
|
return new Eina.Iterator<TValue>(eina_hash_iterator_data_new(Handle), true);
|
2017-11-23 16:49:22 -08:00
|
|
|
|
}
|
|
|
|
|
|
2019-10-14 07:22:56 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets an Iterator for hask.
|
|
|
|
|
/// <para>Since EFL 1.23.</para>
|
|
|
|
|
/// </summary>
|
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();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|