Added GenericValue. EE.run() uses GVs now. Converted line endings in wrap.{c,h}.
git-svn-id: http://llvm-py.googlecode.com/svn/trunk@19 8d1e9007-1d4e-0410-b67e-1979fd6579aa
This commit is contained in:
parent
0a8dc6a115
commit
01eb4a7133
5 changed files with 1051 additions and 942 deletions
126
llvm/_core.c
126
llvm/_core.c
|
|
@ -683,32 +683,103 @@ _wLLVMCreateExecutionEngine(PyObject *self, PyObject *args)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
_wrap_obj2none(LLVMDisposeExecutionEngine, LLVMExecutionEngineRef)
|
/* the args should have been ptr, num */
|
||||||
|
LLVMGenericValueRef LLVMRunFunction2(LLVMExecutionEngineRef EE,
|
||||||
static PyObject *
|
LLVMValueRef F, LLVMGenericValueRef *Args, unsigned NumArgs)
|
||||||
_wLLVMRunFunction(PyObject *self, PyObject *args)
|
|
||||||
{
|
{
|
||||||
PyObject *obj1, *obj2, *obj3;
|
return LLVMRunFunction(EE, F, NumArgs, Args);
|
||||||
LLVMExecutionEngineRef ee;
|
|
||||||
LLVMValueRef fn;
|
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "OOO", &obj1, &obj2, &obj3))
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
/* obj3 is a list of args to the function, ignored currently */
|
|
||||||
|
|
||||||
ee = (LLVMExecutionEngineRef) PyCObject_AsVoidPtr(obj1);
|
|
||||||
fn = (LLVMValueRef) PyCObject_AsVoidPtr(obj2);
|
|
||||||
|
|
||||||
LLVMRunFunction(ee, fn, 0, NULL);
|
|
||||||
|
|
||||||
/* fn return value ignore currently */
|
|
||||||
|
|
||||||
Py_RETURN_NONE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_wrap_obj2none(LLVMDisposeExecutionEngine, LLVMExecutionEngineRef)
|
||||||
|
_wrap_objobjlist2obj(LLVMRunFunction2, LLVMExecutionEngineRef,
|
||||||
|
LLVMValueRef, LLVMGenericValueRef, LLVMGenericValueRef)
|
||||||
_wrap_obj2obj(LLVMGetExecutionEngineTargetData, LLVMExecutionEngineRef,
|
_wrap_obj2obj(LLVMGetExecutionEngineTargetData, LLVMExecutionEngineRef,
|
||||||
LLVMTargetDataRef)
|
LLVMTargetDataRef)
|
||||||
|
_wrap_obj2none(LLVMRunStaticConstructors, LLVMExecutionEngineRef)
|
||||||
|
_wrap_obj2none(LLVMRunStaticDestructors, LLVMExecutionEngineRef)
|
||||||
|
_wrap_objobj2none(LLVMFreeMachineCodeForFunction, LLVMExecutionEngineRef,
|
||||||
|
LLVMValueRef)
|
||||||
|
_wrap_objobj2none(LLVMAddModuleProvider, LLVMExecutionEngineRef,
|
||||||
|
LLVMModuleProviderRef)
|
||||||
|
|
||||||
|
|
||||||
|
/*===----------------------------------------------------------------------===*/
|
||||||
|
/* Generic Value */
|
||||||
|
/*===----------------------------------------------------------------------===*/
|
||||||
|
|
||||||
|
static PyObject *
|
||||||
|
_wLLVMCreateGenericValueOfInt(PyObject *self, PyObject *args)
|
||||||
|
{
|
||||||
|
PyObject *obj1;
|
||||||
|
LLVMTypeRef ty;
|
||||||
|
unsigned long long n;
|
||||||
|
int is_signed;
|
||||||
|
LLVMGenericValueRef gv;
|
||||||
|
|
||||||
|
if (!PyArg_ParseTuple(args, "OLi", &obj1, &n, &is_signed))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
ty = (LLVMTypeRef) PyCObject_AsVoidPtr(obj1);
|
||||||
|
|
||||||
|
gv = LLVMCreateGenericValueOfInt(ty, n, is_signed);
|
||||||
|
return ctor_LLVMGenericValueRef(gv);
|
||||||
|
}
|
||||||
|
|
||||||
|
static PyObject *
|
||||||
|
_wLLVMCreateGenericValueOfFloat(PyObject *self, PyObject *args)
|
||||||
|
{
|
||||||
|
PyObject *obj1;
|
||||||
|
LLVMTypeRef ty;
|
||||||
|
double d;
|
||||||
|
LLVMGenericValueRef gv;
|
||||||
|
|
||||||
|
if (!PyArg_ParseTuple(args, "Od", &obj1, &d))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
ty = (LLVMTypeRef) PyCObject_AsVoidPtr(obj1);
|
||||||
|
|
||||||
|
gv = LLVMCreateGenericValueOfFloat(ty, d);
|
||||||
|
return ctor_LLVMGenericValueRef(gv);
|
||||||
|
}
|
||||||
|
|
||||||
|
static PyObject *
|
||||||
|
_wLLVMGenericValueToInt(PyObject *self, PyObject *args)
|
||||||
|
{
|
||||||
|
PyObject *obj1;
|
||||||
|
int is_signed;
|
||||||
|
LLVMGenericValueRef gv;
|
||||||
|
unsigned long long val;
|
||||||
|
|
||||||
|
if (!PyArg_ParseTuple(args, "Oi", &obj1, &is_signed))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
gv = (LLVMGenericValueRef) PyCObject_AsVoidPtr(obj1);
|
||||||
|
|
||||||
|
val = LLVMGenericValueToInt(gv, is_signed);
|
||||||
|
return is_signed ?
|
||||||
|
PyLong_FromLongLong((long long)val) :
|
||||||
|
PyLong_FromUnsignedLongLong(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
static PyObject *
|
||||||
|
_wLLVMGenericValueToFloat(PyObject *self, PyObject *args)
|
||||||
|
{
|
||||||
|
PyObject *obj1, *obj2;
|
||||||
|
LLVMTypeRef ty;
|
||||||
|
LLVMGenericValueRef gv;
|
||||||
|
double val;
|
||||||
|
|
||||||
|
if (!PyArg_ParseTuple(args, "OO", &obj1, &obj2))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
ty = (LLVMTypeRef) PyCObject_AsVoidPtr(obj1);
|
||||||
|
gv = (LLVMGenericValueRef) PyCObject_AsVoidPtr(obj2);
|
||||||
|
|
||||||
|
val = LLVMGenericValueToFloat(ty, gv);
|
||||||
|
return PyFloat_FromDouble(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
_wrap_obj2none(LLVMDisposeGenericValue, LLVMGenericValueRef)
|
||||||
|
|
||||||
|
|
||||||
/*===----------------------------------------------------------------------===*/
|
/*===----------------------------------------------------------------------===*/
|
||||||
|
|
@ -1060,8 +1131,19 @@ static PyMethodDef core_methods[] = {
|
||||||
/* Execution Engine */
|
/* Execution Engine */
|
||||||
_method( LLVMCreateExecutionEngine )
|
_method( LLVMCreateExecutionEngine )
|
||||||
_method( LLVMDisposeExecutionEngine )
|
_method( LLVMDisposeExecutionEngine )
|
||||||
_method( LLVMRunFunction )
|
_method( LLVMRunFunction2 )
|
||||||
_method( LLVMGetExecutionEngineTargetData )
|
_method( LLVMGetExecutionEngineTargetData )
|
||||||
|
_method( LLVMRunStaticConstructors )
|
||||||
|
_method( LLVMRunStaticDestructors )
|
||||||
|
_method( LLVMFreeMachineCodeForFunction )
|
||||||
|
_method( LLVMAddModuleProvider )
|
||||||
|
|
||||||
|
/* Generic Value */
|
||||||
|
_method( LLVMCreateGenericValueOfInt )
|
||||||
|
_method( LLVMCreateGenericValueOfFloat )
|
||||||
|
_method( LLVMGenericValueToInt )
|
||||||
|
_method( LLVMGenericValueToFloat )
|
||||||
|
_method( LLVMDisposeGenericValue )
|
||||||
|
|
||||||
{ NULL }
|
{ NULL }
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -11,20 +11,20 @@ import llvm
|
||||||
# failures.
|
# failures.
|
||||||
#===----------------------------------------------------------------------===
|
#===----------------------------------------------------------------------===
|
||||||
|
|
||||||
def _check_gen(obj, type):
|
def check_gen(obj, type):
|
||||||
if not isinstance(obj, type):
|
if not isinstance(obj, type):
|
||||||
type_str = type.__name__
|
type_str = type.__name__
|
||||||
msg = "argument not an instance of llvm.core.%s" % type_str
|
msg = "argument not an instance of llvm.core.%s" % type_str
|
||||||
raise TypeError, msg
|
raise TypeError, msg
|
||||||
|
|
||||||
def check_is_type(obj): _check_gen(obj, core.Type)
|
def check_is_type(obj): check_gen(obj, core.Type)
|
||||||
def check_is_value(obj): _check_gen(obj, core.Value)
|
def check_is_value(obj): check_gen(obj, core.Value)
|
||||||
def check_is_pointer(obj): _check_gen(obj, core.Pointer)
|
def check_is_pointer(obj): check_gen(obj, core.Pointer)
|
||||||
def check_is_constant(obj): _check_gen(obj, core.Constant)
|
def check_is_constant(obj): check_gen(obj, core.Constant)
|
||||||
def check_is_function(obj): _check_gen(obj, core.Function)
|
def check_is_function(obj): check_gen(obj, core.Function)
|
||||||
def check_is_basic_block(obj): _check_gen(obj, core.BasicBlock)
|
def check_is_basic_block(obj): check_gen(obj, core.BasicBlock)
|
||||||
def check_is_module(obj): _check_gen(obj, core.Module)
|
def check_is_module(obj): check_gen(obj, core.Module)
|
||||||
def check_is_module_provider(obj): _check_gen(obj, core.ModuleProvider)
|
def check_is_module_provider(obj): check_gen(obj, core.ModuleProvider)
|
||||||
|
|
||||||
def check_is_unowned(ownable):
|
def check_is_unowned(ownable):
|
||||||
if ownable.owner:
|
if ownable.owner:
|
||||||
|
|
@ -37,13 +37,13 @@ def check_is_unowned(ownable):
|
||||||
# the way.
|
# the way.
|
||||||
#===----------------------------------------------------------------------===
|
#===----------------------------------------------------------------------===
|
||||||
|
|
||||||
def _unpack_gen(objlist, check_fn):
|
def unpack_gen(objlist, check_fn):
|
||||||
for obj in objlist: check_fn(obj)
|
for obj in objlist: check_fn(obj)
|
||||||
return [ obj.ptr for obj in objlist ]
|
return [ obj.ptr for obj in objlist ]
|
||||||
|
|
||||||
def unpack_types(objlist): return _unpack_gen(objlist, check_is_type)
|
def unpack_types(objlist): return unpack_gen(objlist, check_is_type)
|
||||||
def unpack_values(objlist): return _unpack_gen(objlist, check_is_value)
|
def unpack_values(objlist): return unpack_gen(objlist, check_is_value)
|
||||||
def unpack_constants(objlist): return _unpack_gen(objlist, check_is_constant)
|
def unpack_constants(objlist): return unpack_gen(objlist, check_is_constant)
|
||||||
|
|
||||||
|
|
||||||
#===----------------------------------------------------------------------===
|
#===----------------------------------------------------------------------===
|
||||||
|
|
|
||||||
65
llvm/ee.py
65
llvm/ee.py
|
|
@ -25,6 +25,53 @@ class TargetData(llvm.Ownable):
|
||||||
return _core.LLVMTargetDataAsString(self.ptr)
|
return _core.LLVMTargetDataAsString(self.ptr)
|
||||||
|
|
||||||
|
|
||||||
|
#===----------------------------------------------------------------------===
|
||||||
|
# Generic value
|
||||||
|
#===----------------------------------------------------------------------===
|
||||||
|
|
||||||
|
class GenericValue(object):
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def int(ty, intval):
|
||||||
|
check_is_type(ty)
|
||||||
|
ptr = _core.LLVMCreateGenericValueOfInt(ty.ptr, intval, 0)
|
||||||
|
return GenericValue(ptr)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def int_signed(ty, intval):
|
||||||
|
check_is_type(ty)
|
||||||
|
ptr = _core.LLVMCreateGenericValueOfInt(ty.ptr, intval, 1)
|
||||||
|
return GenericValue(ptr)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def real(ty, floatval):
|
||||||
|
check_is_type(ty) # only float or double
|
||||||
|
ptr = _core.LLVMCreateGenericValueOfFloat(ty.ptr, floatval)
|
||||||
|
return GenericValue(ptr)
|
||||||
|
|
||||||
|
def __init__(self, ptr):
|
||||||
|
self.ptr = ptr
|
||||||
|
|
||||||
|
def __del__(self):
|
||||||
|
_core.LLVMDisposeGenericValue(self.ptr)
|
||||||
|
|
||||||
|
def as_int(self):
|
||||||
|
return _core.LLVMGenericValueToInt(self.ptr, 0)
|
||||||
|
|
||||||
|
def as_int_signed(self):
|
||||||
|
return _core.LLVMGenericValueToInt(self.ptr, 1)
|
||||||
|
|
||||||
|
def as_real(self, ty):
|
||||||
|
check_is_type(ty) # only float or double
|
||||||
|
return _core.LLVMGenericValueToFloat(ty.ptr, self.ptr)
|
||||||
|
|
||||||
|
|
||||||
|
# helper functions for generic value objects
|
||||||
|
def _check_is_generic_value(obj): check_gen(obj, GenericValue)
|
||||||
|
def _unpack_generic_values(objlist):
|
||||||
|
return unpack_gen(objlist, _check_is_generic_value)
|
||||||
|
|
||||||
|
|
||||||
#===----------------------------------------------------------------------===
|
#===----------------------------------------------------------------------===
|
||||||
# Execution engine
|
# Execution engine
|
||||||
#===----------------------------------------------------------------------===
|
#===----------------------------------------------------------------------===
|
||||||
|
|
@ -49,7 +96,23 @@ class ExecutionEngine(object):
|
||||||
|
|
||||||
def run_function(self, fn, args):
|
def run_function(self, fn, args):
|
||||||
check_is_function(fn)
|
check_is_function(fn)
|
||||||
return _core.LLVMRunFunction(self.ptr, fn.ptr, args)
|
ptrs = _unpack_generic_values(args)
|
||||||
|
gvptr = _core.LLVMRunFunction2(self.ptr, fn.ptr, ptrs)
|
||||||
|
return GenericValue(gvptr)
|
||||||
|
|
||||||
|
def run_static_ctors(self):
|
||||||
|
_core.LLVMRunStaticConstructors(self.ptr)
|
||||||
|
|
||||||
|
def run_static_dtors(self):
|
||||||
|
_core.LLVMRunStaticDestructors(self.ptr)
|
||||||
|
|
||||||
|
def free_machine_code_for(self, fn):
|
||||||
|
check_is_function(fn)
|
||||||
|
_core.LLVMFreeMachineCodeForFunction(self.ptr, fn.ptr)
|
||||||
|
|
||||||
|
def add_module_provider(self, mp):
|
||||||
|
check_is_module_provider(mp)
|
||||||
|
_core.LLVMAddModuleProvider(self.ptr, mp.ptr)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def target_data(self):
|
def target_data(self):
|
||||||
|
|
|
||||||
91
llvm/wrap.c
91
llvm/wrap.c
|
|
@ -1,82 +1,41 @@
|
||||||
#include "wrap.h"
|
#include "wrap.h"
|
||||||
|
|
||||||
|
|
||||||
|
/*===----------------------------------------------------------------------===*/
|
||||||
|
/* Helper functions/macros */
|
||||||
|
/*===----------------------------------------------------------------------===*/
|
||||||
|
|
||||||
|
#define _define_std_ctor(typ) \
|
||||||
|
PyObject * ctor_ ## typ ( typ p) \
|
||||||
|
{ \
|
||||||
|
if (p) \
|
||||||
|
return PyCObject_FromVoidPtr(p, NULL); \
|
||||||
|
Py_RETURN_NONE; \
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*===----------------------------------------------------------------------===*/
|
/*===----------------------------------------------------------------------===*/
|
||||||
/* Type ctor/dtor */
|
/* Type ctor/dtor */
|
||||||
/*===----------------------------------------------------------------------===*/
|
/*===----------------------------------------------------------------------===*/
|
||||||
|
|
||||||
PyObject *ctor_LLVMModuleRef(LLVMModuleRef p)
|
_define_std_ctor(LLVMModuleRef)
|
||||||
{
|
_define_std_ctor(LLVMTypeRef)
|
||||||
if (p)
|
_define_std_ctor(LLVMValueRef)
|
||||||
return PyCObject_FromVoidPtr(p, NULL);
|
_define_std_ctor(LLVMTypeHandleRef)
|
||||||
Py_RETURN_NONE; /* avoiding the `else' since we don't (want to) know what
|
_define_std_ctor(LLVMBasicBlockRef)
|
||||||
the macro Py_RETURN_NONE expands to */
|
_define_std_ctor(LLVMBuilderRef)
|
||||||
}
|
_define_std_ctor(LLVMModuleProviderRef)
|
||||||
|
_define_std_ctor(LLVMMemoryBufferRef)
|
||||||
PyObject *ctor_LLVMTypeRef(LLVMTypeRef p)
|
_define_std_ctor(LLVMPassManagerRef)
|
||||||
{
|
_define_std_ctor(LLVMExecutionEngineRef)
|
||||||
if (p)
|
_define_std_ctor(LLVMTargetDataRef)
|
||||||
return PyCObject_FromVoidPtr(p, NULL);
|
_define_std_ctor(LLVMGenericValueRef)
|
||||||
Py_RETURN_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
PyObject *ctor_LLVMValueRef(LLVMValueRef p)
|
|
||||||
{
|
|
||||||
if (p)
|
|
||||||
return PyCObject_FromVoidPtr(p, NULL);
|
|
||||||
Py_RETURN_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
PyObject *ctor_LLVMTypeHandleRef(LLVMTypeHandleRef p)
|
|
||||||
{
|
|
||||||
if (p)
|
|
||||||
return PyCObject_FromVoidPtr(p, NULL);
|
|
||||||
Py_RETURN_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
PyObject *ctor_LLVMBasicBlockRef(LLVMBasicBlockRef p)
|
|
||||||
{
|
|
||||||
if (p)
|
|
||||||
return PyCObject_FromVoidPtr(p, NULL);
|
|
||||||
Py_RETURN_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
PyObject *ctor_LLVMBuilderRef(LLVMBuilderRef p)
|
|
||||||
{
|
|
||||||
if (p)
|
|
||||||
return PyCObject_FromVoidPtr(p, NULL);
|
|
||||||
Py_RETURN_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
PyObject *ctor_LLVMModuleProviderRef(LLVMModuleProviderRef p)
|
|
||||||
{
|
|
||||||
if (p)
|
|
||||||
return PyCObject_FromVoidPtr(p, NULL);
|
|
||||||
Py_RETURN_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
PyObject *ctor_LLVMMemoryBufferRef(LLVMMemoryBufferRef p)
|
|
||||||
{
|
|
||||||
if (p)
|
|
||||||
return PyCObject_FromVoidPtr(p, NULL);
|
|
||||||
Py_RETURN_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
PyObject *ctor_LLVMPassManagerRef(LLVMPassManagerRef p)
|
|
||||||
{
|
|
||||||
if (p)
|
|
||||||
return PyCObject_FromVoidPtr(p, NULL);
|
|
||||||
Py_RETURN_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
PyObject *ctor_int(int i)
|
PyObject *ctor_int(int i)
|
||||||
{
|
{
|
||||||
return PyInt_FromLong(i);
|
return PyInt_FromLong(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
_define_std_ctor(LLVMExecutionEngineRef)
|
|
||||||
_define_std_ctor(LLVMTargetDataRef)
|
|
||||||
|
|
||||||
|
|
||||||
/*===----------------------------------------------------------------------===*/
|
/*===----------------------------------------------------------------------===*/
|
||||||
/* Helper functions */
|
/* Helper functions */
|
||||||
|
|
|
||||||
81
llvm/wrap.h
81
llvm/wrap.h
|
|
@ -28,49 +28,24 @@
|
||||||
* for various types.
|
* for various types.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* LLVMModuleRef */
|
|
||||||
PyObject *ctor_LLVMModuleRef(LLVMModuleRef p);
|
|
||||||
|
|
||||||
/* LLVMTypeRef */
|
|
||||||
PyObject *ctor_LLVMTypeRef(LLVMTypeRef p);
|
|
||||||
|
|
||||||
/* LLVMValueRef */
|
|
||||||
PyObject *ctor_LLVMValueRef(LLVMValueRef p);
|
|
||||||
|
|
||||||
/* LLVMTypeHandleRef */
|
|
||||||
PyObject *ctor_LLVMTypeHandleRef(LLVMTypeHandleRef p);
|
|
||||||
|
|
||||||
/* LLVMBasicBlockRef */
|
|
||||||
PyObject *ctor_LLVMBasicBlockRef(LLVMBasicBlockRef p);
|
|
||||||
|
|
||||||
/* LLVMBuilderRef */
|
|
||||||
PyObject *ctor_LLVMBuilderRef(LLVMBuilderRef p);
|
|
||||||
|
|
||||||
/* LLVMModuleProviderRef */
|
|
||||||
PyObject *ctor_LLVMModuleProviderRef(LLVMModuleProviderRef p);
|
|
||||||
|
|
||||||
/* LLVMMemoryBufferRef */
|
|
||||||
PyObject *ctor_LLVMMemoryBufferRef(LLVMMemoryBufferRef p);
|
|
||||||
|
|
||||||
/* LLVMPassManagerRef */
|
|
||||||
PyObject *ctor_LLVMPassManagerRef(LLVMPassManagerRef p);
|
|
||||||
|
|
||||||
/* standard types */
|
|
||||||
PyObject *ctor_int(int i);
|
|
||||||
|
|
||||||
#define _declare_std_ctor(typ) \
|
#define _declare_std_ctor(typ) \
|
||||||
PyObject * ctor_ ## typ ( typ p);
|
PyObject * ctor_ ## typ ( typ p);
|
||||||
|
|
||||||
#define _define_std_ctor(typ) \
|
_declare_std_ctor(LLVMModuleRef)
|
||||||
PyObject * ctor_ ## typ ( typ p) \
|
_declare_std_ctor(LLVMTypeRef)
|
||||||
{ \
|
_declare_std_ctor(LLVMValueRef)
|
||||||
if (p) \
|
_declare_std_ctor(LLVMTypeHandleRef)
|
||||||
return PyCObject_FromVoidPtr(p, NULL); \
|
_declare_std_ctor(LLVMBasicBlockRef)
|
||||||
Py_RETURN_NONE; \
|
_declare_std_ctor(LLVMBuilderRef)
|
||||||
}
|
_declare_std_ctor(LLVMModuleProviderRef)
|
||||||
|
_declare_std_ctor(LLVMMemoryBufferRef)
|
||||||
|
_declare_std_ctor(LLVMPassManagerRef)
|
||||||
_declare_std_ctor(LLVMExecutionEngineRef)
|
_declare_std_ctor(LLVMExecutionEngineRef)
|
||||||
_declare_std_ctor(LLVMTargetDataRef)
|
_declare_std_ctor(LLVMTargetDataRef)
|
||||||
|
_declare_std_ctor(LLVMGenericValueRef)
|
||||||
|
|
||||||
|
/* standard types */
|
||||||
|
PyObject *ctor_int(int i);
|
||||||
|
|
||||||
|
|
||||||
/*===----------------------------------------------------------------------===*/
|
/*===----------------------------------------------------------------------===*/
|
||||||
|
|
@ -721,6 +696,36 @@ _w ## func (PyObject *self, PyObject *args) \
|
||||||
return ctor_ ## outtype (ret); \
|
return ctor_ ## outtype (ret); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrap LLVM functions of the type
|
||||||
|
* outtype func(intype1 arg1, intype2 arg2, intype3 *arg3v, unsigned arg3n)
|
||||||
|
* where arg3v is an array of intype3 elements, arg3n in length.
|
||||||
|
*/
|
||||||
|
#define _wrap_objobjlist2obj(func, intype1, intype2, intype3, outtype) \
|
||||||
|
static PyObject * \
|
||||||
|
_w ## func (PyObject *self, PyObject *args) \
|
||||||
|
{ \
|
||||||
|
PyObject *obj1, *obj2, *obj3; \
|
||||||
|
intype1 arg1; \
|
||||||
|
intype2 arg2; \
|
||||||
|
intype3 *arg3v; \
|
||||||
|
unsigned arg3n; \
|
||||||
|
outtype ret; \
|
||||||
|
\
|
||||||
|
if (!PyArg_ParseTuple(args, "OOO", &obj1, &obj2, &obj3)) \
|
||||||
|
return NULL; \
|
||||||
|
\
|
||||||
|
arg1 = ( intype1 ) PyCObject_AsVoidPtr(obj1); \
|
||||||
|
arg2 = ( intype2 ) PyCObject_AsVoidPtr(obj2); \
|
||||||
|
arg3n = (unsigned) PyList_Size(obj3); \
|
||||||
|
if (!(arg3v = ( intype3 *)make_array_from_list(obj3, arg3n))) \
|
||||||
|
return PyErr_NoMemory(); \
|
||||||
|
\
|
||||||
|
ret = func (arg1, arg2, arg3v, arg3n); \
|
||||||
|
free(arg3v); \
|
||||||
|
return ctor_ ## outtype (ret); \
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrap LLVM functions of the type
|
* Wrap LLVM functions of the type
|
||||||
* outtype func(intype1 arg1, intype2 arg2, intype3 *arg3v, unsigned arg3n, const char *arg4)
|
* outtype func(intype1 arg1, intype2 arg2, intype3 *arg3v, unsigned arg3n, const char *arg4)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue