Re: PyObjCPointer

Ronald Oussoren <[email protected]> Sat, 16 Aug 2014 18:04:35 +0200
Newsgroups gmane.comp.python.pyobjc.devel
Message-ID <[email protected]>
On 15 Aug 2014, at 01:14, Adam Duston <[email protected]> wrote:

> Using pyobjc 2.5.1:
> 
>>>> import WebKit
>>>> webview = WebKit.WebView.alloc().init()
>>>> ctx = webview.mainFrame().globalContext()
> 2014-08-14 19:08:09.820 Python[16771:d07] PyObjCPointer created: at
> 0x105edf8d8 of type {OpaqueJSContext=}
>>>> ctx.pointerAsInteger
> Traceback (most recent call last):
>  File "<stdin>", line 1, in <module>
> AttributeError: 'PyObjCPointer' object has no attribute 'pointerAsInteger
> 
> I need to pass the pointer as a ctypes.c_void_p to a ctypes-wrapped
> function, so getting the integral value of the underlying object
> address would be great. I just can't seem to do that. Any way around
> this?

This attribute is not present in PyObjC 2.5. The only way I know of working around that is to use ctypes to directly access the storage area of the pointer object, actually doing that is left as an exercise for the reader ;-)

Ronald


------------------------------------------------------------------------------