[python bindings] Added code to get the length of a memory buffer. Tests are included.
[oota-llvm.git] / bindings / python / llvm / core.py
index 67566374256e521745023a495a47633b23c7f688..bd61a6ac993e7273fb98dfe450ac0fb151ab4bbe 100644 (file)
@@ -83,11 +83,17 @@ class MemoryBuffer(LLVMObject):
 
         LLVMObject.__init__(self, memory, disposer=lib.LLVMDisposeMemoryBuffer)
 
+    def __len__(self):
+        return lib.LLVMGetBufferSize(self)
+
 def register_library(library):
+    # Memory buffer declarations
     library.LLVMCreateMemoryBufferWithContentsOfFile.argtypes = [c_char_p,
             POINTER(c_object_p), POINTER(c_char_p)]
     library.LLVMCreateMemoryBufferWithContentsOfFile.restype = bool
 
+    library.LLVMGetBufferSize.argtypes = [MemoryBuffer]
+
     library.LLVMDisposeMemoryBuffer.argtypes = [MemoryBuffer]
 
 def register_enumerations():