Documentation ¶
Index ¶
- func FromCFArray(ref ArrayRef) ([]interface{}, error)
- func FromCFBoolean(ref BooleanRef) (bool, error)
- func FromCFData(ref DataRef) ([]byte, error)
- func FromCFDictionary(ref DictionaryRef) (map[interface{}]interface{}, error)
- func FromCFNumber(ref NumberRef) (interface{}, error)
- func FromCFString(ref StringRef) (s string, _ error)
- func FromCFTypeRef(ref TypeRef) (interface{}, error)
- func FromCFURL(ref URLRef) (*url.URL, error)
- func Release(ref TypeRef)
- func UserNotificationDisplayAlert(options NotificationAlertOptions) (response uint64, _ error)
- type ArrayRef
- type BooleanRef
- type DataRef
- type DictionaryRef
- type NotificationAlertLevel
- type NotificationAlertOptions
- type NumberRef
- type StringRef
- type TypeRef
- type URLRef
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FromCFArray ¶
FromCFArray will convert a Core Foundation Array reference to a Golang slice.
Elements of the array are also converted to their respective Golang type.
The reference is not released by this function and must be done by the caller.
func FromCFBoolean ¶
func FromCFBoolean(ref BooleanRef) (bool, error)
FromCFBoolean converts a Core Foundation boolean reference to a native Golang bool value.
The reference is not released by this function and must be done by the caller.
func FromCFData ¶
FromCFData will convert a Core Foundation byte array to a Golang slice containing the value of the byte array.
The value of the CFData reference is copied so that the value of the slice doesn't point to the same location in memory, this prevents changes to the slice from effecting the value of the CFData reference.
The reference is not released by this function and must be done by the caller.
func FromCFDictionary ¶
func FromCFDictionary(ref DictionaryRef) (map[interface{}]interface{}, error)
func FromCFNumber ¶
func FromCFString ¶
FromCFString will convert a Core Foundation String reference to a Golang string.
If the CFStringRef points to a C string then the pointer is converted using the standard libraries method for doing so.
Otherwise the bytes of the CFString will be copied into a new Golang string.
The CFStringRef isn't released by this function and will need to be done by the caller.
func FromCFTypeRef ¶
FromCFTypeRef uses reflection provided by the Core Foundation library to identify the type of information represented by the reference.
If the information type is supported by this library, the appropriate conversion method is called to convert the reference to a Golang type.
func Release ¶
func Release(ref TypeRef)
Release will instruct the kernel to release all memory resources allocated for the provided reference.
If the reference is equal to 0 then release is not called to prevent crashing the thread.
func UserNotificationDisplayAlert ¶
func UserNotificationDisplayAlert(options NotificationAlertOptions) (response uint64, _ error)
Types ¶
type BooleanRef ¶
type BooleanRef C.CFBooleanRef
BooleanRef is a Core Foundation pointer to a boolean value
func ToCFBoolean ¶
func ToCFBoolean(b bool) (BooleanRef, error)
ToCFBoolean converts the value of a Golang bool to a Core Foundation boolean reference.
The CFBoolean reference must be released once finished with to prevent memory leaks.
type DataRef ¶
DataRef is a Core Foundation pointer to an array of bytes in memory
type DictionaryRef ¶
type DictionaryRef C.CFDictionaryRef
func ToCFDictionary ¶
func ToCFDictionary(dictionary interface{}) (DictionaryRef, error)
type NotificationAlertLevel ¶
type NotificationAlertLevel uint64
const ( UserNotificationStopAlertLevel NotificationAlertLevel = iota UserNotificationNoteAlertLevel UserNotificationCautionAlertLevel UserNotificationPlainAlertLevel )
type StringRef ¶
type StringRef C.CFStringRef
func ToCFString ¶
ToCFString will create a new Core Foundation String reference by copying the Golang string data, this is to prevent unsafe memory releases by macOS libraries.
As such, the CFStringRef returned must be freed by the caller when appropriate to prevent memory leaks.
type TypeRef ¶
TypeRef is a Core Foundation generic value pointer
func ToCFTypeRef ¶
ToCFTypeRef will use reflection to identify the data type provided, based on the type provided it will call the appropriate conversion method to convert the data to a Core Foundation type reference.