(Is this the right place to ask ctypes questions? There's a mailing list
but the last post to it seems to have been in November 2006.)
Using ctypes I reference a structure which contains a pointer to an array of
another structure:
class SYMBOL(Structure):
_fields_ = [("symbol", c_char_p),
("num", c_int),
("units", c_int),
("baseprice", c_int),
("active", c_int)]
SYMBOL_PTR = POINTER(SYMBOL)
class TABLE(Structure):
_fields_ = [("map", SYMBOL_PTR),
("nsymbols", c_uint),
...]
Effectively, TABLE.map is an array of TABLE.nsymbols SYMBOLS. How to I
reference elements in that array? In C I would just treat TABLE.map like an
array and index into it (for i=0; i< TABLE.nsymbols; i++) ...). This is
data returned from a C library, not something I'm building in Python to pass
into C.
Thx,
Skip 2 6024 sk**@pobox.com schrieb:
(Is this the right place to ask ctypes questions? There's a mailing list
but the last post to it seems to have been in November 2006.)
No, it's active.
Using ctypes I reference a structure which contains a pointer to an array of
another structure:
class SYMBOL(Structure):
_fields_ = [("symbol", c_char_p),
("num", c_int),
("units", c_int),
("baseprice", c_int),
("active", c_int)]
SYMBOL_PTR = POINTER(SYMBOL)
class TABLE(Structure):
_fields_ = [("map", SYMBOL_PTR),
("nsymbols", c_uint),
...]
Effectively, TABLE.map is an array of TABLE.nsymbols SYMBOLS. How to I
reference elements in that array? In C I would just treat TABLE.map like an
array and index into it (for i=0; i< TABLE.nsymbols; i++) ...). This is
data returned from a C library, not something I'm building in Python to pass
into C.
I think you should be able to create an array-type with the required
number of entries, and cast map to that. Along these lines (untested)
ap = POINTER(SYMBOL(table.nsymbols))
map = cast(table.map, ap)
Diez
(Is this the right place to ask ctypes questions? There's a mailing list
but the last post to it seems to have been in November 2006.)
No, it's active.
Thanks. I guess the official ASPN-based archive must be dead.
I managed to sort of get access to the array just using indexing
as I would in C, but I'm having some problems referencing
elements of the SYMBOL struct. I'll keep plugging away.
Skip This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Thomas Heller |
last post by:
ctypes 0.9.1 released - Sept 14, 2004
=====================================
Overview
ctypes is a ffi (Foreign Function Interface) package for Python
2.3 and higher.
ctypes allows to call...
|
by: Kieran Simkin |
last post by:
Hi,
I wonder if anyone can help me, I've been headscratching for a few hours
over this.
Basically, I've defined a struct called cache_object:
struct cache_object {
char hostname;
char ipaddr;...
|
by: mrhicks |
last post by:
Hello all,
I need some advice/help on a particular problem I am having. I have
a basic struct called "indv_rpt_rply" that holds information for a
particular device in our system which I will...
|
by: Paminu |
last post by:
Still having a few problems with malloc and pointers.
I have made a struct. Now I would like to make a pointer an array with 4
pointers to this struct.
#include <stdlib.h>
#include <stdio.h>...
|
by: chris.atlee |
last post by:
Hello,
I've been trying to write a PAM module using ctypes. In the
conversation
function (my_conv in the script below), you're passed in a
pam_response**
pointer. You're supposed to allocate...
|
by: Chris AtLee |
last post by:
Sorry for the repeat post...I'm not sure if my first post (on May
30th) went through or
not.
I've been trying to write a PAM module using ctypes. In the
conversation
function (my_conv in the...
|
by: Szabolcs Borsanyi |
last post by:
Deal all,
The type
typedef double ***tmp_tensor3;
is meant to represent a three-dimensional array. For some reasons the
standard array-of-array-of-array will not work in my case.
Can I...
|
by: Andrew Lentvorski |
last post by:
Basically, I'd like to use the ctypes module as a much more descriptive
"struct" module.
Is there a way to take a ctypes.Structure-based class and convert it
to/from a binary string?
Thanks,...
|
by: overdrigzed |
last post by:
Hello!
I wanted to get the full contents of a character array stored in a
struct, i.e.
_fields_ =
however, ctypes seems to try to return struct.array as a Python string
rather than a...
|
by: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: DJRhino |
last post by:
Was curious if anyone else was having this same issue or not....
I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: Aliciasmith |
last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
|
by: tracyyun |
last post by:
Hello everyone,
I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
|
by: giovanniandrean |
last post by:
The energy model is structured as follows and uses excel sheets to give input data:
1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
|
by: Teri B |
last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course.
0ne-to-many. One course many roles.
Then I created a report based on the Course form and...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM)
Please note that the UK and Europe revert to winter time on...
|
by: nia12 |
last post by:
Hi there,
I am very new to Access so apologies if any of this is obvious/not clear.
I am creating a data collection tool for health care employees to complete. It consists of a number of...
| |