summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Abbatiello <abbeyj@gmail.com>2009-06-27 22:27:14 -0400
committerJames Abbatiello <abbeyj@gmail.com>2009-06-27 22:27:14 -0400
commit8b01514e036c80c275da3c45e633a59015a105b7 (patch)
treec5c51e5c693e3d73a831dde4560b3a042f73a407
parenta69bfd38841871efcb163d0ce36573836271284e (diff)
downloadpython-cheetah-8b01514e036c80c275da3c45e633a59015a105b7.tar.gz
Fix extension compile under MSVC
-rw-r--r--src/c/Cheetah.h51
-rw-r--r--src/c/_filters.c55
-rw-r--r--src/c/_verifytype.c16
3 files changed, 62 insertions, 60 deletions
diff --git a/src/c/Cheetah.h b/src/c/Cheetah.h
index b7b3032..d149c15 100644
--- a/src/c/Cheetah.h
+++ b/src/c/Cheetah.h
@@ -36,57 +36,6 @@ typedef struct {
/* type specific fields */
} PyFilter;
-static PyObject *py_filter(PyObject *self, PyObject *args, PyObject *kwargs);
-
-static struct PyMethodDef py_filtermethods[] = {
- {"filter", (PyCFunction)(py_filter), METH_VARARGS | METH_KEYWORDS,
- PyDoc_STR("Filter stuff")},
- {NULL},
-};
-static PyTypeObject PyFilterType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
- "_filters.Filter", /*tp_name*/
- sizeof(PyFilter), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- 0, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash */
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT, /*tp_flags*/
- "Filter object", /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- py_filtermethods, /* tp_methods */
-#if 0
- py_filtermembers, /* tp_members */
- 0, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)Noddy_init, /* tp_init */
- 0, /* tp_alloc */
- NULL, /* tp_new */
-#endif
-};
-
/*
* End Filter Module
*/
diff --git a/src/c/_filters.c b/src/c/_filters.c
index b74a1bd..c81b3bd 100644
--- a/src/c/_filters.c
+++ b/src/c/_filters.c
@@ -7,7 +7,11 @@
#include "Cheetah.h"
+#if __STDC_VERSION__ >= 199901L
#include <stdbool.h>
+#else
+typedef enum { false, true } bool;
+#endif
#ifdef __cplusplus
extern "C" {
@@ -22,13 +26,58 @@ static PyObject *py_filter(PyObject *self, PyObject *args, PyObject *kwargs)
static const char _filtersdoc[] = "\
\n\
";
-static struct PyMethodDef _filters_methods[] = {
- {NULL}
+static struct PyMethodDef py_filtermethods[] = {
+ {"filter", (PyCFunction)(py_filter), METH_VARARGS | METH_KEYWORDS,
+ PyDoc_STR("Filter stuff")},
+ {NULL},
+};
+static PyTypeObject PyFilterType = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /*ob_size*/
+ "_filters.Filter", /*tp_name*/
+ sizeof(PyFilter), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ 0, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT, /*tp_flags*/
+ "Filter object", /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ py_filtermethods, /* tp_methods */
+#if 0
+ py_filtermembers, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)Noddy_init, /* tp_init */
+ 0, /* tp_alloc */
+ NULL, /* tp_new */
+#endif
};
PyMODINIT_FUNC init_filters()
{
- PyObject *module = Py_InitModule3("_filters", _filters_methods, _filtersdoc);
+ PyObject *module = Py_InitModule3("_filters", py_filtermethods, _filtersdoc);
PyFilterType.tp_new = PyType_GenericNew;
if (PyType_Ready(&PyFilterType) < 0)
diff --git a/src/c/_verifytype.c b/src/c/_verifytype.c
index 06ff947..71cd874 100644
--- a/src/c/_verifytype.c
+++ b/src/c/_verifytype.c
@@ -4,7 +4,11 @@
* (c) 2009, R. Tyler Ballance <tyler@slide.com>
*/
#include <Python.h>
+#if __STDC_VERSION__ >= 199901L
#include <stdbool.h>
+#else
+typedef enum { false, true } bool;
+#endif
#include "Cheetah.h"
@@ -36,7 +40,7 @@ static PyObject *py_verifytype(PyObject *self, PyObject *args, PyObject *kwargs)
}
while (item = PyIter_Next(iterator)) {
- if (argument->ob_type == item) {
+ if ((PyObject *)argument->ob_type == item) {
rc = true;
Py_DECREF(item);
break;
@@ -55,8 +59,8 @@ static PyObject *py_verifytype(PyObject *self, PyObject *args, PyObject *kwargs)
static PyObject *py_verifytypeclass(PyObject *self, PyObject *args, PyObject *kwargs)
{
- PyObject *argument, *legalTypes, *klass, *classType;
- PyObject *verifyTypeArgs, *verifyTypeKwargs;
+ PyObject *argument, *legalTypes, *klass;
+ PyObject *verifyTypeArgs, *v;
char *arg_string, *types_string, *extra;
bool rc = false;
@@ -69,7 +73,7 @@ static PyObject *py_verifytypeclass(PyObject *self, PyObject *args, PyObject *kw
verifyTypeArgs = Py_BuildValue("OsOs", argument, arg_string, legalTypes,
types_string);
- PyObject *v = py_verifytype(self, verifyTypeArgs, NULL);
+ v = py_verifytype(self, verifyTypeArgs, NULL);
if (PyErr_Occurred())
return NULL;
@@ -86,8 +90,8 @@ static const char _verifytypedoc[] = "\
\n\
";
static struct PyMethodDef _verifytype_methods[] = {
- {"verifyType", py_verifytype, METH_VARARGS | METH_KEYWORDS, NULL},
- {"verifyTypeClass", py_verifytypeclass, METH_VARARGS | METH_KEYWORDS, NULL},
+ {"verifyType", (PyCFunction)py_verifytype, METH_VARARGS | METH_KEYWORDS, NULL},
+ {"verifyTypeClass", (PyCFunction)py_verifytypeclass, METH_VARARGS | METH_KEYWORDS, NULL},
{NULL}
};