From e38739bb442263f1ef67b6c2415f932aa49e6646 Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Fri, 30 Aug 2013 16:42:49 +0200 Subject: Convert rust_log.cpp to Rust, closes #8703 --- src/rt/rust_crate_map.cpp | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) (limited to 'src/rt/rust_crate_map.cpp') diff --git a/src/rt/rust_crate_map.cpp b/src/rt/rust_crate_map.cpp index 7faae196000..e6206fd7bcb 100644 --- a/src/rt/rust_crate_map.cpp +++ b/src/rt/rust_crate_map.cpp @@ -1,4 +1,4 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -12,36 +12,52 @@ #include void iter_module_map(const mod_entry* map, - void (*fn)(const mod_entry* entry, void *cookie), - void *cookie) { + void (*fn)(void* fptr, void* env, const mod_entry *entry), + void* fptr, + void* env + ) { for (const mod_entry* cur = map; cur->name; cur++) { - fn(cur, cookie); + fn(fptr, env, cur); } } void iter_crate_map(const cratemap* map, - void (*fn)(const mod_entry* map, void *cookie), - void *cookie, + void (*fn)(void* fptr, void* env, const mod_entry *entry), + void *fptr, + void *env, std::set& visited) { if (visited.find(map) == visited.end()) { // Mark this crate visited visited.insert(map); // First iterate this crate - iter_module_map(map->entries(), fn, cookie); + iter_module_map(map->entries(), fn, fptr, env); // Then recurse on linked crates for (cratemap::iterator i = map->begin(), e = map->end(); i != e; ++i) { - iter_crate_map(*i, fn, cookie, visited); + iter_crate_map(*i, fn, fptr, env, visited); } } } void iter_crate_map(const cratemap* map, - void (*fn)(const mod_entry* map, void *cookie), - void *cookie) { + void (*fn)(void* fptr, void* env, const mod_entry *entry), + void *fptr, + void *env + ) { std::set visited; - iter_crate_map(map, fn, cookie, visited); + iter_crate_map(map, fn, fptr, env, visited); } + +extern "C" CDECL void +rust_iter_crate_map(const cratemap* map, + void (*fn)(void* fptr, void* env, const mod_entry *entry), + void *fptr, + void *env + ) { + return iter_crate_map(map, fn, fptr, env); +} + + // // Local Variables: // mode: C++ -- cgit 1.4.1-3-g733a5