Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Foundation/NSInputStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ public unsafe nint Read (byte [] buffer, int offset, nuint len)
return Read ((IntPtr) ptr, len);
}

[DllImport ("/usr/lib/libobjc.dylib")]
[DllImport (Messaging.LIBOBJC_DYLIB)]
static extern nint objc_msgSend (IntPtr handle, IntPtr sel, [In, Out] byte [] buffer, nuint len);

[DllImport ("/usr/lib/libobjc.dylib")]
[DllImport (Messaging.LIBOBJC_DYLIB)]
static extern nint objc_msgSend (IntPtr handle, IntPtr sel, IntPtr buffer, nuint len);

[DllImport ("/usr/lib/libobjc.dylib")]
[DllImport (Messaging.LIBOBJC_DYLIB)]
static extern nint objc_msgSendSuper (IntPtr handle, IntPtr sel, IntPtr buffer, nuint len);

[Export ("read:maxLength:")]
Expand Down
4 changes: 2 additions & 2 deletions src/Foundation/NSObject2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -671,10 +671,10 @@ public void SetNativeField (string name, NSObject value) {
SetObjCIvar (name, value.Handle);
}

[DllImport ("/usr/lib/libobjc.dylib")]
[DllImport (Messaging.LIBOBJC_DYLIB)]
extern static void object_getInstanceVariable (IntPtr obj, string name, out IntPtr val);

[DllImport ("/usr/lib/libobjc.dylib")]
[DllImport (Messaging.LIBOBJC_DYLIB)]
extern static void object_setInstanceVariable (IntPtr obj, string name, IntPtr val);
#endif // !XAMCORE_3_0

Expand Down
4 changes: 2 additions & 2 deletions src/Foundation/NSOutputStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ public unsafe nint Write (byte [] buffer, int offset, nuint len)
return objc_msgSend (Handle, Selector.GetHandle (selWriteMaxLength), (IntPtr) ptr, len);
}

[DllImport ("/usr/lib/libobjc.dylib")]
[DllImport (Messaging.LIBOBJC_DYLIB)]
static extern nint objc_msgSend (IntPtr handle, IntPtr sel, [In, Out] byte [] buffer, nuint len);

[DllImport ("/usr/lib/libobjc.dylib")]
[DllImport (Messaging.LIBOBJC_DYLIB)]
static extern nint objc_msgSend (IntPtr handle, IntPtr sel, IntPtr buffer, nuint len);
}
}
28 changes: 14 additions & 14 deletions src/ObjCRuntime/Class.cs
Original file line number Diff line number Diff line change
Expand Up @@ -576,50 +576,50 @@ internal static bool IsCustomType (Type type)
throw ErrorHelper.CreateError (8026, $"Can't determine if {type.FullName} is a custom type when the dynamic registrar has been linked away.");
}

[DllImport ("/usr/lib/libobjc.dylib")]
[DllImport (Messaging.LIBOBJC_DYLIB)]
internal static extern IntPtr objc_allocateClassPair (IntPtr superclass, string name, IntPtr extraBytes);

[DllImport ("/usr/lib/libobjc.dylib")]
[DllImport (Messaging.LIBOBJC_DYLIB)]
internal static extern IntPtr objc_getClass (string name);

[DllImport ("/usr/lib/libobjc.dylib")]
[DllImport (Messaging.LIBOBJC_DYLIB)]
internal static extern void objc_registerClassPair (IntPtr cls);

[DllImport ("/usr/lib/libobjc.dylib")]
[DllImport (Messaging.LIBOBJC_DYLIB)]
[return: MarshalAs (UnmanagedType.U1)]
internal static extern bool class_addIvar (IntPtr cls, string name, IntPtr size, byte alignment, string types);

[DllImport ("/usr/lib/libobjc.dylib")]
[DllImport (Messaging.LIBOBJC_DYLIB)]
[return: MarshalAs (UnmanagedType.U1)]
internal static extern bool class_addMethod (IntPtr cls, IntPtr name, IntPtr imp, string types);

