Re: ctypes Structure serialization

2010-02-08 Thread rych
OK, an easier question, hopefully.
How to unpack all fields from ctypes Structure line by line and save
into the name-value pairs?
-- 
http://mail.python.org/mailman/listinfo/python-list


ctypes Structure serialization

2010-02-07 Thread rych
I'm not quite familiar with python serialization but the picle module,
at least, doesn't seem to be able to serialize a ctypes Structure with
array-fields. Even if it was, the ASCII file produced is not in a
human-friendly format.

Could someone please suggest a method of saving and loading the fields
in ctypes' Structure derived class to a json or better yet, to
something like INFO
http://www.boost.org/doc/libs/1_41_0/doc/html/boost_propertytree/parsers.html#boost_propertytree.parsers.info_parser

For example, I have an object of
>>> class MyStruct(Structure):
..._fields_ = [("a", c_int),
...("b", c_float),
...("point_array", c_float * 4)]

I'd like the corresponding file to look like

a 1
b 1.0
point array 1.1 1.2 1.3 1.4

Thanks
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to export functions by name for ctype

2008-06-23 Thread rych
On 23 Jun, 10:32, Nick Craig-Wood <[EMAIL PROTECTED]> wrote:
> rych <[EMAIL PROTECTED]> wrote:
> >  I'm on Windows with VS2005 testing ctypes on a very simple dll
> >  I create a test.dll project which exports a function fntest(). I don't
> >  touch anything in the autogenerated source and build it. I can load
> >  the dll but can't access the function by its name fntest. Only by
> >  ordinal number or calling getattr with "?fntest@@YAHXZ". How do I
> >  export functions by name? It's probably rather a VS2005 question, but
> >  I'm a bit disappointed ctypes doesn't work with a default export
> >  convention.
>
> I guess you've compiled your DLL with C++ and the above is a C++
> mangled name.
>
> Either compile it with C, or export the names in an extern "C" { }
> block.
>
> --
> Nick Craig-Wood <[EMAIL PROTECTED]> --http://www.craig-wood.com/nick

That fixed it, thank you.
--
http://mail.python.org/mailman/listinfo/python-list


how to export functions by name for ctype

2008-06-20 Thread rych
I'm on Windows with VS2005 testing ctypes on a very simple dll
I create a test.dll project which exports a function fntest(). I don't
touch anything in the autogenerated source and build it. I can load
the dll but can't access the function by its name fntest. Only by
ordinal number or calling getattr with "?fntest@@YAHXZ". How do I
export functions by name? It's probably rather a VS2005 question, but
I'm a bit disappointed ctypes doesn't work with a default export
convention.
--
http://mail.python.org/mailman/listinfo/python-list