Change static string in header file to extern

- static will unnecessarily create and intialize a string in the data segment of each compiled cpp that includes it
This commit is contained in:
dand-oss 2012-09-21 21:16:58 -05:00
commit 51611517de
2 changed files with 59 additions and 55 deletions

View file

@ -30,6 +30,8 @@
#include "wrap.h" #include "wrap.h"
const char PYCAP_OBJECT_NAME[] = "llvm.wrap.h";
/*===----------------------------------------------------------------------===*/ /*===----------------------------------------------------------------------===*/
/* Type ctor/dtor */ /* Type ctor/dtor */
/*===----------------------------------------------------------------------===*/ /*===----------------------------------------------------------------------===*/

View file

@ -91,7 +91,7 @@ typedef long long llvmwrap_ll;
/* Type ctor/dtor */ /* Type ctor/dtor */
/*===----------------------------------------------------------------------===*/ /*===----------------------------------------------------------------------===*/
static const char PYCAP_OBJECT_NAME[] = "llvm.wrap.h"; extern const char PYCAP_OBJECT_NAME[] ;
// Cast python object to aTYPE // Cast python object to aTYPE
template <typename aTYPE> template <typename aTYPE>
@ -180,7 +180,6 @@ PyObject* make_list( aTYPE p[], size_t n )
****************************************************************************** ******************************************************************************
*****************************************************************************/ *****************************************************************************/
#define _wrap_none2none(func) \ #define _wrap_none2none(func) \
static PyObject * \ static PyObject * \
_w ## func(PyObject * self, PyObject * args) \ _w ## func(PyObject * self, PyObject * args) \
@ -223,7 +222,7 @@ _w ## func (PyObject *self, PyObject *args) \
return NULL; \ return NULL; \
\ \
return pycap_new<outtype>( func( arg1 ) ); \ return pycap_new<outtype>( func( arg1 ) ); \
_CATCH_ALL \ _CATCH_ALL \
} }
/** /**
@ -576,7 +575,7 @@ _w ## func (PyObject *self, PyObject *args) \
static PyObject * \ static PyObject * \
_w ## func (PyObject *self, PyObject *args) \ _w ## func (PyObject *self, PyObject *args) \
{ \ { \
_TRY \ _TRY \
PyObject *obj1, *obj2; \ PyObject *obj1, *obj2; \
int arg3; \ int arg3; \
\ \
@ -977,70 +976,73 @@ _w ## func (PyObject *self, PyObject *args) \
* Wrap LLVM functions of the type * Wrap LLVM functions of the type
* outtype func(intype1 arg1, intype2 arg2, intype3 arg3, intype arg4) * outtype func(intype1 arg1, intype2 arg2, intype3 arg3, intype arg4)
*/ */
#define _wrap_objobjobjobj2obj(func, intype1, intype2, intype3, intype4, outtype) \ #define _wrap_objobjobjobj2obj(func, intype1, intype2, intype3, \
static PyObject * \ intype4, outtype) \
_w ## func (PyObject *self, PyObject *args) \ static PyObject * \
{ \ _w ## func (PyObject *self, PyObject *args) \
_TRY \ { \
PyObject *obj1, *obj2, *obj3, *obj4; \ _TRY \
\ PyObject *obj1, *obj2, *obj3, *obj4; \
if (!PyArg_ParseTuple(args, "OOOO", &obj1, &obj2, &obj3, &obj4)) \ \
return NULL; \ if (!PyArg_ParseTuple(args, "OOOO", &obj1, &obj2, &obj3, &obj4)) \
\ return NULL; \
const intype1 arg1 = pycap_get< intype1 > (obj1); \ \
const intype2 arg2 = pycap_get< intype2 > (obj2); \ const intype1 arg1 = pycap_get< intype1 > (obj1); \
const intype3 arg3 = pycap_get< intype3 > (obj3); \ const intype2 arg2 = pycap_get< intype2 > (obj2); \
const intype4 arg4 = pycap_get< intype4 > (obj4); \ const intype3 arg3 = pycap_get< intype3 > (obj3); \
return pycap_new<outtype>( func( arg1, arg2, arg3, arg4 ) ); \ const intype4 arg4 = pycap_get< intype4 > (obj4); \
_CATCH_ALL \ return pycap_new<outtype>( func( arg1, arg2, arg3, arg4 ) );\
_CATCH_ALL \
} }
/** /**
* Wrap LLVM functions of the type * Wrap LLVM functions of the type
* outtype func(intype1 arg1, intype2 arg2, intype3 arg3, intype arg4, const char *arg5) * outtype func(intype1 arg1, intype2 arg2, intype3 arg3, intype arg4, const char *arg5)
*/ */
#define _wrap_objobjobjobjstr2obj(func, intype1, intype2, intype3, intype4, outtype)\ #define _wrap_objobjobjobjstr2obj(func, intype1, intype2, intype3, \
static PyObject * \ intype4, outtype)\
_w ## func (PyObject *self, PyObject *args) \ static PyObject * \
{ \ _w ## func (PyObject *self, PyObject *args) \
_TRY \ { \
PyObject *obj1, *obj2, *obj3, *obj4; \ _TRY \
const char *arg5; \ PyObject *obj1, *obj2, *obj3, *obj4; \
\ const char *arg5; \
\
if (!PyArg_ParseTuple(args, "OOOOs", &obj1, &obj2, &obj3, &obj4, &arg5)) \ if (!PyArg_ParseTuple(args, "OOOOs", &obj1, &obj2, &obj3, &obj4, &arg5)) \
return NULL; \ return NULL; \
\ \
const intype1 arg1 = pycap_get< intype1 > (obj1); \ const intype1 arg1 = pycap_get< intype1 > (obj1); \
const intype2 arg2 = pycap_get< intype2 > (obj2); \ const intype2 arg2 = pycap_get< intype2 > (obj2); \
const intype3 arg3 = pycap_get< intype3 > (obj3); \ const intype3 arg3 = pycap_get< intype3 > (obj3); \
const intype4 arg4 = pycap_get< intype4 > (obj4); \ const intype4 arg4 = pycap_get< intype4 > (obj4); \
\ \
return pycap_new<outtype>( func( arg1, arg2, arg3, arg4, arg5 ) ); \ return pycap_new<outtype>( func( arg1, arg2, arg3, arg4, arg5 ) );\
_CATCH_ALL \ _CATCH_ALL \
} }
/** /**
* Wrap LLVM functions of the type * Wrap LLVM functions of the type
* outtype func(intype1 arg1, enum_intype2 arg2, intype3 arg3, intype4 arg4, const char *arg5) * outtype func(intype1 arg1, enum_intype2 arg2, intype3 arg3, intype4 arg4, const char *arg5)
*/ */
#define _wrap_objenumobjobjstr2obj(func, intype1, intype2, intype3, intype4, outtype) \ #define _wrap_objenumobjobjstr2obj(func, intype1, intype2, intype3, \
static PyObject * \ intype4, outtype) \
_w ## func (PyObject *self, PyObject *args) \ static PyObject * \
{ \ _w ## func (PyObject *self, PyObject *args) \
_TRY \ { \
PyObject *obj1, *obj3, *obj4; \ _TRY \
intype2 arg2 ; \ PyObject *obj1, *obj3, *obj4; \
const char *arg5; \ intype2 arg2 ; \
\ const char *arg5; \
if (!PyArg_ParseTuple(args, "OiOOs", &obj1, &arg2, &obj3, &obj4, &arg5)) \ \
return NULL; \ if (!PyArg_ParseTuple(args, "OiOOs", &obj1, &arg2, &obj3, &obj4, &arg5)) \
\ return NULL; \
const intype1 arg1 = pycap_get< intype1 > (obj1); \ \
const intype3 arg3 = pycap_get< intype3 > (obj3); \ const intype1 arg1 = pycap_get< intype1 > (obj1); \
const intype4 arg4 = pycap_get< intype4 > (obj4); \ const intype3 arg3 = pycap_get< intype3 > (obj3); \
\ const intype4 arg4 = pycap_get< intype4 > (obj4); \
return pycap_new<outtype>( func( arg1, arg2, arg3, arg4, arg5 ) ); \ \
_CATCH_ALL \ return pycap_new<outtype>( func( arg1, arg2, arg3, arg4, arg5 ) ); \
_CATCH_ALL \
} }
/** /**