472,358 Members | 2,015 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,358 software developers and data experts.

Re: ctypes - swig - pointer

On Mon, 30 Jun 2008 09:13:42 -0700 (PDT), gianluca <ge*******@gmail.comwrote:
>I've a problem with dll function colled with python/ctypes. My
functions (C) requred a typedef int "value_type" in tree different
way:
same as value_type; - mydll.foo1(value_type)
same as *value_type; - mydll.foo2(*value_type)
same as **value_type; - mydll.foo3(**value_type)

How can pass it in python. If i do that:
rules=POINTER(value_type)
opr=rsl.StrengthOfRules(rules,10)
R=POINTER(rules)
POINTER takes a class and returns a new class which represents a pointer
to input class.

pointer takes an instance and returns a new object which represents a
pointer to that instance.

Jean-Paul
Jun 30 '08 #1
2 16156
On 30 Giu, 18:26, Jean-Paul Calderone <exar...@divmod.comwrote:
On Mon, 30 Jun 2008 09:13:42 -0700 (PDT), gianluca <geonom...@gmail.comwrote:
I've a problem with dll function colled with python/ctypes. My
functions (C) requred a typedef int "value_type" in tree different
way:
same as value_type; - mydll.foo1(value_type)
same as *value_type; - mydll.foo2(*value_type)
same as **value_type; - mydll.foo3(**value_type)
How can pass it in python. If i do that:
rules=POINTER(value_type)
opr=rsl.StrengthOfRules(rules,10)
R=POINTER(rules)

POINTER takes a class and returns a new class which represents a pointer
to input class.

pointer takes an instance and returns a new object which represents a
pointer to that instance.

Jean-Paul
so,
if I write this:
p=pointer(value_type)
mydll.foo1(p)
could be correct but python say me:
TypeError: _type_ must have storage info
what does mean?

thank you

gima
Jun 30 '08 #2

"gianluca" <ge*******@gmail.comwrote in message
news:58**********************************@z72g2000 hsb.googlegroups.com...
On 30 Giu, 18:26, Jean-Paul Calderone <exar...@divmod.comwrote:
>On Mon, 30 Jun 2008 09:13:42 -0700 (PDT), gianluca <geonom...@gmail.com>
wrote:
>I've a problem with dll function colled with python/ctypes. My
functions (C) requred a typedef int "value_type" in tree different
way:
same as value_type; - mydll.foo1(value_type)
same as *value_type; - mydll.foo2(*value_type)
same as **value_type; - mydll.foo3(**value_type)
>How can pass it in python. If i do that:
rules=POINTER(value_type)
opr=rsl.StrengthOfRules(rules,10)
R=POINTER(rules)

POINTER takes a class and returns a new class which represents a pointer
to input class.

pointer takes an instance and returns a new object which represents a
pointer to that instance.

Jean-Paul

so,
if I write this:
p=pointer(value_type)
mydll.foo1(p)
could be correct but python say me:
TypeError: _type_ must have storage info
what does mean?

thank you

gima
It means you cannot create a pointer to a type, you need to provide an
instance of a type:
>>from ctypes import *
px=pointer(c_int)
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
File "C:\dev\python\lib\ctypes\__init__.py", line 282, in pointer
return POINTER(type(inst))(inst)
File "C:\dev\python\lib\ctypes\__init__.py", line 226, in POINTER
{'_type_': cls})
TypeError: _type_ must have storage info
>>x=c_int(5) # make an instance (C equiv. is "int x=5;")
px=pointer(x) # int* px = &x;
ppx=pointer(px) # int** ppx = &px;
x
c_long(5)
>>px
<ctypes.LP_c_long object at 0x00E87350>
>>ppx
<ctypes.LP_LP_c_long object at 0x00E873A0>

--Mark

Jul 1 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: Thomas Heller | last post by:
ctypes 0.9.2 released - Oct 28, 2004 ==================================== Overview ctypes is a ffi (Foreign Function Interface) package for Python 2.3 and higher. ctypes allows to call...
3
by: Lenard Lindstrom | last post by:
Posted in a previous thread was some Python code for accessing Window's Simple MAPI api using the ctypes module. http://groups-beta.google.com/group/comp.lang.python/msg/56fa74cdba9b7be9 This...
2
by: ajikoe | last post by:
Hi, I tried to follow the example in swig homepage. I found error which I don't understand. I use bcc32, I already include directory where my python.h exist in bcc32.cfg. /* File : example.c...
1
by: marc.wyburn | last post by:
hi all and before I start I apologise if I have this completely muddled up but here goes. I'm trying to call functions from a dll file in a python script but I can't work out what functions are...
6
by: Jack | last post by:
I'm not able to build IP2Location's Python interface so I'm trying to use ctypes to call its C interface. The functions return a pointer to the struct below. I haven't been able to figure out how...
8
by: gianluca | last post by:
Hy, I need help about use dll with ctypes. I've compiled my dll C library and I copied it in c:\windows\system32. When I load it with "myDLL=cdll.LoadLibrary(find_library("myDLL.dll"))" It seem...
0
by: gianluca | last post by:
I've a problem with dll function colled with python/ctypes. My functions (C) requred a typedef int "value_type" in tree different way: same as value_type; - mydll.foo1(value_type) same as...
2
by: Sells, Fred | last post by:
Diez wrote... You're right the ctypes does seem more pythonesque; however I'm still stuck trying return all these parameters that the c api uses. my ctypes code is below. It just quits running...
0
by: Terry Reedy | last post by:
dudeja.rajat@gmail.com wrote: Ugh ;-) I have the impression that SWIG has multiple backends for different languages. There is one for automating much of the work of producing an...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
1
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. header("Location:".$urlback); Is this the right layout the...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.