diff options
-rw-r--r-- | SetupConfig.py | 2 | ||||
-rw-r--r-- | src/Filters.py | 4 | ||||
-rw-r--r-- | src/Tests/Performance.py | 4 | ||||
-rw-r--r-- | src/c/Cheetah.h | 82 | ||||
-rw-r--r-- | src/c/_filters.c | 43 | ||||
-rw-r--r-- | src/c/_verifytype.c | 6 |
6 files changed, 134 insertions, 7 deletions
diff --git a/SetupConfig.py b/SetupConfig.py index fcbe9db..047416f 100644 --- a/SetupConfig.py +++ b/SetupConfig.py @@ -44,6 +44,8 @@ if os.name == 'posix': ), Extension("Cheetah._verifytype", [os.path.join('src', 'c', '_verifytype.c')]), + Extension("Cheetah._filters", + [os.path.join('src', 'c', '_filters.c')]), ] else: ext_modules=[] diff --git a/src/Filters.py b/src/Filters.py index b37341c..9b9a416 100644 --- a/src/Filters.py +++ b/src/Filters.py @@ -46,7 +46,6 @@ class Filter(object): RawOrEncodedUnicode = Filter - class EncodeUnicode(Filter): def filter(self, val, encoding='utf8', @@ -235,6 +234,7 @@ def test(): print "Unicode:", `EncodeUnicode().filter(u'aoeu12345\u1234')` -if __name__ == "__main__": test() +if __name__ == "__main__": + test() # vim: shiftwidth=4 tabstop=4 expandtab diff --git a/src/Tests/Performance.py b/src/Tests/Performance.py index 96ec7a2..723f251 100644 --- a/src/Tests/Performance.py +++ b/src/Tests/Performance.py @@ -152,10 +152,6 @@ class FilterTest(PerformanceTest): def performanceSample(self): value = unicode(self.template) - - - - if __name__ == '__main__': if '--debug' in sys.argv: DEBUG = True diff --git a/src/c/Cheetah.h b/src/c/Cheetah.h new file mode 100644 index 0000000..8559391 --- /dev/null +++ b/src/c/Cheetah.h @@ -0,0 +1,82 @@ +/* + * (c) 2009, R. Tyler Ballance <tyler@slide.com> + */ + +#ifndef _CHEETAH_H_ +#define _CHEETAH_H_ + +#include <Python.h> + +#ifdef __cplusplus +extern "C" { +#endif + + +/* + * Filter Module + */ +typedef struct { + PyObject_HEAD + /* type specific fields */ +} PyFilter; + +static PyObject *py_filter(PyObject *self, PyObject *args, PyObject *kwargs); + +static struct PyMethodDef py_filtermethods[] = { + {"filter", (PyCFunction)(py_filter), METH_STATIC | METH_VARAGES | 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 + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/c/_filters.c b/src/c/_filters.c new file mode 100644 index 0000000..2f7cd5f --- /dev/null +++ b/src/c/_filters.c @@ -0,0 +1,43 @@ +/* + * C-version of the src/Filters.py module + * + * (c) 2009, R. Tyler Ballance <tyler@slide.com> + */ +#include <Python.h> + +#include "Cheetah.h" + +#include <stdbool.h> + +#ifdef __cplusplus +extern "C" { +#endif + + +static PyObject *py_filter(PyObject *self, PyObject *args, PyObject *kwargs) +{ +} + +static const char _filtersdoc[] = "\ +\n\ +"; +static struct PyMethodDef _filters_methods[] = { + {NULL} +}; + +PyMODINIT_FUNC init_filters() +{ + PyObject *module = Py_InitModule3("_filters", _filters_methods, _filtersdoc); + + PyFilterType.tp_new = PyType_GenericNew; + if (PyType_Ready(&PyFilterType) < 0) + return; + + Py_INCREF(&PyFilterType); + + PyModule_AddObject(module, "Filter", (PyObject *)(&PyFilterType)); +} + +#ifdef __cplusplus +} +#endif diff --git a/src/c/_verifytype.c b/src/c/_verifytype.c index 33c6c13..290440d 100644 --- a/src/c/_verifytype.c +++ b/src/c/_verifytype.c @@ -1,4 +1,8 @@ - +/* + * C-version of the src/Utils/VerifyType.py module. + * + * (c) 2009, R. Tyler Ballance <tyler@slide.com> + */ #include <Python.h> #include <stdbool.h> |