Merge pull request #23 from dand-oss/master
pycap_new() template replaces a bunch of macro code
This commit is contained in:
commit
d642bfdfe6
3 changed files with 148 additions and 190 deletions
|
|
@ -56,6 +56,48 @@
|
||||||
typedef int Py_ssize_t;
|
typedef int Py_ssize_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
// explicit specializations
|
||||||
|
template <> PyObject* pycap_new<int>(int i)
|
||||||
|
{
|
||||||
|
return PyLong_FromLong(static_cast<long>(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <> PyObject* pycap_new<size_t>(size_t i)
|
||||||
|
{
|
||||||
|
return PyLong_FromLong(static_cast<unsigned long>(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <> PyObject* pycap_new<LLVMTypeKind>(LLVMTypeKind i)
|
||||||
|
{
|
||||||
|
return PyLong_FromLong(static_cast<unsigned long>(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <> PyObject* pycap_new<LLVMLinkage>(LLVMLinkage i)
|
||||||
|
{
|
||||||
|
return PyLong_FromLong(static_cast<unsigned long>(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <> PyObject* pycap_new<LLVMVisibility>(LLVMVisibility i)
|
||||||
|
{
|
||||||
|
return PyLong_FromLong(static_cast<unsigned long>(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <> PyObject* pycap_new<LLVMByteOrdering>(LLVMByteOrdering i)
|
||||||
|
{
|
||||||
|
return PyLong_FromLong(static_cast<unsigned long>(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <> PyObject* pycap_new<unsigned long long>(unsigned long long ull)
|
||||||
|
{
|
||||||
|
return PyLong_FromUnsignedLongLong(ull);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <> PyObject* pycap_new<long long>(long long ll)
|
||||||
|
{
|
||||||
|
return PyLong_FromLongLong(ll);
|
||||||
|
}
|
||||||
|
|
||||||
/*===----------------------------------------------------------------------===*/
|
/*===----------------------------------------------------------------------===*/
|
||||||
/* Modules */
|
/* Modules */
|
||||||
/*===----------------------------------------------------------------------===*/
|
/*===----------------------------------------------------------------------===*/
|
||||||
|
|
@ -71,7 +113,7 @@ _wLLVMModuleCreateWithName(PyObject *self, PyObject *args)
|
||||||
}
|
}
|
||||||
|
|
||||||
const LLVMModuleRef module = LLVMModuleCreateWithName(s);
|
const LLVMModuleRef module = LLVMModuleCreateWithName(s);
|
||||||
return ctor_LLVMModuleRef(module);
|
return pycap_new<LLVMModuleRef>(module);
|
||||||
_CATCH_ALL
|
_CATCH_ALL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -86,7 +128,7 @@ _wrap_objstr2obj(LLVMGetTypeByName, LLVMModuleRef, LLVMTypeRef)
|
||||||
_wrap_obj2none(LLVMDumpModule, LLVMModuleRef)
|
_wrap_obj2none(LLVMDumpModule, LLVMModuleRef)
|
||||||
_wrap_obj2none(LLVMDisposeModule, LLVMModuleRef)
|
_wrap_obj2none(LLVMDisposeModule, LLVMModuleRef)
|
||||||
_wrap_dumper(LLVMDumpModuleToString, LLVMModuleRef)
|
_wrap_dumper(LLVMDumpModuleToString, LLVMModuleRef)
|
||||||
_wrap_obj2obj(LLVMModuleGetPointerSize, LLVMModuleRef, int)
|
_wrap_obj2obj( LLVMModuleGetPointerSize, LLVMModuleRef, int)
|
||||||
_wrap_objstrobj2obj(LLVMModuleGetOrInsertFunction, LLVMModuleRef,
|
_wrap_objstrobj2obj(LLVMModuleGetOrInsertFunction, LLVMModuleRef,
|
||||||
LLVMTypeRef, LLVMValueRef)
|
LLVMTypeRef, LLVMValueRef)
|
||||||
|
|
||||||
|
|
@ -138,7 +180,7 @@ _wLLVMGetModuleFromAssembly(PyObject *self, PyObject *args)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ctor_LLVMModuleRef(mod);
|
return pycap_new<LLVMModuleRef>(mod);
|
||||||
_CATCH_ALL
|
_CATCH_ALL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -168,7 +210,7 @@ _wLLVMGetModuleFromBitcode(PyObject *self, PyObject *args)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ctor_LLVMModuleRef(m);
|
return pycap_new<LLVMModuleRef>(m);
|
||||||
_CATCH_ALL
|
_CATCH_ALL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -309,8 +351,7 @@ obj2arr(PyObject *self, PyObject *args, arrcnt_fn_t cntfunc, obj2arr_fn_t arrfun
|
||||||
arrfunc(type, param_types);
|
arrfunc(type, param_types);
|
||||||
|
|
||||||
/* create a list from the array */
|
/* create a list from the array */
|
||||||
PyObject *list
|
PyObject *list = make_list<LLVMTypeRef>(param_types, param_count);
|
||||||
= make_list_from_LLVMTypeRef_array(param_types, param_count);
|
|
||||||
|
|
||||||
/* free temp storage */
|
/* free temp storage */
|
||||||
delete [] param_types ;
|
delete [] param_types ;
|
||||||
|
|
@ -403,7 +444,7 @@ _wLLVMValueGetUses(PyObject *self, PyObject *args)
|
||||||
LLVMValueRef *uses = 0;
|
LLVMValueRef *uses = 0;
|
||||||
size_t n = LLVMValueGetUses(value, &uses);
|
size_t n = LLVMValueGetUses(value, &uses);
|
||||||
|
|
||||||
PyObject *list = make_list_from_LLVMValueRef_array(uses, n);
|
PyObject *list = make_list<LLVMValueRef>(uses, n);
|
||||||
if (n > 0)
|
if (n > 0)
|
||||||
LLVMDisposeValueRefArray(uses);
|
LLVMDisposeValueRefArray(uses);
|
||||||
|
|
||||||
|
|
@ -444,7 +485,7 @@ _wLLVMConstInt(PyObject *self, PyObject *args)
|
||||||
|
|
||||||
const LLVMValueRef val = LLVMConstInt(ty, n, sign_extend);
|
const LLVMValueRef val = LLVMConstInt(ty, n, sign_extend);
|
||||||
|
|
||||||
return ctor_LLVMValueRef(val);
|
return pycap_new<LLVMValueRef>(val);
|
||||||
_CATCH_ALL
|
_CATCH_ALL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -461,7 +502,7 @@ _wLLVMConstReal(PyObject *self, PyObject *args)
|
||||||
const LLVMTypeRef ty = pycap_get<LLVMTypeRef>( obj ) ;
|
const LLVMTypeRef ty = pycap_get<LLVMTypeRef>( obj ) ;
|
||||||
|
|
||||||
const LLVMValueRef val = LLVMConstReal(ty, d);
|
const LLVMValueRef val = LLVMConstReal(ty, d);
|
||||||
return ctor_LLVMValueRef(val);
|
return pycap_new<LLVMValueRef>(val);
|
||||||
_CATCH_ALL
|
_CATCH_ALL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -483,7 +524,7 @@ _wLLVMConstString(PyObject *self, PyObject *args)
|
||||||
}
|
}
|
||||||
|
|
||||||
LLVMValueRef val = LLVMConstString(s, strlen(s), dont_null_terminate);
|
LLVMValueRef val = LLVMConstString(s, strlen(s), dont_null_terminate);
|
||||||
return ctor_LLVMValueRef(val);
|
return pycap_new<LLVMValueRef>(val);
|
||||||
_CATCH_ALL
|
_CATCH_ALL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -600,7 +641,7 @@ _wLLVMVerifyFunction(PyObject *self, PyObject *args)
|
||||||
const LLVMValueRef fn = get_object_arg<LLVMValueRef>(args);
|
const LLVMValueRef fn = get_object_arg<LLVMValueRef>(args);
|
||||||
if (!fn) return NULL;
|
if (!fn) return NULL;
|
||||||
|
|
||||||
return ctor_int(LLVMVerifyFunction(fn, LLVMReturnStatusAction));
|
return pycap_new<int>(LLVMVerifyFunction(fn, LLVMReturnStatusAction));
|
||||||
_CATCH_ALL
|
_CATCH_ALL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -651,7 +692,7 @@ _wLLVMGetNamedMetadataOperands(PyObject *self, PyObject *args)
|
||||||
LLVMValueRef *operands = new LLVMValueRef[num_operands];
|
LLVMValueRef *operands = new LLVMValueRef[num_operands];
|
||||||
LLVMGetNamedMetadataOperands(module, name, operands);
|
LLVMGetNamedMetadataOperands(module, name, operands);
|
||||||
|
|
||||||
PyObject *list = make_list_from_LLVMValueRef_array(operands, num_operands);
|
PyObject *list = make_list<LLVMValueRef>(operands, num_operands);
|
||||||
delete [] operands;
|
delete [] operands;
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
|
|
@ -749,7 +790,7 @@ _wLLVMBuildInvoke(PyObject *self, PyObject *args)
|
||||||
|
|
||||||
delete [] fnargs;
|
delete [] fnargs;
|
||||||
|
|
||||||
return ctor_LLVMValueRef(inst);
|
return pycap_new<LLVMValueRef>(inst);
|
||||||
_CATCH_ALL
|
_CATCH_ALL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -855,7 +896,7 @@ _wLLVMCreateMemoryBufferWithContentsOfFile(PyObject *self, PyObject *args)
|
||||||
|
|
||||||
char *outmsg;
|
char *outmsg;
|
||||||
if (!LLVMCreateMemoryBufferWithContentsOfFile(path, &ref, &outmsg)) {
|
if (!LLVMCreateMemoryBufferWithContentsOfFile(path, &ref, &outmsg)) {
|
||||||
ret = ctor_LLVMMemoryBufferRef(ref);
|
ret = pycap_new<LLVMMemoryBufferRef>(ref);
|
||||||
} else {
|
} else {
|
||||||
ret = PyUnicode_FromString(outmsg);
|
ret = PyUnicode_FromString(outmsg);
|
||||||
LLVMDisposeMessage(outmsg);
|
LLVMDisposeMessage(outmsg);
|
||||||
|
|
@ -873,7 +914,7 @@ _wLLVMCreateMemoryBufferWithSTDIN(PyObject *self, PyObject *args)
|
||||||
LLVMMemoryBufferRef ref;
|
LLVMMemoryBufferRef ref;
|
||||||
char *outmsg;
|
char *outmsg;
|
||||||
if (!LLVMCreateMemoryBufferWithSTDIN(&ref, &outmsg)) {
|
if (!LLVMCreateMemoryBufferWithSTDIN(&ref, &outmsg)) {
|
||||||
ret = ctor_LLVMMemoryBufferRef(ref);
|
ret = pycap_new<LLVMMemoryBufferRef>(ref);
|
||||||
} else {
|
} else {
|
||||||
ret = PyUnicode_FromString(outmsg);
|
ret = PyUnicode_FromString(outmsg);
|
||||||
LLVMDisposeMessage(outmsg);
|
LLVMDisposeMessage(outmsg);
|
||||||
|
|
@ -1087,7 +1128,7 @@ _wLLVMTargetMachineLookup(PyObject * self, PyObject * args)
|
||||||
PyErr_SetString(PyExc_RuntimeError, error.c_str());
|
PyErr_SetString(PyExc_RuntimeError, error.c_str());
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return ctor_LLVMTargetMachineRef(tm);
|
return pycap_new<LLVMTargetMachineRef>(tm);
|
||||||
_CATCH_ALL
|
_CATCH_ALL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1200,7 +1241,7 @@ _wLLVMEngineBuilderCreate(PyObject *self, PyObject *args)
|
||||||
if( !ee ){ // check if error message is set.
|
if( !ee ){ // check if error message is set.
|
||||||
ret = PyUnicode_FromString(outmsg.c_str());
|
ret = PyUnicode_FromString(outmsg.c_str());
|
||||||
}else{
|
}else{
|
||||||
ret = ctor_LLVMExecutionEngineRef(ee);
|
ret = pycap_new<LLVMExecutionEngineRef>(ee);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
@ -1236,7 +1277,7 @@ _wLLVMCreateExecutionEngine(PyObject *self, PyObject *args)
|
||||||
ret = PyUnicode_FromString(outmsg);
|
ret = PyUnicode_FromString(outmsg);
|
||||||
LLVMDisposeMessage(outmsg);
|
LLVMDisposeMessage(outmsg);
|
||||||
} else {
|
} else {
|
||||||
ret = ctor_LLVMExecutionEngineRef(ee);
|
ret = pycap_new<LLVMExecutionEngineRef>(ee);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
@ -1284,7 +1325,7 @@ _wLLVMRemoveModule2(PyObject *self, PyObject *args)
|
||||||
LLVMRemoveModule(ee, mod, &mod_new, &outmsg);
|
LLVMRemoveModule(ee, mod, &mod_new, &outmsg);
|
||||||
PyObject *ret;
|
PyObject *ret;
|
||||||
if (mod_new) {
|
if (mod_new) {
|
||||||
ret = ctor_LLVMModuleRef(mod_new);
|
ret = pycap_new<LLVMModuleRef>(mod_new);
|
||||||
} else {
|
} else {
|
||||||
if (outmsg) {
|
if (outmsg) {
|
||||||
ret = PyUnicode_FromString(outmsg);
|
ret = PyUnicode_FromString(outmsg);
|
||||||
|
|
@ -1330,7 +1371,7 @@ _wLLVMCreateGenericValueOfInt(PyObject *self, PyObject *args)
|
||||||
const LLVMTypeRef ty = pycap_get<LLVMTypeRef>( obj1 ) ;
|
const LLVMTypeRef ty = pycap_get<LLVMTypeRef>( obj1 ) ;
|
||||||
|
|
||||||
gv = LLVMCreateGenericValueOfInt(ty, n, is_signed);
|
gv = LLVMCreateGenericValueOfInt(ty, n, is_signed);
|
||||||
return ctor_LLVMGenericValueRef(gv);
|
return pycap_new<LLVMGenericValueRef>(gv);
|
||||||
_CATCH_ALL
|
_CATCH_ALL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1348,7 +1389,7 @@ _wLLVMCreateGenericValueOfFloat(PyObject *self, PyObject *args)
|
||||||
const LLVMTypeRef ty = pycap_get<LLVMTypeRef>( obj1 ) ;
|
const LLVMTypeRef ty = pycap_get<LLVMTypeRef>( obj1 ) ;
|
||||||
|
|
||||||
gv = LLVMCreateGenericValueOfFloat(ty, d);
|
gv = LLVMCreateGenericValueOfFloat(ty, d);
|
||||||
return ctor_LLVMGenericValueRef(gv);
|
return pycap_new<LLVMGenericValueRef>(gv);
|
||||||
_CATCH_ALL
|
_CATCH_ALL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1367,7 +1408,7 @@ _wLLVMCreateGenericValueOfPointer(PyObject *self, PyObject *args)
|
||||||
n=n_;
|
n=n_;
|
||||||
|
|
||||||
const LLVMGenericValueRef gv = LLVMCreateGenericValueOfPointer((void*)n);
|
const LLVMGenericValueRef gv = LLVMCreateGenericValueOfPointer((void*)n);
|
||||||
return ctor_LLVMGenericValueRef(gv);
|
return pycap_new<LLVMGenericValueRef>(gv);
|
||||||
_CATCH_ALL
|
_CATCH_ALL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,52 +30,10 @@
|
||||||
|
|
||||||
#include "wrap.h"
|
#include "wrap.h"
|
||||||
|
|
||||||
/*===----------------------------------------------------------------------===*/
|
|
||||||
/* Helper functions/macros */
|
|
||||||
/*===----------------------------------------------------------------------===*/
|
|
||||||
|
|
||||||
#define _define_std_ctor(typ) \
|
|
||||||
PyObject * ctor_ ## typ ( typ p) \
|
|
||||||
{ \
|
|
||||||
if (p){ \
|
|
||||||
return PyCapsule_New(p, NULL, NULL); \
|
|
||||||
} \
|
|
||||||
Py_RETURN_NONE; \
|
|
||||||
}
|
|
||||||
|
|
||||||
/*===----------------------------------------------------------------------===*/
|
/*===----------------------------------------------------------------------===*/
|
||||||
/* Type ctor/dtor */
|
/* Type ctor/dtor */
|
||||||
/*===----------------------------------------------------------------------===*/
|
/*===----------------------------------------------------------------------===*/
|
||||||
|
|
||||||
_define_std_ctor(LLVMModuleRef)
|
|
||||||
_define_std_ctor(LLVMTypeRef)
|
|
||||||
_define_std_ctor(LLVMValueRef)
|
|
||||||
_define_std_ctor(LLVMBasicBlockRef)
|
|
||||||
_define_std_ctor(LLVMBuilderRef)
|
|
||||||
_define_std_ctor(LLVMMemoryBufferRef)
|
|
||||||
_define_std_ctor(LLVMPassManagerRef)
|
|
||||||
_define_std_ctor(LLVMExecutionEngineRef)
|
|
||||||
_define_std_ctor(LLVMTargetDataRef)
|
|
||||||
_define_std_ctor(LLVMGenericValueRef)
|
|
||||||
|
|
||||||
_define_std_ctor(LLVMPassManagerBuilderRef)
|
|
||||||
_define_std_ctor(LLVMEngineBuilderRef)
|
|
||||||
_define_std_ctor(LLVMTargetMachineRef)
|
|
||||||
|
|
||||||
PyObject *ctor_int(int i)
|
|
||||||
{
|
|
||||||
return PyLong_FromLong((long)i);
|
|
||||||
}
|
|
||||||
|
|
||||||
PyObject *ctor_llvmwrap_ull(llvmwrap_ull ull)
|
|
||||||
{
|
|
||||||
return PyLong_FromUnsignedLongLong(ull);
|
|
||||||
}
|
|
||||||
|
|
||||||
PyObject *ctor_llvmwrap_ll(llvmwrap_ll ll)
|
|
||||||
{
|
|
||||||
return PyLong_FromLongLong(ll);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*===----------------------------------------------------------------------===*/
|
/*===----------------------------------------------------------------------===*/
|
||||||
/* Helper functions */
|
/* Helper functions */
|
||||||
|
|
@ -108,24 +66,3 @@ void **make_array_from_list(PyObject *list, int n)
|
||||||
|
|
||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define LIST_FROM_ARRAY_IMPL(TYPE) \
|
|
||||||
PyObject *make_list_from_ ## TYPE ## _array( TYPE *p, size_t n) \
|
|
||||||
{ \
|
|
||||||
size_t i; \
|
|
||||||
PyObject *list = PyList_New(n); \
|
|
||||||
\
|
|
||||||
if (!list) \
|
|
||||||
throw py_exception(); \
|
|
||||||
\
|
|
||||||
for (i=0; i<n; i++) { \
|
|
||||||
PyObject *elem = ctor_ ## TYPE (p[i]); \
|
|
||||||
PyList_SetItem(list, i, elem); \
|
|
||||||
} \
|
|
||||||
\
|
|
||||||
return list; \
|
|
||||||
}
|
|
||||||
|
|
||||||
LIST_FROM_ARRAY_IMPL(LLVMTypeRef)
|
|
||||||
LIST_FROM_ARRAY_IMPL(LLVMValueRef)
|
|
||||||
|
|
||||||
|
|
|
||||||
180
llvm/wrap.h
180
llvm/wrap.h
|
|
@ -91,37 +91,22 @@ typedef long long llvmwrap_ll;
|
||||||
/* Type ctor/dtor */
|
/* Type ctor/dtor */
|
||||||
/*===----------------------------------------------------------------------===*/
|
/*===----------------------------------------------------------------------===*/
|
||||||
|
|
||||||
/* These are functions that can construct a PyCObject (a Python object that
|
// Cast python object to aTYPE
|
||||||
* holds an opaque pointer) from any time. The naming convention is significant,
|
template <typename aTYPE>
|
||||||
* this is assumed by the wrapper macros below. These are the equivalent of
|
aTYPE pycap_get( PyObject* obj )
|
||||||
* what would in C++ have been specializations of a template function ctor<T>
|
{
|
||||||
* for various types.
|
return static_cast<aTYPE> ( PyCapsule_GetPointer(obj, NULL) );
|
||||||
*/
|
}
|
||||||
|
|
||||||
#define _declare_std_ctor(typ) \
|
|
||||||
PyObject * ctor_ ## typ ( typ p);
|
|
||||||
|
|
||||||
_declare_std_ctor(LLVMModuleRef)
|
|
||||||
_declare_std_ctor(LLVMTypeRef)
|
|
||||||
_declare_std_ctor(LLVMValueRef)
|
|
||||||
_declare_std_ctor(LLVMBasicBlockRef)
|
|
||||||
_declare_std_ctor(LLVMBuilderRef)
|
|
||||||
_declare_std_ctor(LLVMMemoryBufferRef)
|
|
||||||
_declare_std_ctor(LLVMPassManagerRef)
|
|
||||||
_declare_std_ctor(LLVMExecutionEngineRef)
|
|
||||||
_declare_std_ctor(LLVMTargetDataRef)
|
|
||||||
_declare_std_ctor(LLVMGenericValueRef)
|
|
||||||
|
|
||||||
// extra LLVM classes
|
|
||||||
_declare_std_ctor(LLVMPassManagerBuilderRef)
|
|
||||||
_declare_std_ctor(LLVMEngineBuilderRef)
|
|
||||||
_declare_std_ctor(LLVMTargetMachineRef)
|
|
||||||
|
|
||||||
/* standard types */
|
|
||||||
_declare_std_ctor(int)
|
|
||||||
_declare_std_ctor(llvmwrap_ull)
|
|
||||||
_declare_std_ctor(llvmwrap_ll)
|
|
||||||
|
|
||||||
|
// Contruct python object to hold aTYPE pointer
|
||||||
|
template <typename aTYPE>
|
||||||
|
PyObject* pycap_new( aTYPE p )
|
||||||
|
{
|
||||||
|
if (p){
|
||||||
|
return PyCapsule_New(p, NULL, NULL);
|
||||||
|
}
|
||||||
|
Py_RETURN_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
/*===----------------------------------------------------------------------===*/
|
/*===----------------------------------------------------------------------===*/
|
||||||
/* Helper methods */
|
/* Helper methods */
|
||||||
|
|
@ -133,6 +118,12 @@ _declare_std_ctor(llvmwrap_ll)
|
||||||
*/
|
*/
|
||||||
void *get_object_arg(PyObject *args);
|
void *get_object_arg(PyObject *args);
|
||||||
|
|
||||||
|
template <typename aTYPE>
|
||||||
|
aTYPE get_object_arg( PyObject* obj )
|
||||||
|
{
|
||||||
|
return static_cast<aTYPE> ( get_object_arg(obj) );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Given a PyList object (list) having n (= PyList_Size(list)) elements,
|
* Given a PyList object (list) having n (= PyList_Size(list)) elements,
|
||||||
* each list object being a PyCObject, return a new()-ed array of
|
* each list object being a PyCObject, return a new()-ed array of
|
||||||
|
|
@ -142,38 +133,29 @@ void *get_object_arg(PyObject *args);
|
||||||
*/
|
*/
|
||||||
void **make_array_from_list(PyObject *list, int n);
|
void **make_array_from_list(PyObject *list, int n);
|
||||||
|
|
||||||
/**
|
|
||||||
* Given an array of LLVMTypeRef's, create a PyList object.
|
|
||||||
*/
|
|
||||||
PyObject *make_list_from_LLVMTypeRef_array(LLVMTypeRef *p, size_t n);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Given an array of LLVMValueRef's, create a PyList object.
|
|
||||||
*/
|
|
||||||
PyObject *make_list_from_LLVMValueRef_array(LLVMValueRef *p, size_t n);
|
|
||||||
|
|
||||||
/*===----------------------------------------------------------------------===*/
|
|
||||||
/* Template functions */
|
|
||||||
|
|
||||||
// wrap the cast
|
|
||||||
template <typename LLTYPE>
|
template <typename LLTYPE>
|
||||||
LLTYPE pycap_get( PyObject* obj )
|
LLTYPE make_array_from_list(PyObject *list, int n)
|
||||||
{
|
{
|
||||||
LLTYPE p = static_cast<LLTYPE> ( PyCapsule_GetPointer(obj, NULL) );
|
LLTYPE p = reinterpret_cast<LLTYPE>(make_array_from_list(list, n)) ;
|
||||||
if ( !p ) throw py_exception();
|
if ( !p ) throw py_exception();
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename LLTYPE>
|
template <typename aTYPE>
|
||||||
LLTYPE get_object_arg( PyObject* obj )
|
PyObject* make_list( aTYPE p[], size_t n )
|
||||||
{
|
{
|
||||||
return static_cast<LLTYPE> ( get_object_arg(obj) );
|
PyObject *list = PyList_New(n);
|
||||||
}
|
|
||||||
|
|
||||||
template <typename LLTYPE>
|
if (!list)
|
||||||
LLTYPE make_array_from_list(PyObject *list, int n)
|
return NULL;
|
||||||
{
|
|
||||||
return reinterpret_cast<LLTYPE>(make_array_from_list(list, n)) ;
|
size_t i;
|
||||||
|
for (i=0; i<n; i++) {
|
||||||
|
PyObject *elem = pycap_new<aTYPE>( p[i] );
|
||||||
|
PyList_SetItem(list, i, elem);
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*===----------------------------------------------------------------------===*/
|
/*===----------------------------------------------------------------------===*/
|
||||||
|
|
@ -216,7 +198,7 @@ _w ## func (PyObject *self, PyObject *args) \
|
||||||
_TRY \
|
_TRY \
|
||||||
intype1 arg1 = get_object_arg<intype1>(args); \
|
intype1 arg1 = get_object_arg<intype1>(args); \
|
||||||
\
|
\
|
||||||
return ctor_ ## outtype ( func (arg1)); \
|
return pycap_new<outtype>( func( arg1 ) ); \
|
||||||
_CATCH_ALL \
|
_CATCH_ALL \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -234,7 +216,7 @@ _w ## func (PyObject *self, PyObject *args) \
|
||||||
if (!PyArg_ParseTuple(args, "i", &arg1)) \
|
if (!PyArg_ParseTuple(args, "i", &arg1)) \
|
||||||
return NULL; \
|
return NULL; \
|
||||||
\
|
\
|
||||||
return ctor_ ## outtype ( func (arg1)); \
|
return pycap_new<outtype>( func( arg1 ) ); \
|
||||||
_CATCH_ALL \
|
_CATCH_ALL \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -255,7 +237,7 @@ _w ## func (PyObject *self, PyObject *args) \
|
||||||
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); \
|
||||||
\
|
\
|
||||||
return ctor_ ## outtype ( func (arg1, arg2)); \
|
return pycap_new<outtype>( func( arg1, arg2 ) ); \
|
||||||
_CATCH_ALL \
|
_CATCH_ALL \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -298,7 +280,7 @@ _w ## func (PyObject *self, PyObject *args) \
|
||||||
\
|
\
|
||||||
const intype1 arg1 = pycap_get< intype1 > (obj1); \
|
const intype1 arg1 = pycap_get< intype1 > (obj1); \
|
||||||
\
|
\
|
||||||
return ctor_ ## outtype ( func (arg1, arg2)); \
|
return pycap_new<outtype>( func( arg1, arg2 ) ); \
|
||||||
_CATCH_ALL \
|
_CATCH_ALL \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -320,7 +302,7 @@ _w ## func (PyObject *self, PyObject *args) \
|
||||||
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); \
|
||||||
\
|
\
|
||||||
return ctor_ ## outtype ( func (arg1, arg2, arg3)); \
|
return pycap_new<outtype>( func( arg1, arg2, arg3 ) ); \
|
||||||
_CATCH_ALL \
|
_CATCH_ALL \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -365,7 +347,7 @@ _w ## func (PyObject *self, PyObject *args) \
|
||||||
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); \
|
||||||
\
|
\
|
||||||
return ctor_ ## outtype ( func (arg1, arg2, arg3)); \
|
return pycap_new<outtype>( func( arg1, arg2, arg3 ) ); \
|
||||||
_CATCH_ALL \
|
_CATCH_ALL \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -387,7 +369,7 @@ _w ## func (PyObject *self, PyObject *args) \
|
||||||
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); \
|
||||||
\
|
\
|
||||||
return ctor_ ## outtype ( func (arg1, arg2, arg3)); \
|
return pycap_new<outtype>( func( arg1, arg2, arg3 ) ); \
|
||||||
_CATCH_ALL \
|
_CATCH_ALL \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -405,7 +387,7 @@ _w ## func (PyObject *self, PyObject *args) \
|
||||||
if (!PyArg_ParseTuple(args, "s", &arg1)) \
|
if (!PyArg_ParseTuple(args, "s", &arg1)) \
|
||||||
return NULL; \
|
return NULL; \
|
||||||
\
|
\
|
||||||
return ctor_ ## outtype ( func (arg1)); \
|
return pycap_new<outtype>( func( arg1 ) ); \
|
||||||
_CATCH_ALL \
|
_CATCH_ALL \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -421,7 +403,7 @@ _w ## func (PyObject *self, PyObject *args) \
|
||||||
if (!PyArg_ParseTuple(args, "")) \
|
if (!PyArg_ParseTuple(args, "")) \
|
||||||
return NULL; \
|
return NULL; \
|
||||||
\
|
\
|
||||||
return ctor_ ## outtype ( func ()); \
|
return pycap_new<outtype>( func() ); \
|
||||||
_CATCH_ALL \
|
_CATCH_ALL \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -451,8 +433,7 @@ static PyObject * \
|
||||||
_w ## func (PyObject *self, PyObject *args) \
|
_w ## func (PyObject *self, PyObject *args) \
|
||||||
{ \
|
{ \
|
||||||
_TRY \
|
_TRY \
|
||||||
intype1 arg1 = get_object_arg<intype1>(args); \
|
const intype1 arg1 = get_object_arg<intype1>(args) ; \
|
||||||
\
|
|
||||||
return PyUnicode_FromString( func (arg1)); \
|
return PyUnicode_FromString( func (arg1)); \
|
||||||
_CATCH_ALL \
|
_CATCH_ALL \
|
||||||
}
|
}
|
||||||
|
|
@ -466,8 +447,7 @@ static PyObject * \
|
||||||
_w ## func (PyObject *self, PyObject *args) \
|
_w ## func (PyObject *self, PyObject *args) \
|
||||||
{ \
|
{ \
|
||||||
_TRY \
|
_TRY \
|
||||||
intype1 arg1 = get_object_arg<intype1>(args); \
|
const intype1 arg1 = get_object_arg<intype1>(args) ; \
|
||||||
\
|
|
||||||
func (arg1); \
|
func (arg1); \
|
||||||
Py_RETURN_NONE; \
|
Py_RETURN_NONE; \
|
||||||
_CATCH_ALL \
|
_CATCH_ALL \
|
||||||
|
|
@ -488,7 +468,7 @@ _w ## func (PyObject *self, PyObject *args) \
|
||||||
if (!PyArg_ParseTuple(args, "Os", &obj1, &arg2)) \
|
if (!PyArg_ParseTuple(args, "Os", &obj1, &arg2)) \
|
||||||
return NULL; \
|
return NULL; \
|
||||||
\
|
\
|
||||||
const intype1 arg1 = pycap_get< intype1 > (obj1); \
|
const intype1 arg1 = pycap_get< intype1 >( obj1 ); \
|
||||||
\
|
\
|
||||||
func (arg1, arg2); \
|
func (arg1, arg2); \
|
||||||
Py_RETURN_NONE; \
|
Py_RETURN_NONE; \
|
||||||
|
|
@ -512,7 +492,7 @@ _w ## func (PyObject *self, PyObject *args) \
|
||||||
\
|
\
|
||||||
const intype1 arg1 = pycap_get< intype1 > (obj1); \
|
const intype1 arg1 = pycap_get< intype1 > (obj1); \
|
||||||
\
|
\
|
||||||
return ctor_ ## outtype ( func (arg1, arg2)); \
|
return pycap_new<outtype>( func( arg1, arg2 ) ); \
|
||||||
_CATCH_ALL \
|
_CATCH_ALL \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -553,7 +533,7 @@ _w ## func (PyObject *self, PyObject *args) \
|
||||||
if (!PyArg_ParseTuple(args, "Oi", &obj1, &arg2)) \
|
if (!PyArg_ParseTuple(args, "Oi", &obj1, &arg2)) \
|
||||||
return NULL; \
|
return NULL; \
|
||||||
\
|
\
|
||||||
const intype1 arg1 = pycap_get< intype1 > (obj1); \
|
const intype1 arg1 = pycap_get< intype1 >( obj1 ); \
|
||||||
\
|
\
|
||||||
func (arg1, arg2); \
|
func (arg1, arg2); \
|
||||||
Py_RETURN_NONE; \
|
Py_RETURN_NONE; \
|
||||||
|
|
@ -578,7 +558,7 @@ _w ## func (PyObject *self, PyObject *args) \
|
||||||
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); \
|
||||||
\
|
\
|
||||||
return ctor_ ## outtype ( func (arg1, arg2, arg3)); \
|
return pycap_new<outtype> ( func (arg1, arg2, arg3)); \
|
||||||
_CATCH_ALL \
|
_CATCH_ALL \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -600,7 +580,7 @@ _w ## func (PyObject *self, PyObject *args) \
|
||||||
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); \
|
||||||
\
|
\
|
||||||
return ctor_ ## outtype ( func (arg1, arg2, arg3)) ; \
|
return pycap_new<outtype>( func( arg1, arg2, arg3 ) ) ; \
|
||||||
_CATCH_ALL \
|
_CATCH_ALL \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -622,7 +602,7 @@ _w ## func (PyObject *self, PyObject *args) \
|
||||||
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); \
|
||||||
\
|
\
|
||||||
return ctor_ ## outtype ( func (arg1, arg2, arg3)) ; \
|
return pycap_new<outtype>( func( arg1, arg2, arg3 ) ) ; \
|
||||||
_CATCH_ALL \
|
_CATCH_ALL \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -664,7 +644,7 @@ _w ## func (PyObject *self, PyObject *args) \
|
||||||
if (!PyArg_ParseTuple(args, "Oii", &obj1, &arg2, &arg3)) \
|
if (!PyArg_ParseTuple(args, "Oii", &obj1, &arg2, &arg3)) \
|
||||||
return NULL; \
|
return NULL; \
|
||||||
\
|
\
|
||||||
const intype1 arg1 = pycap_get< intype1 > (obj1); \
|
const intype1 arg1 = pycap_get< intype1 >( obj1 ); \
|
||||||
\
|
\
|
||||||
func (arg1, arg2, arg3); \
|
func (arg1, arg2, arg3); \
|
||||||
Py_RETURN_NONE; \
|
Py_RETURN_NONE; \
|
||||||
|
|
@ -689,7 +669,7 @@ _w ## func (PyObject *self, PyObject *args) \
|
||||||
const intype1 arg1 = pycap_get< intype1 > (obj1); \
|
const intype1 arg1 = pycap_get< intype1 > (obj1); \
|
||||||
const intype3 arg3 = pycap_get< intype3 > (obj3); \
|
const intype3 arg3 = pycap_get< intype3 > (obj3); \
|
||||||
\
|
\
|
||||||
return ctor_ ## outtype ( func (arg1, arg2, arg3)); \
|
return pycap_new<outtype>( func( arg1, arg2, arg3 ) ); \
|
||||||
_CATCH_ALL \
|
_CATCH_ALL \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -737,7 +717,7 @@ _w ## func (PyObject *self, PyObject *args) \
|
||||||
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); \
|
||||||
\
|
\
|
||||||
return ctor_ ## outtype ( func (arg1, arg2, arg3, arg4)) ; \
|
return pycap_new<outtype>( func( arg1, arg2, arg3, arg4 ) ) ; \
|
||||||
_CATCH_ALL \
|
_CATCH_ALL \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -762,7 +742,7 @@ _w ## func (PyObject *self, PyObject *args) \
|
||||||
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); \
|
||||||
\
|
\
|
||||||
return ctor_ ## outtype ( func (arg1, arg2, arg3, arg4, arg5)) ; \
|
return pycap_new<outtype>( func( arg1, arg2, arg3, arg4, arg5 ) ) ; \
|
||||||
_CATCH_ALL \
|
_CATCH_ALL \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -785,7 +765,7 @@ _w ## func (PyObject *self, PyObject *args) \
|
||||||
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); \
|
||||||
\
|
\
|
||||||
return ctor_ ## outtype ( func (arg1, arg2, arg3, arg4)); \
|
return pycap_new<outtype>( func( arg1, arg2, arg3, arg4 ) ); \
|
||||||
_CATCH_ALL \
|
_CATCH_ALL \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -808,7 +788,7 @@ _w ## func (PyObject *self, PyObject *args) \
|
||||||
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); \
|
||||||
\
|
\
|
||||||
return ctor_ ## outtype ( func (arg1, arg2, arg3, arg4)); \
|
return pycap_new<outtype>( func( arg1, arg2, arg3, arg4 ) ); \
|
||||||
_CATCH_ALL \
|
_CATCH_ALL \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -834,7 +814,7 @@ _w ## func (PyObject *self, PyObject *args) \
|
||||||
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); \
|
||||||
\
|
\
|
||||||
return ctor_ ## outtype ( func (arg1, arg2, arg3, arg4, arg5)); \
|
return pycap_new<outtype>( func( arg1, arg2, arg3, arg4, arg5 ) ); \
|
||||||
_CATCH_ALL \
|
_CATCH_ALL \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -856,7 +836,7 @@ _w ## func (PyObject *self, PyObject *args) \
|
||||||
\
|
\
|
||||||
const intype1 arg1 = pycap_get< intype1 > (obj1); \
|
const intype1 arg1 = pycap_get< intype1 > (obj1); \
|
||||||
\
|
\
|
||||||
return ctor_ ## outtype ( func (arg1, arg2, arg3)); \
|
return pycap_new<outtype>( func( arg1, arg2, arg3 ) ); \
|
||||||
_CATCH_ALL \
|
_CATCH_ALL \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -881,7 +861,7 @@ _w ## func (PyObject *self, PyObject *args) \
|
||||||
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); \
|
||||||
\
|
\
|
||||||
return ctor_ ## outtype ( func (arg1, arg2, arg3, arg4, arg5)); \
|
return pycap_new<outtype>( func( arg1, arg2, arg3, arg4, arg5 ) ); \
|
||||||
_CATCH_ALL \
|
_CATCH_ALL \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -909,7 +889,7 @@ _w ## func (PyObject *self, PyObject *args) \
|
||||||
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); \
|
||||||
\
|
\
|
||||||
return ctor_ ## outtype ( func (arg1, arg2, arg3, arg4, arg5, arg6)); \
|
return pycap_new<outtype>( func( arg1, arg2, arg3, arg4, arg5, arg6 ) );\
|
||||||
_CATCH_ALL \
|
_CATCH_ALL \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -934,7 +914,7 @@ _w ## func (PyObject *self, PyObject *args) \
|
||||||
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 ctor_ ## outtype ( func (arg1, arg2, arg3, arg4, arg5, arg6)); \
|
return pycap_new<outtype>( func( arg1, arg2, arg3, arg4, arg5, arg6 ) ); \
|
||||||
_CATCH_ALL \
|
_CATCH_ALL \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -960,7 +940,7 @@ _w ## func (PyObject *self, PyObject *args) \
|
||||||
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 ctor_ ## outtype ( func (arg1, arg2, arg3, arg4, arg5, arg6)); \
|
return pycap_new<outtype>( func( arg1, arg2, arg3, arg4, arg5, arg6 ) ); \
|
||||||
_CATCH_ALL \
|
_CATCH_ALL \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -983,7 +963,7 @@ _w ## func (PyObject *self, PyObject *args) \
|
||||||
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); \
|
||||||
\
|
\
|
||||||
return ctor_ ## outtype ( func (arg1, arg2, arg3, arg4)); \
|
return pycap_new<outtype>( func( arg1, arg2, arg3, arg4 ) ); \
|
||||||
_CATCH_ALL \
|
_CATCH_ALL \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1005,7 +985,7 @@ _w ## func (PyObject *self, PyObject *args)
|
||||||
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 ctor_ ## outtype ( func (arg1, arg2, arg3, arg4)); \
|
return pycap_new<outtype>( func( arg1, arg2, arg3, arg4 ) ); \
|
||||||
_CATCH_ALL \
|
_CATCH_ALL \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1029,7 +1009,7 @@ _w ## func (PyObject *self, PyObject *args)
|
||||||
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 ctor_ ## outtype ( func (arg1, arg2, arg3, arg4, arg5)); \
|
return pycap_new<outtype>( func( arg1, arg2, arg3, arg4, arg5 ) ); \
|
||||||
_CATCH_ALL \
|
_CATCH_ALL \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1053,7 +1033,7 @@ _w ## func (PyObject *self, PyObject *args)
|
||||||
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 ctor_ ## outtype ( func (arg1, arg2, arg3, arg4, arg5)); \
|
return pycap_new<outtype>( func( arg1, arg2, arg3, arg4, arg5 ) ); \
|
||||||
_CATCH_ALL \
|
_CATCH_ALL \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1072,13 +1052,13 @@ _w ## func (PyObject *self, PyObject *args) \
|
||||||
if (!PyArg_ParseTuple(args, "OO", &obj1, &obj2)) \
|
if (!PyArg_ParseTuple(args, "OO", &obj1, &obj2)) \
|
||||||
return NULL; \
|
return NULL; \
|
||||||
\
|
\
|
||||||
const intype1 arg1 = pycap_get< intype1 > (obj1); \
|
const intype1 arg1 = pycap_get< intype1 >( obj1 ); \
|
||||||
const size_t arg2n = PyList_Size(obj2); \
|
const size_t arg2n = PyList_Size(obj2); \
|
||||||
intype2 *arg2v = make_array_from_list< intype2 *>(obj2, arg2n); \
|
intype2 *arg2v = make_array_from_list< intype2 *>(obj2, arg2n); \
|
||||||
\
|
\
|
||||||
outtype ret = func (arg1, arg2v, arg2n); \
|
outtype ret = func (arg1, arg2v, arg2n); \
|
||||||
delete [] arg2v ; \
|
delete [] arg2v ; \
|
||||||
return ctor_ ## outtype (ret); \
|
return pycap_new<outtype>( ret ); \
|
||||||
_CATCH_ALL \
|
_CATCH_ALL \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1103,7 +1083,7 @@ _w ## func (PyObject *self, PyObject *args) \
|
||||||
\
|
\
|
||||||
outtype ret = func (arg1v, arg1n, arg2); \
|
outtype ret = func (arg1v, arg1n, arg2); \
|
||||||
delete [] arg1v; \
|
delete [] arg1v; \
|
||||||
return ctor_ ## outtype (ret); \
|
return pycap_new<outtype>( ret ); \
|
||||||
_CATCH_ALL \
|
_CATCH_ALL \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1127,7 +1107,7 @@ _w ## func (PyObject *self, PyObject *args) \
|
||||||
\
|
\
|
||||||
outtype ret = func (arg1v, arg1n); \
|
outtype ret = func (arg1v, arg1n); \
|
||||||
delete [] arg1v; \
|
delete [] arg1v; \
|
||||||
return ctor_ ## outtype (ret); \
|
return pycap_new<outtype>( ret ); \
|
||||||
_CATCH_ALL \
|
_CATCH_ALL \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1147,13 +1127,13 @@ _w ## func (PyObject *self, PyObject *args) \
|
||||||
if (!PyArg_ParseTuple(args, "OOi", &obj1, &obj2, &arg3)) \
|
if (!PyArg_ParseTuple(args, "OOi", &obj1, &obj2, &arg3)) \
|
||||||
return NULL; \
|
return NULL; \
|
||||||
\
|
\
|
||||||
intype1 arg1 = pycap_get< intype1 > (obj1); \
|
intype1 arg1 = pycap_get< intype1 >( obj1 ); \
|
||||||
const size_t arg2n = PyList_Size(obj2); \
|
const size_t arg2n = PyList_Size(obj2); \
|
||||||
intype2 *arg2v = make_array_from_list< intype2 *>(obj2, arg2n); \
|
intype2 *arg2v = make_array_from_list< intype2 *>(obj2, arg2n); \
|
||||||
\
|
\
|
||||||
outtype ret = func (arg1, arg2v, arg2n, arg3); \
|
outtype ret = func (arg1, arg2v, arg2n, arg3); \
|
||||||
delete [] arg2v ; \
|
delete [] arg2v ; \
|
||||||
return ctor_ ## outtype (ret); \
|
return pycap_new<outtype>( ret ); \
|
||||||
_CATCH_ALL \
|
_CATCH_ALL \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1174,7 +1154,7 @@ _w ## func (PyObject *self, PyObject *args) \
|
||||||
if (!PyArg_ParseTuple(args, "OOi", &obj1, &obj2, &arg3)) \
|
if (!PyArg_ParseTuple(args, "OOi", &obj1, &obj2, &arg3)) \
|
||||||
return NULL; \
|
return NULL; \
|
||||||
\
|
\
|
||||||
const intype1 arg1 = pycap_get< intype1 > (obj1); \
|
const intype1 arg1 = pycap_get< intype1 >( obj1 ); \
|
||||||
const size_t arg2n = PyList_Size(obj2); \
|
const size_t arg2n = PyList_Size(obj2); \
|
||||||
intype2 *arg2v = make_array_from_list< intype2 *>(obj2, arg2n); \
|
intype2 *arg2v = make_array_from_list< intype2 *>(obj2, arg2n); \
|
||||||
\
|
\
|
||||||
|
|
@ -1200,13 +1180,13 @@ _w ## func (PyObject *self, PyObject *args) \
|
||||||
if (!PyArg_ParseTuple(args, "OiO", &obj1, &arg2, &obj3)) \
|
if (!PyArg_ParseTuple(args, "OiO", &obj1, &arg2, &obj3)) \
|
||||||
return NULL; \
|
return NULL; \
|
||||||
\
|
\
|
||||||
const intype1 arg1 = pycap_get< intype1 > (obj1); \
|
const intype1 arg1 = pycap_get< intype1 >( obj1 ); \
|
||||||
const size_t arg3n = PyList_Size(obj3); \
|
const size_t arg3n = PyList_Size(obj3); \
|
||||||
intype3 *arg3v = make_array_from_list< intype3 *>(obj3, arg3n); \
|
intype3 *arg3v = make_array_from_list< intype3 *>(obj3, arg3n); \
|
||||||
\
|
\
|
||||||
outtype ret = func (arg1, arg2, arg3v, arg3n); \
|
outtype ret = func (arg1, arg2, arg3v, arg3n); \
|
||||||
delete [] arg3v ; \
|
delete [] arg3v ; \
|
||||||
return ctor_ ## outtype (ret); \
|
return pycap_new<outtype>( ret ); \
|
||||||
_CATCH_ALL \
|
_CATCH_ALL \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1232,7 +1212,7 @@ _w ## func (PyObject *self, PyObject *args) \
|
||||||
\
|
\
|
||||||
outtype ret = func (arg1, arg2, arg3v, arg3n); \
|
outtype ret = func (arg1, arg2, arg3v, arg3n); \
|
||||||
delete [] arg3v ; \
|
delete [] arg3v ; \
|
||||||
return ctor_ ## outtype (ret); \
|
return pycap_new<outtype>( ret ); \
|
||||||
_CATCH_ALL \
|
_CATCH_ALL \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1259,7 +1239,7 @@ _w ## func (PyObject *self, PyObject *args) \
|
||||||
\
|
\
|
||||||
outtype ret = func (arg1, arg2, arg3v, arg3n, arg4); \
|
outtype ret = func (arg1, arg2, arg3v, arg3n, arg4); \
|
||||||
delete [] arg3v ; \
|
delete [] arg3v ; \
|
||||||
return ctor_ ## outtype (ret); \
|
return pycap_new<outtype>( ret ); \
|
||||||
_CATCH_ALL \
|
_CATCH_ALL \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue