pub struct FILERes {
f: *libc::FILE,
- drop {
+}
+
+impl Drop for FILERes {
+ fn finalize(&self) {
unsafe {
libc::fclose(self.f);
}
pub struct FdRes {
fd: fd_t,
- drop {
+}
+
+impl Drop for FdRes {
+ fn finalize(&self) {
unsafe {
libc::close(self.fd);
}
fn test_unwrap_resource() {
struct R {
i: @mut int,
- drop { *(self.i) += 1; }
+ }
+
+ impl ::ops::Drop for R {
+ fn finalize(&self) { *(self.i) += 1; }
}
fn R(i: @mut int) -> R {
struct BufferResource<T> {
buffer: ~Buffer<T>,
- drop {
+}
+
+impl<T> ::ops::Drop for BufferResource<T> {
+ fn finalize(&self) {
unsafe {
let b = move_it!(self.buffer);
//let p = ptr::addr_of(*b);
struct ArcDestruct<T> {
mut data: *libc::c_void,
- drop {
+}
+
+impl<T> Drop for ArcDestruct<T>{
+ fn finalize(&self) {
unsafe {
if self.data.is_null() {
return; // Happens when destructing an unwrapper's handle.
struct DeathThroes<T> {
mut ptr: Option<~ArcData<T>>,
mut response: Option<comm::ChanOne<bool>>,
- drop {
+ }
+
+ impl<T> Drop for DeathThroes<T>{
+ fn finalize(&self) {
unsafe {
let response = option::swap_unwrap(&mut self.response);
// In case we get killed early, we need to tell the person who
struct LittleLock {
l: rust_little_lock,
- drop {
+}
+
+impl Drop for LittleLock {
+ fn finalize(&self) {
unsafe {
rustrt::rust_destroy_little_lock(self.l);
}
struct RandRes {
rng: *rust_rng,
- drop {
+}
+
+impl Drop for RandRes {
+ fn finalize(&self) {
unsafe {
rustrt::rand_free(self.rng);
}
}
struct ProgRes {
r: ProgRepr,
- drop {
+ }
+
+ impl Drop for ProgRes {
+ fn finalize(&self) {
unsafe {
// FIXME #4943: This is bad.
destroy_repr(cast::transmute(&self.r));
mut ancestors: AncestorList,
is_main: bool,
notifier: Option<AutoNotify>,
+}
+
+impl Drop for TCB {
// Runs on task exit.
- drop {
+ fn finalize(&self) {
unsafe {
// If we are failing, the whole taskgroup needs to die.
if rt::rust_task_is_unwinding(self.me) {
struct AutoNotify {
notify_chan: Chan<TaskResult>,
mut failed: bool,
- drop {
+}
+
+impl Drop for AutoNotify {
+ fn finalize(&self) {
let result = if self.failed { Failure } else { Success };
self.notify_chan.send(result);
}
/// A non-copyable dummy type.
pub struct NonCopyable {
i: (),
- drop { }
+}
+
+impl Drop for NonCopyable {
+ fn finalize(&self) { }
}
pub fn NonCopyable() -> NonCopyable { NonCopyable { i: () } }
pub struct target_data_res {
TD: TargetDataRef,
- drop {
+}
+
+impl Drop for target_data_res {
+ fn finalize(&self) {
unsafe {
llvm::LLVMDisposeTargetData(self.TD);
}
pub struct pass_manager_res {
PM: PassManagerRef,
- drop {
+}
+
+impl Drop for pass_manager_res {
+ fn finalize(&self) {
unsafe {
llvm::LLVMDisposePassManager(self.PM);
}
pub struct object_file_res {
ObjectFile: ObjectFileRef,
- drop {
+}
+
+impl Drop for object_file_res {
+ fn finalize(&self) {
unsafe {
llvm::LLVMDisposeObjectFile(self.ObjectFile);
}
pub struct section_iter_res {
SI: SectionIteratorRef,
- drop {
+}
+
+impl Drop for section_iter_res {
+ fn finalize(&self) {
unsafe {
llvm::LLVMDisposeSectionIterator(self.SI);
}
pub struct icx_popper {
ccx: @CrateContext,
- drop {
+}
+
+impl Drop for icx_popper {
+ fn finalize(&self) {
if self.ccx.sess.count_llvm_insns() {
self.ccx.stats.llvm_insn_ctxt.pop();
}
pub struct BuilderRef_res {
B: BuilderRef,
- drop {
+}
+
+impl Drop for BuilderRef_res {
+ fn finalize(&self) {
unsafe {
llvm::LLVMDisposeBuilder(self.B);
}
struct finally {
ch: SharedChan<monitor_msg>,
- drop { self.ch.send(done); }
+ }
+
+ impl Drop for finally {
+ fn finalize(&self) { self.ch.send(done); }
}
let _finally = finally { ch: ch };
pub struct _indenter {
_i: (),
- drop { debug!("<<"); }
+}
+
+impl Drop for _indenter {
+ fn finalize(&self) { debug!("<<"); }
}
pub fn _indenter(_i: ()) -> _indenter {
*/
struct Bored {
bored: bool,
- drop { log(error, self.bored); }
+}
+
+impl Drop for Bored {
+ fn finalize(&self) { log(error, self.bored); }
}
/**
channels: ~[Chan<Msg<T>>],
mut next_index: uint,
- drop {
+}
+
+impl<T> Drop for TaskPool<T> {
+ fn finalize(&self) {
for self.channels.each |channel| {
channel.send(Quit);
}
/// Used to determine the path to externally loaded source files
mod_path_stack: @mut ~[~str],
- drop {} /* do not copy the parser; its state is tied to outside state */
+}
+
+impl Drop for Parser {
+ /* do not copy the parser; its state is tied to outside state */
+ fn finalize(&self) {}
}
pub impl Parser {
pub struct S {
x: int,
- drop {
+}
+
+impl Drop for S {
+ fn finalize(&self) {
io::println("goodbye");
}
}
struct S {
x: int,
- drop {}
+}
+
+impl Drop for S {
+ fn finalize(&self) {}
}
impl S {
struct r {
recursed: *mut bool,
- drop {
+}
+
+impl Drop for r {
+ fn finalize(&self) {
unsafe {
if !*(self.recursed) {
*(self.recursed) = true;
struct r {
i: int,
- drop { fail!(~"squirrel") }
+}
+
+impl Drop for r {
+ fn finalize(&self) { fail!(~"squirrel") }
}
fn r(i: int) -> r { r { i: i } }
struct r {
i: int,
- drop { fail!(~"wombat") }
+}
+
+impl Drop for r {
+ fn finalize(&self) { fail!(~"wombat") }
}
fn r(i: int) -> r { r { i: i } }
// This struct can be quite large so we'll disable copying: developers need
// to either pass these structs around via borrowed pointers or move them.
- drop {}
+}
+
+impl Drop for AsciiArt {
+ fn finalize(&self) {}
}
// It's common to define a constructor sort of function to create struct instances.