forked from enlightenment/efl
eolian_mono: fix non-beta build and support for slice/rw_slice keywords
Summary: Add support for `slice` and `rw_slice` keywords in eolian_mono. Now it generates the proper manual binding type for these native types. Make unit tests use these keywords instead of native names. Remove some unnecessary `@beta` tags from eolian types in unit tests so now tests correctly compile without the `mono-beta` compilation flag. Also make tests that use `Eina.Binbuf` "beta only". In a future update, the external type `Eina.Binbuf` will be marked as beta, so we shield the binding in anticipation. Test Plan: `meson -Dbindings=mono -Dmono-beta=true` and `meson -Dbindings=mono -Dmono-beta=false` Reviewers: lauromoura, felipealmeida, q66, segfaultxavi, bu5hm4n Reviewed By: lauromoura Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D9238
This commit is contained in:
parent
1193e1a757
commit
7769779a4d
|
@ -393,6 +393,16 @@ struct visitor_generate
|
|||
return c;
|
||||
}
|
||||
}
|
||||
, {"slice", nullptr, nullptr, [&]
|
||||
{
|
||||
return regular_type_def{" Eina.Slice", complex.outer.base_qualifier, {}};
|
||||
}
|
||||
}
|
||||
, {"rw_slice", nullptr, nullptr, [&]
|
||||
{
|
||||
return regular_type_def{" Eina.RwSlice", complex.outer.base_qualifier, {}};
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
auto default_match = [&] (attributes::complex_type_def const& complex)
|
||||
|
|
|
@ -10,6 +10,8 @@ using static EinaTestData.BaseData;
|
|||
namespace TestSuite
|
||||
{
|
||||
|
||||
#if EFL_BETA
|
||||
|
||||
class TestEinaBinbuf
|
||||
{
|
||||
private static readonly byte[] test_string = System.Text.Encoding.UTF8.GetBytes("0123456789ABCDEF");
|
||||
|
@ -307,12 +309,15 @@ class TestEinaBinbuf
|
|||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
class TestEinaSlice
|
||||
{
|
||||
private static readonly byte[] base_seq = BaseSequence.Values();
|
||||
private static readonly GCHandle pinnedData = GCHandle.Alloc(base_seq, GCHandleType.Pinned);
|
||||
private static readonly IntPtr pinnedPtr = pinnedData.AddrOfPinnedObject();
|
||||
|
||||
#if EFL_BETA
|
||||
public static void eina_slice_marshalling()
|
||||
{
|
||||
var binbuf = new Eina.Binbuf(base_seq);
|
||||
|
@ -323,6 +328,7 @@ class TestEinaSlice
|
|||
Test.Assert(slc.GetBytes().SequenceEqual(base_seq));
|
||||
Test.Assert(base_seq.Length == (int)(slc.Len));
|
||||
}
|
||||
#endif
|
||||
|
||||
public static void eina_slice_size()
|
||||
{
|
||||
|
@ -330,12 +336,14 @@ class TestEinaSlice
|
|||
Test.Assert(Marshal.SizeOf(typeof(Eina.RwSlice)) == Marshal.SizeOf(typeof(UIntPtr)) + Marshal.SizeOf(typeof(IntPtr)));
|
||||
}
|
||||
|
||||
#if EFL_BETA
|
||||
public static void pinned_data_set()
|
||||
{
|
||||
var binbuf = new Eina.Binbuf();
|
||||
binbuf.Append(new Eina.Slice().PinnedDataSet(pinnedPtr, (UIntPtr)3));
|
||||
Test.Assert(binbuf.GetBytes().SequenceEqual(base_seq));
|
||||
}
|
||||
#endif
|
||||
|
||||
public static void test_eina_slice_in()
|
||||
{
|
||||
|
|
|
@ -152,6 +152,7 @@ class NativeInheritImpl : Dummy.TestObject
|
|||
|
||||
// //
|
||||
//
|
||||
#if EFL_BETA
|
||||
override public bool EinaBinbufIn(Eina.Binbuf binbuf)
|
||||
{
|
||||
binbuf_in_flag = true;
|
||||
|
@ -280,6 +281,7 @@ class NativeInheritImpl : Dummy.TestObject
|
|||
binbuf_return_own_binbuf = null;
|
||||
return r;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
} // EinaTestData
|
||||
|
|
|
@ -176,6 +176,7 @@ class TestEoEvents
|
|||
Test.AssertEquals(sent_struct.Fstring, received_struct.Fstring);
|
||||
}
|
||||
|
||||
#if EFL_BETA
|
||||
public static void event_with_struct_complex_payload()
|
||||
{
|
||||
var obj = new Dummy.TestObject();
|
||||
|
@ -191,6 +192,7 @@ class TestEoEvents
|
|||
|
||||
Test.AssertEquals(sent_struct.Fobj, received_struct.Fobj);
|
||||
}
|
||||
#endif
|
||||
|
||||
public static void event_with_array_payload()
|
||||
{
|
||||
|
|
|
@ -120,6 +120,7 @@ internal class StructHelpers
|
|||
Test.Assert(simple.Fstringshare == null);
|
||||
}
|
||||
|
||||
#if EFL_BETA
|
||||
internal static Dummy.StructComplex structComplexWithValues()
|
||||
{
|
||||
var complex = new Dummy.StructComplex();
|
||||
|
@ -211,7 +212,7 @@ internal class StructHelpers
|
|||
|
||||
Test.Assert(complex.Fobj == null);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -20,11 +20,13 @@ internal class TestStructs
|
|||
checkZeroedStructSimple(simple);
|
||||
}
|
||||
|
||||
#if EFL_BETA
|
||||
private static void complex_default_instantiation()
|
||||
{
|
||||
var complex = new Dummy.StructComplex();
|
||||
checkZeroedStructComplex(complex);
|
||||
}
|
||||
#endif
|
||||
|
||||
public static void parameter_initialization()
|
||||
{
|
||||
|
@ -283,6 +285,7 @@ internal class TestStructs
|
|||
}
|
||||
|
||||
// Complex Structs
|
||||
#if EFL_BETA
|
||||
public static void complex_in()
|
||||
{
|
||||
var complex = structComplexWithValues();
|
||||
|
@ -330,6 +333,7 @@ internal class TestStructs
|
|||
// public static void complex_ptr_return_own()
|
||||
// {
|
||||
// }
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import eina_types;
|
||||
|
||||
class @beta Dummy.Event_Manager extends Efl.Object {
|
||||
class Dummy.Event_Manager extends Efl.Object {
|
||||
|
||||
methods {
|
||||
@property emitter {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import eina_types;
|
||||
|
||||
class @beta Dummy.Part_Holder extends Dummy.Test_Object implements Efl.Part {
|
||||
class Dummy.Part_Holder extends Dummy.Test_Object implements Efl.Part {
|
||||
|
||||
parts {
|
||||
one: Dummy.Test_Object; [[ Part number one. ]]
|
||||
|
|
|
@ -74,7 +74,7 @@ struct @free(free) Dummy.StructSimple
|
|||
fmyint: Dummy.MyInt;
|
||||
}
|
||||
|
||||
struct @free(free) Dummy.StructComplex {
|
||||
struct @beta @free(free) Dummy.StructComplex {
|
||||
farray: array<ptr(int)>;
|
||||
flist: list<string>;
|
||||
fhash: hash<string, string>;
|
||||
|
@ -82,7 +82,7 @@ struct @free(free) Dummy.StructComplex {
|
|||
fany_value: any_value;
|
||||
fany_value_ptr: any_value_ptr;
|
||||
fbinbuf: ptr(Eina.Binbuf);
|
||||
fslice: Eina.Slice;
|
||||
fslice: slice<ubyte>;
|
||||
// fslice: ptr(Eina.Slice); // TODO
|
||||
fobj: Dummy.Numberwrapper;
|
||||
}
|
||||
|
@ -253,71 +253,71 @@ class Dummy.Test_Object extends Efl.Object implements Dummy.Test_Iface {
|
|||
|
||||
eina_slice_in {
|
||||
params {
|
||||
@in slice: Eina.Slice;
|
||||
@in slice: slice<ubyte>;
|
||||
}
|
||||
return: bool;
|
||||
}
|
||||
|
||||
eina_rw_slice_in {
|
||||
params {
|
||||
@in slice: Eina.Rw_Slice;
|
||||
@in slice: rw_slice<ubyte>;
|
||||
}
|
||||
return: bool;
|
||||
}
|
||||
|
||||
eina_slice_out {
|
||||
params {
|
||||
@out slice: Eina.Slice;
|
||||
@out slice: slice<ubyte>;
|
||||
}
|
||||
return: bool;
|
||||
}
|
||||
|
||||
eina_rw_slice_out {
|
||||
params {
|
||||
@out slice: Eina.Rw_Slice;
|
||||
@out slice: rw_slice<ubyte>;
|
||||
}
|
||||
return: bool;
|
||||
}
|
||||
|
||||
eina_rw_slice_inout {
|
||||
params {
|
||||
@inout slice: Eina.Rw_Slice;
|
||||
@inout slice: rw_slice<ubyte>;
|
||||
}
|
||||
return: bool;
|
||||
}
|
||||
|
||||
/*
|
||||
eina_slice_return {
|
||||
return: Eina.Slice;
|
||||
return: slice<ubyte>;
|
||||
}
|
||||
|
||||
eina_rw_slice_return {
|
||||
return: Eina.Rw_Slice;
|
||||
return: rw_slice<ubyte>;
|
||||
}
|
||||
*/
|
||||
|
||||
eina_binbuf_in {
|
||||
eina_binbuf_in @beta {
|
||||
params {
|
||||
@in binbuf: ptr(Eina.Binbuf);
|
||||
}
|
||||
return: bool;
|
||||
}
|
||||
|
||||
call_eina_binbuf_in {
|
||||
call_eina_binbuf_in @beta {
|
||||
params {
|
||||
@in binbuf: ptr(Eina.Binbuf);
|
||||
}
|
||||
return: bool;
|
||||
}
|
||||
|
||||
eina_binbuf_in_own {
|
||||
eina_binbuf_in_own @beta {
|
||||
params {
|
||||
@in binbuf: ptr(Eina.Binbuf) @owned;
|
||||
}
|
||||
return: bool;
|
||||
}
|
||||
|
||||
call_eina_binbuf_in_own {
|
||||
call_eina_binbuf_in_own @beta {
|
||||
params {
|
||||
@in str: ptr(Eina.Binbuf) @owned;
|
||||
}
|
||||
|
@ -328,14 +328,14 @@ class Dummy.Test_Object extends Efl.Object implements Dummy.Test_Iface {
|
|||
return: bool;
|
||||
}
|
||||
|
||||
eina_binbuf_out {
|
||||
eina_binbuf_out @beta {
|
||||
params {
|
||||
@out binbuf: ptr(Eina.Binbuf);
|
||||
}
|
||||
return: bool;
|
||||
}
|
||||
|
||||
call_eina_binbuf_out {
|
||||
call_eina_binbuf_out @beta {
|
||||
return: ptr(Eina.Binbuf);
|
||||
}
|
||||
|
||||
|
@ -343,22 +343,22 @@ class Dummy.Test_Object extends Efl.Object implements Dummy.Test_Iface {
|
|||
return: bool;
|
||||
}
|
||||
|
||||
eina_binbuf_out_own {
|
||||
eina_binbuf_out_own @beta {
|
||||
params {
|
||||
@out binbuf: ptr(Eina.Binbuf) @owned;
|
||||
}
|
||||
return: bool;
|
||||
}
|
||||
|
||||
call_eina_binbuf_out_own {
|
||||
call_eina_binbuf_out_own @beta {
|
||||
return: ptr(Eina.Binbuf) @owned;
|
||||
}
|
||||
|
||||
eina_binbuf_return {
|
||||
eina_binbuf_return @beta {
|
||||
return: ptr(Eina.Binbuf);
|
||||
}
|
||||
|
||||
call_eina_binbuf_return {
|
||||
call_eina_binbuf_return @beta {
|
||||
return: ptr(Eina.Binbuf);
|
||||
}
|
||||
|
||||
|
@ -366,11 +366,11 @@ class Dummy.Test_Object extends Efl.Object implements Dummy.Test_Iface {
|
|||
return: bool;
|
||||
}
|
||||
|
||||
eina_binbuf_return_own {
|
||||
eina_binbuf_return_own @beta {
|
||||
return: ptr(Eina.Binbuf) @owned;
|
||||
}
|
||||
|
||||
call_eina_binbuf_return_own {
|
||||
call_eina_binbuf_return_own @beta {
|
||||
return: ptr(Eina.Binbuf) @owned;
|
||||
}
|
||||
|
||||
|
@ -1400,57 +1400,57 @@ class Dummy.Test_Object extends Efl.Object implements Dummy.Test_Iface {
|
|||
return: ptr(Dummy.StructSimple) @owned;
|
||||
}
|
||||
|
||||
struct_complex_in {
|
||||
struct_complex_in @beta {
|
||||
params {
|
||||
@in complex: Dummy.StructComplex;
|
||||
}
|
||||
return: bool;
|
||||
}
|
||||
|
||||
struct_complex_ptr_in {
|
||||
struct_complex_ptr_in @beta {
|
||||
params {
|
||||
@in complex: ptr(Dummy.StructComplex);
|
||||
}
|
||||
return: bool;
|
||||
}
|
||||
|
||||
struct_complex_ptr_in_own {
|
||||
struct_complex_ptr_in_own @beta {
|
||||
params {
|
||||
@in complex: ptr(Dummy.StructComplex) @owned;
|
||||
}
|
||||
return: bool;
|
||||
}
|
||||
|
||||
struct_complex_out {
|
||||
struct_complex_out @beta {
|
||||
params {
|
||||
@out complex: Dummy.StructComplex;
|
||||
}
|
||||
return: bool;
|
||||
}
|
||||
|
||||
// struct_complex_ptr_out {
|
||||
// struct_complex_ptr_out @beta {
|
||||
// params {
|
||||
// @out complex: ptr(Dummy.StructComplex);
|
||||
// }
|
||||
// return: bool;
|
||||
// }
|
||||
//
|
||||
// struct_complex_ptr_out_own {
|
||||
// struct_complex_ptr_out_own @beta {
|
||||
// params {
|
||||
// @out complex: ptr(Dummy.StructComplex) @owned;
|
||||
// }
|
||||
// return: bool;
|
||||
// }
|
||||
|
||||
struct_complex_return {
|
||||
struct_complex_return @beta {
|
||||
return: Dummy.StructComplex;
|
||||
}
|
||||
|
||||
// struct_complex_ptr_return {
|
||||
// struct_complex_ptr_return @beta {
|
||||
// return: ptr(Dummy.StructComplex);
|
||||
// }
|
||||
//
|
||||
// struct_complex_ptr_return_own {
|
||||
// struct_complex_ptr_return_own @beta {
|
||||
// return: ptr(Dummy.StructComplex) @owned;
|
||||
// }
|
||||
|
||||
|
@ -1502,7 +1502,7 @@ class Dummy.Test_Object extends Efl.Object implements Dummy.Test_Iface {
|
|||
}
|
||||
}
|
||||
|
||||
emit_event_with_struct_complex {
|
||||
emit_event_with_struct_complex @beta {
|
||||
params {
|
||||
@in data: Dummy.StructComplex;
|
||||
}
|
||||
|
@ -1627,7 +1627,7 @@ class Dummy.Test_Object extends Efl.Object implements Dummy.Test_Iface {
|
|||
evt,with,obj @hot: Dummy.Test_Object;
|
||||
evt,with,error @hot: Eina.Error;
|
||||
evt,with,struct @hot: Dummy.StructSimple;
|
||||
evt,with,struct,complex @hot: Dummy.StructComplex;
|
||||
evt,with,struct,complex @beta @hot: Dummy.StructComplex;
|
||||
evt,with,array @hot: const(array<string>);
|
||||
evt_with,under @hot: void;
|
||||
|
||||
|
|
Loading…
Reference in New Issue