Added Module.to_native_object() and Module.to_native_assembly().

Added test for these new functions.
This commit is contained in:
Siu Kwan Lam 2012-08-09 15:41:55 -07:00
commit bed4f24cbd
5 changed files with 175 additions and 3 deletions

View file

@ -184,6 +184,30 @@ _wLLVMGetBitcodeFromModule(PyObject *self, PyObject *args)
return ret;
}
static PyObject *
_wLLVMGetNativeCodeFromModule(PyObject * self, PyObject * args)
{
PyObject * ret;
unsigned len;
unsigned char * bytes;
LLVMModuleRef m;
PyObject * arg_m;
int arg_use_asm;
if (!PyArg_ParseTuple(args, "Oi", &arg_m, &arg_use_asm))
return NULL;
m = (LLVMModuleRef) PyCapsule_GetPointer(arg_m, NULL);
if ( !(bytes = LLVMGetNativeCodeFromModule(m, arg_use_asm, &len)) )
Py_RETURN_NONE;
ret = PyBytes_FromStringAndSize((char *)bytes, (Py_ssize_t)len);
delete [] bytes;
return ret;
}
static PyObject *
_wLLVMLinkModules(PyObject *self, PyObject *args)
{
@ -873,6 +897,8 @@ _wLLVMInitializePasses(PyObject * self, PyObject * args)
Py_RETURN_NONE;
}
_wrap_none2obj(LLVMInitializeNativeTarget, int)
/*===----------------------------------------------------------------------===*/
/* Passes */
@ -1335,6 +1361,7 @@ static PyMethodDef core_methods[] = {
_method( LLVMGetModuleFromAssembly )
_method( LLVMGetModuleFromBitcode )
_method( LLVMGetBitcodeFromModule )
_method( LLVMGetNativeCodeFromModule )
_method( LLVMModuleGetPointerSize )
_method( LLVMModuleGetOrInsertFunction )
_method( LLVMLinkModules )
@ -1717,6 +1744,7 @@ static PyMethodDef core_methods[] = {
_method( LLVMDumpPasses )
_method( LLVMAddPassByName )
_method( LLVMInitializePasses )
_method( LLVMInitializeNativeTarget )
/* Passes */