]> gitweb.factorcode.org Git - factor.git/blob - basis/core-foundation/bundles/bundles.factor
factor: ?if to ?if-old
[factor.git] / basis / core-foundation / bundles / bundles.factor
1 ! Copyright (C) 2008 Slava Pestov.
2 ! See https://factorcode.org/license.txt for BSD license.
3 USING: alien.c-types alien.syntax core-foundation
4 core-foundation.urls kernel sequences ;
5 IN: core-foundation.bundles
6
7 TYPEDEF: void* CFBundleRef
8
9 FUNCTION: CFBundleRef CFBundleCreate ( CFAllocatorRef allocator, CFURLRef bundleURL )
10
11 FUNCTION: Boolean CFBundleLoadExecutable ( CFBundleRef bundle )
12
13 : <CFBundle> ( string -- bundle )
14     t <CFFileSystemURL> [
15         f swap CFBundleCreate
16     ] keep CFRelease ;
17
18 : load-framework ( name -- )
19     [ <CFBundle> ]
20     [ CFBundleLoadExecutable drop ]
21     [ "Cannot load bundle named " prepend throw ] ?if ;