From 040f7e6ba2e2282b80f332a031b77d7d34b4fc85 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Mon, 24 Aug 2009 21:44:22 -0700 Subject: Significant memory-management refactoring any Python extension. --- lang_ext/python/definition.h | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'lang_ext/python/definition.h') diff --git a/lang_ext/python/definition.h b/lang_ext/python/definition.h index 8731b8a..040019d 100644 --- a/lang_ext/python/definition.h +++ b/lang_ext/python/definition.h @@ -16,16 +16,30 @@ extern "C" { #endif +typedef struct { + PyObject_HEAD + struct upb_context *context; +} PyUpb_Context; + typedef struct { PyObject_HEAD struct upb_msgdef *def; -} PyUpb_MessageDefinition; + PyUpb_Context *context; +} PyUpb_MsgDef; -extern PyTypeObject PyUpb_MessageDefinitionType; +extern PyTypeObject PyUpb_MsgDefType; /* What format string should be passed to PyArg_ParseTuple to get just a raw * string of bytes and a length. */ -extern const char *bytes_format; +#if PY_MAJOR_VERSION >= 3 +#define BYTES_FORMAT "y#" +#else +#define BYTES_FORMAT "s#" +#endif + +PyUpb_MsgDef *get_or_create_msgdef(struct upb_msgdef *def); + +#define RETURN_BOOL(val) if(val) { Py_RETURN_TRUE; } else { Py_RETURN_FALSE; } #ifdef __cplusplus } /* extern "C" */ -- cgit v1.2.3