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
5ee4cfe7
Commit
5ee4cfe7
authored
Feb 17, 1997
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made changes to be more useful for DocumentTemplates.
parent
959a884e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
70 additions
and
64 deletions
+70
-64
lib/Components/ExtensionClass/MultiMapping.c
lib/Components/ExtensionClass/MultiMapping.c
+35
-32
lib/Components/ExtensionClass/src/MultiMapping.c
lib/Components/ExtensionClass/src/MultiMapping.c
+35
-32
No files found.
lib/Components/ExtensionClass/MultiMapping.c
View file @
5ee4cfe7
/*
/*
$Id: MultiMapping.c,v 1.
2 1996/10/23 18:37:45
jim Exp $
$Id: MultiMapping.c,v 1.
3 1997/02/17 16:34:09
jim Exp $
Sample extension class program that implements multi-mapping objects.
Sample extension class program that implements multi-mapping objects.
...
@@ -50,23 +50,13 @@
...
@@ -50,23 +50,13 @@
If you have questions regarding this software,
If you have questions regarding this software,
contact:
contact:
Jim Fulton, jim@digicool.com
Digital Creations L.L.C.
Digital Creations L.C.
info@digicool.com
(540) 371-6909
(540) 371-6909
Full description
*****************************************************************************/
$Log: MultiMapping.c,v $
Revision 1.2 1996/10/23 18:37:45 jim
Fixed misspelling in class name.
Revision 1.1 1996/10/22 22:27:42 jim
*** empty log message ***
*/
#include "Python.h"
#include "Python.h"
#include "ExtensionClass.h"
#include "ExtensionClass.h"
...
@@ -85,7 +75,7 @@ MM_push(self, args)
...
@@ -85,7 +75,7 @@ MM_push(self, args)
PyObject
*
args
;
PyObject
*
args
;
{
{
PyObject
*
src
;
PyObject
*
src
;
UNLESS
(
PyArg_Parse
Tuple
(
args
,
"O"
,
&
src
))
return
NULL
;
UNLESS
(
PyArg_Parse
(
args
,
"O"
,
&
src
))
return
NULL
;
UNLESS
(
-
1
!=
PyList_Append
(
self
->
data
,
src
))
return
NULL
;
UNLESS
(
-
1
!=
PyList_Append
(
self
->
data
,
src
))
return
NULL
;
Py_INCREF
(
Py_None
);
Py_INCREF
(
Py_None
);
return
Py_None
;
return
Py_None
;
...
@@ -96,16 +86,14 @@ MM_pop(self, args)
...
@@ -96,16 +86,14 @@ MM_pop(self, args)
MMobject
*
self
;
MMobject
*
self
;
PyObject
*
args
;
PyObject
*
args
;
{
{
long
l
;
int
i
=
1
,
l
;
PyObject
*
r
;
PyObject
*
r
;
static
PyObject
*
emptyList
=
0
;
if
(
args
)
UNLESS
(
PyArg_Parse
(
args
,
"i"
,
&
i
))
return
NULL
;
UNLESS
(
emptyList
)
UNLESS
(
emptyList
=
PyList_New
(
0
))
return
NULL
;
if
((
l
=
PyList_Size
(
self
->
data
))
<
0
)
return
NULL
;
UNLESS
(
PyArg_ParseTuple
(
args
,
""
))
return
NULL
;
i
=
l
-
i
;
UNLESS
(
-
1
!=
(
l
=
PyList_Size
(
self
->
data
)))
return
NULL
;
UNLESS
(
r
=
PySequence_GetItem
(
self
->
data
,
l
-
1
))
return
NULL
;
l
--
;
if
(
PyList_SetSlice
(
self
->
data
,
i
,
l
,
NULL
)
<
0
)
goto
err
;
UNLESS
(
r
=
PySequence_GetItem
(
self
->
data
,
l
))
return
NULL
;
UNLESS
(
-
1
!=
PyList_SetSlice
(
self
->
data
,
l
,
l
+
1
,
emptyList
))
goto
err
;
return
r
;
return
r
;
err:
err:
Py_DECREF
(
r
);
Py_DECREF
(
r
);
...
@@ -117,21 +105,18 @@ MM__init__(self, args)
...
@@ -117,21 +105,18 @@ MM__init__(self, args)
MMobject
*
self
;
MMobject
*
self
;
PyObject
*
args
;
PyObject
*
args
;
{
{
UNLESS
(
PyArg_Parse
Tuple
(
args
,
""
))
return
NULL
;
UNLESS
(
PyArg_Parse
(
args
,
""
))
return
NULL
;
UNLESS
(
self
->
data
=
PyList_New
(
0
))
goto
err
;
UNLESS
(
self
->
data
=
PyList_New
(
0
))
return
NULL
;
Py_INCREF
(
Py_None
);
Py_INCREF
(
Py_None
);
return
Py_None
;
return
Py_None
;
err:
Py_DECREF
(
self
);
return
NULL
;
}
}
static
struct
PyMethodDef
MM_methods
[]
=
{
static
struct
PyMethodDef
MM_methods
[]
=
{
{
"__init__"
,
(
PyCFunction
)
MM__init__
,
1
,
{
"__init__"
,
(
PyCFunction
)
MM__init__
,
0
,
"__init__() -- Create a new empty multi-mapping"
},
"__init__() -- Create a new empty multi-mapping"
},
{
"push"
,
(
PyCFunction
)
MM_push
,
1
,
{
"push"
,
(
PyCFunction
)
MM_push
,
0
,
"push(mapping_object) -- Add a data source"
},
"push(mapping_object) -- Add a data source"
},
{
"pop"
,
(
PyCFunction
)
MM_pop
,
1
,
{
"pop"
,
(
PyCFunction
)
MM_pop
,
0
,
"pop() -- Remove and return the last data source added"
},
"pop() -- Remove and return the last data source added"
},
{
NULL
,
NULL
}
/* sentinel */
{
NULL
,
NULL
}
/* sentinel */
};
};
...
@@ -234,12 +219,30 @@ void
...
@@ -234,12 +219,30 @@ void
initMultiMapping
()
initMultiMapping
()
{
{
PyObject
*
m
,
*
d
;
PyObject
*
m
,
*
d
;
char
*
rev
=
"$Revision: 1.3 $"
;
m
=
Py_InitModule4
(
"MultiMapping"
,
MultiMapping_methods
,
m
=
Py_InitModule4
(
"MultiMapping"
,
MultiMapping_methods
,
"MultiMapping -- Wrap multiple mapping objects for lookup"
,
"MultiMapping -- Wrap multiple mapping objects for lookup"
,
(
PyObject
*
)
NULL
,
PYTHON_API_VERSION
);
(
PyObject
*
)
NULL
,
PYTHON_API_VERSION
);
d
=
PyModule_GetDict
(
m
);
d
=
PyModule_GetDict
(
m
);
PyExtensionClass_Export
(
d
,
"MultiMapping"
,
MMtype
);
PyExtensionClass_Export
(
d
,
"MultiMapping"
,
MMtype
);
PyDict_SetItemString
(
d
,
"__version__"
,
PyString_FromStringAndSize
(
rev
+
11
,
strlen
(
rev
+
11
)
-
2
));
if
(
PyErr_Occurred
())
Py_FatalError
(
"can't initialize module MultiMapping"
);
if
(
PyErr_Occurred
())
Py_FatalError
(
"can't initialize module MultiMapping"
);
}
}
/*****************************************************************************
$Log: MultiMapping.c,v $
Revision 1.3 1997/02/17 16:34:09 jim
Made changes to be more useful for DocumentTemplates.
Revision 1.2 1996/10/23 18:37:45 jim
Fixed misspelling in class name.
Revision 1.1 1996/10/22 22:27:42 jim
*** empty log message ***
*****************************************************************************/
lib/Components/ExtensionClass/src/MultiMapping.c
View file @
5ee4cfe7
/*
/*
$Id: MultiMapping.c,v 1.
2 1996/10/23 18:37:45
jim Exp $
$Id: MultiMapping.c,v 1.
3 1997/02/17 16:34:09
jim Exp $
Sample extension class program that implements multi-mapping objects.
Sample extension class program that implements multi-mapping objects.
...
@@ -50,23 +50,13 @@
...
@@ -50,23 +50,13 @@
If you have questions regarding this software,
If you have questions regarding this software,
contact:
contact:
Jim Fulton, jim@digicool.com
Digital Creations L.L.C.
Digital Creations L.C.
info@digicool.com
(540) 371-6909
(540) 371-6909
Full description
*****************************************************************************/
$Log: MultiMapping.c,v $
Revision 1.2 1996/10/23 18:37:45 jim
Fixed misspelling in class name.
Revision 1.1 1996/10/22 22:27:42 jim
*** empty log message ***
*/
#include "Python.h"
#include "Python.h"
#include "ExtensionClass.h"
#include "ExtensionClass.h"
...
@@ -85,7 +75,7 @@ MM_push(self, args)
...
@@ -85,7 +75,7 @@ MM_push(self, args)
PyObject
*
args
;
PyObject
*
args
;
{
{
PyObject
*
src
;
PyObject
*
src
;
UNLESS
(
PyArg_Parse
Tuple
(
args
,
"O"
,
&
src
))
return
NULL
;
UNLESS
(
PyArg_Parse
(
args
,
"O"
,
&
src
))
return
NULL
;
UNLESS
(
-
1
!=
PyList_Append
(
self
->
data
,
src
))
return
NULL
;
UNLESS
(
-
1
!=
PyList_Append
(
self
->
data
,
src
))
return
NULL
;
Py_INCREF
(
Py_None
);
Py_INCREF
(
Py_None
);
return
Py_None
;
return
Py_None
;
...
@@ -96,16 +86,14 @@ MM_pop(self, args)
...
@@ -96,16 +86,14 @@ MM_pop(self, args)
MMobject
*
self
;
MMobject
*
self
;
PyObject
*
args
;
PyObject
*
args
;
{
{
long
l
;
int
i
=
1
,
l
;
PyObject
*
r
;
PyObject
*
r
;
static
PyObject
*
emptyList
=
0
;
if
(
args
)
UNLESS
(
PyArg_Parse
(
args
,
"i"
,
&
i
))
return
NULL
;
UNLESS
(
emptyList
)
UNLESS
(
emptyList
=
PyList_New
(
0
))
return
NULL
;
if
((
l
=
PyList_Size
(
self
->
data
))
<
0
)
return
NULL
;
UNLESS
(
PyArg_ParseTuple
(
args
,
""
))
return
NULL
;
i
=
l
-
i
;
UNLESS
(
-
1
!=
(
l
=
PyList_Size
(
self
->
data
)))
return
NULL
;
UNLESS
(
r
=
PySequence_GetItem
(
self
->
data
,
l
-
1
))
return
NULL
;
l
--
;
if
(
PyList_SetSlice
(
self
->
data
,
i
,
l
,
NULL
)
<
0
)
goto
err
;
UNLESS
(
r
=
PySequence_GetItem
(
self
->
data
,
l
))
return
NULL
;
UNLESS
(
-
1
!=
PyList_SetSlice
(
self
->
data
,
l
,
l
+
1
,
emptyList
))
goto
err
;
return
r
;
return
r
;
err:
err:
Py_DECREF
(
r
);
Py_DECREF
(
r
);
...
@@ -117,21 +105,18 @@ MM__init__(self, args)
...
@@ -117,21 +105,18 @@ MM__init__(self, args)
MMobject
*
self
;
MMobject
*
self
;
PyObject
*
args
;
PyObject
*
args
;
{
{
UNLESS
(
PyArg_Parse
Tuple
(
args
,
""
))
return
NULL
;
UNLESS
(
PyArg_Parse
(
args
,
""
))
return
NULL
;
UNLESS
(
self
->
data
=
PyList_New
(
0
))
goto
err
;
UNLESS
(
self
->
data
=
PyList_New
(
0
))
return
NULL
;
Py_INCREF
(
Py_None
);
Py_INCREF
(
Py_None
);
return
Py_None
;
return
Py_None
;
err:
Py_DECREF
(
self
);
return
NULL
;
}
}
static
struct
PyMethodDef
MM_methods
[]
=
{
static
struct
PyMethodDef
MM_methods
[]
=
{
{
"__init__"
,
(
PyCFunction
)
MM__init__
,
1
,
{
"__init__"
,
(
PyCFunction
)
MM__init__
,
0
,
"__init__() -- Create a new empty multi-mapping"
},
"__init__() -- Create a new empty multi-mapping"
},
{
"push"
,
(
PyCFunction
)
MM_push
,
1
,
{
"push"
,
(
PyCFunction
)
MM_push
,
0
,
"push(mapping_object) -- Add a data source"
},
"push(mapping_object) -- Add a data source"
},
{
"pop"
,
(
PyCFunction
)
MM_pop
,
1
,
{
"pop"
,
(
PyCFunction
)
MM_pop
,
0
,
"pop() -- Remove and return the last data source added"
},
"pop() -- Remove and return the last data source added"
},
{
NULL
,
NULL
}
/* sentinel */
{
NULL
,
NULL
}
/* sentinel */
};
};
...
@@ -234,12 +219,30 @@ void
...
@@ -234,12 +219,30 @@ void
initMultiMapping
()
initMultiMapping
()
{
{
PyObject
*
m
,
*
d
;
PyObject
*
m
,
*
d
;
char
*
rev
=
"$Revision: 1.3 $"
;
m
=
Py_InitModule4
(
"MultiMapping"
,
MultiMapping_methods
,
m
=
Py_InitModule4
(
"MultiMapping"
,
MultiMapping_methods
,
"MultiMapping -- Wrap multiple mapping objects for lookup"
,
"MultiMapping -- Wrap multiple mapping objects for lookup"
,
(
PyObject
*
)
NULL
,
PYTHON_API_VERSION
);
(
PyObject
*
)
NULL
,
PYTHON_API_VERSION
);
d
=
PyModule_GetDict
(
m
);
d
=
PyModule_GetDict
(
m
);
PyExtensionClass_Export
(
d
,
"MultiMapping"
,
MMtype
);
PyExtensionClass_Export
(
d
,
"MultiMapping"
,
MMtype
);
PyDict_SetItemString
(
d
,
"__version__"
,
PyString_FromStringAndSize
(
rev
+
11
,
strlen
(
rev
+
11
)
-
2
));
if
(
PyErr_Occurred
())
Py_FatalError
(
"can't initialize module MultiMapping"
);
if
(
PyErr_Occurred
())
Py_FatalError
(
"can't initialize module MultiMapping"
);
}
}
/*****************************************************************************
$Log: MultiMapping.c,v $
Revision 1.3 1997/02/17 16:34:09 jim
Made changes to be more useful for DocumentTemplates.
Revision 1.2 1996/10/23 18:37:45 jim
Fixed misspelling in class name.
Revision 1.1 1996/10/22 22:27:42 jim
*** empty log message ***
*****************************************************************************/
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