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

This commit is contained in:
thefiddler 2014-01-05 22:05:54 +01:00
parent fa386dc991
commit b458b40683

View file

@ -62,6 +62,7 @@ namespace OpenTK.Platform.MacOS.Carbon
}
}
}
struct CFDictionary
{
public CFDictionary(IntPtr reference)
@ -79,18 +80,16 @@ namespace OpenTK.Platform.MacOS.Carbon
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 @@ namespace OpenTK.Platform.MacOS.Carbon
);
[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 unsafe static extern bool CFNumberGetValue(IntPtr number, CFNumberType theType, double* valuePtr);
internal static extern bool CFNumberGetValue (IntPtr number, CFNumberType theType, out long valuePtr);
[DllImport(appServices)]
internal static extern bool CFNumberGetValue(IntPtr number, CFNumberType theType, out double valuePtr);
internal enum CFNumberType
{