Niki Spahiev | 1 Sep 10:03 2006
Picon

Re: memmove args not auto-converted to pointers with ctypes 0.9.9.3 through 1.0.0

Lenard Lindstrom wrote:
> On 30 Aug 2006 at 21:03, Thomas Heller wrote:
>>
>> So, the c_void_p .from_param method doesn't do this automatic byref() call,
>> and it may indeed be a bug.  Is it worth to fix it, for Python 2.5.1?
>>
> I would say it is not so much a bug as not what I expect as a C 
> programmer. (void *) pointers behave the same as any other pointer 
> when it comes to assignment except that no casting is required. So if 
> a non c_void_p pointer does an automatic byref() in its from_param 
> method I would expect the same for c_void_p. But this leads to an 
> ambiguity. If I pass a pointer to a c_void_p do I want an implicit 
> cast or a pointer to a pointer, an automatic byref() call?

Using void * for pointer to a pointer is very unlikely. So automatic 
byref on pointers is not necessary.

Niki Spahiev

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
Lenard Lindstrom | 1 Sep 19:35 2006
Picon

Re: memmove args not auto-converted to pointers with ctypes 0.9.9.3 through 1.0.0

On 1 Sep 2006 at 11:03, Niki Spahiev wrote:

> Using void * for pointer to a pointer is very unlikely. So automatic 
> byref on pointers is not necessary.
> 
I agree. But it will mean a footnote in the ctypes documentation.

Lenard Lindstrom
<len-l <at> telus.net>

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
RayS | 3 Sep 00:53 2006

Re: Two questions: casting lParams and dealing with numpy arrays

Hi Gary,

I did some similar direct transfer from ctypes function calls with 
Numeric/numarray - not tested on numpy:
http://aspn.activestate.com/ASPN/Mail/Message/numpy-discussion/2255754
http://aspn.activestate.com/ASPN/Mail/Message/ctypes-users/2255729
and see
http://mail.python.org/pipermail/python-bugs-list/2005-June/029294.html

it used to be in older NUmeric
split(repr(buffer(a)))[5][:-1]
to get/use an address with ctypes...

now more like:
ptr = tpcnv[a.typecode()]()
pythonapi.PyObject_AsReadBuffer(py_object(a),
      byref(ptr),
      byref(c_int()))
ptr.refed_array = a

Ray Schumacher

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
Travis E. Oliphant | 5 Sep 01:50 2006
Picon

Re: Two questions: casting lParams and dealing with numpy arrays

Hubbard, Gary wrote:
> Hi,
> 
> I have been using ctypes quite successfully.  It is great.  Two things 
> currently have me stumped, although I have work arounds for both.
> 
> 
> The other issue is that some of these events indicate that a data buffer 
> is available.  The api allocates buffer objects and returns buffer 
> handles.  There is a call that turns these handles into an address.  
> Right now I am essentially doing
> 
>         address = GetAddressFromHandle(handle)
> 

