Skeleton for topological sort

This commit is contained in:
David Tolnay 2020-11-01 23:55:21 -08:00
parent dfb82d74d5
commit 58cd0c75b4
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
3 changed files with 11 additions and 2 deletions

View File

@ -12,6 +12,7 @@ pub(super) mod include;
mod namespace;
mod nested;
pub(super) mod out;
mod toposort;
mod write;
pub(super) use self::error::Error;

8
gen/src/toposort.rs Normal file
View File

@ -0,0 +1,8 @@
use crate::syntax::{Api, Types};
use std::iter::FromIterator;
pub fn sort<'a>(apis: &'a [Api], types: &Types) -> Vec<&'a Api> {
// TODO https://github.com/dtolnay/cxx/issues/292
let _ = types;
Vec::from_iter(apis)
}

View File

@ -1,7 +1,7 @@
use crate::gen::block::Block;
use crate::gen::nested::NamespaceEntries;
use crate::gen::out::OutFile;
use crate::gen::{builtin, include, Opt};
use crate::gen::{builtin, include, toposort, Opt};
use crate::syntax::atom::Atom::{self, *};
use crate::syntax::symbol::Symbol;
use crate::syntax::{
@ -76,7 +76,7 @@ fn write_data_structures<'a>(out: &mut OutFile<'a>, apis: &'a [Api]) {
}
}
for api in apis {
for api in toposort::sort(apis, out.types) {
match api {
Api::Struct(strct) => {
out.next_section();