1 #ifndef Py_STRUCTMEMBER_H
2 #define Py_STRUCTMEMBER_H
7 /***********************************************************
8 Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
13 Permission to use, copy, modify, and distribute this software and its
14 documentation for any purpose and without fee is hereby granted,
15 provided that the above copyright notice appear in all copies and that
16 both that copyright notice and this permission notice appear in
17 supporting documentation, and that the names of Stichting Mathematisch
18 Centrum or CWI or Corporation for National Research Initiatives or
19 CNRI not be used in advertising or publicity pertaining to
20 distribution of the software without specific, written prior
23 While CWI is the initial source for this software, a modified version
24 is made available by the Corporation for National Research Initiatives
25 (CNRI) at the Internet address ftp://ftp.python.org.
27 STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH
28 REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
29 MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH
30 CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
31 DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
32 PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
33 TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
34 PERFORMANCE OF THIS SOFTWARE.
36 ******************************************************************/
38 /* Interface to map C struct members to Python object attributes */
41 #include <stddef.h> /* For offsetof */
44 /* The offsetof() macro calculates the offset of a structure member
45 in its structure. Unfortunately this cannot be written down
46 portably, hence it is provided by a Standard C header file.
47 For pre-Standard C compilers, here is a version that usually works
51 #define offsetof(type, member) ( (int) & ((type*)0) -> member )
54 /* An array of memberlist structures defines the name, type and offset
55 of selected members of a C structure. These can be read by
56 PyMember_Get() and set by PyMember_Set() (except if their READONLY flag
57 is set). The array must be terminated with an entry whose name
75 /* XXX the ordering here is weird for binary compatibility */
76 #define T_CHAR 7 /* 1-character string */
77 #define T_BYTE 8 /* 8-bit signed int */
78 /* unsigned variants: */
84 /* Added by Jack: strings contained in the structure */
85 #define T_STRING_INPLACE 13
87 #define T_PSTRING 14 /* macintosh pascal-style counted string */
88 #define T_PSTRING_INPLACE 15
89 #endif /* macintosh */
93 #define RO READONLY /* Shorthand */
95 DL_IMPORT(PyObject
*) PyMember_Get
Py_PROTO((char *, struct memberlist
*, char *));
96 DL_IMPORT(int) PyMember_Set
Py_PROTO((char *, struct memberlist
*, char *, PyObject
*));
101 #endif /* !Py_STRUCTMEMBER_H */