Add DynamicLibrary and InlineFunction

This commit is contained in:
Siu Kwan Lam 2013-02-08 18:12:51 -06:00
commit 60336d1c5f
3 changed files with 64 additions and 3 deletions

View file

@ -6,6 +6,7 @@
#include <llvm/Support/raw_ostream.h>
#include <llvm/Support/FormattedStream.h>
#include <llvm/Support/MemoryBuffer.h>
#include <llvm/Support/DynamicLibrary.h>
#include <llvm/Bitcode/ReaderWriter.h>
#include <llvm/ExecutionEngine/ExecutionEngine.h>
#include <llvm/ExecutionEngine/GenericValue.h>
@ -747,3 +748,28 @@ PyObject* IRBuilder_CreateAggregateRet(llvm::IRBuilder<>* builder,
return pycapsule_new(inst, "llvm::Value", "llvm:ReturnInst");
}
static
PyObject* DynamicLibrary_LoadLibraryPermanently(const char * Filename,
PyObject* ErrMsg = 0)
{
using namespace llvm::sys;
bool failed;
if (ErrMsg) {
std::string errmsg;
failed = DynamicLibrary::LoadLibraryPermanently(Filename, &errmsg);
if (failed) {
if (-1 == PyFile_WriteString(errmsg.c_str(), ErrMsg)) {
return NULL;
}
}
} else {
failed = DynamicLibrary::LoadLibraryPermanently(Filename);
}
if (failed) {
Py_RETURN_TRUE;
} else {
Py_RETURN_FALSE;
}
}