Add llvm::Module::addLibrary to exposed API

This commit is contained in:
Travis E. Oliphant 2012-06-21 01:25:23 -05:00
commit 7b6aac79fb
4 changed files with 16 additions and 0 deletions

View file

@ -87,6 +87,7 @@ _wrap_obj2str(LLVMGetDataLayout, LLVMModuleRef)
_wrap_objstr2none(LLVMSetDataLayout, LLVMModuleRef) _wrap_objstr2none(LLVMSetDataLayout, LLVMModuleRef)
_wrap_obj2str(LLVMGetTarget, LLVMModuleRef) _wrap_obj2str(LLVMGetTarget, LLVMModuleRef)
_wrap_objstr2none(LLVMSetTarget, LLVMModuleRef) _wrap_objstr2none(LLVMSetTarget, LLVMModuleRef)
_wrap_objstr2none(LLVMModuleAddLibrary, LLVMModuleRef)
_wrap_objstr2obj(LLVMGetTypeByName, LLVMModuleRef, LLVMTypeRef) _wrap_objstr2obj(LLVMGetTypeByName, LLVMModuleRef, LLVMTypeRef)
_wrap_obj2none(LLVMDumpModule, LLVMModuleRef) _wrap_obj2none(LLVMDumpModule, LLVMModuleRef)
_wrap_obj2none(LLVMDisposeModule, LLVMModuleRef) _wrap_obj2none(LLVMDisposeModule, LLVMModuleRef)
@ -1321,6 +1322,7 @@ static PyMethodDef core_methods[] = {
_method( LLVMSetDataLayout ) _method( LLVMSetDataLayout )
_method( LLVMGetTarget ) _method( LLVMGetTarget )
_method( LLVMSetTarget ) _method( LLVMSetTarget )
_method( LLVMModuleAddLibrary )
_method( LLVMGetTypeByName ) _method( LLVMGetTypeByName )
_method( LLVMDumpModule ) _method( LLVMDumpModule )
_method( LLVMDisposeModule ) _method( LLVMDisposeModule )

View file

@ -505,6 +505,9 @@ class Module(llvm.Ownable, llvm.Cacheable):
raise llvm.LLVMException("Unable to create bitcode") raise llvm.LLVMException("Unable to create bitcode")
fileobj.write(data) fileobj.write(data)
def add_library(self, name):
return _core.LLVMModuleAddLibrary(self.ptr, name)
#===----------------------------------------------------------------------=== #===----------------------------------------------------------------------===
# Types # Types

View file

@ -100,6 +100,14 @@ char *LLVMDumpModuleToString(LLVMModuleRef module)
return strdup(buf.str().c_str()); return strdup(buf.str().c_str());
} }
void LLVMModuleAddLibrary(LLVMModuleRef module, const char *name)
{
llvm::Module *M = llvm::unwrap(module);
llvm::StringRef namestr = llvm::StringRef(name);
M->addLibrary(namestr);
return;
}
char *LLVMDumpTypeToString(LLVMTypeRef type) char *LLVMDumpTypeToString(LLVMTypeRef type)
{ {
return do_print<LLVMTypeRef, llvm::Type>(type); return do_print<LLVMTypeRef, llvm::Type>(type);

View file

@ -50,6 +50,9 @@ extern "C" {
* LLVMDisposeMessage(). */ * LLVMDisposeMessage(). */
char *LLVMDumpModuleToString(LLVMModuleRef module); char *LLVMDumpModuleToString(LLVMModuleRef module);
/* Wraps llvm::Module::addLibrary(name). */
void LLVMModuleAddLibrary(LLVMModuleRef module, const char *name);
/* Wraps llvm::Type::print(). Dispose the returned string after use, via /* Wraps llvm::Type::print(). Dispose the returned string after use, via
* LLVMDisposeMessage(). */ * LLVMDisposeMessage(). */
char *LLVMDumpTypeToString(LLVMTypeRef type); char *LLVMDumpTypeToString(LLVMTypeRef type);