Fix <CFDictionary>

db4
Slava Pestov 2009-01-18 23:44:02 -06:00
parent 8509027428
commit 0c1cf6209d
2 changed files with 21 additions and 4 deletions

View File

@ -1,6 +1,18 @@
! Copyright (C) 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: tools.test core-foundation core-foundation.dictionaries ;
USING: tools.test core-foundation core-foundation.dictionaries
arrays destructors core-foundation.strings kernel namespaces ;
IN: core-foundation.dictionaries.tests
[ ] [ { } <CFDictionary> CFRelease ] unit-test
[ ] [ { } <CFDictionary> CFRelease ] unit-test
[ "raps in the back of cars and doesn't afraid of anything" ] [
[
"cpst" <CFString> &CFRelease dup "key" set
"raps in the back of cars and doesn't afraid of anything" <CFString> &CFRelease
2array 1array <CFDictionary> &CFRelease
"key" get
CFDictionaryGetValue
dup [ CF>string ] when
] with-destructors
] unit-test

View File

@ -1,6 +1,6 @@
! Copyright (C) 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: alien.syntax core-foundation kernel assocs alien.c-types
USING: alien.syntax core-foundation kernel assocs
specialized-arrays.alien math sequences accessors ;
IN: core-foundation.dictionaries
@ -18,10 +18,15 @@ FUNCTION: CFDictionaryRef CFDictionaryCreate (
CFDictionaryValueCallBacks* valueCallBacks
) ;
FUNCTION: void* CFDictionaryGetValue (
CFDictionaryRef theDict,
void* key
) ;
: <CFDictionary> ( alist -- dictionary )
[ kCFAllocatorDefault ] dip
unzip [ >void*-array ] bi@
[ [ underlying>> ] bi@ ] [ nip length "void*" heap-size /i ] 2bi
[ [ underlying>> ] bi@ ] [ nip length ] 2bi
&: kCFTypeDictionaryCallBacks
&: kCFTypeDictionaryValueCallbacks
CFDictionaryCreate ;