pub struct PassManager<'a>(InvariantOpaque<'a>);
extern { pub type PassManagerBuilder; }
extern { pub type ObjectFile; }
-extern { pub type SectionIterator; }
-pub type SectionIteratorRef = *mut SectionIterator;
+pub struct SectionIterator<'a>(InvariantOpaque<'a>);
extern { pub type Pass; }
extern { pub type TargetMachine; }
extern { pub type Archive; }
pub fn LLVMDisposeObjectFile(ObjFile: &'static mut ObjectFile);
/// Enumerates the sections in an object file.
- pub fn LLVMGetSections(ObjFile: &ObjectFile) -> SectionIteratorRef;
+ pub fn LLVMGetSections(ObjFile: &'a ObjectFile) -> &'a mut SectionIterator<'a>;
/// Destroys a section iterator.
- pub fn LLVMDisposeSectionIterator(SI: SectionIteratorRef);
+ pub fn LLVMDisposeSectionIterator(SI: &'a mut SectionIterator<'a>);
/// Returns true if the section iterator is at the end of the section
/// list:
- pub fn LLVMIsSectionIteratorAtEnd(ObjFile: &ObjectFile, SI: SectionIteratorRef) -> Bool;
+ pub fn LLVMIsSectionIteratorAtEnd(ObjFile: &'a ObjectFile, SI: &SectionIterator<'a>) -> Bool;
/// Moves the section iterator to point to the next section.
- pub fn LLVMMoveToNextSection(SI: SectionIteratorRef);
+ pub fn LLVMMoveToNextSection(SI: &SectionIterator);
/// Returns the current section size.
- pub fn LLVMGetSectionSize(SI: SectionIteratorRef) -> c_ulonglong;
+ pub fn LLVMGetSectionSize(SI: &SectionIterator) -> c_ulonglong;
/// Returns the current section contents as a string buffer.
- pub fn LLVMGetSectionContents(SI: SectionIteratorRef) -> *const c_char;
+ pub fn LLVMGetSectionContents(SI: &SectionIterator) -> *const c_char;
/// Reads the given file and returns it as a memory buffer. Use
/// LLVMDisposeMemoryBuffer() to get rid of it.
pub fn LLVMRustArchiveIteratorFree(AIR: ArchiveIteratorRef);
pub fn LLVMRustDestroyArchive(AR: &'static mut Archive);
- pub fn LLVMRustGetSectionName(SI: SectionIteratorRef, data: &mut *const c_char) -> size_t;
+ pub fn LLVMRustGetSectionName(SI: &SectionIterator, data: &mut *const c_char) -> size_t;
pub fn LLVMRustWriteTwineToString(T: &Twine, s: &RustString);
// Memory-managed interface to section iterators.
-pub struct SectionIter {
- pub llsi: SectionIteratorRef,
+pub struct SectionIter<'a> {
+ pub llsi: &'a mut SectionIterator<'a>,
}
-impl Drop for SectionIter {
+impl Drop for SectionIter<'a> {
fn drop(&mut self) {
unsafe {
- LLVMDisposeSectionIterator(self.llsi);
+ LLVMDisposeSectionIterator(&mut *(self.llsi as *mut _));
}
}
}
-pub fn mk_section_iter(llof: &ffi::ObjectFile) -> SectionIter {
+pub fn mk_section_iter(llof: &'a ffi::ObjectFile) -> SectionIter<'a> {
unsafe { SectionIter { llsi: LLVMGetSections(llof) } }
}