Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[Mac] Use out/ref parameters instead of unsafe pointers in bindings

  • Loading branch information...
commit b458b406834fe79ef9dc0ea14eb15d49509ae1af 1 parent fa386dc
thefiddler thefiddler authored
Showing with 11 additions and 10 deletions.
  1. +11 −10 Source/OpenTK/Platform/MacOS/CarbonBindings/CoreFoundation.cs
21 Source/OpenTK/Platform/MacOS/CarbonBindings/CoreFoundation.cs
View
@@ -62,6 +62,7 @@ public int Count
}
}
}
+
struct CFDictionary
{
public CFDictionary(IntPtr reference)
@@ -79,18 +80,16 @@ public int Count
return CF.CFDictionaryGetCount(dictionaryRef);
}
}
+
public double GetNumberValue(string key)
{
- unsafe
- {
- double retval;
- IntPtr cfnum = CF.CFDictionaryGetValue(dictionaryRef,
- CF.CFSTR(key));
+ double retval;
+ IntPtr cfnum = CF.CFDictionaryGetValue(dictionaryRef,
+ CF.CFSTR(key));
- CF.CFNumberGetValue(cfnum, CF.CFNumberType.kCFNumberDoubleType, &retval);
+ CF.CFNumberGetValue(cfnum, CF.CFNumberType.kCFNumberDoubleType, out retval);
- return retval;
- }
+ return retval;
}
}
class CF
@@ -150,9 +149,11 @@ CFStringRef theString
);
[DllImport(appServices)]
- internal unsafe static extern bool CFNumberGetValue (IntPtr number, CFNumberType theType, int* valuePtr);
+ internal static extern bool CFNumberGetValue (IntPtr number, CFNumberType theType, out int valuePtr);
+ [DllImport(appServices)]
+ internal static extern bool CFNumberGetValue (IntPtr number, CFNumberType theType, out long valuePtr);
[DllImport(appServices)]
- internal unsafe static extern bool CFNumberGetValue(IntPtr number, CFNumberType theType, double* valuePtr);
+ internal static extern bool CFNumberGetValue(IntPtr number, CFNumberType theType, out double valuePtr);
internal enum CFNumberType
{
Please sign in to comment.
Something went wrong with that request. Please try again.