Thread: [Pyobjc-dev] Using global functions and constants?
Brought to you by:
ronaldoussoren
|
From: Orestis M. <or...@or...> - 2008-02-02 23:14:32
|
Hello,
I'm trying to use IOBluetooth and IOBluetoothUI. I've figured out
using the Obj-C part (using objc.loadBundle) but IOBluetooth uses some
external functions, like IOBluetoothNSStringToDeviceAddress in
IOBluetoothUtilities. I can't find a way to use this.
I've tried using gen_bridge_metadata but I get a compiler error.
Checking, I've seen that there is a IOBluetooth.bridgesupport file
inside the framework resources but it doesn't contain the above
function. After looking around, I've tried using a constant it *does*
contain, ie kBluetoothFeatureEncryption, but Python still can't find it.
I'm using:
import objc as _objc
_objc.loadBundle('IOBluetooth', globals(),
bundle_path=u'/System/Library/Frameworks/IOBluetooth.framework')
in IOBluetooth.py and
from IOBluetooth import *
in my main class.
The documentation on wrapping global functions/constants is *severely*
lacking, so any help appreciated :)
--
Orestis Markou
or...@or...
http://orestis.gr/
|
|
From: Michael M. <mic...@gm...> - 2008-02-03 01:17:40
|
Hi, I just found this in an email from Bob Ippolito a while back. (at http://www.mail-archive.com/pyt...@py.../msg02013.html ) Try using objc.loadBundleFunctions. if IOBluetoothNSStringToDeviceAddress is pretty simple, that might work. Here's the example from the email: bundle = NSBundle.bundleWithPath_('/System/Library/Frameworks/Carbon.framework') objc.loadBundleFunctions(bundle, globals(), ( ('SetSystemUIMode', 'III', " Sets the presentation mode for system-provided user interface elements."), )) On Feb 2, 2008 3:14 PM, Orestis Markou <or...@or...> wrote: > Hello, > > I'm trying to use IOBluetooth and IOBluetoothUI. I've figured out > using the Obj-C part (using objc.loadBundle) but IOBluetooth uses some > external functions, like IOBluetoothNSStringToDeviceAddress in > IOBluetoothUtilities. I can't find a way to use this. > > I've tried using gen_bridge_metadata but I get a compiler error. > Checking, I've seen that there is a IOBluetooth.bridgesupport file > inside the framework resources but it doesn't contain the above > function. After looking around, I've tried using a constant it *does* > contain, ie kBluetoothFeatureEncryption, but Python still can't find it. > > I'm using: > > import objc as _objc > > _objc.loadBundle('IOBluetooth', globals(), > bundle_path=u'/System/Library/Frameworks/IOBluetooth.framework') > > in IOBluetooth.py and > > from IOBluetooth import * > > in my main class. > > The documentation on wrapping global functions/constants is *severely* > lacking, so any help appreciated :) > -- > Orestis Markou > or...@or... > http://orestis.gr/ > > > > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > Pyobjc-dev mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev > -- Michael McCracken UCSD CSE PhD Candidate research: http://www.cse.ucsd.edu/~mmccrack/ misc: http://michael-mccracken.net/wp/ |
|
From: Orestis M. <or...@or...> - 2008-02-03 13:05:58
|
Thanks, I've made some progress. Here is my code:
bundle =3D NSBundle.bundleWithPath_('/System/Library/Frameworks/=20
IOBluetooth.framework')
objc.loadBundleFunctions(bundle, globals(),(
('IOBluetoothNSStringToDeviceAddress', "i:@^@","blah test" ),
))
print IOBluetoothNSStringToDeviceAddress
This yields: <objc.function object at 0xdc97a0> which I suppose means =20=
that the function was loaded.
However, if I follow with:
address =3D "00-1d-28-e1-bd-90"
out =3D None
print IOBluetoothNSStringToDeviceAddress(address, out)
I get:
TypeError: Need 3 arguments, got 2
I tried changing the signature to i:@o^@ , to account for the output =20
parameter but I get a segmentation fault.
The Objective-C function signature is:
extern IOReturn IOBluetoothNSStringToDeviceAddress( NSString =20
*inNameString, BluetoothDeviceAddress *outDeviceAddress );
I've tried to divine the method signature from =
http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Artic=
les/chapter_13_section_9.html#/=20
/apple_ref/doc/uid/TP30001163-CH9-TPXREF165
but I don't think I've succeeded...
--
Orestis Markou
or...@or...
http://orestis.gr/
On 03 =CE=A6=CE=B5=CE=B2 2008, at 3:15 =CE=A0=CE=9C, Michael McCracken =
wrote:
> Hi, I just found this in an email from Bob Ippolito a while back. (at
> http://www.mail-archive.com/pyt...@py.../msg02013.html )
> Try using objc.loadBundleFunctions.
> if IOBluetoothNSStringToDeviceAddress is pretty simple, that might =20
> work.
>
> Here's the example from the email:
>
> bundle =3D NSBundle.bundleWithPath_('/System/Library/Frameworks/=20
> Carbon.framework')
> objc.loadBundleFunctions(bundle, globals(), (
> ('SetSystemUIMode', 'III', " Sets the presentation mode for
> system-provided user interface elements."),
> ))
>
>
>
> On Feb 2, 2008 3:14 PM, Orestis Markou <or...@or...> wrote:
>> Hello,
>>
>> I'm trying to use IOBluetooth and IOBluetoothUI. I've figured out
>> using the Obj-C part (using objc.loadBundle) but IOBluetooth uses =20
>> some
>> external functions, like IOBluetoothNSStringToDeviceAddress in
>> IOBluetoothUtilities. I can't find a way to use this.
>>
>> I've tried using gen_bridge_metadata but I get a compiler error.
>> Checking, I've seen that there is a IOBluetooth.bridgesupport file
>> inside the framework resources but it doesn't contain the above
>> function. After looking around, I've tried using a constant it *does*
>> contain, ie kBluetoothFeatureEncryption, but Python still can't =20
>> find it.
>>
>> I'm using:
>>
>> import objc as _objc
>>
>> _objc.loadBundle('IOBluetooth', globals(),
>> bundle_path=3Du'/System/Library/Frameworks/IOBluetooth.framework')
>>
>> in IOBluetooth.py and
>>
>> from IOBluetooth import *
>>
>> in my main class.
>>
>> The documentation on wrapping global functions/constants is =20
>> *severely*
>> lacking, so any help appreciated :)
>> --
>> Orestis Markou
>> or...@or...
>> http://orestis.gr/
>>
>>
>>
>>
>>
>> =
-------------------------------------------------------------------------
>> This SF.net email is sponsored by: Microsoft
>> Defy all challenges. Microsoft(R) Visual Studio 2008.
>> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
>> _______________________________________________
>> Pyobjc-dev mailing list
>> Pyo...@li...
>> https://lists.sourceforge.net/lists/listinfo/pyobjc-dev
>>
>
>
>
> --=20
> Michael McCracken
> UCSD CSE PhD Candidate
> research: http://www.cse.ucsd.edu/~mmccrack/
> misc: http://michael-mccracken.net/wp/
|