diff options
| author | Florian Hahn <flo@fhahn.com> | 2013-08-30 16:42:49 +0200 |
|---|---|---|
| committer | Florian Hahn <flo@fhahn.com> | 2013-09-04 14:18:56 +0200 |
| commit | e38739bb442263f1ef67b6c2415f932aa49e6646 (patch) | |
| tree | 832cc6ef84a7f48f8cd776c1b058a1f34ffe89a3 /src/rt/rust_crate_map.cpp | |
| parent | ed422b88727807aee40495a6193a69e4c3842be1 (diff) | |
| download | rust-e38739bb442263f1ef67b6c2415f932aa49e6646.tar.gz rust-e38739bb442263f1ef67b6c2415f932aa49e6646.zip | |
Convert rust_log.cpp to Rust, closes #8703
Diffstat (limited to 'src/rt/rust_crate_map.cpp')
| -rw-r--r-- | src/rt/rust_crate_map.cpp | 38 |
1 files changed, 27 insertions, 11 deletions
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 <set> 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<const cratemap*>& 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<const cratemap*> 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++ |
