+++ /dev/null
-"""framer's C code templates.\r
-\r
-Templates use the following variables:\r
-\r
-FileName: name of the file that contains the C source code\r
-ModuleName: name of the module, as in "import ModuleName"\r
-ModuleDocstring: C string containing the module doc string\r
-"""\r
-\r
-module_start = '#include "Python.h"'\r
-member_include = '#include "structmember.h"'\r
-\r
-module_doc = """\\r
-PyDoc_STRVAR(%(ModuleName)s_doc,\r
-%(ModuleDocstring)s);\r
-"""\r
-\r
-methoddef_start = """\\r
-static struct PyMethodDef %(MethodDefName)s[] = {"""\r
-\r
-methoddef_def = """\\r
- {"%(PythonName)s", (PyCFunction)%(CName)s, %(MethType)s},"""\r
-\r
-methoddef_def_doc = """\\r
- {"%(PythonName)s", (PyCFunction)%(CName)s, %(MethType)s,\r
- %(DocstringVar)s},"""\r
-\r
-methoddef_end = """\\r
- {NULL, NULL}\r
-};\r
-"""\r
-\r
-memberdef_start = """\\r
-#define OFF(X) offsetof(%(StructName)s, X)\r
-\r
-static struct PyMemberDef %(MemberDefName)s[] = {"""\r
-\r
-memberdef_def_doc = """\\r
- {"%(PythonName)s", %(Type)s, OFF(%(CName)s), %(Flags)s,\r
- %(Docstring)s},"""\r
-\r
-memberdef_def = """\\r
- {"%(PythonName)s", %(Type)s, OFF(%(CName)s), %(Flags)s},"""\r
-\r
-memberdef_end = """\\r
- {NULL}\r
-};\r
-\r
-#undef OFF\r
-"""\r
-\r
-dealloc_func = """static void\r
-%(name)s(PyObject *ob)\r
-{\r
-}\r
-"""\r
-\r
-docstring = """\\r
-PyDoc_STRVAR(%(DocstringVar)s,\r
-%(Docstring)s);\r
-"""\r
-\r
-funcdef_start = """\\r
-static PyObject *\r
-%(name)s(%(args)s)\r
-{"""\r
-\r
-funcdef_end = """\\r
-}\r
-"""\r
-\r
-varargs = """\\r
- if (!PyArg_ParseTuple(args, \"%(ArgParse)s:%(PythonName)s\",\r
- %(ArgTargets)s))\r
- return NULL;"""\r
-\r
-module_init_start = """\\r
-PyMODINIT_FUNC\r
-init%(ModuleName)s(void)\r
-{\r
- PyObject *mod;\r
-\r
- mod = Py_InitModule3("%(ModuleName)s", %(MethodDefName)s,\r
- %(ModuleName)s_doc);\r
- if (mod == NULL)\r
- return;\r
-"""\r
-\r
-type_init_type = " %(CTypeName)s.ob_type = &PyType_Type;"\r
-module_add_type = """\\r
- if (!PyObject_SetAttrString(mod, "%(TypeName)s",\r
- (PyObject *)&%(CTypeName)s))\r
- return;\r
-"""\r
-\r
-type_struct_start = """\\r
-static PyTypeObject %(CTypeName)s = {\r
- PyObject_HEAD_INIT(0)"""\r
-\r
-type_struct_end = """\\r
-};\r
-"""\r