[runtime] Replace xamarin_try_get_nsobject with xamarin_has_nsobject.

Removes one usage of ObjectWrapper, since we don't actually need
the return value, we just need to know if an object exists.
This commit is contained in:
Rolf Bjarne Kvinge 2016-02-17 12:02:41 +01:00
Родитель fc0f656a53
Коммит ac5ff5e321
5 изменённых файлов: 12 добавлений и 13 удалений

Просмотреть файл

@ -67,14 +67,14 @@
"SEL", "IntPtr", "sel"
) { WrappedManagedFunction = "GetMethodForSelector" },
new XDelegate ("MonoObject *", "IntPtr", "xamarin_try_get_nsobject",
"id", "IntPtr", "obj"
) { WrappedManagedFunction = "TryGetNSObjectWrapped" },
new XDelegate ("MonoObject *", "IntPtr", "xamarin_get_nsobject",
"id", "IntPtr", "obj"
) { WrappedManagedFunction = "GetNSObjectWrapped" },
new XDelegate ("bool", "bool", "xamarin_has_nsobject",
"id", "IntPtr", "obj"
) { WrappedManagedFunction = "HasNSObject" },
new XDelegate ("id", "IntPtr", "xamarin_get_handle_for_inativeobject",
"MonoObject *", "IntPtr", "obj"
) { WrappedManagedFunction = "GetHandleForINativeObject" },

Просмотреть файл

@ -27,8 +27,7 @@ xamarin_invoke_trampoline (enum TrampolineType type, id self, SEL sel, iterator_
bool is_ctor = type == Tramp_Ctor;
if (is_ctor) {
void *obj = xamarin_try_get_nsobject (self);
if (obj != NULL) {
if (xamarin_has_nsobject (self)) {
self = xamarin_invoke_objc_method_implementation (self, sel, (IMP) xamarin_ctor_trampoline);
marshal_return_value (context, "|", sizeof (id), self, NULL, false, NULL);
return;

Просмотреть файл

@ -172,7 +172,7 @@ MonoObject* xamarin_get_selector (SEL ptr);
Class xamarin_get_class_handle (MonoObject *obj);
SEL xamarin_get_selector_handle (MonoObject *obj);
MethodDescription xamarin_get_method_for_selector (Class cls, SEL sel);
MonoObject* xamarin_try_get_nsobject (id obj);
bool xamarin_has_nsobject (id obj);
MonoObject* xamarin_get_nsobject (id obj);
id xamarin_get_handle_for_inativeobject (MonoObject *obj);
void xamarin_unregister_nsobject (id native_obj, MonoObject *managed_obj);

Просмотреть файл

@ -517,16 +517,16 @@ namespace XamCore.ObjCRuntime {
return Registrar.GetMethodDescription (Class.Lookup (cls), sel);
}
static IntPtr TryGetNSObjectWrapped (IntPtr ptr)
{
return ObjectWrapper.Convert (TryGetNSObject (ptr));
}
static IntPtr GetNSObjectWrapped (IntPtr ptr)
{
return ObjectWrapper.Convert (TryGetNSObject (ptr, true));
}
static bool HasNSObject (IntPtr ptr)
{
return TryGetNSObject (ptr) != null;
}
static IntPtr GetHandleForINativeObject (IntPtr ptr)
{
return ((INativeObject) ObjectWrapper.Convert (ptr)).Handle;

Просмотреть файл

@ -3186,7 +3186,7 @@ namespace XamCore.Registrar {
body.Unindent ();
if (isCtor) {
body.WriteLine ("if (xamarin_try_get_nsobject (self)) {");
body.WriteLine ("if (xamarin_has_nsobject (self)) {");
body.WriteLine ("*call_super = true;");
body.WriteLine ("return self;");
body.WriteLine ("}");