Create a buffer object from this address (using a Python API call like

obj = pythonapi.PyBuffer_FromReadWriteMemory(address, 
numSamples*sizeof(c_short))

--- or use PyBuffer_FromMemory if it's read-only).

Then create a numpy object from the buffer.

numpy.frombuffer(obj, numpy.short)

This will not copy the data but just create a NumPy array that views the 
data.

-Travis
(Continue reading)

| 5 Sep 08:42 2006
Picon

(有難う御座います)

【フリーメールアドレスでご利用できます!】
この度は、当番組をお選び頂き誠に有難う御座います。
時間の許す限りお楽しみ下さい。当番組は完全男女素人の優良指定番組の証しトリプルA(安心・安全・確実)
を取得(05年度取得)していますので安心して相手探しが可能です。貴方が探している理想の相手が今日現実に見つかります。
【パソコン&携帯同時利用可能】
【フリーメールアドレスでOK!!】
 
トリプルAの実績を感じて下さい。
下記のURLよりご入場下さい↓

【貴殿は審査を通過しております】
 
 
 
 
 
 
 
◇問合わせ、不要な方はこちらまで
■Uselessness to serve
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
ctypes-users mailing list
ctypes-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ctypes-users
Mark Heslep | 5 Sep 21:38 2006
Picon

inline header functions

For some time there's been a mention of plans to do more with inline'd 
functions in the Codegen/TODO:
http://svn.python.org/projects/ctypes/trunk/codegen/TODO

Doing more w/ inline functions is especially important for my current 
project (~130+ in opencv).  I don't follow how far the concept outlined 
in the TODO is intended to go.  Could we get a few more comments on the 
plan forward?  Is there some intention to parse the body of the function 
to XML and thence to Py?  Absent some plan like that I dont see any 
alternative to compiling the header inlines into a library.  Then the 
formerly no-compiler-needed ctypes port requires one, or one must start 
shipping (and installing in the library path?) a shared binary library 
with your 'python' package.  Comments?

Regards,
Mark

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
Thomas Heller | 6 Sep 21:21 2006
Picon

Re: Two questions: casting lParams and dealing with numpy arrays

Hubbard, Gary schrieb:
> Hi,
> 
> I have been using ctypes quite successfully.  It is great.  Two things
> currently have me stumped, although I have work arounds for both.
> 
> The api I am currently wrapping sends back Microsoft Windows messages
> when certain events complete.  The lParam value passed back can be set
> by the caller.  I want to have it be a Python object, so I set it as
> being of type py_object on the way in.  When the windows proc gets
> called it has the address of the object I want, but I don't see how to
> convert it back to the object itself.  It seems like the cast call
> should work, but I can't make it happen.

cast(address, py_object)  returns a py_object instance 'containing'
the Python object at address 'address'.  You can get the object itself
with the .value attribute:

  cast(address, py_object).value

Of course, the object at 'address' must be kept alive elsewhere.

Thomas

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
Thomas Heller | 6 Sep 21:28 2006
Picon

Re: inline header functions

Mark Heslep schrieb:
> For some time there's been a mention of plans to do more with inline'd 
> functions in the Codegen/TODO:
> http://svn.python.org/projects/ctypes/trunk/codegen/TODO
> 
> Doing more w/ inline functions is especially important for my current 
> project (~130+ in opencv).  I don't follow how far the concept outlined 
> in the TODO is intended to go.

There is no concept in the TODO ;-), there are only some code snippets
explaining (well, to me) what is happoing now.  Currently, for inline functions
the same code is generated as for normal functions, which will of course not work.

> Could we get a few more comments on the 
> plan forward?  Is there some intention to parse the body of the function 
> to XML and thence to Py?

You mean convert the C code to Python code?  Kind of writing a C emulator
in Python?  Could maybe work for 'sane' header files, but Windows header
files sometimes even contain inline assembly in C/C++ inline functions.

> Absent some plan like that I dont see any 
> alternative to compiling the header inlines into a library.  Then the 
> formerly no-compiler-needed ctypes port requires one, or one must start 
> shipping (and installing in the library path?) a shared binary library 
> with your 'python' package.  Comments?

Why not.  The code generator could just collect the inline function declararation,
and generate C code for a shared lib exposing the inline, and maybe also
intrinsic functions to normal ctypes.

Sounds like a good idea - if someone wants to implement that.

Thomas

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
Ray Schumacher | 7 Sep 01:59 2006

segfault on LoadLibrary, where to look?

We are trying to load a driver for an Eagle ADC card in Linux:
[/home/seb/projects] # cdll.LoadLibrary("/home/seb/projects/edreapi.so")
segmentation fault

test loads like cdll.LoadLibrary("libc.so.6") work fine.
Where to start looking?

We attempted to use gdb, and it appears that it stops at getutmpx() in libc.so.6 (assuming we are using gdb correctly)

(Eagle class reference: http://www.eagle.co.za/download/manual/edreonline/classEDREObject.html)

Thanks,
Ray Schumacher

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
Luke Dunstan | 7 Sep 02:20 2006
Picon

Cannot cast c_char_p to c_void_p in Python 2.5

Hi,

I get this error:

>>> ctypes.cast(ctypes.c_char_p('abc'), ctypes.c_void_p)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "c:\python25\lib\ctypes\__init__.py", line 450, in cast
    return _cast(obj, obj, typ)
SystemError: \loewis\25\python\Objects\dictobject.c:599: bad argument to 
internal function

Apparently obj->b_objects is assumed to be a dict but is actually a string. 
The same error occurs when casting from c_wchar_p. If this can't be fixed 
before the 2.5 release then is there a work around?

Luke

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

Gmane