C++ cleanup of old C conventions - prefer C++ casting to unsafe C style casts - use templates to encapsulate casting - prefer new to malloc - apply const when possible - decalare variables as near to use as possible

This commit is contained in:
dand-oss 2012-09-09 19:57:26 -05:00 • committed by Siu Kwan Lam
commit db00a6b8de
3 changed files with 265 additions and 388 deletions

View file

@ -51,9 +51,6 @@
typedef unsigned int LLVMLinkerMode; typedef unsigned int LLVMLinkerMode;
#endif #endif
/* libc includes */
#include <stdarg.h> /* for malloc(), free() */
/* Compatibility with Python 2.4: Py_ssize_t is not available. */ /* Compatibility with Python 2.4: Py_ssize_t is not available. */
#ifndef PY_SSIZE_T_MAX #ifndef PY_SSIZE_T_MAX
typedef int Py_ssize_t; typedef int Py_ssize_t;
@ -67,13 +64,12 @@ static PyObject *
_wLLVMModuleCreateWithName(PyObject *self, PyObject *args) _wLLVMModuleCreateWithName(PyObject *self, PyObject *args)
{ {
const char *s; const char *s;
LLVMModuleRef module;
if (!PyArg_ParseTuple(args, "s:LLVMModuleCreateWithName", &s)) { if (!PyArg_ParseTuple(args, "s:LLVMModuleCreateWithName", &s)) {
return NULL; return NULL;
} }
module = LLVMModuleCreateWithName(s); const LLVMModuleRef module = LLVMModuleCreateWithName(s);
return ctor_LLVMModuleRef(module); return ctor_LLVMModuleRef(module);
} }
@ -95,16 +91,13 @@ _wrap_objstrobj2obj(LLVMModuleGetOrInsertFunction, LLVMModuleRef,
static PyObject * static PyObject *
_wLLVMVerifyModule(PyObject *self, PyObject *args) _wLLVMVerifyModule(PyObject *self, PyObject *args)
{ {
char *outmsg; const LLVMModuleRef m = get_object_arg<LLVMModuleRef>(args) ;
PyObject *ret; if (!m) return NULL;
LLVMModuleRef m;
if (!(m = (LLVMModuleRef)get_object_arg(args))) char *outmsg = 0;
return NULL;
outmsg = 0;
(void) LLVMVerifyModule(m, LLVMReturnStatusAction, &outmsg); (void) LLVMVerifyModule(m, LLVMReturnStatusAction, &outmsg);
PyObject *ret;
if (outmsg) { if (outmsg) {
ret = PyUnicode_FromString(outmsg); ret = PyUnicode_FromString(outmsg);
LLVMDisposeMessage(outmsg); LLVMDisposeMessage(outmsg);
@ -122,13 +115,13 @@ _wLLVMVerifyModule(PyObject *self, PyObject *args)
static PyObject* static PyObject*
_wLLVMGetModuleFromAssembly(PyObject *self, PyObject *args) _wLLVMGetModuleFromAssembly(PyObject *self, PyObject *args)
{ {
char * str; const char * str;
if ( !PyArg_ParseTuple(args, "s", &str) ){ if ( !PyArg_ParseTuple(args, "s", &str) ){
return NULL; return NULL;
} }
char * outmsg = 0; char * outmsg = 0;
LLVMModuleRef mod = LLVMGetModuleFromAssembly(str, &outmsg); const LLVMModuleRef mod = LLVMGetModuleFromAssembly(str, &outmsg);
if ( !mod ){ if ( !mod ){
if ( outmsg ){ if ( outmsg ){
@ -146,19 +139,18 @@ _wLLVMGetModuleFromAssembly(PyObject *self, PyObject *args)
static PyObject * static PyObject *
_wLLVMGetModuleFromBitcode(PyObject *self, PyObject *args) _wLLVMGetModuleFromBitcode(PyObject *self, PyObject *args)
{ {
PyObject *obj, *ret; PyObject *obj ;
Py_ssize_t len;
char *start, *outmsg;
LLVMModuleRef m;
if (!PyArg_ParseTuple(args, "S", &obj)) if (!PyArg_ParseTuple(args, "S", &obj))
return NULL; return NULL;
start = PyBytes_AsString(obj); const char *start = PyBytes_AsString(obj);
len = PyBytes_Size(obj); const Py_ssize_t len = PyBytes_Size(obj);
outmsg = 0; char *outmsg = 0;
m = LLVMGetModuleFromBitcode(start, len, &outmsg); LLVMModuleRef m = LLVMGetModuleFromBitcode(start, len, &outmsg);
PyObject *ret;
if (!m) { if (!m) {
if (outmsg) { if (outmsg) {
ret = PyUnicode_FromString(outmsg); ret = PyUnicode_FromString(outmsg);
@ -175,29 +167,23 @@ _wLLVMGetModuleFromBitcode(PyObject *self, PyObject *args)
static PyObject * static PyObject *
_wLLVMGetBitcodeFromModule(PyObject *self, PyObject *args) _wLLVMGetBitcodeFromModule(PyObject *self, PyObject *args)
{ {
PyObject *ret;
unsigned len;
unsigned char *bytes;
LLVMModuleRef m;
if (!(m = (LLVMModuleRef)get_object_arg(args))) const LLVMModuleRef m = get_object_arg<LLVMModuleRef>(args) ;
return NULL; if (!m ) return NULL;
if (!(bytes = LLVMGetBitcodeFromModule(m, &len))) size_t len;
Py_RETURN_NONE; unsigned const char *ubytes = LLVMGetBitcodeFromModule(m, &len) ;
if ( !ubytes ) Py_RETURN_NONE;
ret = PyBytes_FromStringAndSize((char *)bytes, (Py_ssize_t)len); const char *chars = reinterpret_cast<const char*>(ubytes) ;
LLVMDisposeMessage((char *)bytes); PyObject *ret = PyBytes_FromStringAndSize(chars, len);
LLVMDisposeMessage(const_cast<char*>(chars));
return ret; return ret;
} }
static PyObject * static PyObject *
_wLLVMGetNativeCodeFromModule(PyObject * self, PyObject * args) _wLLVMGetNativeCodeFromModule(PyObject * self, PyObject * args)
{ {
PyObject * ret;
unsigned len;
unsigned char * bytes;
LLVMModuleRef m;
PyObject * arg_m; PyObject * arg_m;
int arg_use_asm; int arg_use_asm;
@ -205,33 +191,38 @@ _wLLVMGetNativeCodeFromModule(PyObject * self, PyObject * args)
if (!PyArg_ParseTuple(args, "Oi", &arg_m, &arg_use_asm)) if (!PyArg_ParseTuple(args, "Oi", &arg_m, &arg_use_asm))
return NULL; return NULL;
m = (LLVMModuleRef) PyCapsule_GetPointer(arg_m, NULL); const LLVMModuleRef m = pycap_get<LLVMModuleRef>( arg_m ) ;
std::string error; std::string error;
bytes = LLVMGetNativeCodeFromModule(m, arg_use_asm, &len, error); size_t len;
unsigned const char * ubytes
= LLVMGetNativeCodeFromModule(m, arg_use_asm, &len, error);
if ( !error.empty() ){ if ( !error.empty() ){
PyErr_SetString(PyExc_RuntimeError, error.c_str()); PyErr_SetString(PyExc_RuntimeError, error.c_str());
} }
ret = PyBytes_FromStringAndSize((char *)bytes, (Py_ssize_t)len); const char *chars = reinterpret_cast<const char*>(ubytes) ;
delete [] bytes; PyObject * ret = PyBytes_FromStringAndSize(chars, len);
LLVMDisposeMessage(const_cast<char*>(chars));
return ret; return ret;
} }
static PyObject * static PyObject *
_wLLVMLinkModules(PyObject *self, PyObject *args) _wLLVMLinkModules(PyObject *self, PyObject *args)
{ {
PyObject *dest_obj, *src_obj, *ret; size_t mode = 0;
LLVMModuleRef dest, src;
char *errmsg;
unsigned int mode = 0;
PyObject *dest_obj, *src_obj ;
if (!PyArg_ParseTuple(args, "OO|I", &dest_obj, &src_obj, &mode)) if (!PyArg_ParseTuple(args, "OO|I", &dest_obj, &src_obj, &mode))
return NULL; return NULL;
dest = (LLVMModuleRef) PyCapsule_GetPointer(dest_obj, NULL); const LLVMModuleRef dest = pycap_get<LLVMModuleRef>(dest_obj ) ;
src = (LLVMModuleRef) PyCapsule_GetPointer(src_obj, NULL); const LLVMModuleRef src = pycap_get<LLVMModuleRef>(src_obj) ;
PyObject *ret;
char *errmsg;
if (!LLVMLinkModules(dest, src, (LLVMLinkerMode)mode, &errmsg)) { if (!LLVMLinkModules(dest, src, (LLVMLinkerMode)mode, &errmsg)) {
if (errmsg) { if (errmsg) {
ret = PyUnicode_FromString(errmsg); ret = PyUnicode_FromString(errmsg);
@ -291,29 +282,27 @@ typedef unsigned (*arrcnt_fn_t)(LLVMTypeRef ty);
static PyObject * static PyObject *
obj2arr(PyObject *self, PyObject *args, arrcnt_fn_t cntfunc, obj2arr_fn_t arrfunc) obj2arr(PyObject *self, PyObject *args, arrcnt_fn_t cntfunc, obj2arr_fn_t arrfunc)
{ {
LLVMTypeRef type, *param_types; size_t param_count;
unsigned param_count;
PyObject *list;
/* get the function object ptr */ /* get the function object ptr */
if (!(type = (LLVMTypeRef)get_object_arg(args))) const LLVMTypeRef type = get_object_arg<LLVMTypeRef>(args) ;
return NULL; if (!type) return NULL;
/* get param count */ /* get param count */
param_count = cntfunc(type); param_count = cntfunc(type);
/* alloc enough space for all of them */ /* alloc enough space for all of them */
if (!(param_types = (LLVMTypeRef *)malloc(sizeof(LLVMTypeRef) * param_count))) LLVMTypeRef* param_types = new LLVMTypeRef[param_count] ;
return PyErr_NoMemory();
/* call LLVM func */ /* call LLVM func */
arrfunc(type, param_types); arrfunc(type, param_types);
/* create a list from the array */ /* create a list from the array */
list = make_list_from_LLVMTypeRef_array(param_types, param_count); PyObject *list
= make_list_from_LLVMTypeRef_array(param_types, param_count);
/* free temp storage */ /* free temp storage */
free(param_types); delete [] param_types ;
return list; return list;
} }
@ -337,7 +326,8 @@ _wrap_objstr2none(LLVMSetStructName, LLVMTypeRef)
static PyObject * static PyObject *
_wLLVMGetStructElementTypes(PyObject *self, PyObject *args) _wLLVMGetStructElementTypes(PyObject *self, PyObject *args)
{ {
return obj2arr(self, args, LLVMCountStructElementTypes, LLVMGetStructElementTypes); return obj2arr(self, args, LLVMCountStructElementTypes,
LLVMGetStructElementTypes);
} }
@ -392,13 +382,11 @@ _wrap_obj2obj(LLVMValueGetNumUses, LLVMValueRef, int)
static PyObject * static PyObject *
_wLLVMValueGetUses(PyObject *self, PyObject *args) _wLLVMValueGetUses(PyObject *self, PyObject *args)
{ {
LLVMValueRef value; const LLVMValueRef value = get_object_arg<LLVMValueRef>(args) ;
if (!value) return NULL;
if (!(value = (LLVMValueRef)get_object_arg(args)))
return NULL;
LLVMValueRef *uses = 0; LLVMValueRef *uses = 0;
unsigned n = LLVMValueGetUses(value, &uses); size_t n = LLVMValueGetUses(value, &uses);
PyObject *list = make_list_from_LLVMValueRef_array(uses, n); PyObject *list = make_list_from_LLVMValueRef_array(uses, n);
if (n > 0) if (n > 0)
@ -431,15 +419,14 @@ _wLLVMConstInt(PyObject *self, PyObject *args)
PyObject *obj; PyObject *obj;
unsigned long long n; unsigned long long n;
int sign_extend; int sign_extend;
LLVMTypeRef ty;
LLVMValueRef val;
if (!PyArg_ParseTuple(args, "OKi", &obj, &n, &sign_extend)) if (!PyArg_ParseTuple(args, "OKi", &obj, &n, &sign_extend))
return NULL; return NULL;
ty = (LLVMTypeRef) PyCapsule_GetPointer(obj, NULL); const LLVMTypeRef ty = pycap_get<LLVMTypeRef>( obj ) ;
const LLVMValueRef val = LLVMConstInt(ty, n, sign_extend);
val = LLVMConstInt(ty, n, sign_extend);
return ctor_LLVMValueRef(val); return ctor_LLVMValueRef(val);
} }
@ -448,15 +435,13 @@ _wLLVMConstReal(PyObject *self, PyObject *args)
{ {
PyObject *obj; PyObject *obj;
double d; double d;
LLVMTypeRef ty;
LLVMValueRef val;
if (!PyArg_ParseTuple(args, "Od", &obj, &d)) if (!PyArg_ParseTuple(args, "Od", &obj, &d))
return NULL; return NULL;
ty = (LLVMTypeRef) PyCapsule_GetPointer(obj, NULL); const LLVMTypeRef ty = pycap_get<LLVMTypeRef>( obj ) ;
val = LLVMConstReal(ty, d); const LLVMValueRef val = LLVMConstReal(ty, d);
return ctor_LLVMValueRef(val); return ctor_LLVMValueRef(val);
} }
@ -471,13 +456,12 @@ _wLLVMConstString(PyObject *self, PyObject *args)
{ {
const char *s; const char *s;
int dont_null_terminate; int dont_null_terminate;
LLVMValueRef val;
if (!PyArg_ParseTuple(args, "si:LLVMConstString", &s, &dont_null_terminate)) { if (!PyArg_ParseTuple(args, "si:LLVMConstString", &s, &dont_null_terminate)) {
return NULL; return NULL;
} }
val = LLVMConstString(s, strlen(s), dont_null_terminate); LLVMValueRef val = LLVMConstString(s, strlen(s), dont_null_terminate);
return ctor_LLVMValueRef(val); return ctor_LLVMValueRef(val);
} }
@ -590,10 +574,8 @@ _wrap_objenum2none(LLVMRemoveFunctionAttr, LLVMValueRef, LLVMAttribute)
static PyObject * static PyObject *
_wLLVMVerifyFunction(PyObject *self, PyObject *args) _wLLVMVerifyFunction(PyObject *self, PyObject *args)
{ {
LLVMValueRef fn; const LLVMValueRef fn = get_object_arg<LLVMValueRef>(args);
if (!fn) return NULL;
if (!(fn = (LLVMValueRef)get_object_arg(args)))
return NULL;
return ctor_int(LLVMVerifyFunction(fn, LLVMReturnStatusAction)); return ctor_int(LLVMVerifyFunction(fn, LLVMReturnStatusAction));
} }
@ -695,33 +677,28 @@ _wLLVMBuildInvoke(PyObject *self, PyObject *args)
{ {
PyObject *obj1, *obj2, *obj3, *obj4, *obj5; PyObject *obj1, *obj2, *obj3, *obj4, *obj5;
const char *name; const char *name;
LLVMBuilderRef builder;
LLVMValueRef func;
LLVMValueRef *fnargs;
unsigned fnarg_count;
LLVMBasicBlockRef then_blk, catch_blk;
LLVMValueRef inst;
if (!PyArg_ParseTuple(args, "OOOOOs:LLVMBuildInvoke", &obj1, &obj2, &obj3, &obj4, &obj5, &name)) { if (!PyArg_ParseTuple(args, "OOOOOs:LLVMBuildInvoke", &obj1, &obj2, &obj3, &obj4, &obj5, &name)) {
return NULL; return NULL;
} }
builder = (LLVMBuilderRef) PyCapsule_GetPointer(obj1, NULL); const LLVMBuilderRef builder = pycap_get<LLVMBuilderRef>( obj1);
func = (LLVMValueRef) PyCapsule_GetPointer(obj2, NULL); const LLVMValueRef func = pycap_get<LLVMValueRef>( obj2 ) ;
size_t fnarg_count = PyList_Size(obj3);
fnarg_count = (unsigned) PyList_Size(obj3); LLVMValueRef *fnargs
fnargs = (LLVMValueRef *)make_array_from_list(obj3, fnarg_count); = make_array_from_list<LLVMValueRef *>(obj3, fnarg_count);
if (!fnargs) if (!fnargs)
return PyErr_NoMemory(); return PyErr_NoMemory();
then_blk = (LLVMBasicBlockRef) PyCapsule_GetPointer(obj4, NULL); const LLVMBasicBlockRef then_blk = pycap_get<LLVMBasicBlockRef> ( obj4 ) ;
catch_blk = (LLVMBasicBlockRef) PyCapsule_GetPointer(obj5, NULL); const LLVMBasicBlockRef catch_blk = pycap_get<LLVMBasicBlockRef> ( obj5 ) ;
const LLVMValueRef inst
= LLVMBuildInvoke(builder, func, fnargs, fnarg_count, then_blk,
catch_blk, name);
inst = LLVMBuildInvoke(builder, func, fnargs, fnarg_count, then_blk, catch_blk, name); delete [] fnargs;
free(fnargs);
return ctor_LLVMValueRef(inst); return ctor_LLVMValueRef(inst);
} }
@ -819,13 +796,13 @@ _wLLVMCreateMemoryBufferWithContentsOfFile(PyObject *self, PyObject *args)
{ {
const char *path; const char *path;
LLVMMemoryBufferRef ref; LLVMMemoryBufferRef ref;
char *outmsg;
PyObject *ret; PyObject *ret;
if (!PyArg_ParseTuple(args, "s:LLVMCreateMemoryBufferWithContentsOfFile", &path)) { if (!PyArg_ParseTuple(args, "s:LLVMCreateMemoryBufferWithContentsOfFile", &path)) {
return NULL; return NULL;
} }
char *outmsg;
if (!LLVMCreateMemoryBufferWithContentsOfFile(path, &ref, &outmsg)) { if (!LLVMCreateMemoryBufferWithContentsOfFile(path, &ref, &outmsg)) {
ret = ctor_LLVMMemoryBufferRef(ref); ret = ctor_LLVMMemoryBufferRef(ref);
} else { } else {
@ -839,10 +816,9 @@ _wLLVMCreateMemoryBufferWithContentsOfFile(PyObject *self, PyObject *args)
static PyObject * static PyObject *
_wLLVMCreateMemoryBufferWithSTDIN(PyObject *self, PyObject *args) _wLLVMCreateMemoryBufferWithSTDIN(PyObject *self, PyObject *args)
{ {
PyObject *ret;
LLVMMemoryBufferRef ref; LLVMMemoryBufferRef ref;
char *outmsg; char *outmsg;
PyObject *ret;
if (!LLVMCreateMemoryBufferWithSTDIN(&ref, &outmsg)) { if (!LLVMCreateMemoryBufferWithSTDIN(&ref, &outmsg)) {
ret = ctor_LLVMMemoryBufferRef(ref); ret = ctor_LLVMMemoryBufferRef(ref);
} else { } else {
@ -1062,11 +1038,6 @@ _wLLVMTargetMachineLookup(PyObject * self, PyObject * args)
static PyObject * static PyObject *
_wLLVMTargetMachineEmitFile(PyObject * self, PyObject * args) _wLLVMTargetMachineEmitFile(PyObject * self, PyObject * args)
{ {
PyObject * ret;
unsigned len;
unsigned char * bytes;
LLVMTargetMachineRef tm;
LLVMModuleRef m;
PyObject *arg_tm, *arg_m; PyObject *arg_tm, *arg_m;
int arg_use_asm; int arg_use_asm;
@ -1074,18 +1045,22 @@ _wLLVMTargetMachineEmitFile(PyObject * self, PyObject * args)
if (!PyArg_ParseTuple(args, "OOi", &arg_tm, &arg_m, &arg_use_asm)) if (!PyArg_ParseTuple(args, "OOi", &arg_tm, &arg_m, &arg_use_asm))
return NULL; return NULL;
tm = (LLVMTargetMachineRef) PyCapsule_GetPointer(arg_tm, NULL); const LLVMTargetMachineRef tm
m = (LLVMModuleRef) PyCapsule_GetPointer(arg_m, NULL); = pycap_get<LLVMTargetMachineRef>( arg_tm ) ;
const LLVMModuleRef m = pycap_get<LLVMModuleRef>( arg_m ) ;
std::string error; std::string error;
bytes = LLVMTargetMachineEmitFile(tm, m, arg_use_asm, &len, error); size_t len;
unsigned const char * ubytes
= LLVMTargetMachineEmitFile(tm, m, arg_use_asm, &len, error);
if ( !error.empty() ){ if ( !error.empty() ){
PyErr_SetString(PyExc_RuntimeError, error.c_str()); PyErr_SetString(PyExc_RuntimeError, error.c_str());
return NULL; return NULL;
} }
ret = PyBytes_FromStringAndSize((char *)bytes, (Py_ssize_t)len); const char *chars = reinterpret_cast<const char*>(ubytes) ;
delete [] bytes; PyObject * ret = PyBytes_FromStringAndSize(chars, len);
delete [] ubytes;
return ret; return ret;
} }
@ -1109,15 +1084,11 @@ _wrap_obj2none(LLVMDisposeTargetData, LLVMTargetDataRef)
static PyObject * static PyObject *
_wLLVMTargetDataAsString(PyObject *self, PyObject *args) _wLLVMTargetDataAsString(PyObject *self, PyObject *args)
{ {
LLVMTargetDataRef td; const LLVMTargetDataRef td = get_object_arg<LLVMTargetDataRef>(args);
char *tdrep = 0; if (!td) return NULL;
PyObject *ret;
if (!(td = (LLVMTargetDataRef)get_object_arg(args))) char *tdrep = LLVMCopyStringRepOfTargetData(td);
return NULL; PyObject *ret = PyUnicode_FromString(tdrep);
tdrep = LLVMCopyStringRepOfTargetData(td);
ret = PyUnicode_FromString(tdrep);
LLVMDisposeMessage(tdrep); LLVMDisposeMessage(tdrep);
return ret; return ret;
} }
@ -1160,13 +1131,13 @@ _wrap_objstr2none(LLVMEngineBuilderSetMAttrs, LLVMEngineBuilderRef)
static PyObject * static PyObject *
_wLLVMEngineBuilderCreate(PyObject *self, PyObject *args) _wLLVMEngineBuilderCreate(PyObject *self, PyObject *args)
{ {
LLVMEngineBuilderRef obj; const LLVMEngineBuilderRef obj
if (!(obj = (LLVMEngineBuilderRef)get_object_arg(args))) = get_object_arg<LLVMEngineBuilderRef>(args) ;
if (!obj)
return NULL; return NULL;
std::string outmsg; std::string outmsg;
const LLVMExecutionEngineRef ee = LLVMEngineBuilderCreate(obj, outmsg);
LLVMExecutionEngineRef ee = LLVMEngineBuilderCreate(obj, outmsg);
PyObject * ret; PyObject * ret;
if( !ee ){ // check if error message is set. if( !ee ){ // check if error message is set.
@ -1185,24 +1156,23 @@ _wLLVMEngineBuilderCreate(PyObject *self, PyObject *args)
static PyObject * static PyObject *
_wLLVMCreateExecutionEngine(PyObject *self, PyObject *args) _wLLVMCreateExecutionEngine(PyObject *self, PyObject *args)
{ {
LLVMModuleRef mod;
PyObject *obj; PyObject *obj;
int force_interpreter; int force_interpreter;
LLVMExecutionEngineRef ee;
char *outmsg = 0; char *outmsg = 0;
PyObject *ret;
int error; int error;
if (!PyArg_ParseTuple(args, "Oi", &obj, &force_interpreter)) if (!PyArg_ParseTuple(args, "Oi", &obj, &force_interpreter))
return NULL; return NULL;
mod = (LLVMModuleRef) PyCapsule_GetPointer(obj, NULL); const LLVMModuleRef mod = pycap_get<LLVMModuleRef>( obj ) ;
LLVMExecutionEngineRef ee;
if (force_interpreter) if (force_interpreter)
error = LLVMCreateInterpreterForModule(&ee, mod, &outmsg); error = LLVMCreateInterpreterForModule(&ee, mod, &outmsg);
else else
error = LLVMCreateJITCompilerForModule(&ee, mod, 1 /*fast*/, &outmsg); error = LLVMCreateJITCompilerForModule(&ee, mod, 1 /*fast*/, &outmsg);
PyObject *ret;
if (error) { if (error) {
ret = PyUnicode_FromString(outmsg); ret = PyUnicode_FromString(outmsg);
LLVMDisposeMessage(outmsg); LLVMDisposeMessage(outmsg);
@ -1218,14 +1188,12 @@ _wLLVMGetPointerToFunction(PyObject *self, PyObject *args)
{ {
PyObject *obj_ee; PyObject *obj_ee;
PyObject *obj_fn; PyObject *obj_fn;
LLVMExecutionEngineRef ee;
LLVMValueRef fn;
if (!PyArg_ParseTuple(args, "OO", &obj_ee, &obj_fn)) if (!PyArg_ParseTuple(args, "OO", &obj_ee, &obj_fn))
return NULL; return NULL;
ee = (LLVMExecutionEngineRef) PyCapsule_GetPointer(obj_ee, NULL); const LLVMExecutionEngineRef ee = pycap_get<LLVMExecutionEngineRef>(obj_ee ) ;
fn = (LLVMValueRef) PyCapsule_GetPointer(obj_fn, NULL); const LLVMValueRef fn = pycap_get<LLVMValueRef>( obj_fn ) ;
return PyLong_FromVoidPtr(LLVMGetPointerToFunction(ee,fn)); return PyLong_FromVoidPtr(LLVMGetPointerToFunction(ee,fn));
} }
@ -1241,19 +1209,18 @@ static PyObject *
_wLLVMRemoveModule2(PyObject *self, PyObject *args) _wLLVMRemoveModule2(PyObject *self, PyObject *args)
{ {
PyObject *obj_ee; PyObject *obj_ee;
PyObject *obj_mod;
LLVMExecutionEngineRef ee;
LLVMModuleRef mod, mod_new = 0;
char *outmsg = 0;
PyObject *ret;
PyObject *obj_mod;
if (!PyArg_ParseTuple(args, "OO", &obj_ee, &obj_mod)) if (!PyArg_ParseTuple(args, "OO", &obj_ee, &obj_mod))
return NULL; return NULL;
ee = (LLVMExecutionEngineRef) PyCapsule_GetPointer(obj_ee, NULL); const LLVMExecutionEngineRef ee = pycap_get<LLVMExecutionEngineRef>( obj_ee ) ;
mod = (LLVMModuleRef) PyCapsule_GetPointer(obj_mod, NULL); const LLVMModuleRef mod = pycap_get<LLVMModuleRef>(obj_mod) ;
char *outmsg = 0;
LLVMModuleRef mod_new = 0;
LLVMRemoveModule(ee, mod, &mod_new, &outmsg); LLVMRemoveModule(ee, mod, &mod_new, &outmsg);
PyObject *ret;
if (mod_new) { if (mod_new) {
ret = ctor_LLVMModuleRef(mod_new); ret = ctor_LLVMModuleRef(mod_new);
} else { } else {
@ -1289,7 +1256,6 @@ static PyObject *
_wLLVMCreateGenericValueOfInt(PyObject *self, PyObject *args) _wLLVMCreateGenericValueOfInt(PyObject *self, PyObject *args)
{ {
PyObject *obj1; PyObject *obj1;
LLVMTypeRef ty;
unsigned long long n; unsigned long long n;
int is_signed; int is_signed;
LLVMGenericValueRef gv; LLVMGenericValueRef gv;
@ -1297,7 +1263,7 @@ _wLLVMCreateGenericValueOfInt(PyObject *self, PyObject *args)
if (!PyArg_ParseTuple(args, "OLi", &obj1, &n, &is_signed)) if (!PyArg_ParseTuple(args, "OLi", &obj1, &n, &is_signed))
return NULL; return NULL;
ty = (LLVMTypeRef) PyCapsule_GetPointer(obj1, NULL); const LLVMTypeRef ty = pycap_get<LLVMTypeRef>( obj1 ) ;
gv = LLVMCreateGenericValueOfInt(ty, n, is_signed); gv = LLVMCreateGenericValueOfInt(ty, n, is_signed);
return ctor_LLVMGenericValueRef(gv); return ctor_LLVMGenericValueRef(gv);
@ -1307,14 +1273,13 @@ static PyObject *
_wLLVMCreateGenericValueOfFloat(PyObject *self, PyObject *args) _wLLVMCreateGenericValueOfFloat(PyObject *self, PyObject *args)
{ {
PyObject *obj1; PyObject *obj1;
LLVMTypeRef ty;
double d; double d;
LLVMGenericValueRef gv; LLVMGenericValueRef gv;
if (!PyArg_ParseTuple(args, "Od", &obj1, &d)) if (!PyArg_ParseTuple(args, "Od", &obj1, &d))
return NULL; return NULL;
ty = (LLVMTypeRef) PyCapsule_GetPointer(obj1, NULL); const LLVMTypeRef ty = pycap_get<LLVMTypeRef>( obj1 ) ;
gv = LLVMCreateGenericValueOfFloat(ty, d); gv = LLVMCreateGenericValueOfFloat(ty, d);
return ctor_LLVMGenericValueRef(gv); return ctor_LLVMGenericValueRef(gv);
@ -1327,16 +1292,13 @@ _wLLVMCreateGenericValueOfPointer(PyObject *self, PyObject *args)
// LLVMTypeRef ty; //unused? // LLVMTypeRef ty; //unused?
unsigned long long n_; unsigned long long n_;
size_t n; size_t n;
LLVMGenericValueRef gv;
if (!PyArg_ParseTuple(args, "L", &n_)) if (!PyArg_ParseTuple(args, "L", &n_))
return NULL; return NULL;
n=n_; n=n_;
// ty = (LLVMTypeRef) PyCapsule_GetPointer(obj1, NULL); const LLVMGenericValueRef gv = LLVMCreateGenericValueOfPointer((void*)n);
gv = LLVMCreateGenericValueOfPointer((void*)n);
return ctor_LLVMGenericValueRef(gv); return ctor_LLVMGenericValueRef(gv);
} }
@ -1345,13 +1307,12 @@ _wLLVMGenericValueToInt(PyObject *self, PyObject *args)
{ {
PyObject *obj1; PyObject *obj1;
int is_signed; int is_signed;
LLVMGenericValueRef gv;
unsigned long long val; unsigned long long val;
if (!PyArg_ParseTuple(args, "Oi", &obj1, &is_signed)) if (!PyArg_ParseTuple(args, "Oi", &obj1, &is_signed))
return NULL; return NULL;
gv = (LLVMGenericValueRef) PyCapsule_GetPointer(obj1, NULL); LLVMGenericValueRef gv = pycap_get<LLVMGenericValueRef>(obj1);
val = LLVMGenericValueToInt(gv, is_signed); val = LLVMGenericValueToInt(gv, is_signed);
return is_signed ? return is_signed ?
@ -1363,17 +1324,14 @@ static PyObject *
_wLLVMGenericValueToFloat(PyObject *self, PyObject *args) _wLLVMGenericValueToFloat(PyObject *self, PyObject *args)
{ {
PyObject *obj1, *obj2; PyObject *obj1, *obj2;
LLVMTypeRef ty;
LLVMGenericValueRef gv;
double val;
if (!PyArg_ParseTuple(args, "OO", &obj1, &obj2)) if (!PyArg_ParseTuple(args, "OO", &obj1, &obj2))
return NULL; return NULL;
ty = (LLVMTypeRef) PyCapsule_GetPointer(obj1, NULL); const LLVMTypeRef ty = pycap_get<LLVMTypeRef>( obj1 ) ;
gv = (LLVMGenericValueRef) PyCapsule_GetPointer(obj2, NULL); const LLVMGenericValueRef gv = pycap_get<LLVMGenericValueRef>( obj2 ) ;
val = LLVMGenericValueToFloat(ty, gv); double val = LLVMGenericValueToFloat(ty, gv);
return PyFloat_FromDouble(val); return PyFloat_FromDouble(val);
} }
@ -1381,15 +1339,13 @@ static PyObject *
_wLLVMGenericValueToPointer(PyObject *self, PyObject *args) _wLLVMGenericValueToPointer(PyObject *self, PyObject *args)
{ {
PyObject *obj1; PyObject *obj1;
LLVMGenericValueRef gv;
void * val;
if (!PyArg_ParseTuple(args, "O", &obj1)) if (!PyArg_ParseTuple(args, "O", &obj1))
return NULL; return NULL;
gv = (LLVMGenericValueRef) PyCapsule_GetPointer(obj1, NULL); const LLVMGenericValueRef gv = pycap_get<LLVMGenericValueRef>( obj1 ) ;
val = LLVMGenericValueToPointer(gv); void * val = LLVMGenericValueToPointer(gv);
return PyLong_FromVoidPtr(val); return PyLong_FromVoidPtr(val);
} }
@ -1407,14 +1363,13 @@ static PyObject *
_wLLVMLoadLibraryPermanently(PyObject *self, PyObject *args) _wLLVMLoadLibraryPermanently(PyObject *self, PyObject *args)
{ {
const char *filename; const char *filename;
char *outmsg;
PyObject *ret; PyObject *ret;
if (!PyArg_ParseTuple(args, "s:LLVMLoadLibraryPermanently", &filename)) { if (!PyArg_ParseTuple(args, "s:LLVMLoadLibraryPermanently", &filename)) {
return NULL; return NULL;
} }
outmsg = 0; char *outmsg = 0;
if (!LLVMLoadLibraryPermanently(filename, &outmsg)) { if (!LLVMLoadLibraryPermanently(filename, &outmsg)) {
if (outmsg) { if (outmsg) {
ret = PyUnicode_FromString(outmsg); ret = PyUnicode_FromString(outmsg);

View file

@ -91,15 +91,14 @@ void *get_object_arg(PyObject *args)
return PyCapsule_GetPointer(o, NULL); return PyCapsule_GetPointer(o, NULL);
} }
// must delete [] returned array
void **make_array_from_list(PyObject *list, int n) void **make_array_from_list(PyObject *list, int n)
{ {
int i; void **arr = new void*[n] ;
void **arr;
arr = (void **)malloc(sizeof(void *) * n);
if (!arr) if (!arr)
return NULL; return NULL;
int i;
for (i=0; i<n; i++) { for (i=0; i<n; i++) {
PyObject *e = PyList_GetItem(list, i); PyObject *e = PyList_GetItem(list, i);
arr[i] = PyCapsule_GetPointer(e, NULL); arr[i] = PyCapsule_GetPointer(e, NULL);

View file

@ -124,13 +124,34 @@ void **make_array_from_list(PyObject *list, int n);
/** /**
* Given an array of LLVMTypeRef's, create a PyList object. * Given an array of LLVMTypeRef's, create a PyList object.
*/ */
PyObject *make_list_from_LLVMTypeRef_array(LLVMTypeRef *p, unsigned n); PyObject *make_list_from_LLVMTypeRef_array(LLVMTypeRef *p, size_t n);
/** /**
* Given an array of LLVMValueRef's, create a PyList object. * Given an array of LLVMValueRef's, create a PyList object.
*/ */
PyObject *make_list_from_LLVMValueRef_array(LLVMValueRef *p, unsigned n); PyObject *make_list_from_LLVMValueRef_array(LLVMValueRef *p, size_t n);
/*===----------------------------------------------------------------------===*/
/* Template functions */
// wrap the cast
template <typename LLTYPE>
LLTYPE pycap_get( PyObject* obj )
{
return static_cast<LLTYPE> ( PyCapsule_GetPointer(obj, NULL) );
}
template <typename LLTYPE>
LLTYPE get_object_arg( PyObject* obj )
{
return static_cast<LLTYPE> ( get_object_arg(obj) );
}
template <typename LLTYPE>
LLTYPE make_array_from_list(PyObject *list, int n)
{
return reinterpret_cast<LLTYPE>(make_array_from_list(list, n)) ;
}
/*===----------------------------------------------------------------------===*/ /*===----------------------------------------------------------------------===*/
/* Wrapper macros */ /* Wrapper macros */
@ -169,7 +190,7 @@ _w ## func (PyObject *self, PyObject *args) \
{ \ { \
intype1 arg1; \ intype1 arg1; \
\ \
if (!(arg1 = ( intype1 )get_object_arg(args))) \ if (!(arg1 = get_object_arg<intype1>(args))) \
return NULL; \ return NULL; \
\ \
return ctor_ ## outtype ( func (arg1)); \ return ctor_ ## outtype ( func (arg1)); \
@ -200,14 +221,12 @@ static PyObject * \
_w ## func (PyObject *self, PyObject *args) \ _w ## func (PyObject *self, PyObject *args) \
{ \ { \
PyObject *obj1, *obj2; \ PyObject *obj1, *obj2; \
intype1 arg1; \
intype2 arg2; \
\ \
if (!PyArg_ParseTuple(args, "OO", &obj1, &obj2)) \ if (!PyArg_ParseTuple(args, "OO", &obj1, &obj2)) \
return NULL; \ return NULL; \
\ \
arg1 = ( intype1 ) PyCapsule_GetPointer(obj1, NULL); \ const intype1 arg1 = pycap_get< intype1 > (obj1); \
arg2 = ( intype2 ) PyCapsule_GetPointer(obj2, NULL); \ const intype2 arg2 = pycap_get< intype2 > (obj2); \
\ \
return ctor_ ## outtype ( func (arg1, arg2)); \ return ctor_ ## outtype ( func (arg1, arg2)); \
} }
@ -221,14 +240,12 @@ static PyObject * \
_w ## func (PyObject *self, PyObject *args) \ _w ## func (PyObject *self, PyObject *args) \
{ \ { \
PyObject *obj1, *obj2; \ PyObject *obj1, *obj2; \
intype1 arg1; \
intype2 arg2; \
\ \
if (!PyArg_ParseTuple(args, "OO", &obj1, &obj2)) \ if (!PyArg_ParseTuple(args, "OO", &obj1, &obj2)) \
return NULL; \ return NULL; \
\ \
arg1 = ( intype1 ) PyCapsule_GetPointer(obj1, NULL);\ intype1 arg1 = pycap_get< intype1 > (obj1); \
arg2 = ( intype2 ) PyCapsule_GetPointer(obj2, NULL);\ intype2 arg2 = pycap_get< intype2 > (obj2); \
\ \
func (arg1, arg2); \ func (arg1, arg2); \
Py_RETURN_NONE; \ Py_RETURN_NONE; \
@ -243,13 +260,12 @@ static PyObject * \
_w ## func (PyObject *self, PyObject *args) \ _w ## func (PyObject *self, PyObject *args) \
{ \ { \
PyObject *obj1; \ PyObject *obj1; \
intype1 arg1; \ size_t arg2; \
unsigned int arg2; \
\ \
if (!PyArg_ParseTuple(args, "OI", &obj1, &arg2)) \ if (!PyArg_ParseTuple(args, "OI", &obj1, &arg2)) \
return NULL; \ return NULL; \
\ \
arg1 = ( intype1 ) PyCapsule_GetPointer(obj1, NULL);\ const intype1 arg1 = pycap_get< intype1 > (obj1); \
\ \
return ctor_ ## outtype ( func (arg1, arg2)); \ return ctor_ ## outtype ( func (arg1, arg2)); \
} }
@ -263,16 +279,13 @@ static PyObject * \
_w ## func (PyObject *self, PyObject *args) \ _w ## func (PyObject *self, PyObject *args) \
{ \ { \
PyObject *obj1, *obj2, *obj3; \ PyObject *obj1, *obj2, *obj3; \
intype1 arg1; \
intype2 arg2; \
intype3 arg3; \
\ \
if (!PyArg_ParseTuple(args, "OOO", &obj1, &obj2, &obj3)) \ if (!PyArg_ParseTuple(args, "OOO", &obj1, &obj2, &obj3)) \
return NULL; \ return NULL; \
\ \
arg1 = ( intype1 ) PyCapsule_GetPointer(obj1, NULL); \ const intype1 arg1 = pycap_get< intype1 > (obj1); \
arg2 = ( intype2 ) PyCapsule_GetPointer(obj2, NULL); \ const intype2 arg2 = pycap_get< intype2 > (obj2); \
arg3 = ( intype3 ) PyCapsule_GetPointer(obj3, NULL); \ const intype3 arg3 = pycap_get< intype3 > (obj3); \
\ \
return ctor_ ## outtype ( func (arg1, arg2, arg3)); \ return ctor_ ## outtype ( func (arg1, arg2, arg3)); \
} }
@ -286,16 +299,13 @@ static PyObject * \
_w ## func (PyObject *self, PyObject *args) \ _w ## func (PyObject *self, PyObject *args) \
{ \ { \
PyObject *obj1, *obj2, *obj3; \ PyObject *obj1, *obj2, *obj3; \
intype1 arg1; \
intype2 arg2; \
intype3 arg3; \
\ \
if (!PyArg_ParseTuple(args, "OOO", &obj1, &obj2, &obj3)) \ if (!PyArg_ParseTuple(args, "OOO", &obj1, &obj2, &obj3)) \
return NULL; \ return NULL; \
\ \
arg1 = ( intype1 ) PyCapsule_GetPointer(obj1, NULL); \ const intype1 arg1 = pycap_get< intype1 > (obj1); \
arg2 = ( intype2 ) PyCapsule_GetPointer(obj2, NULL); \ const intype2 arg2 = pycap_get< intype2 > (obj2); \
arg3 = ( intype3 ) PyCapsule_GetPointer(obj3, NULL); \ const intype3 arg3 = pycap_get< intype3 > (obj3); \
\ \
func (arg1, arg2, arg3); \ func (arg1, arg2, arg3); \
Py_RETURN_NONE; \ Py_RETURN_NONE; \
@ -309,16 +319,14 @@ _w ## func (PyObject *self, PyObject *args) \
static PyObject * \ static PyObject * \
_w ## func (PyObject *self, PyObject *args) \ _w ## func (PyObject *self, PyObject *args) \
{ \ { \
unsigned int arg1; \ size_t arg1; \
PyObject *obj2, *obj3; \ PyObject *obj2, *obj3; \
intype2 arg2; \
intype3 arg3; \
\ \
if (!PyArg_ParseTuple(args, "IOO", &arg1, &obj2, &obj3)) \ if (!PyArg_ParseTuple(args, "IOO", &arg1, &obj2, &obj3)) \
return NULL; \ return NULL; \
\ \
arg2 = ( intype2 ) PyCapsule_GetPointer(obj2, NULL); \ const intype2 arg2 = pycap_get< intype2 > (obj2); \
arg3 = ( intype3 ) PyCapsule_GetPointer(obj3, NULL); \ const intype3 arg3 = pycap_get< intype3 > (obj3); \
\ \
return ctor_ ## outtype ( func (arg1, arg2, arg3)); \ return ctor_ ## outtype ( func (arg1, arg2, arg3)); \
} }
@ -333,14 +341,12 @@ _w ## func (PyObject *self, PyObject *args) \
{ \ { \
intype1 arg1; \ intype1 arg1; \
PyObject *obj2, *obj3; \ PyObject *obj2, *obj3; \
intype2 arg2; \
intype3 arg3; \
\ \
if (!PyArg_ParseTuple(args, "IOO", &arg1, &obj2, &obj3)) \ if (!PyArg_ParseTuple(args, "IOO", &arg1, &obj2, &obj3)) \
return NULL; \ return NULL; \
\ \
arg2 = ( intype2 ) PyCapsule_GetPointer(obj2, NULL); \ const intype2 arg2 = pycap_get< intype2 > (obj2); \
arg3 = ( intype3 ) PyCapsule_GetPointer(obj3, NULL); \ const intype3 arg3 = pycap_get< intype3 > (obj3); \
\ \
return ctor_ ## outtype ( func (arg1, arg2, arg3)); \ return ctor_ ## outtype ( func (arg1, arg2, arg3)); \
} }
@ -400,7 +406,7 @@ _w ## func (PyObject *self, PyObject *args) \
{ \ { \
intype1 arg1; \ intype1 arg1; \
\ \
if (!(arg1 = ( intype1 )get_object_arg(args))) \ if (!(arg1 = get_object_arg<intype1>(args))) \
return NULL; \ return NULL; \
\ \
return PyUnicode_FromString( func (arg1)); \ return PyUnicode_FromString( func (arg1)); \
@ -416,7 +422,7 @@ _w ## func (PyObject *self, PyObject *args) \
{ \ { \
intype1 arg1; \ intype1 arg1; \
\ \
if (!(arg1 = ( intype1 )get_object_arg(args))) \ if (!(arg1 = get_object_arg<intype1>(args))) \
return NULL; \ return NULL; \
\ \
func (arg1); \ func (arg1); \
@ -433,12 +439,11 @@ _w ## func (PyObject *self, PyObject *args) \
{ \ { \
PyObject *obj1; \ PyObject *obj1; \
const char *arg2; \ const char *arg2; \
intype1 arg1; \
\ \
if (!PyArg_ParseTuple(args, "Os", &obj1, &arg2)) \ if (!PyArg_ParseTuple(args, "Os", &obj1, &arg2)) \
return NULL; \ return NULL; \
\ \
arg1 = ( intype1 ) PyCapsule_GetPointer(obj1, NULL);\ const intype1 arg1 = pycap_get< intype1 > (obj1); \
\ \
func (arg1, arg2); \ func (arg1, arg2); \
Py_RETURN_NONE; \ Py_RETURN_NONE; \
@ -454,12 +459,11 @@ _w ## func (PyObject *self, PyObject *args) \
{ \ { \
PyObject *obj1; \ PyObject *obj1; \
const char *arg2; \ const char *arg2; \
intype1 arg1; \
\ \
if (!PyArg_ParseTuple(args, "Os", &obj1, &arg2)) \ if (!PyArg_ParseTuple(args, "Os", &obj1, &arg2)) \
return NULL; \ return NULL; \
\ \
arg1 = ( intype1 ) PyCapsule_GetPointer(obj1, NULL);\ const intype1 arg1 = pycap_get< intype1 > (obj1); \
\ \
return ctor_ ## outtype ( func (arg1, arg2)); \ return ctor_ ## outtype ( func (arg1, arg2)); \
} }
@ -474,12 +478,11 @@ _w ## func (PyObject *self, PyObject *args) \
{ \ { \
PyObject *obj1; \ PyObject *obj1; \
int arg2; \ int arg2; \
intype1 arg1; \
\ \
if (!PyArg_ParseTuple(args, "Oi", &obj1, &arg2)) \ if (!PyArg_ParseTuple(args, "Oi", &obj1, &arg2)) \
return NULL; \ return NULL; \
\ \
arg1 = ( intype1 ) PyCapsule_GetPointer(obj1, NULL);\ const intype1 arg1 = pycap_get< intype1 > (obj1); \
\ \
func (arg1, arg2); \ func (arg1, arg2); \
Py_RETURN_NONE; \ Py_RETURN_NONE; \
@ -493,14 +496,13 @@ _w ## func (PyObject *self, PyObject *args) \
static PyObject * \ static PyObject * \
_w ## func (PyObject *self, PyObject *args) \ _w ## func (PyObject *self, PyObject *args) \
{ \ { \
PyObject *obj1; \
intype1 arg1; \
intype2 arg2; \ intype2 arg2; \
PyObject *obj1; \
\ \
if (!PyArg_ParseTuple(args, "Oi", &obj1, &arg2)) \ if (!PyArg_ParseTuple(args, "Oi", &obj1, &arg2)) \
return NULL; \ return NULL; \
\ \
arg1 = ( intype1 ) PyCapsule_GetPointer(obj1, NULL);\ const intype1 arg1 = pycap_get< intype1 > (obj1); \
\ \
func (arg1, arg2); \ func (arg1, arg2); \
Py_RETURN_NONE; \ Py_RETURN_NONE; \
@ -515,15 +517,13 @@ static PyObject * \
_w ## func (PyObject *self, PyObject *args) \ _w ## func (PyObject *self, PyObject *args) \
{ \ { \
PyObject *obj1, *obj2; \ PyObject *obj1, *obj2; \
intype1 arg1; \
intype2 arg2; \
const char *arg3; \ const char *arg3; \
\ \
if (!PyArg_ParseTuple(args, "OOs", &obj1, &obj2, &arg3)) \ if (!PyArg_ParseTuple(args, "OOs", &obj1, &obj2, &arg3)) \
return NULL; \ return NULL; \
\ \
arg1 = ( intype1 ) PyCapsule_GetPointer(obj1, NULL); \ const intype1 arg1 = pycap_get< intype1 > (obj1); \
arg2 = ( intype2 ) PyCapsule_GetPointer(obj2, NULL); \ const intype2 arg2 = pycap_get< intype2 > (obj2); \
\ \
return ctor_ ## outtype ( func (arg1, arg2, arg3)); \ return ctor_ ## outtype ( func (arg1, arg2, arg3)); \
} }
@ -537,15 +537,13 @@ static PyObject * \
_w ## func (PyObject *self, PyObject *args) \ _w ## func (PyObject *self, PyObject *args) \
{ \ { \
PyObject *obj1, *obj2; \ PyObject *obj1, *obj2; \
intype1 arg1; \
intype2 arg2; \
int arg3; \ int arg3; \
\ \
if (!PyArg_ParseTuple(args, "OOi", &obj1, &obj2, &arg3)) \ if (!PyArg_ParseTuple(args, "OOi", &obj1, &obj2, &arg3)) \
return NULL; \ return NULL; \
\ \
arg1 = ( intype1 ) PyCapsule_GetPointer(obj1, NULL); \ const intype1 arg1 = pycap_get< intype1 > (obj1); \
arg2 = ( intype2 ) PyCapsule_GetPointer(obj2, NULL); \ const intype2 arg2 = pycap_get< intype2 > (obj2); \
\ \
return ctor_ ## outtype ( func (arg1, arg2, arg3)) ; \ return ctor_ ## outtype ( func (arg1, arg2, arg3)) ; \
} }
@ -559,15 +557,13 @@ static PyObject * \
_w ## func (PyObject *self, PyObject *args) \ _w ## func (PyObject *self, PyObject *args) \
{ \ { \
PyObject *obj1, *obj2; \ PyObject *obj1, *obj2; \
intype1 arg1; \
intype2 arg2; \
unsigned long long arg3; \ unsigned long long arg3; \
\ \
if (!PyArg_ParseTuple(args, "OOK", &obj1, &obj2, &arg3)) \ if (!PyArg_ParseTuple(args, "OOK", &obj1, &obj2, &arg3)) \
return NULL; \ return NULL; \
\ \
arg1 = ( intype1 ) PyCapsule_GetPointer(obj1, NULL); \ const intype1 arg1 = pycap_get< intype1 > (obj1); \
arg2 = ( intype2 ) PyCapsule_GetPointer(obj2, NULL); \ const intype2 arg2 = pycap_get< intype2 > (obj2); \
\ \
return ctor_ ## outtype ( func (arg1, arg2, arg3)) ; \ return ctor_ ## outtype ( func (arg1, arg2, arg3)) ; \
} }
@ -581,13 +577,12 @@ static PyObject * \
_w ## func (PyObject *self, PyObject *args) \ _w ## func (PyObject *self, PyObject *args) \
{ \ { \
PyObject *obj1; \ PyObject *obj1; \
intype1 arg1; \
int arg2, arg3; \ int arg2, arg3; \
\ \
if (!PyArg_ParseTuple(args, "Oii", &obj1, &arg2, &arg3)) \ if (!PyArg_ParseTuple(args, "Oii", &obj1, &arg2, &arg3)) \
return NULL; \ return NULL; \
\ \
arg1 = ( intype1 ) PyCapsule_GetPointer(obj1, NULL); \ const intype1 arg1 = pycap_get< intype1 > (obj1); \
\ \
func (arg1, arg2, arg3); \ func (arg1, arg2, arg3); \
Py_RETURN_NONE; \ Py_RETURN_NONE; \
@ -602,14 +597,13 @@ static PyObject * \
_w ## func (PyObject *self, PyObject *args) \ _w ## func (PyObject *self, PyObject *args) \
{ \ { \
PyObject *obj1; \ PyObject *obj1; \
intype1 arg1; \
int arg2; \ int arg2; \
intype3 arg3; \ intype3 arg3; \
\ \
if (!PyArg_ParseTuple(args, "Oii", &obj1, &arg2, &arg3)) \ if (!PyArg_ParseTuple(args, "Oii", &obj1, &arg2, &arg3)) \
return NULL; \ return NULL; \
\ \
arg1 = ( intype1 ) PyCapsule_GetPointer(obj1, NULL); \ const intype1 arg1 = pycap_get< intype1 > (obj1); \
\ \
func (arg1, arg2, arg3); \ func (arg1, arg2, arg3); \
Py_RETURN_NONE; \ Py_RETURN_NONE; \
@ -624,15 +618,13 @@ static PyObject * \
_w ## func (PyObject *self, PyObject *args) \ _w ## func (PyObject *self, PyObject *args) \
{ \ { \
PyObject *obj1, *obj3; \ PyObject *obj1, *obj3; \
intype1 arg1; \
const char *arg2; \ const char *arg2; \
intype3 arg3; \
\ \
if (!PyArg_ParseTuple(args, "OsO", &obj1, &arg2, &obj3)) \ if (!PyArg_ParseTuple(args, "OsO", &obj1, &arg2, &obj3)) \
return NULL; \ return NULL; \
\ \
arg1 = ( intype1 ) PyCapsule_GetPointer(obj1, NULL); \ const intype1 arg1 = pycap_get< intype1 > (obj1); \
arg3 = ( intype3 ) PyCapsule_GetPointer(obj3, NULL); \ const intype3 arg3 = pycap_get< intype3 > (obj3); \
\ \
return ctor_ ## outtype ( func (arg1, arg2, arg3)); \ return ctor_ ## outtype ( func (arg1, arg2, arg3)); \
} }
@ -646,15 +638,13 @@ static PyObject * \
_w ## func (PyObject *self, PyObject *args) \ _w ## func (PyObject *self, PyObject *args) \
{ \ { \
PyObject *obj1, *obj3; \ PyObject *obj1, *obj3; \
intype1 arg1; \
const char *arg2; \ const char *arg2; \
intype3 arg3; \
\ \
if (!PyArg_ParseTuple(args, "OsO", &obj1, &arg2, &obj3)) \ if (!PyArg_ParseTuple(args, "OsO", &obj1, &arg2, &obj3)) \
return NULL; \ return NULL; \
\ \
arg1 = ( intype1 ) PyCapsule_GetPointer(obj1, NULL); \ const intype1 arg1 = pycap_get< intype1 > (obj1); \
arg3 = ( intype3 ) PyCapsule_GetPointer(obj3, NULL); \ const intype3 arg3 = pycap_get< intype3 > (obj3); \
\ \
func(arg1, arg2, arg3); \ func(arg1, arg2, arg3); \
\ \
@ -671,16 +661,14 @@ static PyObject * \
_w ## func (PyObject *self, PyObject *args) \ _w ## func (PyObject *self, PyObject *args) \
{ \ { \
PyObject *obj1, *obj2; \ PyObject *obj1, *obj2; \
intype1 arg1; \
intype2 arg2; \
int arg3; \ int arg3; \
const char *arg4; \ const char *arg4; \
\ \
if (!PyArg_ParseTuple(args, "OOis", &obj1, &obj2, &arg3, &arg4)) \ if (!PyArg_ParseTuple(args, "OOis", &obj1, &obj2, &arg3, &arg4)) \
return NULL; \ return NULL; \
\ \
arg1 = ( intype1 ) PyCapsule_GetPointer(obj1, NULL); \ const intype1 arg1 = pycap_get< intype1 > (obj1); \
arg2 = ( intype2 ) PyCapsule_GetPointer(obj2, NULL); \ const intype2 arg2 = pycap_get< intype2 > (obj2); \
\ \
return ctor_ ## outtype ( func (arg1, arg2, arg3, arg4)) ; \ return ctor_ ## outtype ( func (arg1, arg2, arg3, arg4)) ; \
} }
@ -694,9 +682,6 @@ static PyObject * \
_w ## func (PyObject *self, PyObject *args) \ _w ## func (PyObject *self, PyObject *args) \
{ \ { \
PyObject *obj1, *obj2, *obj3; \ PyObject *obj1, *obj2, *obj3; \
intype1 arg1; \
intype2 arg2; \
intype3 arg3; \
int arg4; \ int arg4; \
const char *arg5; \ const char *arg5; \
\ \
@ -704,9 +689,9 @@ _w ## func (PyObject *self, PyObject *args) \
&arg5)) \ &arg5)) \
return NULL; \ return NULL; \
\ \
arg1 = ( intype1 ) PyCapsule_GetPointer(obj1, NULL); \ const intype1 arg1 = pycap_get< intype1 > (obj1); \
arg2 = ( intype2 ) PyCapsule_GetPointer(obj2, NULL); \ const intype2 arg2 = pycap_get< intype2 > (obj2); \
arg3 = ( intype3 ) PyCapsule_GetPointer(obj3, NULL); \ const intype3 arg3 = pycap_get< intype3 > (obj3); \
\ \
return ctor_ ## outtype ( func (arg1, arg2, arg3, arg4, arg5)) ; \ return ctor_ ## outtype ( func (arg1, arg2, arg3, arg4, arg5)) ; \
} }
@ -720,17 +705,14 @@ static PyObject * \
_w ## func (PyObject *self, PyObject *args) \ _w ## func (PyObject *self, PyObject *args) \
{ \ { \
PyObject *obj1, *obj2, *obj3; \ PyObject *obj1, *obj2, *obj3; \
intype1 arg1; \
intype2 arg2; \
intype3 arg3; \
const char *arg4; \ const char *arg4; \
\ \
if (!PyArg_ParseTuple(args, "OOOs", &obj1, &obj2, &obj3, &arg4)) \ if (!PyArg_ParseTuple(args, "OOOs", &obj1, &obj2, &obj3, &arg4)) \
return NULL; \ return NULL; \
\ \
arg1 = ( intype1 ) PyCapsule_GetPointer(obj1, NULL); \ const intype1 arg1 = pycap_get< intype1 > (obj1); \
arg2 = ( intype2 ) PyCapsule_GetPointer(obj2, NULL); \ const intype2 arg2 = pycap_get< intype2 > (obj2); \
arg3 = ( intype3 ) PyCapsule_GetPointer(obj3, NULL); \ const intype3 arg3 = pycap_get< intype3 > (obj3); \
\ \
return ctor_ ## outtype ( func (arg1, arg2, arg3, arg4)); \ return ctor_ ## outtype ( func (arg1, arg2, arg3, arg4)); \
} }
@ -744,16 +726,14 @@ static PyObject * \
_w ## func (PyObject *self, PyObject *args) \ _w ## func (PyObject *self, PyObject *args) \
{ \ { \
PyObject *obj1, *obj2; \ PyObject *obj1, *obj2; \
intype1 arg1; \
intype2 arg2; \
const char *arg3; \ const char *arg3; \
int arg4; \ int arg4; \
\ \
if (!PyArg_ParseTuple(args, "OOsi", &obj1, &obj2, &arg3, &arg4)) \ if (!PyArg_ParseTuple(args, "OOsi", &obj1, &obj2, &arg3, &arg4)) \
return NULL; \ return NULL; \
\ \
arg1 = ( intype1 ) PyCapsule_GetPointer(obj1, NULL); \ const intype1 arg1 = pycap_get< intype1 > (obj1); \
arg2 = ( intype2 ) PyCapsule_GetPointer(obj2, NULL); \ const intype2 arg2 = pycap_get< intype2 > (obj2); \
\ \
return ctor_ ## outtype ( func (arg1, arg2, arg3, arg4)); \ return ctor_ ## outtype ( func (arg1, arg2, arg3, arg4)); \
} }
@ -769,8 +749,6 @@ static PyObject * \
_w ## func (PyObject *self, PyObject *args) \ _w ## func (PyObject *self, PyObject *args) \
{ \ { \
PyObject *obj1, *obj2; \ PyObject *obj1, *obj2; \
intype1 arg1; \
intype2 arg2; \
int arg3; \ int arg3; \
const char *arg4; \ const char *arg4; \
int arg5; \ int arg5; \
@ -778,10 +756,10 @@ _w ## func (PyObject *self, PyObject *args) \
if (!PyArg_ParseTuple(args, "OOisi", &obj1, &obj2, &arg3, &arg4, &arg5)) \ if (!PyArg_ParseTuple(args, "OOisi", &obj1, &obj2, &arg3, &arg4, &arg5)) \
return NULL; \ return NULL; \
\ \
arg1 = ( intype1 ) PyCapsule_GetPointer(obj1, NULL); \ const intype1 arg1 = pycap_get< intype1 > (obj1); \
arg2 = ( intype2 ) PyCapsule_GetPointer(obj2, NULL); \ const intype2 arg2 = pycap_get< intype2 > (obj2); \
\ \
return ctor_ ## outtype ( func (arg1, arg2, arg3, arg4, arg5)); \ return ctor_ ## outtype ( func (arg1, arg2, arg3, arg4, arg5)); \
} }
/** /**
@ -793,14 +771,13 @@ static PyObject * \
_w ## func (PyObject *self, PyObject *args) \ _w ## func (PyObject *self, PyObject *args) \
{ \ { \
PyObject *obj1; \ PyObject *obj1; \
intype1 arg1; \
const char *arg2; \ const char *arg2; \
int arg3; \ int arg3; \
\ \
if (!PyArg_ParseTuple(args, "Osi", &obj1, &arg2, &arg3)) \ if (!PyArg_ParseTuple(args, "Osi", &obj1, &arg2, &arg3)) \
return NULL; \ return NULL; \
\ \
arg1 = ( intype1 ) PyCapsule_GetPointer(obj1, NULL); \ const intype1 arg1 = pycap_get< intype1 > (obj1); \
\ \
return ctor_ ## outtype ( func (arg1, arg2, arg3)); \ return ctor_ ## outtype ( func (arg1, arg2, arg3)); \
} }
@ -815,18 +792,15 @@ static PyObject * \
_w ## func (PyObject *self, PyObject *args) \ _w ## func (PyObject *self, PyObject *args) \
{ \ { \
PyObject *obj1, *obj2, *obj3; \ PyObject *obj1, *obj2, *obj3; \
intype1 arg1; \
intype2 arg2; \
intype3 arg3; \
const char *arg4; \ const char *arg4; \
int arg5; \ int arg5; \
\ \
if (!PyArg_ParseTuple(args, "OOOsi", &obj1, &obj2, &obj3, &arg4, &arg5)) \ if (!PyArg_ParseTuple(args, "OOOsi", &obj1, &obj2, &obj3, &arg4, &arg5)) \
return NULL; \ return NULL; \
\ \
arg1 = ( intype1 ) PyCapsule_GetPointer(obj1, NULL); \ const intype1 arg1 = pycap_get< intype1 > (obj1); \
arg2 = ( intype2 ) PyCapsule_GetPointer(obj2, NULL); \ const intype2 arg2 = pycap_get< intype2 > (obj2); \
arg3 = ( intype3 ) PyCapsule_GetPointer(obj3, NULL); \ const intype3 arg3 = pycap_get< intype3 > (obj3); \
\ \
return ctor_ ## outtype ( func (arg1, arg2, arg3, arg4, arg5)); \ return ctor_ ## outtype ( func (arg1, arg2, arg3, arg4, arg5)); \
} }
@ -843,9 +817,6 @@ static PyObject * \
_w ## func (PyObject *self, PyObject *args) \ _w ## func (PyObject *self, PyObject *args) \
{ \ { \
PyObject *obj1, *obj2, *obj3; \ PyObject *obj1, *obj2, *obj3; \
intype1 arg1; \
intype2 arg2; \
intype3 arg3; \
int arg4; \ int arg4; \
const char *arg5; \ const char *arg5; \
int arg6; \ int arg6; \
@ -853,9 +824,9 @@ _w ## func (PyObject *self, PyObject *args) \
if (!PyArg_ParseTuple(args, "OOOisi", &obj1, &obj2, &obj3, &arg4, &arg5, &arg6)) \ if (!PyArg_ParseTuple(args, "OOOisi", &obj1, &obj2, &obj3, &arg4, &arg5, &arg6)) \
return NULL; \ return NULL; \
\ \
arg1 = ( intype1 ) PyCapsule_GetPointer(obj1, NULL); \ const intype1 arg1 = pycap_get< intype1 > (obj1); \
arg2 = ( intype2 ) PyCapsule_GetPointer(obj2, NULL); \ const intype2 arg2 = pycap_get< intype2 > (obj2); \
arg3 = ( intype3 ) PyCapsule_GetPointer(obj3, NULL); \ const intype3 arg3 = pycap_get< intype3 > (obj3); \
\ \
return ctor_ ## outtype ( func (arg1, arg2, arg3, arg4, arg5, arg6)); \ return ctor_ ## outtype ( func (arg1, arg2, arg3, arg4, arg5, arg6)); \
} }
@ -869,20 +840,16 @@ static PyObject * \
_w ## func (PyObject *self, PyObject *args) \ _w ## func (PyObject *self, PyObject *args) \
{ \ { \
PyObject *obj1, *obj2, *obj3, *obj4; \ PyObject *obj1, *obj2, *obj3, *obj4; \
intype1 arg1; \
intype2 arg2; \
intype3 arg3; \
intype4 arg4; \
const char *arg5; \ const char *arg5; \
int arg6; \ int arg6; \
\ \
if (!PyArg_ParseTuple(args, "OOOOsi", &obj1, &obj2, &obj3, &obj4, &arg5, &arg6)) \ if (!PyArg_ParseTuple(args, "OOOOsi", &obj1, &obj2, &obj3, &obj4, &arg5, &arg6)) \
return NULL; \ return NULL; \
\ \
arg1 = ( intype1 ) PyCapsule_GetPointer(obj1, NULL); \ const intype1 arg1 = pycap_get< intype1 > (obj1); \
arg2 = ( intype2 ) PyCapsule_GetPointer(obj2, NULL); \ const intype2 arg2 = pycap_get< intype2 > (obj2); \
arg3 = ( intype3 ) PyCapsule_GetPointer(obj3, NULL); \ const intype3 arg3 = pycap_get< intype3 > (obj3); \
arg4 = ( intype4 ) PyCapsule_GetPointer(obj4, NULL); \ const intype4 arg4 = pycap_get< intype4 > (obj4); \
\ \
return ctor_ ## outtype ( func (arg1, arg2, arg3, arg4, arg5, arg6)); \ return ctor_ ## outtype ( func (arg1, arg2, arg3, arg4, arg5, arg6)); \
} }
@ -897,19 +864,16 @@ static PyObject * \
_w ## func (PyObject *self, PyObject *args) \ _w ## func (PyObject *self, PyObject *args) \
{ \ { \
PyObject *obj1, *obj3, *obj4; \ PyObject *obj1, *obj3, *obj4; \
intype1 arg1; \
const char *arg2; \ const char *arg2; \
intype3 arg3; \
intype4 arg4; \
const char *arg5; \ const char *arg5; \
int arg6; \ int arg6; \
\ \
if (!PyArg_ParseTuple(args, "OsOOsi", &obj1, &arg2, &obj3, &obj4, &arg5, &arg6)) \ if (!PyArg_ParseTuple(args, "OsOOsi", &obj1, &arg2, &obj3, &obj4, &arg5, &arg6)) \
return NULL; \ return NULL; \
\ \
arg1 = ( intype1 ) PyCapsule_GetPointer(obj1, NULL); \ const intype1 arg1 = pycap_get< intype1 > (obj1); \
arg3 = ( intype3 ) PyCapsule_GetPointer(obj3, NULL); \ const intype3 arg3 = pycap_get< intype3 > (obj3); \
arg4 = ( intype4 ) PyCapsule_GetPointer(obj4, NULL); \ const intype4 arg4 = pycap_get< intype4 > (obj4); \
\ \
return ctor_ ## outtype ( func (arg1, arg2, arg3, arg4, arg5, arg6)); \ return ctor_ ## outtype ( func (arg1, arg2, arg3, arg4, arg5, arg6)); \
} }
@ -923,17 +887,14 @@ static PyObject * \
_w ## func (PyObject *self, PyObject *args) \ _w ## func (PyObject *self, PyObject *args) \
{ \ { \
PyObject *obj1, *obj2, *obj3; \ PyObject *obj1, *obj2, *obj3; \
intype1 arg1; \
intype2 arg2; \
intype3 arg3; \
int arg4; \ int arg4; \
\ \
if (!PyArg_ParseTuple(args, "OOOi", &obj1, &obj2, &obj3, &arg4)) \ if (!PyArg_ParseTuple(args, "OOOi", &obj1, &obj2, &obj3, &arg4)) \
return NULL; \ return NULL; \
\ \
arg1 = ( intype1 ) PyCapsule_GetPointer(obj1, NULL); \ const intype1 arg1 = pycap_get< intype1 > (obj1); \
arg2 = ( intype2 ) PyCapsule_GetPointer(obj2, NULL); \ const intype2 arg2 = pycap_get< intype2 > (obj2); \
arg3 = ( intype3 ) PyCapsule_GetPointer(obj3, NULL); \ const intype3 arg3 = pycap_get< intype3 > (obj3); \
\ \
return ctor_ ## outtype ( func (arg1, arg2, arg3, arg4)); \ return ctor_ ## outtype ( func (arg1, arg2, arg3, arg4)); \
} }
@ -947,19 +908,14 @@ static PyObject *
_w ## func (PyObject *self, PyObject *args) \ _w ## func (PyObject *self, PyObject *args) \
{ \ { \
PyObject *obj1, *obj2, *obj3, *obj4; \ PyObject *obj1, *obj2, *obj3, *obj4; \
intype1 arg1; \
intype2 arg2; \
intype3 arg3; \
intype4 arg4; \
\ \
if (!PyArg_ParseTuple(args, "OOOO", &obj1, &obj2, &obj3, &obj4)) \ if (!PyArg_ParseTuple(args, "OOOO", &obj1, &obj2, &obj3, &obj4)) \
return NULL; \ return NULL; \
\ \
arg1 = ( intype1 ) PyCapsule_GetPointer(obj1, NULL); \ const intype1 arg1 = pycap_get< intype1 > (obj1); \
arg2 = ( intype2 ) PyCapsule_GetPointer(obj2, NULL); \ const intype2 arg2 = pycap_get< intype2 > (obj2); \
arg3 = ( intype3 ) PyCapsule_GetPointer(obj3, NULL); \ const intype3 arg3 = pycap_get< intype3 > (obj3); \
arg4 = ( intype4 ) PyCapsule_GetPointer(obj4, NULL); \ const intype4 arg4 = pycap_get< intype4 > (obj4); \
\
return ctor_ ## outtype ( func (arg1, arg2, arg3, arg4)); \ return ctor_ ## outtype ( func (arg1, arg2, arg3, arg4)); \
} }
@ -972,19 +928,15 @@ static PyObject *
_w ## func (PyObject *self, PyObject *args) \ _w ## func (PyObject *self, PyObject *args) \
{ \ { \
PyObject *obj1, *obj2, *obj3, *obj4; \ PyObject *obj1, *obj2, *obj3, *obj4; \
intype1 arg1; \
intype2 arg2; \
intype3 arg3; \
intype4 arg4; \
const char *arg5; \ 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; \
\ \
arg1 = ( intype1 ) PyCapsule_GetPointer(obj1, NULL); \ const intype1 arg1 = pycap_get< intype1 > (obj1); \
arg2 = ( intype2 ) PyCapsule_GetPointer(obj2, NULL); \ const intype2 arg2 = pycap_get< intype2 > (obj2); \
arg3 = ( intype3 ) PyCapsule_GetPointer(obj3, NULL); \ const intype3 arg3 = pycap_get< intype3 > (obj3); \
arg4 = ( intype4 ) PyCapsule_GetPointer(obj4, NULL); \ const intype4 arg4 = pycap_get< intype4 > (obj4); \
\ \
return ctor_ ## outtype ( func (arg1, arg2, arg3, arg4, arg5)); \ return ctor_ ## outtype ( func (arg1, arg2, arg3, arg4, arg5)); \
} }
@ -998,18 +950,15 @@ static PyObject *
_w ## func (PyObject *self, PyObject *args) \ _w ## func (PyObject *self, PyObject *args) \
{ \ { \
PyObject *obj1, *obj3, *obj4; \ PyObject *obj1, *obj3, *obj4; \
intype1 arg1; \ intype2 arg2 ; \
intype2 arg2; \
intype3 arg3; \
intype4 arg4; \
const char *arg5; \ const char *arg5; \
\ \
if (!PyArg_ParseTuple(args, "OiOOs", &obj1, &arg2, &obj3, &obj4, &arg5)) \ if (!PyArg_ParseTuple(args, "OiOOs", &obj1, &arg2, &obj3, &obj4, &arg5)) \
return NULL; \ return NULL; \
\ \
arg1 = ( intype1 ) PyCapsule_GetPointer(obj1, NULL); \ const intype1 arg1 = pycap_get< intype1 > (obj1); \
arg3 = ( intype3 ) PyCapsule_GetPointer(obj3, NULL); \ const intype3 arg3 = pycap_get< intype3 > (obj3); \
arg4 = ( intype4 ) PyCapsule_GetPointer(obj4, NULL); \ const intype4 arg4 = pycap_get< intype4 > (obj4); \
\ \
return ctor_ ## outtype ( func (arg1, arg2, arg3, arg4, arg5)); \ return ctor_ ## outtype ( func (arg1, arg2, arg3, arg4, arg5)); \
} }
@ -1024,21 +973,18 @@ static PyObject * \
_w ## func (PyObject *self, PyObject *args) \ _w ## func (PyObject *self, PyObject *args) \
{ \ { \
PyObject *obj1, *obj2; \ PyObject *obj1, *obj2; \
intype1 arg1; \
intype2 *arg2v; \
unsigned arg2n; \
outtype ret; \
\ \
if (!PyArg_ParseTuple(args, "OO", &obj1, &obj2)) \ if (!PyArg_ParseTuple(args, "OO", &obj1, &obj2)) \
return NULL; \ return NULL; \
\ \
arg1 = ( intype1 ) PyCapsule_GetPointer(obj1, NULL); \ const intype1 arg1 = pycap_get< intype1 > (obj1); \
arg2n = (unsigned) PyList_Size(obj2); \ const size_t arg2n = PyList_Size(obj2); \
if (!(arg2v = ( intype2 *)make_array_from_list(obj2, arg2n)))\ intype2 *arg2v; \
if (!(arg2v = make_array_from_list< intype2 *>(obj2, arg2n))) \
return PyErr_NoMemory(); \ return PyErr_NoMemory(); \
\ \
ret = func (arg1, arg2v, arg2n); \ outtype ret = func (arg1, arg2v, arg2n); \
free(arg2v); \ delete [] arg2v ; \
return ctor_ ## outtype (ret); \ return ctor_ ## outtype (ret); \
} }
@ -1053,19 +999,17 @@ _w ## func (PyObject *self, PyObject *args) \
{ \ { \
PyObject *obj1; \ PyObject *obj1; \
int arg2; \ int arg2; \
intype1 *arg1v; \
unsigned arg1n; \
outtype ret; \
\ \
if (!PyArg_ParseTuple(args, "Oi", &obj1, &arg2)) \ if (!PyArg_ParseTuple(args, "Oi", &obj1, &arg2)) \
return NULL; \ return NULL; \
\ \
arg1n = (unsigned) PyList_Size(obj1); \ const size_t arg1n = PyList_Size(obj1); \
if (!(arg1v = ( intype1 *)make_array_from_list(obj1, arg1n)))\ intype1 *arg1v; \
if (!(arg1v = make_array_from_list< intype1 *>(obj1, arg1n)))\
return PyErr_NoMemory(); \ return PyErr_NoMemory(); \
\ \
ret = func (arg1v, arg1n, arg2); \ outtype ret = func (arg1v, arg1n, arg2); \
free(arg1v); \ delete [] arg1v; \
return ctor_ ## outtype (ret); \ return ctor_ ## outtype (ret); \
} }
@ -1079,19 +1023,17 @@ static PyObject * \
_w ## func (PyObject *self, PyObject *args) \ _w ## func (PyObject *self, PyObject *args) \
{ \ { \
PyObject *obj1; \ PyObject *obj1; \
intype1 *arg1v; \
unsigned arg1n; \
outtype ret; \
\ \
if (!PyArg_ParseTuple(args, "O", &obj1)) \ if (!PyArg_ParseTuple(args, "O", &obj1)) \
return NULL; \ return NULL; \
\ \
arg1n = (unsigned) PyList_Size(obj1); \ const size_t arg1n = PyList_Size(obj1); \
if (!(arg1v = ( intype1 *)make_array_from_list(obj1, arg1n)))\ intype1 *arg1v; \
if (!(arg1v = make_array_from_list< intype1 *>(obj1, arg1n)))\
return PyErr_NoMemory(); \ return PyErr_NoMemory(); \
\ \
ret = func (arg1v, arg1n); \ outtype ret = func (arg1v, arg1n); \
free(arg1v); \ delete [] arg1v; \
return ctor_ ## outtype (ret); \ return ctor_ ## outtype (ret); \
} }
@ -1105,22 +1047,19 @@ static PyObject * \
_w ## func (PyObject *self, PyObject *args) \ _w ## func (PyObject *self, PyObject *args) \
{ \ { \
PyObject *obj1, *obj2; \ PyObject *obj1, *obj2; \
intype1 arg1; \
intype2 *arg2v = NULL; \
unsigned arg2n; \
int arg3; \ int arg3; \
outtype ret; \
\ \
if (!PyArg_ParseTuple(args, "OOi", &obj1, &obj2, &arg3)) \ if (!PyArg_ParseTuple(args, "OOi", &obj1, &obj2, &arg3)) \
return NULL; \ return NULL; \
\ \
arg1 = ( intype1 ) PyCapsule_GetPointer(obj1, NULL); \ intype1 arg1 = pycap_get< intype1 > (obj1); \
arg2n = (unsigned) PyList_Size(obj2); \ const size_t arg2n = PyList_Size(obj2); \
if (arg2n && !(arg2v = ( intype2 *)make_array_from_list(obj2, arg2n)))\ intype2 *arg2v = NULL; \
if (arg2n && !(arg2v = make_array_from_list< intype2 *>(obj2, arg2n)))\
return PyErr_NoMemory(); \ return PyErr_NoMemory(); \
\ \
ret = func (arg1, arg2v, arg2n, arg3); \ outtype ret = func (arg1, arg2v, arg2n, arg3); \
free(arg2v); \ delete [] arg2v ; \
return ctor_ ## outtype (ret); \ return ctor_ ## outtype (ret); \
} }
@ -1135,21 +1074,19 @@ static PyObject * \
_w ## func (PyObject *self, PyObject *args) \ _w ## func (PyObject *self, PyObject *args) \
{ \ { \
PyObject *obj1, *obj2; \ PyObject *obj1, *obj2; \
intype1 arg1; \
intype2 *arg2v; \
unsigned arg2n; \
int arg3; \ int arg3; \
\ \
if (!PyArg_ParseTuple(args, "OOi", &obj1, &obj2, &arg3)) \ if (!PyArg_ParseTuple(args, "OOi", &obj1, &obj2, &arg3)) \
return NULL; \ return NULL; \
\ \
arg1 = ( intype1 ) PyCapsule_GetPointer(obj1, NULL); \ const intype1 arg1 = pycap_get< intype1 > (obj1); \
arg2n = (unsigned) PyList_Size(obj2); \ const size_t arg2n = PyList_Size(obj2); \
if (!(arg2v = ( intype2 *)make_array_from_list(obj2, arg2n)))\ intype2 *arg2v; \
if (!(arg2v = make_array_from_list< intype2 *>(obj2, arg2n)))\
return PyErr_NoMemory(); \ return PyErr_NoMemory(); \
\ \
func (arg1, arg2v, arg2n, arg3); \ func (arg1, arg2v, arg2n, arg3); \
free(arg2v); \ delete [] arg2v ; \
Py_RETURN_NONE; \ Py_RETURN_NONE; \
} }
@ -1163,22 +1100,19 @@ static PyObject * \
_w ## func (PyObject *self, PyObject *args) \ _w ## func (PyObject *self, PyObject *args) \
{ \ { \
PyObject *obj1, *obj3; \ PyObject *obj1, *obj3; \
intype1 arg1; \
int arg2; \ int arg2; \
intype3 *arg3v; \
unsigned arg3n; \
outtype ret; \
\ \
if (!PyArg_ParseTuple(args, "OiO", &obj1, &arg2, &obj3)) \ if (!PyArg_ParseTuple(args, "OiO", &obj1, &arg2, &obj3)) \
return NULL; \ return NULL; \
\ \
arg1 = ( intype1 ) PyCapsule_GetPointer(obj1, NULL); \ const intype1 arg1 = pycap_get< intype1 > (obj1); \
arg3n = (unsigned) PyList_Size(obj3); \ const size_t arg3n = PyList_Size(obj3); \
if (!(arg3v = ( intype3 *)make_array_from_list(obj3, arg3n)))\ intype3 *arg3v; \
if (!(arg3v = make_array_from_list< intype3 *>(obj3, arg3n))) \
return PyErr_NoMemory(); \ return PyErr_NoMemory(); \
\ \
ret = func (arg1, arg2, arg3v, arg3n); \ outtype ret = func (arg1, arg2, arg3v, arg3n); \
free(arg3v); \ delete [] arg3v ; \
return ctor_ ## outtype (ret); \ return ctor_ ## outtype (ret); \
} }
@ -1192,23 +1126,19 @@ static PyObject * \
_w ## func (PyObject *self, PyObject *args) \ _w ## func (PyObject *self, PyObject *args) \
{ \ { \
PyObject *obj1, *obj2, *obj3; \ PyObject *obj1, *obj2, *obj3; \
intype1 arg1; \
intype2 arg2; \
intype3 *arg3v; \
unsigned arg3n; \
outtype ret; \
\ \
if (!PyArg_ParseTuple(args, "OOO", &obj1, &obj2, &obj3)) \ if (!PyArg_ParseTuple(args, "OOO", &obj1, &obj2, &obj3)) \
return NULL; \ return NULL; \
\ \
arg1 = ( intype1 ) PyCapsule_GetPointer(obj1, NULL); \ const intype1 arg1 = pycap_get< intype1 > (obj1); \
arg2 = ( intype2 ) PyCapsule_GetPointer(obj2, NULL); \ const intype2 arg2 = pycap_get< intype2 > (obj2); \
arg3n = (unsigned) PyList_Size(obj3); \ const size_t arg3n = PyList_Size(obj3); \
if (!(arg3v = ( intype3 *)make_array_from_list(obj3, arg3n))) \ intype3 *arg3v; \
if (!(arg3v = make_array_from_list< intype3 *>(obj3, arg3n))) \
return PyErr_NoMemory(); \ return PyErr_NoMemory(); \
\ \
ret = func (arg1, arg2, arg3v, arg3n); \ outtype ret = func (arg1, arg2, arg3v, arg3n); \
free(arg3v); \ delete [] arg3v ; \
return ctor_ ## outtype (ret); \ return ctor_ ## outtype (ret); \
} }
@ -1223,23 +1153,19 @@ _w ## func (PyObject *self, PyObject *args) \
{ \ { \
PyObject *obj1, *obj2, *obj3; \ PyObject *obj1, *obj2, *obj3; \
const char *arg4; \ const char *arg4; \
intype1 arg1; \
intype2 arg2; \
intype3 *arg3v; \
unsigned arg3n; \
outtype ret; \
\ \
if (!PyArg_ParseTuple(args, "OOOs", &obj1, &obj2, &obj3, &arg4)) \ if (!PyArg_ParseTuple(args, "OOOs", &obj1, &obj2, &obj3, &arg4)) \
return NULL; \ return NULL; \
\ \
arg1 = ( intype1 ) PyCapsule_GetPointer(obj1, NULL); \ const intype1 arg1 = pycap_get< intype1 > (obj1); \
arg2 = ( intype2 ) PyCapsule_GetPointer(obj2, NULL); \ const intype2 arg2 = pycap_get< intype2 > (obj2); \
arg3n = ( unsigned ) PyList_Size(obj3); \ const size_t arg3n = PyList_Size(obj3); \
if (!(arg3v = ( intype3 *)make_array_from_list(obj3, arg3n))) \ intype3 *arg3v; \
if (!(arg3v = make_array_from_list< intype3 *>(obj3, arg3n))) \
return PyErr_NoMemory(); \ return PyErr_NoMemory(); \
\ \
ret = func (arg1, arg2, arg3v, arg3n, arg4); \ outtype ret = func (arg1, arg2, arg3v, arg3n, arg4); \
free(arg3v); \ delete [] arg3v ; \
return ctor_ ## outtype (ret); \ return ctor_ ## outtype (ret); \
} }
@ -1254,18 +1180,15 @@ static PyObject * \
_w ## func (PyObject *self, PyObject *args) \ _w ## func (PyObject *self, PyObject *args) \
{ \ { \
intype1 arg1; \ intype1 arg1; \
char *val; \
PyObject *ret; \
\ \
if (!(arg1= ( intype1 ) get_object_arg(args))) \ if (!(arg1 = get_object_arg<intype1>(args))) \
return NULL; \ return NULL; \
\ \
val = func (arg1); \ const char *val = func (arg1); \
ret = PyUnicode_FromString(val); \ PyObject *ret = PyUnicode_FromString(val); \
LLVMDisposeMessage(val); \ LLVMDisposeMessage(const_cast<char*>(val)); \
return ret; \ return ret; \
} }
#endif /* LLVM_PY_WRAP_H */ #endif /* LLVM_PY_WRAP_H */