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
4222a21a
Commit
4222a21a
authored
Jul 03, 2001
by
matt@zope.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added Acquisition C API
parent
d158105f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
250 additions
and
72 deletions
+250
-72
lib/Components/ExtensionClass/src/Acquisition.c
lib/Components/ExtensionClass/src/Acquisition.c
+155
-72
lib/Components/ExtensionClass/src/Acquisition.h
lib/Components/ExtensionClass/src/Acquisition.h
+95
-0
No files found.
lib/Components/ExtensionClass/src/Acquisition.c
View file @
4222a21a
...
...
@@ -33,7 +33,7 @@
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.
$Id: Acquisition.c,v 1.5
1 2001/03/28 14:06:50 jeremy
Exp $
$Id: Acquisition.c,v 1.5
2 2001/07/03 19:38:20 matt
Exp $
If you have questions regarding this software,
contact:
...
...
@@ -46,6 +46,11 @@
*/
#include "ExtensionClass.h"
#define _IN_ACQUISITION_C
#include "Acquisition.h"
static
ACQUISITIONCAPI
AcquisitionCAPI
;
static
void
PyVar_Assign
(
PyObject
**
v
,
PyObject
*
e
)
{
...
...
@@ -1210,21 +1215,12 @@ static struct PyMethodDef Xaq_methods[] = {
};
static
PyObject
*
module_aq_acquire
(
PyObject
*
ignored
,
PyObject
*
args
,
PyObject
*
kw
)
capi_aq_acquire
(
PyObject
*
self
,
PyObject
*
name
,
PyObject
*
filter
,
PyObject
*
extra
,
int
explicit
,
PyObject
*
defalt
,
int
containment
)
{
PyObject
*
self
;
PyObject
*
name
,
*
filter
=
0
,
*
extra
=
Py_None
;
PyObject
*
expl
=
0
,
*
defalt
=
0
;
int
explicit
=
1
,
containment
=
0
;
UNLESS
(
PyArg_ParseTupleAndKeywords
(
args
,
kw
,
"OO|OOOOi"
,
acquire_args
,
&
self
,
&
name
,
&
filter
,
&
extra
,
&
explicit
,
&
defalt
,
&
containment
))
return
NULL
;
if
(
expl
)
explicit
=
PyObject_IsTrue
(
expl
);
PyObject
*
result
;
if
(
filter
==
Py_None
)
filter
=
0
;
/* We got a wrapped object, so business as usual */
...
...
@@ -1242,47 +1238,78 @@ module_aq_acquire(PyObject *ignored, PyObject *args, PyObject *kw)
UNLESS
(
self
=
newWrapper
(
self
,
NULL
,
(
PyTypeObject
*
)
&
Wrappertype
))
return
NULL
;
ignored
=
Wrapper_findattr
(
WRAPPER
(
self
),
name
,
filter
,
extra
,
OBJECT
(
self
),
result
=
Wrapper_findattr
(
WRAPPER
(
self
),
name
,
filter
,
extra
,
OBJECT
(
self
),
1
,
1
,
explicit
,
containment
);
/* get rid of temp wrapper */
Py_DECREF
(
self
);
return
ignored
;
return
result
;
}
static
PyObject
*
module_aq_
get
(
PyObject
*
r
,
PyObject
*
args
)
module_aq_
acquire
(
PyObject
*
ignored
,
PyObject
*
args
,
PyObject
*
kw
)
{
PyObject
*
self
,
*
name
,
*
defalt
=
0
;
int
containment
=
0
;
UNLESS
(
PyArg_ParseTuple
(
args
,
"OO|Oi"
,
&
self
,
&
name
,
&
defalt
,
&
containment
))
return
NULL
;
PyObject
*
self
;
PyObject
*
name
,
*
filter
=
0
,
*
extra
=
Py_None
;
PyObject
*
expl
=
0
,
*
defalt
=
0
;
int
explicit
=
1
,
containment
=
0
;
UNLESS
(
PyArg_ParseTupleAndKeywords
(
args
,
kw
,
"OO|OOOOi"
,
acquire_args
,
&
self
,
&
name
,
&
filter
,
&
extra
,
&
expl
,
&
defalt
,
&
containment
))
return
NULL
;
if
(
expl
)
explicit
=
PyObject_IsTrue
(
expl
);
return
capi_aq_acquire
(
self
,
name
,
filter
,
extra
,
explicit
,
defalt
,
containment
);
}
static
PyObject
*
capi_aq_get
(
PyObject
*
self
,
PyObject
*
name
,
PyObject
*
defalt
,
int
containment
)
{
PyObject
*
result
=
NULL
;
/* We got a wrapped object, so business as usual */
if
(
isWrapper
(
self
))
r
=
Wrapper_findattr
(
WRAPPER
(
self
),
name
,
0
,
0
,
OBJECT
(
self
),
1
,
1
,
1
,
r
esult
=
Wrapper_findattr
(
WRAPPER
(
self
),
name
,
0
,
0
,
OBJECT
(
self
),
1
,
1
,
1
,
containment
);
else
r
=
PyObject_GetAttr
(
self
,
name
);
r
esult
=
PyObject_GetAttr
(
self
,
name
);
if
(
!
r
&&
defalt
)
if
(
!
r
esult
&&
defalt
)
{
PyErr_Clear
();
r
=
defalt
;
Py_INCREF
(
r
);
r
esult
=
defalt
;
Py_INCREF
(
r
esult
);
}
return
r
;
return
r
esult
;
}
static
PyObject
*
module_aq_
base
(
PyObject
*
ignored
,
PyObject
*
args
)
module_aq_
get
(
PyObject
*
r
,
PyObject
*
args
)
{
PyObject
*
self
,
*
r
;
UNLESS
(
PyArg_ParseTuple
(
args
,
"O"
,
&
self
))
return
NULL
;
PyObject
*
self
,
*
name
,
*
defalt
=
0
;
int
containment
=
0
;
UNLESS
(
PyArg_ParseTuple
(
args
,
"OO|Oi"
,
&
self
,
&
name
,
&
defalt
,
&
containment
))
return
NULL
;
return
capi_aq_get
(
self
,
name
,
defalt
,
containment
);
}
static
int
capi_aq_iswrapper
(
PyObject
*
self
)
{
return
isWrapper
(
self
);
}
static
PyObject
*
capi_aq_base
(
PyObject
*
self
)
{
PyObject
*
result
;
if
(
!
isWrapper
(
self
))
{
Py_INCREF
(
self
);
...
...
@@ -1291,50 +1318,75 @@ module_aq_base(PyObject *ignored, PyObject *args)
if
(
WRAPPER
(
self
)
->
obj
)
{
r
=
WRAPPER
(
self
)
->
obj
;
while
(
isWrapper
(
r
)
&&
WRAPPER
(
r
)
->
obj
)
r
=
WRAPPER
(
r
)
->
obj
;
result
=
WRAPPER
(
self
)
->
obj
;
while
(
isWrapper
(
result
)
&&
WRAPPER
(
result
)
->
obj
)
result
=
WRAPPER
(
result
)
->
obj
;
}
else
r
=
Py_None
;
Py_INCREF
(
r
);
return
r
;
else
r
esult
=
Py_None
;
Py_INCREF
(
r
esult
);
return
r
esult
;
}
static
PyObject
*
module_aq_
parent
(
PyObject
*
ignored
,
PyObject
*
args
)
module_aq_
base
(
PyObject
*
ignored
,
PyObject
*
args
)
{
PyObject
*
self
,
*
r
=
Py_None
;
PyObject
*
self
;
UNLESS
(
PyArg_ParseTuple
(
args
,
"O"
,
&
self
))
return
NULL
;
if
(
isWrapper
(
self
)
&&
WRAPPER
(
self
)
->
container
)
r
=
WRAPPER
(
self
)
->
container
;
return
capi_aq_base
(
self
);
}
Py_INCREF
(
r
);
return
r
;
static
PyObject
*
capi_aq_parent
(
PyObject
*
self
)
{
PyObject
*
result
=
Py_None
;
if
(
isWrapper
(
self
)
&&
WRAPPER
(
self
)
->
container
)
result
=
WRAPPER
(
self
)
->
container
;
Py_INCREF
(
result
);
return
result
;
}
static
PyObject
*
module_aq_
self
(
PyObject
*
ignored
,
PyObject
*
args
)
module_aq_
parent
(
PyObject
*
ignored
,
PyObject
*
args
)
{
PyObject
*
self
,
*
r
;
PyObject
*
self
;
UNLESS
(
PyArg_ParseTuple
(
args
,
"O"
,
&
self
))
return
NULL
;
return
capi_aq_parent
(
self
);
}
static
PyObject
*
capi_aq_self
(
PyObject
*
self
)
{
PyObject
*
result
;
if
(
!
isWrapper
(
self
))
{
Py_INCREF
(
self
);
return
self
;
}
if
(
WRAPPER
(
self
)
->
obj
)
r
=
WRAPPER
(
self
)
->
obj
;
else
r
=
Py_None
;
if
(
WRAPPER
(
self
)
->
obj
)
r
esult
=
WRAPPER
(
self
)
->
obj
;
else
r
esult
=
Py_None
;
Py_INCREF
(
r
);
return
r
;
Py_INCREF
(
r
esult
);
return
r
esult
;
}
static
PyObject
*
module_aq_
inner
(
PyObject
*
ignored
,
PyObject
*
args
)
module_aq_
self
(
PyObject
*
ignored
,
PyObject
*
args
)
{
PyObject
*
self
,
*
r
;
PyObject
*
self
;
UNLESS
(
PyArg_ParseTuple
(
args
,
"O"
,
&
self
))
return
NULL
;
return
capi_aq_self
(
self
);
}
static
PyObject
*
capi_aq_inner
(
PyObject
*
self
)
{
PyObject
*
result
;
if
(
!
isWrapper
(
self
))
{
Py_INCREF
(
self
);
...
...
@@ -1343,30 +1395,35 @@ module_aq_inner(PyObject *ignored, PyObject *args)
if
(
WRAPPER
(
self
)
->
obj
)
{
r
=
WRAPPER
(
self
)
->
obj
;
while
(
isWrapper
(
r
)
&&
WRAPPER
(
r
)
->
obj
)
r
esult
=
WRAPPER
(
self
)
->
obj
;
while
(
isWrapper
(
r
esult
)
&&
WRAPPER
(
result
)
->
obj
)
{
self
=
r
;
r
=
WRAPPER
(
r
)
->
obj
;
self
=
r
esult
;
r
esult
=
WRAPPER
(
result
)
->
obj
;
}
r
=
self
;
r
esult
=
self
;
}
else
r
=
Py_None
;
else
r
esult
=
Py_None
;
Py_INCREF
(
r
);
return
r
;
Py_INCREF
(
r
esult
);
return
r
esult
;
}
static
PyObject
*
module_aq_
chain
(
PyObject
*
ignored
,
PyObject
*
args
)
module_aq_
inner
(
PyObject
*
ignored
,
PyObject
*
args
)
{
PyObject
*
self
,
*
r
;
int
containment
=
0
;
PyObject
*
self
;
UNLESS
(
PyArg_ParseTuple
(
args
,
"O|i"
,
&
self
,
&
containment
))
return
NULL
;
UNLESS
(
PyArg_ParseTuple
(
args
,
"O"
,
&
self
))
return
NULL
;
return
capi_aq_inner
(
self
);
}
UNLESS
(
r
=
PyList_New
(
0
))
return
NULL
;
static
PyObject
*
capi_aq_chain
(
PyObject
*
self
,
int
containment
)
{
PyObject
*
result
;
UNLESS
(
result
=
PyList_New
(
0
))
return
NULL
;
while
(
1
)
{
...
...
@@ -1377,7 +1434,7 @@ module_aq_chain(PyObject *ignored, PyObject *args)
if
(
containment
)
while
(
WRAPPER
(
self
)
->
obj
&&
isWrapper
(
WRAPPER
(
self
)
->
obj
))
self
=
WRAPPER
(
self
)
->
obj
;
if
(
PyList_Append
(
r
,
OBJECT
(
self
))
<
0
)
if
(
PyList_Append
(
r
esult
,
OBJECT
(
self
))
<
0
)
goto
err
;
}
if
(
WRAPPER
(
self
)
->
container
)
...
...
@@ -1387,16 +1444,28 @@ module_aq_chain(PyObject *ignored, PyObject *args)
}
}
else
if
(
PyList_Append
(
r
,
self
)
<
0
)
if
(
PyList_Append
(
r
esult
,
self
)
<
0
)
goto
err
;
break
;
}
return
r
;
return
r
esult
;
err:
Py_DECREF
(
r
);
return
r
;
Py_DECREF
(
result
);
return
result
;
}
static
PyObject
*
module_aq_chain
(
PyObject
*
ignored
,
PyObject
*
args
)
{
PyObject
*
self
;
int
containment
=
0
;
UNLESS
(
PyArg_ParseTuple
(
args
,
"O|i"
,
&
self
,
&
containment
))
return
NULL
;
return
capi_aq_chain
(
self
,
containment
);
}
static
struct
PyMethodDef
methods
[]
=
{
...
...
@@ -1427,7 +1496,8 @@ void
initAcquisition
(
void
)
{
PyObject
*
m
,
*
d
;
char
*
rev
=
"$Revision: 1.51 $"
;
PyObject
*
api
;
char
*
rev
=
"$Revision: 1.52 $"
;
PURE_MIXIN_CLASS
(
Acquirer
,
"Base class for objects that implicitly"
" acquire attributes from containers
\n
"
...
...
@@ -1446,7 +1516,7 @@ initAcquisition(void)
/* Create the module and add the functions */
m
=
Py_InitModule4
(
"Acquisition"
,
methods
,
"Provide base classes for acquiring objects
\n\n
"
"$Id: Acquisition.c,v 1.5
1 2001/03/28 14:06:50 jeremy
Exp $
\n
"
,
"$Id: Acquisition.c,v 1.5
2 2001/07/03 19:38:20 matt
Exp $
\n
"
,
OBJECT
(
NULL
),
PYTHON_API_VERSION
);
d
=
PyModule_GetDict
(
m
);
...
...
@@ -1464,5 +1534,18 @@ initAcquisition(void)
PyString_FromStringAndSize
(
rev
+
11
,
strlen
(
rev
+
11
)
-
2
));
PyDict_SetItemString
(
d
,
"Acquired"
,
Acquired
);
AcquisitionCAPI
.
AQ_Acquire
=
capi_aq_acquire
;
AcquisitionCAPI
.
AQ_Get
=
capi_aq_get
;
AcquisitionCAPI
.
AQ_IsWrapper
=
capi_aq_iswrapper
;
AcquisitionCAPI
.
AQ_Base
=
capi_aq_base
;
AcquisitionCAPI
.
AQ_Parent
=
capi_aq_parent
;
AcquisitionCAPI
.
AQ_Self
=
capi_aq_self
;
AcquisitionCAPI
.
AQ_Inner
=
capi_aq_inner
;
AcquisitionCAPI
.
AQ_Chain
=
capi_aq_chain
;
api
=
PyCObject_FromVoidPtr
(
&
AcquisitionCAPI
,
NULL
);
PyDict_SetItemString
(
d
,
"AcquisitionCAPI"
,
api
);
Py_DECREF
(
api
);
CHECK_FOR_ERRORS
(
"can't initialize module Acquisition"
);
}
lib/Components/ExtensionClass/src/Acquisition.h
0 → 100644
View file @
4222a21a
/*
Copyright (c) 1996-2001, Digital Creations, Fredericksburg, VA, USA.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
o Redistributions of source code must retain the above copyright
notice, this list of conditions, and the disclaimer that follows.
o Redistributions in binary form must reproduce the above copyright
notice, this list of conditions, and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
o Neither the name of Digital Creations nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY DIGITAL CREATIONS AND CONTRIBUTORS *AS
IS* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DIGITAL
CREATIONS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.
$Id: Acquisition.h,v 1.1 2001/07/03 19:38:20 matt Exp $
If you have questions regarding this software,
contact:
Digital Creations L.C.
info@digicool.com
(540) 371-6909
*/
#ifndef __ACQUISITION_H_
#define __ACQUISITION_H_
typedef
struct
{
PyObject
*
(
*
AQ_Acquire
)
(
PyObject
*
obj
,
PyObject
*
name
,
PyObject
*
filter
,
PyObject
*
extra
,
int
explicit
,
PyObject
*
deflt
,
int
containment
);
PyObject
*
(
*
AQ_Get
)
(
PyObject
*
obj
,
PyObject
*
name
,
PyObject
*
deflt
,
int
containment
);
int
(
*
AQ_IsWrapper
)
(
PyObject
*
obj
);
PyObject
*
(
*
AQ_Base
)
(
PyObject
*
obj
);
PyObject
*
(
*
AQ_Parent
)
(
PyObject
*
obj
);
PyObject
*
(
*
AQ_Self
)
(
PyObject
*
obj
);
PyObject
*
(
*
AQ_Inner
)
(
PyObject
*
obj
);
PyObject
*
(
*
AQ_Chain
)
(
PyObject
*
obj
,
int
containment
);
}
ACQUISITIONCAPI
;
#ifndef _IN_ACQUISITION_C
#define aq_Acquire(obj, name, filter, extra, explicit, deflt, containment ) (AcquisitionCAPI == NULL ? NULL : (AcquisitionCAPI->AQ_Acquire(obj, name, filter, extra, explicit, deflt, containment)))
#define aq_acquire(obj, name) (AcquisitionCAPI == NULL ? NULL : (AcquisitionCAPI->AQ_Acquire(obj, name, NULL, NULL, 1, NULL, 0)))
#define aq_get(obj, name, deflt, containment) (AcquistionCAPI == NULL ? NULL : (AcquisitionCAPI->AQ_Get(obj, name, deflt, containment)))
#define aq_isWrapper(obj) (AcquisitionCAPI == NULL ? -1 : (AcquisitionCAPI->AQ_IsWrapper(obj)))
#define aq_base(obj) (AcquisitionCAPI == NULL ? NULL : (AcquisitionCAPI->AQ_Base(obj)))
#define aq_parent(obj) (AcquisitionCAPI == NULL ? NULL : (AcquisitionCAPI->AQ_Parent(obj)))
#define aq_self(obj) (AcquisitionCAPI == NULL ? NULL : (AcquisitionCAPI->AQ_Self(obj)))
#define aq_inner(obj) (AcquisitionCAPI == NULL ? NULL : (AcquisitionCAPI->AQ_Inner(obj)))
#define aq_chain(obj, containment) (AcquisitionCAPI == NULL ? NULL : (AcquisitionCAPI->AQ_CHain(obj, containment)))
static
ACQUISITIONCAPI
*
AcquisitionCAPI
=
NULL
;
#define aq_init() { \
PyObject *module; \
PyObject *api; \
if ((module = PyImport_ImportModule("Acquisition")) == NULL) \
Py_FatalError("Acquisition CAPI failed to load Acquisition"); \
if ((api = PyObject_GetAttrString(module,"AcquisitionCAPI")) \
== NULL) Py_FatalError("Acquisition CAPI failed to load AcquistionCAPI"); \
Py_DECREF(module); \
AcquisitionCAPI = PyCObject_AsVoidPtr(api); \
Py_DECREF(api); \
}
#endif
#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