[DllImport ("/usr/lib/libobjc.dylib")]
[DllImport (Messaging.LIBOBJC_DYLIB)]
[return: MarshalAs (UnmanagedType.U1)]
internal extern static bool class_addMethod (IntPtr cls, IntPtr name, Delegate imp, string types);

[DllImport ("/usr/lib/libobjc.dylib")]
[DllImport (Messaging.LIBOBJC_DYLIB)]
[return: MarshalAs (UnmanagedType.U1)]
internal extern static bool class_addProtocol (IntPtr cls, IntPtr protocol);

[DllImport ("/usr/lib/libobjc.dylib")]
[DllImport (Messaging.LIBOBJC_DYLIB)]
internal static extern IntPtr class_getName (IntPtr cls);

[DllImport ("/usr/lib/libobjc.dylib")]
[DllImport (Messaging.LIBOBJC_DYLIB)]
internal static extern IntPtr class_getSuperclass (IntPtr cls);

[DllImport ("/usr/lib/libobjc.dylib")]
[DllImport (Messaging.LIBOBJC_DYLIB)]
internal static extern IntPtr object_getClass (IntPtr obj);

[DllImport ("/usr/lib/libobjc.dylib")]
[DllImport (Messaging.LIBOBJC_DYLIB)]
internal extern static IntPtr class_getMethodImplementation (IntPtr cls, IntPtr sel);

[DllImport ("/usr/lib/libobjc.dylib")]
[DllImport (Messaging.LIBOBJC_DYLIB)]
internal extern static IntPtr class_getInstanceVariable (IntPtr cls, string name);

[DllImport ("/usr/lib/libobjc.dylib")]
[DllImport (Messaging.LIBOBJC_DYLIB)]
internal extern static IntPtr class_getInstanceMethod (IntPtr cls, IntPtr sel);

[DllImport ("/usr/lib/libobjc.dylib", CharSet=CharSet.Ansi)]
[DllImport (Messaging.LIBOBJC_DYLIB, CharSet=CharSet.Ansi)]
[return: MarshalAs (UnmanagedType.U1)]
internal extern static bool class_addProperty (IntPtr cls, string name, objc_attribute_prop [] attributes, int count);

Expand Down
5 changes: 5 additions & 0 deletions src/ObjCRuntime/Messaging.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
namespace ObjCRuntime {
static partial class Messaging {
internal const string LIBOBJC_DYLIB = "/usr/lib/libobjc.dylib";
}
}
14 changes: 7 additions & 7 deletions src/ObjCRuntime/Protocol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,25 +61,25 @@ public static IntPtr GetHandle (string name)
return objc_getProtocol (name);
}

[DllImport ("/usr/lib/libobjc.dylib")]
[DllImport (Messaging.LIBOBJC_DYLIB)]
internal extern static IntPtr objc_getProtocol (string? name);

[DllImport ("/usr/lib/libobjc.dylib")]
[DllImport (Messaging.LIBOBJC_DYLIB)]
internal extern static IntPtr objc_allocateProtocol (string name);

[DllImport ("/usr/lib/libobjc.dylib")]
[DllImport (Messaging.LIBOBJC_DYLIB)]
internal extern static void objc_registerProtocol (IntPtr protocol);

[DllImport ("/usr/lib/libobjc.dylib")]
[DllImport (Messaging.LIBOBJC_DYLIB)]
internal extern static void protocol_addProperty (IntPtr protocol, string name, Class.objc_attribute_prop [] attributes, int count, [MarshalAs (UnmanagedType.I1)] bool isRequired, [MarshalAs (UnmanagedType.I1)] bool isInstance);

