Squeak and bluetooth

John M McIntosh johnmci at smalltalkconsulting.com
Tue Jan 10 17:44:31 UTC 2006


Sure, you're missing the entire Sophie code base which uses this,  
however at the moment the implementation of the caller of this is via

Tweak-Platforms from the impara tweak server.

I had added these types (MacCFString, MacCFType, MacCFURL, MacCFURL),  
and the FFI interfaces to assist in getting the folder paths for  
known os-x folder locations, however I've not actually tested *all*  
the api calls yet.

Usage is quite straightforward.


	buffer _ ByteArray new: 4096.
	error := self cFStringGetCString: possibleCFString buffer: buffer  
size: buffer size encoding: 0.
	self cFRelease: possibleCFString.

Typically I've been copying the C definition into the method like so  
for documentation purposes.

cFStringGetCString: aStringRef buffer: aBuffer size: aSize encoding:  
anEncoding
	<cdecl: bool 'CFStringGetCString' (MacCFString* char* long long)  
module:'Carbon.framework'>
	^ self externalCallFailed

"Boolean CFStringGetCString (
    CFStringRef theString,
    char *buffer,
    CFIndex bufferSize,
    CFStringEncoding encoding
);"

I'll note that I'm cheating and resolving CFIndes and  
CFStdringEncoding to long, but you could define a structured class  
with a long field for those.

Save your image often, mistakes in coding the FFI logic will  
generally crash your VM.

On 10-Jan-06, at 5:42 AM, Davide Varvello wrote:

> Hi Bert,
>
>
>> As for your questions, yes, FFI is just fine for this. And I'd  
>> recommend Carbon.
>>
>> For a bit of working recent Carbon FFI code have a look at
>>
>> 	http://source.impara.de/Sophie.html
>>
>> The "Files-Locations" package uses FFI calls to locate system folders
>
>
> I downloaded the Files-Locations-bf.18.mcz it contains 4 classes:  
> MacCFString, MacCFType, MacCFURL, MacCFURL but there are no methods  
> that call os libraries. Am I missing something?
> Thanks
>  Davide
>
>

--
======================================================================== 
===
John M. McIntosh <johnmci at smalltalkconsulting.com> 1-800-477-2659
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
======================================================================== 
===




More information about the Squeak-dev mailing list