coreFoundation

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 31, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromCFArray

func FromCFArray(ref ArrayRef) ([]interface{}, error)

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

func FromCFData(ref DataRef) ([]byte, error)

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 FromCFNumber(ref NumberRef) (interface{}, error)

func FromCFString

func FromCFString(ref StringRef) (s string, _ error)

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

func FromCFTypeRef(ref TypeRef) (interface{}, error)

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 FromCFURL

func FromCFURL(ref URLRef) (*url.URL, error)

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 ArrayRef

type ArrayRef C.CFArrayRef

ArrayRef is a Core Foundation pointer to an array type

func ToCFArray

func ToCFArray(v interface{}) (ArrayRef, error)

ToCFArray will create a new Core Foundation Array reference from a Golang slice, each element of the slice is converted to it's respective CF type.

The CFArray reference must be released once finished with to prevent memory leaks.

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

type DataRef C.CFDataRef

DataRef is a Core Foundation pointer to an array of bytes in memory

func ToCFData

func ToCFData(data []byte) (DataRef, error)

ToCFData will create a new Core Foundation data reference from a Golang slice, the value of the slice is copied to internal memory to prevent changes in the slice affecting the data reference.

The CFData reference must be released once finished with to prevent memory leaks.

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 NotificationAlertOptions

type NotificationAlertOptions struct {
	Timeout              time.Duration
	Level                NotificationAlertLevel
	Icon                 *url.URL
	Localization         *url.URL
	AlertHeader          string
	AlertMessage         string
	DefaultButtonTitle   string
	AlternateButtonTitle string
	OtherButtonTitle     string
}

type NumberRef

type NumberRef C.CFNumberRef

func ToCFNumber

func ToCFNumber(v interface{}) (NumberRef, error)

type StringRef

type StringRef C.CFStringRef

func ToCFString

func ToCFString(s string) (StringRef, error)

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

type TypeRef C.CFTypeRef

TypeRef is a Core Foundation generic value pointer

func ToCFTypeRef

func ToCFTypeRef(v interface{}) (TypeRef, error)

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.

type URLRef

type URLRef C.CFURLRef

func ToCFURL

func ToCFURL(value *url.URL) (URLRef, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL