forked from enlightenment/efl
csharp: Fix wrapping of private classes
Summary: Sometimes, valid Eo objects of private classes can be returned from methods. Currently we try to wrap in a minimal `Efl.Object` instance, but as it is an abstract class, we can't instantiate directly. This commits adds a dummy `Efl.ObjectRealized` to be instantiated when wrapping such classes alongside a test case. Fixes: T8258 Reviewers: felipealmeida, brunobelo, segfaultxavi, Jaehyun_Cho Reviewed By: brunobelo Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D10101
This commit is contained in:
parent
351072711c
commit
2e7b508312
|
@ -413,4 +413,15 @@ public abstract class EoWrapper : IWrapper, IDisposable
|
||||||
|
|
||||||
} // namespace Eo
|
} // namespace Eo
|
||||||
|
|
||||||
|
/// <summary>Concrete realization of Efl.Object.
|
||||||
|
///
|
||||||
|
/// Some legacy classes (like Evas.Canvas) may be returned by some methods. As these classes are not bound, we
|
||||||
|
/// allow minimal interaction with them through <see cref="Efl.Object" />.
|
||||||
|
///
|
||||||
|
/// But as <see cref="Efl.Object" /> is abstract, whis realized class will allow us to create C# instances of it.</summary>
|
||||||
|
internal class ObjectRealized : Efl.Object
|
||||||
|
{
|
||||||
|
protected ObjectRealized(Efl.Eo.Globals.WrappingHandle ch) : base(ch) { }
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Efl
|
} // namespace Efl
|
||||||
|
|
|
@ -843,7 +843,7 @@ public static class ClassRegister
|
||||||
|
|
||||||
if (t == null)
|
if (t == null)
|
||||||
{
|
{
|
||||||
return typeof(Efl.Object);
|
return typeof(Efl.ObjectRealized);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -621,4 +621,15 @@ class TestStaticInterfaceMembers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class TestHiddenClasses
|
||||||
|
{
|
||||||
|
public static void test_hidden_class()
|
||||||
|
{
|
||||||
|
var obj = new Dummy.TestObject();
|
||||||
|
var hidden = obj.HiddenObject;
|
||||||
|
|
||||||
|
Test.AssertEquals(hidden.Name, "hidden_object");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
#include "libefl_mono_native_test.h"
|
||||||
|
|
||||||
|
typedef struct Dummy_Hidden_Object_Data
|
||||||
|
{
|
||||||
|
} Dummy_Hidden_Object_Data;
|
||||||
|
|
||||||
|
|
||||||
|
#include "dummy_hidden_object.eo.c"
|
|
@ -0,0 +1,2 @@
|
||||||
|
class Dummy.Hidden_Object extends Efl.Object {
|
||||||
|
}
|
|
@ -22,6 +22,7 @@ typedef struct Dummy_Test_Object_Data
|
||||||
Eo *iface_provider;
|
Eo *iface_provider;
|
||||||
int prop1;
|
int prop1;
|
||||||
int prop2;
|
int prop2;
|
||||||
|
Eo *hidden_object;
|
||||||
|
|
||||||
// Containers passed to C# as iterator/accessors
|
// Containers passed to C# as iterator/accessors
|
||||||
Eina_Array *out_array;
|
Eina_Array *out_array;
|
||||||
|
@ -75,6 +76,8 @@ _dummy_test_object_efl_object_constructor(Eo *obj, Dummy_Test_Object_Data *pd)
|
||||||
{
|
{
|
||||||
efl_constructor(efl_super(obj, DUMMY_TEST_OBJECT_CLASS));
|
efl_constructor(efl_super(obj, DUMMY_TEST_OBJECT_CLASS));
|
||||||
pd->provider = efl_add(DUMMY_NUMBERWRAPPER_CLASS, obj);
|
pd->provider = efl_add(DUMMY_NUMBERWRAPPER_CLASS, obj);
|
||||||
|
pd->hidden_object = efl_add(DUMMY_HIDDEN_OBJECT_CLASS, obj);
|
||||||
|
efl_name_set(pd->hidden_object, "hidden_object");
|
||||||
|
|
||||||
if (efl_parent_get(obj) == NULL) { // Avoid recursion
|
if (efl_parent_get(obj) == NULL) { // Avoid recursion
|
||||||
pd->iface_provider = efl_add(DUMMY_TEST_OBJECT_CLASS, obj);
|
pd->iface_provider = efl_add(DUMMY_TEST_OBJECT_CLASS, obj);
|
||||||
|
@ -4738,6 +4741,11 @@ int _dummy_test_object_dummy_test_iface_call_method_protected(const Eo *obj, EIN
|
||||||
return dummy_test_iface_method_protected(obj, x);
|
return dummy_test_iface_method_protected(obj, x);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Eo *_dummy_test_object_hidden_object_get(EINA_UNUSED const Eo *obj, Dummy_Test_Object_Data *pd)
|
||||||
|
{
|
||||||
|
return pd->hidden_object;
|
||||||
|
}
|
||||||
|
|
||||||
// Inherit
|
// Inherit
|
||||||
int _dummy_inherit_helper_receive_dummy_and_call_int_out(Dummy_Test_Object *x)
|
int _dummy_inherit_helper_receive_dummy_and_call_int_out(Dummy_Test_Object *x)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1646,6 +1646,14 @@ class Dummy.Test_Object extends Efl.Object implements Dummy.Test_Iface {
|
||||||
}
|
}
|
||||||
return: const(ptr(Eina.Value_Type));
|
return: const(ptr(Eina.Value_Type));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@property hidden_object {
|
||||||
|
get {}
|
||||||
|
|
||||||
|
values {
|
||||||
|
obj: Efl.Object;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
implements {
|
implements {
|
||||||
Efl.Object.constructor;
|
Efl.Object.constructor;
|
||||||
|
|
|
@ -56,6 +56,7 @@
|
||||||
#include "dummy_part_holder.eo.h"
|
#include "dummy_part_holder.eo.h"
|
||||||
#include "dummy_event_manager.eo.h"
|
#include "dummy_event_manager.eo.h"
|
||||||
#include "dummy_constructible_object.eo.h"
|
#include "dummy_constructible_object.eo.h"
|
||||||
|
#include "dummy_hidden_object.eo.h"
|
||||||
|
|
||||||
#include <interfaces/efl_part.eo.h>
|
#include <interfaces/efl_part.eo.h>
|
||||||
|
|
||||||
|
|
|
@ -10,9 +10,13 @@ eo_files = [
|
||||||
'dummy_constructible_object.eo',
|
'dummy_constructible_object.eo',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
private_eo_files = [
|
||||||
|
'dummy_hidden_object.eo'
|
||||||
|
]
|
||||||
|
|
||||||
eo_file_targets = []
|
eo_file_targets = []
|
||||||
|
|
||||||
foreach eo_file : eo_files
|
foreach eo_file : eo_files + private_eo_files
|
||||||
eo_file_targets += custom_target('eolian_gen_' + eo_file,
|
eo_file_targets += custom_target('eolian_gen_' + eo_file,
|
||||||
input : eo_file,
|
input : eo_file,
|
||||||
output : [eo_file + '.h'],
|
output : [eo_file + '.h'],
|
||||||
|
@ -35,6 +39,7 @@ efl_mono_native_test = library('efl_mono_native_test',
|
||||||
'dummy_test_object.c',
|
'dummy_test_object.c',
|
||||||
'dummy_event_manager.c',
|
'dummy_event_manager.c',
|
||||||
'dummy_constructible_object.c',
|
'dummy_constructible_object.c',
|
||||||
|
'dummy_hidden_object.c',
|
||||||
],
|
],
|
||||||
dependencies : [ecore, eo, efl],
|
dependencies : [ecore, eo, efl],
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue