forked from enlightenment/efl
efl_mono: Generate support for accessors in .eos
Summary: Depends on D6190 Reviewers: felipealmeida, vitor.sousa Reviewed By: vitor.sousa Subscribers: cedric, #committers, zmike Tags: #efl Differential Revision: https://phab.enlightenment.org/D6191
This commit is contained in:
parent
cfafd01bbe
commit
54f1e56b34
|
@ -237,6 +237,11 @@ struct marshall_type_visitor_generate
|
||||||
return regular_type_def{" System.IntPtr", complex.outer.base_qualifier, {}};
|
return regular_type_def{" System.IntPtr", complex.outer.base_qualifier, {}};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
,{"accessor", nullptr, nullptr, [&]
|
||||||
|
{
|
||||||
|
return regular_type_def{" System.IntPtr", complex.outer.base_qualifier, {}};
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
auto default_match = [&] (attributes::complex_type_def const& complex)
|
auto default_match = [&] (attributes::complex_type_def const& complex)
|
||||||
|
|
|
@ -275,6 +275,10 @@ inline bool param_should_use_out_var(attributes::parameter_def const& param, boo
|
||||||
|| param_is_acceptable(param, "Eina_Inlist *", WANT_OWN, WANT_OUT)
|
|| param_is_acceptable(param, "Eina_Inlist *", WANT_OWN, WANT_OUT)
|
||||||
|| param_is_acceptable(param, "const Eina_Inlist *", !WANT_OWN, WANT_OUT)
|
|| param_is_acceptable(param, "const Eina_Inlist *", !WANT_OWN, WANT_OUT)
|
||||||
|| param_is_acceptable(param, "const Eina_Inlist *", WANT_OWN, WANT_OUT)
|
|| param_is_acceptable(param, "const Eina_Inlist *", WANT_OWN, WANT_OUT)
|
||||||
|
|| param_is_acceptable(param, "Eina_Accessor *", !WANT_OWN, WANT_OUT)
|
||||||
|
|| param_is_acceptable(param, "Eina_Accessor *", WANT_OWN, WANT_OUT)
|
||||||
|
|| param_is_acceptable(param, "const Eina_Accessor *", !WANT_OWN, WANT_OUT)
|
||||||
|
|| param_is_acceptable(param, "const Eina_Accessor *", WANT_OWN, WANT_OUT)
|
||||||
|| param_is_acceptable(param, "Eina_Hash *", !WANT_OWN, WANT_OUT)
|
|| param_is_acceptable(param, "Eina_Hash *", !WANT_OWN, WANT_OUT)
|
||||||
|| param_is_acceptable(param, "Eina_Hash *", WANT_OWN, WANT_OUT)
|
|| param_is_acceptable(param, "Eina_Hash *", WANT_OWN, WANT_OUT)
|
||||||
|| param_is_acceptable(param, "const Eina_Hash *", !WANT_OWN, WANT_OUT)
|
|| param_is_acceptable(param, "const Eina_Hash *", !WANT_OWN, WANT_OUT)
|
||||||
|
@ -321,6 +325,10 @@ inline bool param_should_use_in_var(attributes::parameter_def const& param, bool
|
||||||
|| param_is_acceptable(param, "const Eina_List *", WANT_OWN, !WANT_OUT)
|
|| param_is_acceptable(param, "const Eina_List *", WANT_OWN, !WANT_OUT)
|
||||||
|| param_is_acceptable(param, "Eina_Inlist *", !WANT_OWN, !WANT_OUT)
|
|| param_is_acceptable(param, "Eina_Inlist *", !WANT_OWN, !WANT_OUT)
|
||||||
|| param_is_acceptable(param, "Eina_Inlist *", WANT_OWN, !WANT_OUT)
|
|| param_is_acceptable(param, "Eina_Inlist *", WANT_OWN, !WANT_OUT)
|
||||||
|
|| param_is_acceptable(param, "Eina_Accessor *", !WANT_OWN, !WANT_OUT)
|
||||||
|
|| param_is_acceptable(param, "Eina_Accessor *", WANT_OWN, !WANT_OUT)
|
||||||
|
|| param_is_acceptable(param, "const Eina_Accessor *", !WANT_OWN, !WANT_OUT)
|
||||||
|
|| param_is_acceptable(param, "const Eina_Accessor *", WANT_OWN, !WANT_OUT)
|
||||||
|| param_is_acceptable(param, "const Eina_Inlist *", !WANT_OWN, !WANT_OUT)
|
|| param_is_acceptable(param, "const Eina_Inlist *", !WANT_OWN, !WANT_OUT)
|
||||||
|| param_is_acceptable(param, "const Eina_Inlist *", WANT_OWN, !WANT_OUT)
|
|| param_is_acceptable(param, "const Eina_Inlist *", WANT_OWN, !WANT_OUT)
|
||||||
|| param_is_acceptable(param, "Eina_Hash *", !WANT_OWN, !WANT_OUT)
|
|| param_is_acceptable(param, "Eina_Hash *", !WANT_OWN, !WANT_OUT)
|
||||||
|
@ -578,6 +586,7 @@ struct native_convert_in_variable_generator
|
||||||
|| param.type.c_type == "Eina_List *" || param.type.c_type == "const Eina_List *"
|
|| param.type.c_type == "Eina_List *" || param.type.c_type == "const Eina_List *"
|
||||||
|| param.type.c_type == "Eina_Inlist *" || param.type.c_type == "const Eina_Inlist *"
|
|| param.type.c_type == "Eina_Inlist *" || param.type.c_type == "const Eina_Inlist *"
|
||||||
|| param.type.c_type == "Eina_Iterator *" || param.type.c_type == "const Eina_Iterator *"
|
|| param.type.c_type == "Eina_Iterator *" || param.type.c_type == "const Eina_Iterator *"
|
||||||
|
|| param.type.c_type == "Eina_Accessor *" || param.type.c_type == "const Eina_Accessor *"
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
attributes::complex_type_def const* complex = efl::eina::get<attributes::complex_type_def>(¶m.type.original_type);
|
attributes::complex_type_def const* complex = efl::eina::get<attributes::complex_type_def>(¶m.type.original_type);
|
||||||
|
@ -665,6 +674,7 @@ struct convert_in_variable_generator
|
||||||
|| param.type.c_type == "Eina_List *" || param.type.c_type == "const Eina_List *"
|
|| param.type.c_type == "Eina_List *" || param.type.c_type == "const Eina_List *"
|
||||||
|| param.type.c_type == "Eina_Inlist *" || param.type.c_type == "const Eina_Inlist *"
|
|| param.type.c_type == "Eina_Inlist *" || param.type.c_type == "const Eina_Inlist *"
|
||||||
|| param.type.c_type == "Eina_Iterator *" || param.type.c_type == "const Eina_Iterator *"
|
|| param.type.c_type == "Eina_Iterator *" || param.type.c_type == "const Eina_Iterator *"
|
||||||
|
|| param.type.c_type == "Eina_Accessor *" || param.type.c_type == "const Eina_Accessor *"
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
attributes::complex_type_def const* complex = efl::eina::get<attributes::complex_type_def>(¶m.type.original_type);
|
attributes::complex_type_def const* complex = efl::eina::get<attributes::complex_type_def>(¶m.type.original_type);
|
||||||
|
@ -743,6 +753,10 @@ struct convert_out_variable_generator
|
||||||
|| param_is_acceptable(param, "Eina_Inlist *", !WANT_OWN, WANT_OUT)
|
|| param_is_acceptable(param, "Eina_Inlist *", !WANT_OWN, WANT_OUT)
|
||||||
|| param_is_acceptable(param, "const Eina_Inlist *", WANT_OWN, WANT_OUT)
|
|| param_is_acceptable(param, "const Eina_Inlist *", WANT_OWN, WANT_OUT)
|
||||||
|| param_is_acceptable(param, "const Eina_Inlist *", !WANT_OWN, WANT_OUT)
|
|| param_is_acceptable(param, "const Eina_Inlist *", !WANT_OWN, WANT_OUT)
|
||||||
|
|| param_is_acceptable(param, "Eina_Accessor *", WANT_OWN, WANT_OUT)
|
||||||
|
|| param_is_acceptable(param, "Eina_Accessor *", !WANT_OWN, WANT_OUT)
|
||||||
|
|| param_is_acceptable(param, "const Eina_Accessor *", WANT_OWN, WANT_OUT)
|
||||||
|
|| param_is_acceptable(param, "const Eina_Accessor *", !WANT_OWN, WANT_OUT)
|
||||||
|| param_is_acceptable(param, "Eina_Hash *", WANT_OWN, WANT_OUT)
|
|| param_is_acceptable(param, "Eina_Hash *", WANT_OWN, WANT_OUT)
|
||||||
|| param_is_acceptable(param, "Eina_Hash *", !WANT_OWN, WANT_OUT)
|
|| param_is_acceptable(param, "Eina_Hash *", !WANT_OWN, WANT_OUT)
|
||||||
|| param_is_acceptable(param, "const Eina_Hash *", WANT_OWN, WANT_OUT)
|
|| param_is_acceptable(param, "const Eina_Hash *", WANT_OWN, WANT_OUT)
|
||||||
|
@ -818,6 +832,10 @@ struct native_convert_out_variable_generator
|
||||||
|| param_is_acceptable(param, "Eina_Inlist *", !WANT_OWN, WANT_OUT)
|
|| param_is_acceptable(param, "Eina_Inlist *", !WANT_OWN, WANT_OUT)
|
||||||
|| param_is_acceptable(param, "const Eina_Inlist *", WANT_OWN, WANT_OUT)
|
|| param_is_acceptable(param, "const Eina_Inlist *", WANT_OWN, WANT_OUT)
|
||||||
|| param_is_acceptable(param, "const Eina_Inlist *", !WANT_OWN, WANT_OUT)
|
|| param_is_acceptable(param, "const Eina_Inlist *", !WANT_OWN, WANT_OUT)
|
||||||
|
|| param_is_acceptable(param, "Eina_Accessor *", WANT_OWN, WANT_OUT)
|
||||||
|
|| param_is_acceptable(param, "Eina_Accessor *", !WANT_OWN, WANT_OUT)
|
||||||
|
|| param_is_acceptable(param, "const Eina_Accessor *", WANT_OWN, WANT_OUT)
|
||||||
|
|| param_is_acceptable(param, "const Eina_Accessor *", !WANT_OWN, WANT_OUT)
|
||||||
|| param_is_acceptable(param, "Eina_Hash *", WANT_OWN, WANT_OUT)
|
|| param_is_acceptable(param, "Eina_Hash *", WANT_OWN, WANT_OUT)
|
||||||
|| param_is_acceptable(param, "Eina_Hash *", !WANT_OWN, WANT_OUT)
|
|| param_is_acceptable(param, "Eina_Hash *", !WANT_OWN, WANT_OUT)
|
||||||
|| param_is_acceptable(param, "const Eina_Hash *", WANT_OWN, WANT_OUT)
|
|| param_is_acceptable(param, "const Eina_Hash *", WANT_OWN, WANT_OUT)
|
||||||
|
@ -926,6 +944,10 @@ struct convert_out_assign_generator
|
||||||
|| param_is_acceptable(param, "Eina_Inlist *", !WANT_OWN, WANT_OUT)
|
|| param_is_acceptable(param, "Eina_Inlist *", !WANT_OWN, WANT_OUT)
|
||||||
|| param_is_acceptable(param, "const Eina_Inlist *", WANT_OWN, WANT_OUT)
|
|| param_is_acceptable(param, "const Eina_Inlist *", WANT_OWN, WANT_OUT)
|
||||||
|| param_is_acceptable(param, "const Eina_Inlist *", !WANT_OWN, WANT_OUT)
|
|| param_is_acceptable(param, "const Eina_Inlist *", !WANT_OWN, WANT_OUT)
|
||||||
|
|| param_is_acceptable(param, "Eina_Accessor *", WANT_OWN, WANT_OUT)
|
||||||
|
|| param_is_acceptable(param, "Eina_Accessor *", !WANT_OWN, WANT_OUT)
|
||||||
|
|| param_is_acceptable(param, "const Eina_Accessor *", WANT_OWN, WANT_OUT)
|
||||||
|
|| param_is_acceptable(param, "const Eina_Accessor *", !WANT_OWN, WANT_OUT)
|
||||||
|| param_is_acceptable(param, "Eina_Iterator *", WANT_OWN, WANT_OUT)
|
|| param_is_acceptable(param, "Eina_Iterator *", WANT_OWN, WANT_OUT)
|
||||||
|| param_is_acceptable(param, "Eina_Iterator *", !WANT_OWN, WANT_OUT)
|
|| param_is_acceptable(param, "Eina_Iterator *", !WANT_OWN, WANT_OUT)
|
||||||
|| param_is_acceptable(param, "const Eina_Iterator *", WANT_OWN, WANT_OUT)
|
|| param_is_acceptable(param, "const Eina_Iterator *", WANT_OWN, WANT_OUT)
|
||||||
|
@ -1045,6 +1067,7 @@ struct convert_return_generator
|
||||||
|| ret_type.c_type == "Eina_List *" || ret_type.c_type == "const Eina_List *"
|
|| ret_type.c_type == "Eina_List *" || ret_type.c_type == "const Eina_List *"
|
||||||
|| ret_type.c_type == "Eina_Inlist *" || ret_type.c_type == "const Eina_Inlist *"
|
|| ret_type.c_type == "Eina_Inlist *" || ret_type.c_type == "const Eina_Inlist *"
|
||||||
|| ret_type.c_type == "Eina_Iterator *" || ret_type.c_type == "const Eina_Iterator *"
|
|| ret_type.c_type == "Eina_Iterator *" || ret_type.c_type == "const Eina_Iterator *"
|
||||||
|
|| ret_type.c_type == "Eina_Accessor *" || ret_type.c_type == "const Eina_Accessor *"
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
attributes::complex_type_def const* complex = efl::eina::get<attributes::complex_type_def>(&ret_type.original_type);
|
attributes::complex_type_def const* complex = efl::eina::get<attributes::complex_type_def>(&ret_type.original_type);
|
||||||
|
@ -1175,6 +1198,10 @@ struct native_convert_out_assign_generator
|
||||||
|| param_is_acceptable(param, "Eina_Iterator *", !WANT_OWN, WANT_OUT)
|
|| param_is_acceptable(param, "Eina_Iterator *", !WANT_OWN, WANT_OUT)
|
||||||
|| param_is_acceptable(param, "const Eina_Iterator *", WANT_OWN, WANT_OUT)
|
|| param_is_acceptable(param, "const Eina_Iterator *", WANT_OWN, WANT_OUT)
|
||||||
|| param_is_acceptable(param, "const Eina_Iterator *", !WANT_OWN, WANT_OUT)
|
|| param_is_acceptable(param, "const Eina_Iterator *", !WANT_OWN, WANT_OUT)
|
||||||
|
|| param_is_acceptable(param, "Eina_Accessor *", WANT_OWN, WANT_OUT)
|
||||||
|
|| param_is_acceptable(param, "Eina_Accessor *", !WANT_OWN, WANT_OUT)
|
||||||
|
|| param_is_acceptable(param, "const Eina_Accessor *", WANT_OWN, WANT_OUT)
|
||||||
|
|| param_is_acceptable(param, "const Eina_Accessor *", !WANT_OWN, WANT_OUT)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
attributes::complex_type_def const* complex = efl::eina::get<attributes::complex_type_def>(¶m.type.original_type);
|
attributes::complex_type_def const* complex = efl::eina::get<attributes::complex_type_def>(¶m.type.original_type);
|
||||||
|
@ -1302,6 +1329,7 @@ struct native_convert_return_generator
|
||||||
|| ret_type.c_type == "Eina_List *" || ret_type.c_type == "const Eina_List *"
|
|| ret_type.c_type == "Eina_List *" || ret_type.c_type == "const Eina_List *"
|
||||||
|| ret_type.c_type == "Eina_Inlist *" || ret_type.c_type == "const Eina_Inlist *"
|
|| ret_type.c_type == "Eina_Inlist *" || ret_type.c_type == "const Eina_Inlist *"
|
||||||
|| ret_type.c_type == "Eina_Iterator *" || ret_type.c_type == "const Eina_Iterator *"
|
|| ret_type.c_type == "Eina_Iterator *" || ret_type.c_type == "const Eina_Iterator *"
|
||||||
|
|| ret_type.c_type == "Eina_Accessor *" || ret_type.c_type == "const Eina_Accessor *"
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
attributes::complex_type_def const* complex = efl::eina::get<attributes::complex_type_def>(&ret_type.original_type);
|
attributes::complex_type_def const* complex = efl::eina::get<attributes::complex_type_def>(&ret_type.original_type);
|
||||||
|
|
|
@ -287,8 +287,6 @@ struct visitor_generate
|
||||||
{
|
{
|
||||||
(*this)(regular_type_def{" eina.Future", complex.outer.base_qualifier, {}});
|
(*this)(regular_type_def{" eina.Future", complex.outer.base_qualifier, {}});
|
||||||
return attributes::type_def::variant_type();
|
return attributes::type_def::variant_type();
|
||||||
// return replace_outer
|
|
||||||
// (complex, regular_type_def{" ::efl::shared_future", complex.outer.base_qualifier, {}});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
, {"iterator", nullptr, nullptr, [&]
|
, {"iterator", nullptr, nullptr, [&]
|
||||||
|
@ -300,10 +298,9 @@ struct visitor_generate
|
||||||
}
|
}
|
||||||
, {"accessor", nullptr, nullptr, [&]
|
, {"accessor", nullptr, nullptr, [&]
|
||||||
{
|
{
|
||||||
(*this)(regular_type_def{" int", complex.outer.base_qualifier, {}});
|
complex_type_def c = complex;
|
||||||
return attributes::type_def::variant_type();
|
c.outer.base_type = "eina.Accessor";
|
||||||
// return replace_outer
|
return c;
|
||||||
// (complex, regular_type_def{" ::efl::eina::accessor", complex.outer.base_qualifier, {}});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -26,6 +26,19 @@ public class Accessor<T> : IEnumerable<T>, IDisposable
|
||||||
/// <summary>Who is in charge of releasing the resources wrapped by this instance.</summary>
|
/// <summary>Who is in charge of releasing the resources wrapped by this instance.</summary>
|
||||||
private Ownership Ownership { get; set; }
|
private Ownership Ownership { get; set; }
|
||||||
|
|
||||||
|
// FIXME Part of the implicit EFL Container interface. Need to make it explicit.
|
||||||
|
public bool Own
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return Ownership == Ownership.Managed;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
Ownership = value ? Ownership.Managed : Ownership.Unmanaged;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>Create a new accessor wrapping the given pointer.</summary>
|
/// <summary>Create a new accessor wrapping the given pointer.</summary>
|
||||||
public Accessor(IntPtr handle, Ownership owner=Ownership.Managed)
|
public Accessor(IntPtr handle, Ownership owner=Ownership.Managed)
|
||||||
{
|
{
|
||||||
|
@ -33,6 +46,11 @@ public class Accessor<T> : IEnumerable<T>, IDisposable
|
||||||
Ownership = owner;
|
Ownership = owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Accessor(IntPtr handle, bool own, bool ownContent=false)
|
||||||
|
: this(handle, own ? Ownership.Managed : Ownership.Unmanaged)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>Release the native resources held by this instance.</summary>
|
/// <summary>Release the native resources held by this instance.</summary>
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace TestSuite
|
namespace TestSuite
|
||||||
{
|
{
|
||||||
|
@ -224,4 +225,25 @@ class TestTypedefs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class TestEoAccessors
|
||||||
|
{
|
||||||
|
public static void basic_eo_accessors()
|
||||||
|
{
|
||||||
|
test.ITesting obj = new test.Testing();
|
||||||
|
eina.List<int> lst = new eina.List<int>();
|
||||||
|
lst.Append(4);
|
||||||
|
lst.Append(3);
|
||||||
|
lst.Append(2);
|
||||||
|
lst.Append(5);
|
||||||
|
eina.Accessor<int> acc = obj.CloneAccessor(lst.GetAccessor());
|
||||||
|
|
||||||
|
var zipped = acc.Zip(lst, (first, second) => new Tuple<int, int>(first, second));
|
||||||
|
|
||||||
|
foreach(Tuple<int, int> pair in zipped)
|
||||||
|
{
|
||||||
|
Test.AssertEquals(pair.Item1, pair.Item2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,6 +52,7 @@ typedef struct Test_Testing_Data
|
||||||
Eo *part1;
|
Eo *part1;
|
||||||
Eo *part2;
|
Eo *part2;
|
||||||
Eina_Promise *promise;
|
Eina_Promise *promise;
|
||||||
|
Eina_List *list_for_accessor;
|
||||||
} Test_Testing_Data;
|
} Test_Testing_Data;
|
||||||
|
|
||||||
typedef struct Test_Numberwrapper_Data
|
typedef struct Test_Numberwrapper_Data
|
||||||
|
@ -3841,6 +3842,20 @@ void _test_testing_reject_promise(Eo *obj, Test_Testing_Data *pd, Eina_Error err
|
||||||
eina_promise_reject(pd->promise, err);
|
eina_promise_reject(pd->promise, err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Eina_Accessor *_test_testing_clone_accessor(Eo *obj, Test_Testing_Data *pd, Eina_Accessor *acc)
|
||||||
|
{
|
||||||
|
if (pd->list_for_accessor)
|
||||||
|
eina_list_free(pd->list_for_accessor);
|
||||||
|
|
||||||
|
unsigned int i;
|
||||||
|
int *data;
|
||||||
|
EINA_ACCESSOR_FOREACH(acc, i, data)
|
||||||
|
{
|
||||||
|
pd->list_for_accessor = eina_list_append(pd->list_for_accessor, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
return eina_list_accessor_new(pd->list_for_accessor);
|
||||||
|
}
|
||||||
|
|
||||||
#include "test_testing.eo.c"
|
#include "test_testing.eo.c"
|
||||||
#include "test_numberwrapper.eo.c"
|
#include "test_numberwrapper.eo.c"
|
||||||
|
|
|
@ -1633,6 +1633,14 @@ class Test.Testing (Efl.Object, Efl.Part) {
|
||||||
@in error: Eina.Error;
|
@in error: Eina.Error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Accessors */
|
||||||
|
clone_accessor {
|
||||||
|
params {
|
||||||
|
@in acc: accessor<ptr(int)>;
|
||||||
|
}
|
||||||
|
return: accessor<ptr(int)> @owned;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
implements {
|
implements {
|
||||||
class.constructor;
|
class.constructor;
|
||||||
|
|
Loading…
Reference in New Issue