[DllImport ("/usr/lib/libobjc.dylib")]
[DllImport (Messaging.LIBOBJC_DYLIB)]
internal extern static void protocol_addMethodDescription (IntPtr protocol, IntPtr nameSelector, string signature, [MarshalAs (UnmanagedType.I1)] bool isRequired, [MarshalAs (UnmanagedType.I1)] bool isInstance);

[DllImport ("/usr/lib/libobjc.dylib")]
[DllImport (Messaging.LIBOBJC_DYLIB)]
internal extern static void protocol_addProtocol (IntPtr protocol, IntPtr addition);

[DllImport ("/usr/lib/libobjc.dylib")]
[DllImport (Messaging.LIBOBJC_DYLIB)]
internal extern static IntPtr protocol_getName (IntPtr protocol);
#endif
}
Expand Down
7 changes: 4 additions & 3 deletions src/ObjCRuntime/Selector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
using System;
using System.Runtime.InteropServices;
using Foundation;
using ObjCRuntime;

#nullable enable

Expand Down Expand Up @@ -136,16 +137,16 @@ public static Selector Register (NativeHandle handle)
}

// objc/runtime.h
[DllImport ("/usr/lib/libobjc.dylib")]
[DllImport (Messaging.LIBOBJC_DYLIB)]
extern static /* const char* */ IntPtr sel_getName (/* SEL */ IntPtr sel);

// objc/runtime.h
// Selector.GetHandle is optimized by the AOT compiler, and the current implementation only supports IntPtr, so we can't switch to NativeHandle quite yet (the AOT compiler crashes).
[DllImport ("/usr/lib/libobjc.dylib", EntryPoint="sel_registerName")]
[DllImport (Messaging.LIBOBJC_DYLIB, EntryPoint="sel_registerName")]
public extern static /* SEL */ IntPtr GetHandle (/* const char* */ string name);

// objc/objc.h
[DllImport ("/usr/lib/libobjc.dylib")]
[DllImport (Messaging.LIBOBJC_DYLIB)]
[return: MarshalAs (UnmanagedType.U1)]
extern static /* BOOL */ bool sel_isMapped (/* SEL */ IntPtr sel);
}
Expand Down
2 changes: 1 addition & 1 deletion src/ObjCRuntime/TrampolineBlockBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public abstract class TrampolineBlockBase {

readonly IntPtr blockPtr;

[DllImport ("/usr/lib/libobjc.dylib")]
[DllImport (Messaging.LIBOBJC_DYLIB)]
static extern IntPtr _Block_copy (IntPtr ptr);

protected unsafe TrampolineBlockBase (BlockLiteral *block)
Expand Down
1 change: 1 addition & 0 deletions src/frameworks.sources
Original file line number Diff line number Diff line change
Expand Up @@ -1874,6 +1874,7 @@ SHARED_CORE_SOURCES = \
ObjCRuntime/ErrorConstants.cs \
ObjCRuntime/INativeObject.cs \
ObjCRuntime/LinkWithAttribute.cs \
ObjCRuntime/Messaging.cs \
ObjCRuntime/NativeAttribute.cs \
ObjCRuntime/NativeHandle.cs \
ObjCRuntime/NativeNameAttribute.cs \
Expand Down
2 changes: 1 addition & 1 deletion src/generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2417,8 +2417,8 @@ public void Go ()
print (m, "namespace {0} {{", ns.ObjCRuntime);
print (m, "\tstatic partial class Messaging {");

print (m, "\t\tinternal const string LIBOBJC_DYLIB = \"/usr/lib/libobjc.dylib\";\n");
if (BindThirdPartyLibrary){
print (m, "\t\tinternal const string LIBOBJC_DYLIB = \"/usr/lib/libobjc.dylib\";\n");
print (m, "\t\tstatic internal System.Reflection.Assembly this_assembly = typeof (Messaging).Assembly;\n");
// IntPtr_objc_msgSend[Super]: for init
print (m, "\t\t[DllImport (LIBOBJC_DYLIB, EntryPoint=\"objc_msgSend\")]");
Expand Down