Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
07ae417b
Commit
07ae417b
authored
Dec 06, 1996
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added support for attro functions and made use of cobject to export C
interfaces.
parent
6cc20dbd
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
116 additions
and
20 deletions
+116
-20
lib/Components/ExtensionClass/ExtensionClass.h
lib/Components/ExtensionClass/ExtensionClass.h
+58
-10
lib/Components/ExtensionClass/src/ExtensionClass.h
lib/Components/ExtensionClass/src/ExtensionClass.h
+58
-10
No files found.
lib/Components/ExtensionClass/ExtensionClass.h
View file @
07ae417b
/*
$Id: ExtensionClass.h,v 1.
2 1996/11/08 22:07:26
jim Exp $
$Id: ExtensionClass.h,v 1.
3 1996/12/06 17:13:17
jim Exp $
Extension Class Definitions
...
...
@@ -56,6 +56,10 @@
$Log: ExtensionClass.h,v $
Revision 1.3 1996/12/06 17:13:17 jim
Added support for attro functions and made use of cobject to export C
interfaces.
Revision 1.2 1996/11/08 22:07:26 jim
Added parens in if to make -Wall happy.
...
...
@@ -73,6 +77,11 @@
/* Declarations for objects of type ExtensionClass */
#if PYTHON_API_VERSION < 1005
typedef
long
getattrofunc
;
typedef
long
setattrofunc
;
#endif
typedef
struct
{
PyObject_VAR_HEAD
char
*
tp_name
;
/* For printing */
...
...
@@ -98,9 +107,8 @@ typedef struct {
hashfunc
tp_hash
;
ternaryfunc
tp_call
;
reprfunc
tp_str
;
long
tp_xxx1
;
/*getattrofunc tp_getattro;*/
long
tp_xxx2
;
/*setattrofunc tp_setattro;*/
getattrofunc
tp_getattro
;
setattrofunc
tp_setattro
;
/* Space for future expansion */
long
tp_xxx3
;
long
tp_xxx4
;
...
...
@@ -124,15 +132,54 @@ typedef struct {
#endif
}
PyExtensionClass
;
#ifdef Py_COBJECT_H
PyObject
*
(
*
PyEC_getattrs
)(
PyObject
*
,
char
*
)
=
NULL
;
PyObject
*
(
*
PyEC_getattro
)(
PyObject
*
,
PyObject
*
)
=
NULL
;
int
(
*
PyEC_setattrs
)(
PyObject
*
,
char
*
,
PyObject
*
)
=
NULL
;
int
(
*
PyEC_setattro
)(
PyObject
*
,
PyObject
*
,
PyObject
*
)
=
NULL
;
#define Py_FindMethod(M,SELF,NAME) PyEC_getattrs((SELF),(NAME))
#define Py_FindAttrString(SELF,NAME) PyEC_getattrs((SELF),(NAME))
#define Py_FindAttr(SELF,NAME) PyEC_getattro((SELF),(NAME))
#define PyEC_SetAttrString(SELF,NAME,V) PyEC_setattrs((SELF),(NAME),(V))
#define PyEC_SetAttr(SELF,NAME,V) PyEC_setattro((SELF),(NAME),(V))
#define IMPORT_C_OBJECT(P,C,M) { \
PyObject *_IMPORT_C_OBJECT; \
if((_IMPORT_C_OBJECT=PyObject_GetAttrString(M,#P))) { \
C=PyCObject_AsVoidPtr(_IMPORT_C_OBJECT); \
Py_DECREF(_IMPORT_C_OBJECT); }}
#define PyExtensionClass_Export(D,N,T) { \
PyObject *_ExtensionClass_module, *_ExtensionClass_spam; \
if((_ExtensionClass_module=PyImport_ImportModule("ExtensionClass"))) { \
if(_ExtensionClass_spam= \
PyObject_CallMethod(_ExtensionClass_module, \
"ExtensionClassType", "Oi", &T, 42)) { \
Py_DECREF(_ExtensionClass_spam); \
PyMapping_SetItemString(D,N,(PyObject*)&T); } \
IMPORT_C_OBJECT(_PyEC_getattrs,PyEC_getattrs,_ExtensionClass_module) \
IMPORT_C_OBJECT(_PyEC_getattro,PyEC_getattro,_ExtensionClass_module) \
IMPORT_C_OBJECT(_PyEC_setattrs,PyEC_setattrs,_ExtensionClass_module) \
IMPORT_C_OBJECT(_PyEC_setattro,PyEC_setattro,_ExtensionClass_module) \
Py_DECREF(_ExtensionClass_module); }}
#else
/* Don't look at this. :-) */
#define Py_FindMethod(M,SELF,NAME) \
((getattrfunc)(SELF->ob_type->ob_type->tp_getattr(SELF
->ob_type,"."))) \
(
SELF,NAME
)
((getattrfunc)((SELF)->ob_type->ob_type->tp_getattr((SELF)
->ob_type,"."))) \
(
(SELF),(NAME)
)
#define Py_FindAttrString(SELF,NAME) \
((getattrfunc)(SELF->ob_type->ob_type->tp_getattr(SELF->ob_type,"."))) \
(SELF,NAME)
((getattrfunc)((SELF)->ob_type->ob_type->tp_getattr((SELF)->ob_type,"."))) \
((SELF),(NAME) )
#define PyEC_SetAttrString(SELF,NAME,V) \
((setattrfunc)((SELF)->ob_type->ob_type->tp_getattr((SELF)->ob_type, \
".s"))) \
((SELF),(NAME),(V))
#define PyExtensionClass_Export(D,N,T) { \
PyObject *_ExtensionClass_module; \
...
...
@@ -144,6 +191,8 @@ typedef struct {
} \
}
#endif
#define METHOD_CHAIN(DEF) { DEF, NULL }
#define CHECK_FOR_ERRORS(MESS) \
...
...
@@ -159,7 +208,6 @@ if(PyErr_Occurred()) { \
Py_FatalError(# MESS); \
}
#endif
lib/Components/ExtensionClass/src/ExtensionClass.h
View file @
07ae417b
/*
$Id: ExtensionClass.h,v 1.
2 1996/11/08 22:07:26
jim Exp $
$Id: ExtensionClass.h,v 1.
3 1996/12/06 17:13:17
jim Exp $
Extension Class Definitions
...
...
@@ -56,6 +56,10 @@
$Log: ExtensionClass.h,v $
Revision 1.3 1996/12/06 17:13:17 jim
Added support for attro functions and made use of cobject to export C
interfaces.
Revision 1.2 1996/11/08 22:07:26 jim
Added parens in if to make -Wall happy.
...
...
@@ -73,6 +77,11 @@
/* Declarations for objects of type ExtensionClass */
#if PYTHON_API_VERSION < 1005
typedef
long
getattrofunc
;
typedef
long
setattrofunc
;
#endif
typedef
struct
{
PyObject_VAR_HEAD
char
*
tp_name
;
/* For printing */
...
...
@@ -98,9 +107,8 @@ typedef struct {
hashfunc
tp_hash
;
ternaryfunc
tp_call
;
reprfunc
tp_str
;
long
tp_xxx1
;
/*getattrofunc tp_getattro;*/
long
tp_xxx2
;
/*setattrofunc tp_setattro;*/
getattrofunc
tp_getattro
;
setattrofunc
tp_setattro
;
/* Space for future expansion */
long
tp_xxx3
;
long
tp_xxx4
;
...
...
@@ -124,15 +132,54 @@ typedef struct {
#endif
}
PyExtensionClass
;
#ifdef Py_COBJECT_H
PyObject
*
(
*
PyEC_getattrs
)(
PyObject
*
,
char
*
)
=
NULL
;
PyObject
*
(
*
PyEC_getattro
)(
PyObject
*
,
PyObject
*
)
=
NULL
;
int
(
*
PyEC_setattrs
)(
PyObject
*
,
char
*
,
PyObject
*
)
=
NULL
;
int
(
*
PyEC_setattro
)(
PyObject
*
,
PyObject
*
,
PyObject
*
)
=
NULL
;
#define Py_FindMethod(M,SELF,NAME) PyEC_getattrs((SELF),(NAME))
#define Py_FindAttrString(SELF,NAME) PyEC_getattrs((SELF),(NAME))
#define Py_FindAttr(SELF,NAME) PyEC_getattro((SELF),(NAME))
#define PyEC_SetAttrString(SELF,NAME,V) PyEC_setattrs((SELF),(NAME),(V))
#define PyEC_SetAttr(SELF,NAME,V) PyEC_setattro((SELF),(NAME),(V))
#define IMPORT_C_OBJECT(P,C,M) { \
PyObject *_IMPORT_C_OBJECT; \
if((_IMPORT_C_OBJECT=PyObject_GetAttrString(M,#P))) { \
C=PyCObject_AsVoidPtr(_IMPORT_C_OBJECT); \
Py_DECREF(_IMPORT_C_OBJECT); }}
#define PyExtensionClass_Export(D,N,T) { \
PyObject *_ExtensionClass_module, *_ExtensionClass_spam; \
if((_ExtensionClass_module=PyImport_ImportModule("ExtensionClass"))) { \
if(_ExtensionClass_spam= \
PyObject_CallMethod(_ExtensionClass_module, \
"ExtensionClassType", "Oi", &T, 42)) { \
Py_DECREF(_ExtensionClass_spam); \
PyMapping_SetItemString(D,N,(PyObject*)&T); } \
IMPORT_C_OBJECT(_PyEC_getattrs,PyEC_getattrs,_ExtensionClass_module) \
IMPORT_C_OBJECT(_PyEC_getattro,PyEC_getattro,_ExtensionClass_module) \
IMPORT_C_OBJECT(_PyEC_setattrs,PyEC_setattrs,_ExtensionClass_module) \
IMPORT_C_OBJECT(_PyEC_setattro,PyEC_setattro,_ExtensionClass_module) \
Py_DECREF(_ExtensionClass_module); }}
#else
/* Don't look at this. :-) */
#define Py_FindMethod(M,SELF,NAME) \
((getattrfunc)(SELF->ob_type->ob_type->tp_getattr(SELF
->ob_type,"."))) \
(
SELF,NAME
)
((getattrfunc)((SELF)->ob_type->ob_type->tp_getattr((SELF)
->ob_type,"."))) \
(
(SELF),(NAME)
)
#define Py_FindAttrString(SELF,NAME) \
((getattrfunc)(SELF->ob_type->ob_type->tp_getattr(SELF->ob_type,"."))) \
(SELF,NAME)
((getattrfunc)((SELF)->ob_type->ob_type->tp_getattr((SELF)->ob_type,"."))) \
((SELF),(NAME) )
#define PyEC_SetAttrString(SELF,NAME,V) \
((setattrfunc)((SELF)->ob_type->ob_type->tp_getattr((SELF)->ob_type, \
".s"))) \
((SELF),(NAME),(V))
#define PyExtensionClass_Export(D,N,T) { \
PyObject *_ExtensionClass_module; \
...
...
@@ -144,6 +191,8 @@ typedef struct {
} \
}
#endif
#define METHOD_CHAIN(DEF) { DEF, NULL }
#define CHECK_FOR_ERRORS(MESS) \
...
...
@@ -159,7 +208,6 @@ if(PyErr_Occurred()) { \
Py_FatalError(# MESS); \
}
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment