diff options
author | Joshua Haberman <joshua@reverberate.org> | 2009-08-24 21:44:22 -0700 |
---|---|---|
committer | Joshua Haberman <joshua@reverberate.org> | 2009-08-24 21:44:22 -0700 |
commit | 040f7e6ba2e2282b80f332a031b77d7d34b4fc85 (patch) | |
tree | 1d5e273fb9fcca51f6ce299b766ee0a97ee92863 /lang_ext/python/cext.h | |
parent | a223f9af30738cf00c313fabee8de75d04fb9a1a (diff) |
Significant memory-management refactoring any Python extension.
Diffstat (limited to 'lang_ext/python/cext.h')
-rw-r--r-- | lang_ext/python/cext.h | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/lang_ext/python/cext.h b/lang_ext/python/cext.h new file mode 100644 index 0000000..e0e7832 --- /dev/null +++ b/lang_ext/python/cext.h @@ -0,0 +1,48 @@ +/* + * upb - a minimalist implementation of protocol buffers. + * + * Copyright (c) 2009 Joshua Haberman. See LICENSE for details. + * + */ + +#ifndef UPB_PYTHON_CEXT_H_ +#define UPB_PYTHON_CEXT_H_ + +#include <Python.h> + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + PyObject_HEAD + struct upb_context *context; + PyObject *created_defs; +} PyUpb_Context; + +typedef struct { + PyObject_HEAD + struct upb_msgdef *def; + PyUpb_Context *context; +} PyUpb_MsgDef; + +extern PyTypeObject PyUpb_MsgDefType; + +/* What format string should be passed to PyArg_ParseTuple to get just a raw + * string of bytes and a length. */ +#if PY_MAJOR_VERSION >= 3 +#define BYTES_FORMAT "y#" +#else +#define BYTES_FORMAT "s#" +#endif + +#define RETURN_BOOL(val) if(val) { Py_RETURN_TRUE; } else { Py_RETURN_FALSE; } + +extern PyMODINIT_FUNC initdefinition(void); +extern PyMODINIT_FUNC initpb(void); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif |