mirror of
https://github.com/topjohnwu/cxx.git
synced 2025-02-24 01:52:27 +00:00
Merge pull request #405 from dtolnay/sort
Emit data structures and functions in source order
This commit is contained in:
commit
eed76fa82a
@ -20,7 +20,8 @@ pub(super) fn gen(apis: &[Api], types: &Types, opt: &Opt, header: bool) -> Vec<u
|
||||
|
||||
let apis_by_namespace = NamespaceEntries::new(apis);
|
||||
write_namespace_forward_declarations(out, &apis_by_namespace);
|
||||
write_namespace_contents(out, &apis_by_namespace);
|
||||
write_data_structures(out, apis);
|
||||
write_functions(out, apis);
|
||||
|
||||
if !header {
|
||||
out.next_section();
|
||||
@ -53,9 +54,7 @@ fn write_namespace_forward_declarations(out: &mut OutFile, ns_entries: &Namespac
|
||||
}
|
||||
}
|
||||
|
||||
fn write_namespace_contents<'a>(out: &mut OutFile<'a>, ns_entries: &'a NamespaceEntries<'a>) {
|
||||
let apis = ns_entries.direct_content();
|
||||
|
||||
fn write_data_structures<'a>(out: &mut OutFile<'a>, apis: &'a [Api]) {
|
||||
let mut methods_for_type = HashMap::new();
|
||||
for api in apis {
|
||||
if let Api::RustFunction(efn) = api {
|
||||
@ -102,7 +101,9 @@ fn write_namespace_contents<'a>(out: &mut OutFile<'a>, ns_entries: &'a Namespace
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn write_functions<'a>(out: &mut OutFile<'a>, apis: &'a [Api]) {
|
||||
if !out.header {
|
||||
for api in apis {
|
||||
match api {
|
||||
@ -119,10 +120,6 @@ fn write_namespace_contents<'a>(out: &mut OutFile<'a>, ns_entries: &'a Namespace
|
||||
write_rust_function_shim(out, efn);
|
||||
}
|
||||
}
|
||||
|
||||
for (_, nested_ns_entries) in ns_entries.nested_content() {
|
||||
write_namespace_contents(out, nested_ns_entries);
|
||||
}
|
||||
}
|
||||
|
||||
fn pick_includes_and_builtins(out: &mut OutFile) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user