Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
namespace Microsoft.Macios.Generator.Emitters;

static partial class BindingSyntaxFactory {
public static readonly ExpressionSyntax Runtime = GetIdentifierName ("Runtime");
public static readonly ExpressionSyntax Runtime = GetIdentifierName (
@namespace: ["ObjCRuntime"],
@class: "Runtime",
isGlobal: true);
public const string ClassPtr = "class_ptr";

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,9 @@ public static partial Foundation.NSCharacterSet Alphanumerics
{
Foundation.NSCharacterSet ret;
if (IsDirectBinding) {
ret = Runtime.GetNSObject<Foundation.NSCharacterSet> (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSend (this.Handle, Selector.GetHandle ("alphanumericCharacterSet")))!;
ret = global::ObjCRuntime.Runtime.GetNSObject<Foundation.NSCharacterSet> (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSend (this.Handle, Selector.GetHandle ("alphanumericCharacterSet")))!;
} else {
ret = Runtime.GetNSObject<Foundation.NSCharacterSet> (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSendSuper (this.Handle, Selector.GetHandle ("alphanumericCharacterSet")))!;
ret = global::ObjCRuntime.Runtime.GetNSObject<Foundation.NSCharacterSet> (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSendSuper (this.Handle, Selector.GetHandle ("alphanumericCharacterSet")))!;
}
GC.KeepAlive (this);
return ret;
Expand All @@ -245,9 +245,9 @@ public virtual partial Foundation.NSAttributedString AttributedStringByInflectin
{
Foundation.NSAttributedString ret;
if (IsDirectBinding) {
ret = Runtime.GetNSObject<Foundation.NSAttributedString> (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSend (this.Handle, Selector.GetHandle ("attributedStringByInflectingString")))!;
ret = global::ObjCRuntime.Runtime.GetNSObject<Foundation.NSAttributedString> (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSend (this.Handle, Selector.GetHandle ("attributedStringByInflectingString")))!;
} else {
ret = Runtime.GetNSObject<Foundation.NSAttributedString> (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSendSuper (this.Handle, Selector.GetHandle ("attributedStringByInflectingString")))!;
ret = global::ObjCRuntime.Runtime.GetNSObject<Foundation.NSAttributedString> (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSendSuper (this.Handle, Selector.GetHandle ("attributedStringByInflectingString")))!;
}
GC.KeepAlive (this);
return ret;
Expand Down Expand Up @@ -482,9 +482,9 @@ internal virtual partial Foundation.NSLocale Locale
{
Foundation.NSLocale ret;
if (IsDirectBinding) {
ret = Runtime.GetNSObject<Foundation.NSLocale> (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSend (this.Handle, Selector.GetHandle ("locale")))!;
ret = global::ObjCRuntime.Runtime.GetNSObject<Foundation.NSLocale> (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSend (this.Handle, Selector.GetHandle ("locale")))!;
} else {
ret = Runtime.GetNSObject<Foundation.NSLocale> (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSendSuper (this.Handle, Selector.GetHandle ("locale")))!;
ret = global::ObjCRuntime.Runtime.GetNSObject<Foundation.NSLocale> (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSendSuper (this.Handle, Selector.GetHandle ("locale")))!;
}
GC.KeepAlive (this);
return ret;
Expand Down Expand Up @@ -752,9 +752,9 @@ public virtual partial Foundation.NSObject? WeakDelegate
{
Foundation.NSObject? ret;
if (IsDirectBinding) {
ret = Runtime.GetNSObject<Foundation.NSObject> (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSend (this.Handle, Selector.GetHandle ("delegate")));
ret = global::ObjCRuntime.Runtime.GetNSObject<Foundation.NSObject> (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSend (this.Handle, Selector.GetHandle ("delegate")));
} else {
ret = Runtime.GetNSObject<Foundation.NSObject> (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSendSuper (this.Handle, Selector.GetHandle ("delegate")));
ret = global::ObjCRuntime.Runtime.GetNSObject<Foundation.NSObject> (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSendSuper (this.Handle, Selector.GetHandle ("delegate")));
}
GC.KeepAlive (this);
return ret;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,9 @@ public static partial Foundation.NSCharacterSet Alphanumerics
{
Foundation.NSCharacterSet ret;
if (IsDirectBinding) {
ret = Runtime.GetNSObject<Foundation.NSCharacterSet> (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSend (this.Handle, Selector.GetHandle ("alphanumericCharacterSet")))!;
ret = global::ObjCRuntime.Runtime.GetNSObject<Foundation.NSCharacterSet> (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSend (this.Handle, Selector.GetHandle ("alphanumericCharacterSet")))!;
} else {
ret = Runtime.GetNSObject<Foundation.NSCharacterSet> (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSendSuper (this.Handle, Selector.GetHandle ("alphanumericCharacterSet")))!;
ret = global::ObjCRuntime.Runtime.GetNSObject<Foundation.NSCharacterSet> (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSendSuper (this.Handle, Selector.GetHandle ("alphanumericCharacterSet")))!;
}
GC.KeepAlive (this);
return ret;
Expand All @@ -245,9 +245,9 @@ public virtual partial Foundation.NSAttributedString AttributedStringByInflectin
{
Foundation.NSAttributedString ret;
if (IsDirectBinding) {
ret = Runtime.GetNSObject<Foundation.NSAttributedString> (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSend (this.Handle, Selector.GetHandle ("attributedStringByInflectingString")))!;
ret = global::ObjCRuntime.Runtime.GetNSObject<Foundation.NSAttributedString> (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSend (this.Handle, Selector.GetHandle ("attributedStringByInflectingString")))!;
} else {
ret = Runtime.GetNSObject<Foundation.NSAttributedString> (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSendSuper (this.Handle, Selector.GetHandle ("attributedStringByInflectingString")))!;
ret = global::ObjCRuntime.Runtime.GetNSObject<Foundation.NSAttributedString> (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSendSuper (this.Handle, Selector.GetHandle ("attributedStringByInflectingString")))!;
}
GC.KeepAlive (this);
return ret;
Expand Down Expand Up @@ -482,9 +482,9 @@ internal virtual partial Foundation.NSLocale Locale
{
Foundation.NSLocale ret;
if (IsDirectBinding) {
ret = Runtime.GetNSObject<Foundation.NSLocale> (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSend (this.Handle, Selector.GetHandle ("locale")))!;
ret = global::ObjCRuntime.Runtime.GetNSObject<Foundation.NSLocale> (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSend (this.Handle, Selector.GetHandle ("locale")))!;
} else {
ret = Runtime.GetNSObject<Foundation.NSLocale> (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSendSuper (this.Handle, Selector.GetHandle ("locale")))!;
ret = global::ObjCRuntime.Runtime.GetNSObject<Foundation.NSLocale> (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSendSuper (this.Handle, Selector.GetHandle ("locale")))!;
}
GC.KeepAlive (this);
return ret;
Expand Down Expand Up @@ -752,9 +752,9 @@ public virtual partial Foundation.NSObject? WeakDelegate
{
Foundation.NSObject? ret;
if (IsDirectBinding) {
ret = Runtime.GetNSObject<Foundation.NSObject> (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSend (this.Handle, Selector.GetHandle ("delegate")));
ret = global::ObjCRuntime.Runtime.GetNSObject<Foundation.NSObject> (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSend (this.Handle, Selector.GetHandle ("delegate")));
} else {
ret = Runtime.GetNSObject<Foundation.NSObject> (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSendSuper (this.Handle, Selector.GetHandle ("delegate")));
ret = global::ObjCRuntime.Runtime.GetNSObject<Foundation.NSObject> (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSendSuper (this.Handle, Selector.GetHandle ("delegate")));
}
GC.KeepAlive (this);
return ret;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,9 @@ public static partial Foundation.NSCharacterSet Alphanumerics
{
Foundation.NSCharacterSet ret;
if (IsDirectBinding) {
ret = Runtime.GetNSObject<Foundation.NSCharacterSet> (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSend (this.Handle, Selector.GetHandle ("alphanumericCharacterSet")))!;
ret = global::ObjCRuntime.Runtime.GetNSObject<Foundation.NSCharacterSet> (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSend (this.Handle, Selector.GetHandle ("alphanumericCharacterSet")))!;
} else {
ret = Runtime.GetNSObject<Foundation.NSCharacterSet> (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSendSuper (this.Handle, Selector.GetHandle ("alphanumericCharacterSet")))!;
ret = global::ObjCRuntime.Runtime.GetNSObject<Foundation.NSCharacterSet> (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSendSuper (this.Handle, Selector.GetHandle ("alphanumericCharacterSet")))!;
}
GC.KeepAlive (this);
return ret;
Expand All @@ -245,9 +245,9 @@ public virtual partial Foundation.NSAttributedString AttributedStringByInflectin
{
Foundation.NSAttributedString ret;
if (IsDirectBinding) {
ret = Runtime.GetNSObject<Foundation.NSAttributedString> (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSend (this.Handle, Selector.GetHandle ("attributedStringByInflectingString")))!;
ret = global::ObjCRuntime.Runtime.GetNSObject<Foundation.NSAttributedString> (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSend (this.Handle, Selector.GetHandle ("attributedStringByInflectingString")))!;
} else {
ret = Runtime.GetNSObject<Foundation.NSAttributedString> (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSendSuper (this.Handle, Selector.GetHandle ("attributedStringByInflectingString")))!;
ret = global::ObjCRuntime.Runtime.GetNSObject<Foundation.NSAttributedString> (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSendSuper (this.Handle, Selector.GetHandle ("attributedStringByInflectingString")))!;
}
GC.KeepAlive (this);
return ret;
Expand Down Expand Up @@ -482,9 +482,9 @@ internal virtual partial Foundation.NSLocale Locale
{
Foundation.NSLocale ret;
if (IsDirectBinding) {
ret = Runtime.GetNSObject<Foundation.NSLocale> (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSend (this.Handle, Selector.GetHandle ("locale")))!;
ret = global::ObjCRuntime.Runtime.GetNSObject<Foundation.NSLocale> (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSend (this.Handle, Selector.GetHandle ("locale")))!;
} else {
ret = Runtime.GetNSObject<Foundation.NSLocale> (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSendSuper (this.Handle, Selector.GetHandle ("locale")))!;
ret = global::ObjCRuntime.Runtime.GetNSObject<Foundation.NSLocale> (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSendSuper (this.Handle, Selector.GetHandle ("locale")))!;
}
GC.KeepAlive (this);
return ret;
Expand Down Expand Up @@ -752,9 +752,9 @@ public virtual partial Foundation.NSObject? WeakDelegate
{
Foundation.NSObject? ret;
if (IsDirectBinding) {
ret = Runtime.GetNSObject<Foundation.NSObject> (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSend (this.Handle, Selector.GetHandle ("delegate")));
ret = global::ObjCRuntime.Runtime.GetNSObject<Foundation.NSObject> (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSend (this.Handle, Selector.GetHandle ("delegate")));
} else {
ret = Runtime.GetNSObject<Foundation.NSObject> (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSendSuper (this.Handle, Selector.GetHandle ("delegate")));
ret = global::ObjCRuntime.Runtime.GetNSObject<Foundation.NSObject> (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSendSuper (this.Handle, Selector.GetHandle ("delegate")));
}
GC.KeepAlive (this);
return ret;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ public partial class CGColorSpaceNames {
";

yield return [nsArrayFieldProperty,
"Runtime.GetNSObject<Foundation.NSArray> (Dlfcn.GetIndirect (Libraries.CoreGraphics.Handle, \"kCGColorSpaceGenericGray\"))!"];
"global::ObjCRuntime.Runtime.GetNSObject<Foundation.NSArray> (Dlfcn.GetIndirect (Libraries.CoreGraphics.Handle, \"kCGColorSpaceGenericGray\"))!"];

const string nsNumberFieldProperty = @"
using System;
Expand All @@ -540,7 +540,7 @@ public partial class CGColorSpaceNames {
";

yield return [nsNumberFieldProperty,
"Runtime.GetNSObject<Foundation.NSNumber> (Dlfcn.GetIndirect (Libraries.CoreGraphics.Handle, \"kCGColorSpaceGenericGray\"))!"];
"global::ObjCRuntime.Runtime.GetNSObject<Foundation.NSNumber> (Dlfcn.GetIndirect (Libraries.CoreGraphics.Handle, \"kCGColorSpaceGenericGray\"))!"];

const string sbyteEnumFieldProperty = @"
using System;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,8 @@ public IEnumerator<object []> GetEnumerator ()

yield return [
property,
"ret = Runtime.GetNSObject<Foundation.NSObject> (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSend (this.Handle, Selector.GetHandle (\"myProperty\")))!",
"ret = Runtime.GetNSObject<Foundation.NSObject> (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSendSuper (this.Handle, Selector.GetHandle (\"myProperty\")))!"
"ret = global::ObjCRuntime.Runtime.GetNSObject<Foundation.NSObject> (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSend (this.Handle, Selector.GetHandle (\"myProperty\")))!",
"ret = global::ObjCRuntime.Runtime.GetNSObject<Foundation.NSObject> (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSendSuper (this.Handle, Selector.GetHandle (\"myProperty\")))!"
];

property = new Property (
Expand All @@ -240,8 +240,8 @@ public IEnumerator<object []> GetEnumerator ()

yield return [
property,
"ret = Runtime.GetNSObject<Foundation.NSObject> (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSend (this.Handle, Selector.GetHandle (\"myProperty\")))",
"ret = Runtime.GetNSObject<Foundation.NSObject> (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSendSuper (this.Handle, Selector.GetHandle (\"myProperty\")))"
"ret = global::ObjCRuntime.Runtime.GetNSObject<Foundation.NSObject> (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSend (this.Handle, Selector.GetHandle (\"myProperty\")))",
"ret = global::ObjCRuntime.Runtime.GetNSObject<Foundation.NSObject> (global::ObjCRuntime.Messaging.NativeHandle_objc_msgSendSuper (this.Handle, Selector.GetHandle (\"myProperty\")))"
];

property = new Property (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -573,15 +573,15 @@ public IEnumerator<object []> GetEnumerator ()
ImmutableArray.Create (
Argument (IdentifierName ("arg1"))),
false,
"Runtime.GetNSObject<NSString> (arg1)"
"global::ObjCRuntime.Runtime.GetNSObject<NSString> (arg1)"
];

yield return [
"NSString",
ImmutableArray.Create (
Argument (IdentifierName ("arg1"))),
true,
"Runtime.GetNSObject<NSString> (arg1)!"
"global::ObjCRuntime.Runtime.GetNSObject<NSString> (arg1)!"
];

yield return [
Expand All @@ -592,7 +592,7 @@ public IEnumerator<object []> GetEnumerator ()
Argument (IdentifierName ("arg3"))
),
false,
"Runtime.GetNSObject<NSNumber> (arg1, arg2, arg3)"
"global::ObjCRuntime.Runtime.GetNSObject<NSNumber> (arg1, arg2, arg3)"
];

yield return [
Expand All @@ -603,7 +603,7 @@ public IEnumerator<object []> GetEnumerator ()
Argument (IdentifierName ("arg3"))
),
true,
"Runtime.GetNSObject<NSNumber> (arg1, arg2, arg3)!"
"global::ObjCRuntime.Runtime.GetNSObject<NSNumber> (arg1, arg2, arg3)!"
];
}

Expand All @@ -626,15 +626,15 @@ public IEnumerator<object []> GetEnumerator ()
ImmutableArray.Create (
Argument (IdentifierName ("arg1"))),
false,
"Runtime.GetINativeObject<NSString> (arg1)"
"global::ObjCRuntime.Runtime.GetINativeObject<NSString> (arg1)"
];

yield return [
"NSString",
ImmutableArray.Create (
Argument (IdentifierName ("arg1"))),
true,
"Runtime.GetINativeObject<NSString> (arg1)!"
"global::ObjCRuntime.Runtime.GetINativeObject<NSString> (arg1)!"
];

yield return [
Expand All @@ -645,7 +645,7 @@ public IEnumerator<object []> GetEnumerator ()
Argument (IdentifierName ("arg3"))
),
false,
"Runtime.GetINativeObject<NSNumber> (arg1, arg2, arg3)"
"global::ObjCRuntime.Runtime.GetINativeObject<NSNumber> (arg1, arg2, arg3)"
];

yield return [
Expand All @@ -656,7 +656,7 @@ public IEnumerator<object []> GetEnumerator ()
Argument (IdentifierName ("arg3"))
),
true,
"Runtime.GetINativeObject<NSNumber> (arg1, arg2, arg3)!"
"global::ObjCRuntime.Runtime.GetINativeObject<NSNumber> (arg1, arg2, arg3)!"
];
}

Expand Down Expand Up @@ -712,7 +712,7 @@ public IEnumerator<object []> GetEnumerator ()
yield return [
ImmutableArray.Create (
Argument (IdentifierName ("arg1"))),
"Runtime.RetainAndAutoreleaseNSObject (arg1)",
"global::ObjCRuntime.Runtime.RetainAndAutoreleaseNSObject (arg1)",
];

yield return [
Expand All @@ -721,7 +721,7 @@ public IEnumerator<object []> GetEnumerator ()
Argument (IdentifierName ("arg2")),
Argument (IdentifierName ("arg3"))
),
"Runtime.RetainAndAutoreleaseNSObject (arg1, arg2, arg3)",
"global::ObjCRuntime.Runtime.RetainAndAutoreleaseNSObject (arg1, arg2, arg3)",
];
}

Expand All @@ -742,7 +742,7 @@ public IEnumerator<object []> GetEnumerator ()
yield return [
ImmutableArray.Create (
Argument (IdentifierName ("arg1"))),
"Runtime.RetainAndAutoreleaseNativeObject (arg1)",
"global::ObjCRuntime.Runtime.RetainAndAutoreleaseNativeObject (arg1)",
];

yield return [
Expand All @@ -751,7 +751,7 @@ public IEnumerator<object []> GetEnumerator ()
Argument (IdentifierName ("arg2")),
Argument (IdentifierName ("arg3"))
),
"Runtime.RetainAndAutoreleaseNativeObject (arg1, arg2, arg3)",
"global::ObjCRuntime.Runtime.RetainAndAutoreleaseNativeObject (arg1, arg2, arg3)",
];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void MyMethod (Callback cb) {}

yield return [
arrayNSObjectResult,
"Runtime.RetainAndAutoreleaseNSObject (NSArray.FromNSObjects (auxVariable))"
"global::ObjCRuntime.Runtime.RetainAndAutoreleaseNSObject (NSArray.FromNSObjects (auxVariable))"
];

const string nsObjectResult = @"
Expand All @@ -51,7 +51,7 @@ public void MyMethod (Callback cb) {}

yield return [
nsObjectResult,
"Runtime.RetainAndAutoreleaseNSObject (auxVariable)"
"global::ObjCRuntime.Runtime.RetainAndAutoreleaseNSObject (auxVariable)"
];

const string nativeObjectResult = @"
Expand All @@ -70,7 +70,7 @@ public void MyMethod (Callback cb) {}

yield return [
nativeObjectResult,
"Runtime.RetainAndAutoreleaseNativeObject (auxVariable)"
"global::ObjCRuntime.Runtime.RetainAndAutoreleaseNativeObject (auxVariable)"
];

const string protocolResult = @"
Expand All @@ -89,7 +89,7 @@ public void MyMethod (Callback cb) {}

yield return [
protocolResult,
"Runtime.RetainAndAutoreleaseNSObject (auxVariable)"
"global::ObjCRuntime.Runtime.RetainAndAutoreleaseNSObject (auxVariable)"
];

const string systemStringResult = @"
Expand Down
Loading