Skip to content

Commit

Permalink
[CoreFoundation] Remove !NET code.
Browse files Browse the repository at this point in the history
  • Loading branch information
rolfbjarne committed Feb 26, 2025
1 parent 97fbaaf commit 8d3f452
Show file tree
Hide file tree
Showing 29 changed files with 2 additions and 1,024 deletions.
16 changes: 0 additions & 16 deletions src/CoreFoundation/CFAllocator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@
using Foundation;
using ObjCRuntime;

#if !NET
using NativeHandle = System.IntPtr;
#endif

namespace CoreFoundation {

// CFBase.h
Expand All @@ -50,20 +46,8 @@ public partial class CFAllocator : NativeObject {
static CFAllocator? Null_cf;
#endif

#if !NET
[Obsolete ("Use the overload that takes a 'bool owns' parameter instead.")]
public CFAllocator (NativeHandle handle)
: base (handle, true /* backwards compatibility means we have to pass true here as opposed to the general pattern */)
{
}
#endif

[Preserve (Conditional = true)]
#if NET
internal CFAllocator (NativeHandle handle, bool owns)
#else
public CFAllocator (NativeHandle handle, bool owns)
#endif
: base (handle, owns)
{
}
Expand Down
15 changes: 0 additions & 15 deletions src/CoreFoundation/CFArray.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,12 @@
using Foundation;
using ObjCRuntime;

#if NET
using CFIndex = System.IntPtr;
#else
using CFIndex = System.nint;
#endif
using CFArrayRef = System.IntPtr;
using CFAllocatorRef = System.IntPtr;

#nullable enable

#if !NET
using NativeHandle = System.IntPtr;
#endif

namespace CoreFoundation {

// interesting bits: https://github.com/opensource-apple/CF/blob/master/CFArray.c
Expand All @@ -56,13 +48,6 @@ public partial class CFArray : NativeObject {
// this cache the handle instead of issuing a native call
internal static NativeHandle CFNullHandle = _CFNullHandle;

#if !NET
internal CFArray (NativeHandle handle)
: base (handle, false)
{
}
#endif

[Preserve (Conditional = true)]
internal CFArray (NativeHandle handle, bool owns)
: base (handle, owns)
Expand Down
6 changes: 0 additions & 6 deletions src/CoreFoundation/CFBoolean.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,13 @@
using ObjCRuntime;
using Foundation;

#if !NET
using NativeHandle = System.IntPtr;
#endif

namespace CoreFoundation {


#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
#endif
// CFNumber.h
partial class CFBoolean : NativeObject {
[Preserve (Conditional = true)]
Expand Down
30 changes: 0 additions & 30 deletions src/CoreFoundation/CFBundle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@
using CoreFoundation;
using Foundation;

#if !NET
using NativeHandle = System.IntPtr;
#endif

namespace CoreFoundation {

public partial class CFBundle : NativeObject {
Expand All @@ -28,12 +24,10 @@ public enum PackageType {
Bundle
}

#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
#endif
public struct PackageInfo {
public PackageInfo (CFBundle.PackageType type, string creator)
{
Expand Down Expand Up @@ -650,21 +644,13 @@ public CFBundle.Architecture []? Architectures {
}

#if MONOMAC
#if NET
[SupportedOSPlatform ("macos")]
[UnsupportedOSPlatform ("maccatalyst")]
#else
[NoMacCatalyst]
#endif
[DllImport (Constants.CoreFoundationLibrary)]
extern static byte CFBundleIsExecutableLoadable (IntPtr bundle);

#if NET
[SupportedOSPlatform ("macos")]
[UnsupportedOSPlatform ("maccatalyst")]
#else
[NoMacCatalyst]
#endif
public static bool IsExecutableLoadable (CFBundle bundle)
{
if (bundle is null)
Expand All @@ -673,21 +659,13 @@ public static bool IsExecutableLoadable (CFBundle bundle)
return CFBundleIsExecutableLoadable (bundle.GetCheckedHandle ()) != 0;
}

#if NET
[SupportedOSPlatform ("macos")]
[UnsupportedOSPlatform ("maccatalyst")]
#else
[NoMacCatalyst]
#endif
[DllImport (Constants.CoreFoundationLibrary)]
extern static byte CFBundleIsExecutableLoadableForURL (IntPtr bundle);

#if NET
[SupportedOSPlatform ("macos")]
[UnsupportedOSPlatform ("maccatalyst")]
#else
[NoMacCatalyst]
#endif
public static bool IsExecutableLoadable (NSUrl url)
{
if (url is null)
Expand All @@ -696,21 +674,13 @@ public static bool IsExecutableLoadable (NSUrl url)
return CFBundleIsExecutableLoadableForURL (url.Handle) != 0;
}

#if NET
[SupportedOSPlatform ("macos")]
[UnsupportedOSPlatform ("maccatalyst")]
#else
[NoMacCatalyst]
#endif
[DllImport (Constants.CoreFoundationLibrary)]
extern static byte CFBundleIsArchitectureLoadable (/*cpu_type_t => integer_t => int*/ Architecture architecture);

#if NET
[SupportedOSPlatform ("macos")]
[UnsupportedOSPlatform ("maccatalyst")]
#else
[NoMacCatalyst]
#endif
public static bool IsArchitectureLoadable (Architecture architecture) => CFBundleIsArchitectureLoadable (architecture) != 0;

#endif
Expand Down
4 changes: 0 additions & 4 deletions src/CoreFoundation/CFData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@
using Foundation;
using ObjCRuntime;

#if !NET
using NativeHandle = System.IntPtr;
#endif

namespace CoreFoundation {

class CFData : NativeObject {
Expand Down
4 changes: 0 additions & 4 deletions src/CoreFoundation/CFDictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@
using Foundation;
using ObjCRuntime;

#if !NET
using NativeHandle = System.IntPtr;
#endif

namespace CoreFoundation {

class CFDictionary : NativeObject {
Expand Down
6 changes: 0 additions & 6 deletions src/CoreFoundation/CFException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,10 @@

namespace CoreFoundation {

#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
#endif
public static class CFErrorDomain {

/// <summary>To be added.</summary>
Expand All @@ -68,12 +66,10 @@ static CFErrorDomain ()
}
}

#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
#endif
public static class CFExceptionDataKey {

/// <summary>To be added.</summary>
Expand Down Expand Up @@ -103,12 +99,10 @@ static CFExceptionDataKey ()
}
}

#if NET
[SupportedOSPlatform ("ios")]
[SupportedOSPlatform ("maccatalyst")]
[SupportedOSPlatform ("macos")]
[SupportedOSPlatform ("tvos")]
#endif
public class CFException : Exception {

public CFException (string? description, NSString? domain, nint code, string? failureReason, string? recoverySuggestion)
Expand Down
14 changes: 0 additions & 14 deletions src/CoreFoundation/CFMachPort.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@
using Foundation;
using ObjCRuntime;

#if !NET
using NativeHandle = System.IntPtr;
#endif

namespace CoreFoundation {

#if false
Expand All @@ -42,18 +38,8 @@ internal public struct CFMachPortContext {
public class CFMachPort : NativeObject {
delegate void CFMachPortCallBack (IntPtr cfmachport, IntPtr msg, nint len, IntPtr context);

#if !NET
public CFMachPort (NativeHandle handle) : base (handle, false)
{
}
#endif

[Preserve (Conditional = true)]
#if NET
internal CFMachPort (NativeHandle handle, bool owns)
#else
public CFMachPort (NativeHandle handle, bool owns)
#endif
: base (handle, owns)
{
}
Expand Down
Loading

0 comments on commit 8d3f452

Please sign in to comment.