Commit 54c775b4 authored by Jim Fulton's avatar Jim Fulton

Moved macros for handling specific key or value types to separate

include files. This cleaned up the code quite a bit and should make it
pretty easy to add additional types in the future.
parent 54c9b1ce
#define NOVAL
#define INTKEY int
/* Setup template macros */
#define PREFIX "I"
#define INITMODULE initIBTree
#define DEFAULT_MAX_BUCKET_SIZE 100
#include "intkeymacros.h"
#include "novaluemacros.h"
#include "BTreeTemplate.c"
#define INTVAL int
#define INTKEY int
/* Setup template macros */
#define PREFIX "II"
#define INITMODULE initIIBTree
#define DEFAULT_MAX_BUCKET_SIZE 100
#include "intkeymacros.h"
#include "intvaluemacros.h"
#include "BTreeTemplate.c"
#define INTKEY int
#define PREFIX "IO"
#define DEFAULT_MAX_BUCKET_SIZE 32
#define INITMODULE initIOBTree
#include "intkeymacros.h"
#include "objectvaluemacros.h"
#include "BTreeTemplate.c"
#define NOVAL
#define PREFIX "O"
#define INITMODULE initOBTree
#define DEFAULT_MAX_BUCKET_SIZE 100
#include "objectkeymacros.h"
#include "novaluemacros.h"
#include "BTreeTemplate.c"
#define INTVAL int
#define PREFIX "OI"
#define INITMODULE initOIBTree
#define DEFAULT_MAX_BUCKET_SIZE 64
#include "objectkeymacros.h"
#include "intvaluemacros.h"
#include "BTreeTemplate.c"
#define PREFIX "OO"
#define INITMODULE initOOBTree
#define DEFAULT_MAX_BUCKET_SIZE 32
#include "objectkeymacros.h"
#include "objectvaluemacros.h"
#include "BTreeTemplate.c"
#define KEY_TYPE int
#define KET_PARSE "i"
#define TEST_KEY(KEY, TARGET) ( (KEY) - (TARGET) )
#define DECREF_KEY(KEY)
#define INCREF_KEY(k)
#define COPY_KEY(KEY, E) (KEY=(E))
#define COPY_KEY_TO_OBJECT(O, K) O=PyInt_FromLong(K)
#define COPY_KEY_FROM_ARG(TARGET, ARG, STATUS) \
if (PyInt_Check(ARG)) TARGET=PyInt_AsLong(ARG); else { \
PyErr_SetString(PyExc_TypeError, "expected integer key"); \
*(STATUS)=0; }
#define VALUE_TYPE int
#define DECLARE_VALUE(NAME) VALUE_TYPE NAME
#define VALUE_PARSE "i"
#define DECREF_VALUE(k)
#define INCREF_VALUE(k)
#define COPY_VALUE(V, E) (V=(E))
#define COPY_VALUE_TO_OBJECT(O, K) O=PyInt_FromLong(K)
#define COPY_VALUE_FROM_ARG(TARGET, ARG, STATUS) \
if (PyInt_Check(ARG)) TARGET=PyInt_AsLong(ARG); else { \
PyErr_SetString(PyExc_TypeError, "expected integer value"); \
*(STATUS)=0; }
#define NOVAL
#define DECLARE_VALUE(NAME)
#define DECREF_VALUE(k)
#define INCREF_VALUE(k)
#define COPY_VALUE(V, E)
#define COPY_VALUE_TO_OBJECT(O, K)
#define COPY_VALUE_FROM_ARG(TARGET, ARG, S)
#define KEY_TYPE PyObject *
#define TEST_KEY(KEY, TARGET) PyObject_Compare((KEY),(TARGET))
#define INCREF_KEY(k) Py_INCREF(k)
#define DECREF_KEY(KEY) Py_DECREF(KEY)
#define COPY_KEY(KEY, E) KEY=(E)
#define COPY_KEY_TO_OBJECT(O, K) O=(K); Py_INCREF(O)
#define COPY_KEY_FROM_ARG(TARGET, ARG, S) TARGET=(ARG)
#define VALUE_TYPE PyObject *
#define DECLARE_VALUE(NAME) VALUE_TYPE NAME
#define INCREF_VALUE(k) Py_INCREF(k)
#define DECREF_VALUE(k) Py_DECREF(k)
#define COPY_VALUE(k,e) k=(e)
#define COPY_VALUE_TO_OBJECT(O, K) O=(K); Py_INCREF(O)
#define COPY_VALUE_FROM_ARG(TARGET, ARG, S) TARGET=(ARG)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment