aboutsummaryrefslogtreecommitdiffstats
path: root/bindings/python/llvm/object.py
diff options
context:
space:
mode:
authorGregory Szorc <gregory.szorc@gmail.com>2012-03-09 18:56:33 +0000
committerGregory Szorc <gregory.szorc@gmail.com>2012-03-09 18:56:33 +0000
commit07c32218f448b7637d4acad8e87ce7cfaef0277e (patch)
tree09b98f3a686f3007b5a47266efe414b6d86712b0 /bindings/python/llvm/object.py
parent5992f67e683b665392f45b167fe5c9abd91455c9 (diff)
downloadexternal_llvm-07c32218f448b7637d4acad8e87ce7cfaef0277e.zip
external_llvm-07c32218f448b7637d4acad8e87ce7cfaef0277e.tar.gz
external_llvm-07c32218f448b7637d4acad8e87ce7cfaef0277e.tar.bz2
[llvm.py] Make ObjectFile destructor work
Previous code had a double free in MemoryBuffer. The tests now pass. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152422 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'bindings/python/llvm/object.py')
-rw-r--r--bindings/python/llvm/object.py21
1 files changed, 13 insertions, 8 deletions
diff --git a/bindings/python/llvm/object.py b/bindings/python/llvm/object.py
index a55a5cb..f633f60 100644
--- a/bindings/python/llvm/object.py
+++ b/bindings/python/llvm/object.py
@@ -11,6 +11,7 @@ from ctypes import c_char_p
from ctypes import c_uint64
from ctypes import c_void_p
+from .common import LLVMObject
from .common import get_library
from .core import MemoryBuffer
@@ -40,9 +41,14 @@ class ObjectFile(object):
self._memory = contents
self._obj = lib.LLVMCreateObjectFile(contents)
+ contents.release_ownership()
+ self._as_parameter_ = self._obj
def __del__(self):
- lib.LLVMDisposeObjectFile(self._obj)
+ lib.LLVMDisposeObjectFile(self)
+
+ def from_param(self):
+ return self._as_parameter_
def get_sections(self):
"""Obtain the sections in this object file.
@@ -143,7 +149,6 @@ class Relocation(object):
def value_string(self):
pass
-ObjectFileRef = c_void_p
SectionIteratorRef = c_void_p
SymbolIteratorRef = c_void_p
RelocationIteratorRef = c_void_p
@@ -153,16 +158,16 @@ def register_library(library):
# Object.h functions
library.LLVMCreateObjectFile.argtypes = [MemoryBuffer]
- library.LLVMCreateObjectFile.restype = ObjectFileRef
+ library.LLVMCreateObjectFile.restype = LLVMObject
- library.LLVMDisposeObjectFile.argtypes = [ObjectFileRef]
+ library.LLVMDisposeObjectFile.argtypes = [ObjectFile]
- library.LLVMGetSections.argtypes = [ObjectFileRef]
+ library.LLVMGetSections.argtypes = [ObjectFile]
library.LLVMGetSections.restype = SectionIteratorRef
library.LLVMDisposeSectionIterator.argtypes = [SectionIteratorRef]
- library.LLVMIsSectionIteratorAtEnd.argtypes = [ObjectFileRef,
+ library.LLVMIsSectionIteratorAtEnd.argtypes = [ObjectFile,
SectionIteratorRef]
library.LLVMIsSectionIteratorAtEnd.restype = bool
@@ -171,12 +176,12 @@ def register_library(library):
library.LLVMMoveToContainingSection.argtypes = [SectionIteratorRef,
SymbolIteratorRef]
- library.LLVMGetSymbols.argtypes = [ObjectFileRef]
+ library.LLVMGetSymbols.argtypes = [ObjectFile]
library.LLVMGetSymbols.restype = SymbolIteratorRef
library.LLVMDisposeSymbolIterator.argtypes = [SymbolIteratorRef]
- library.LLVMIsSymbolIteratorAtEnd.argtypes = [ObjectFileRef,
+ library.LLVMIsSymbolIteratorAtEnd.argtypes = [ObjectFile,
SymbolIteratorRef]
library.LLVMIsSymbolIteratorAtEnd.restype = bool