factor/library/cocoa/core-foundation.factor

51 lines
1.5 KiB
Factor
Raw Normal View History

2006-02-09 20:36:11 -05:00
! Copyright (C) 2006 Slava Pestov
! See http://factorcode.org/license.txt for BSD license.
IN: cocoa
2006-02-09 22:11:22 -05:00
USING: alien arrays hashtables kernel namespaces ;
TYPEDEF: int CFIndex
2006-02-09 20:36:11 -05:00
! Core Foundation utilities -- will be moved elsewhere
: kCFURLPOSIXPathStyle 0 ;
: kCFStringEncodingMacRoman 0 ;
FUNCTION: void* CFURLCreateWithFileSystemPath ( void* allocator, void* filePath, int pathStyle, bool isDirectory ) ;
FUNCTION: void* CFURLCreateWithString ( void* allocator, void* string, void* base ) ;
FUNCTION: void* CFStringCreateWithCString ( void* allocator, char* cStr, int encoding ) ;
2006-02-09 22:11:22 -05:00
FUNCTION: CFIndex CFStringGetLength ( void* theString ) ;
FUNCTION: char* CFStringGetCStringPtr ( void* theString, int encoding ) ;
2006-02-09 20:36:11 -05:00
FUNCTION: void* CFBundleCreate ( void* allocator, void* bundleURL ) ;
FUNCTION: void* CFBundleGetFunctionPointerForName ( void* bundle, void* functionName ) ;
FUNCTION: bool CFBundleLoadExecutable ( void* bundle ) ;
FUNCTION: void CFRelease ( void* cf ) ;
: <CFString> ( string -- cf )
f swap kCFStringEncodingMacRoman CFStringCreateWithCString ;
2006-02-09 22:11:22 -05:00
: CF>string ( string -- string )
kCFStringEncodingMacRoman CFStringGetCStringPtr ;
2006-02-09 20:36:11 -05:00
: <CFFileSystemURL> ( string dir? -- cf )
>r <CFString> f over kCFURLPOSIXPathStyle
r> CFURLCreateWithFileSystemPath swap CFRelease ;
: <CFURL> ( string -- cf )
<CFString>
[ f swap f CFURLCreateWithString ] keep
CFRelease ;
: <CFBundle> ( string -- cf )
t <CFFileSystemURL> f over CFBundleCreate swap CFRelease ;
: load-framework ( name -- )
2006-02-09 22:11:22 -05:00
<CFBundle> CFBundleLoadExecutable drop ;