Skip to content

Commit

Permalink
Forward declare and include in type impl
Browse files Browse the repository at this point in the history
  • Loading branch information
Fernthedev committed Jul 1, 2023
1 parent 21729c6 commit e8797b9
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/generate/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,17 +197,22 @@ impl CppContext {
.try_for_each(|i| i.write(&mut typedef_writer))?;

// write forward declares
// and includes for impl
{
CppInclude::new(diff_paths(&self.typedef_path, base_path).unwrap())
.write(&mut typeimpl_writer)?;

self.typedef_types
.values()
.flat_map(|t| &t.requirements.forward_declares)
.map(|(d, _)| d)
.unique()
// TODO: Check forward declare is not of own type
.try_for_each(|i| i.write(&mut typedef_writer))?;
.try_for_each(|(fd, i)| {
// Forward declare and include
fd.write(&mut typeimpl_writer)?;
i.write(&mut typedef_writer)
})?;

CppInclude::new(diff_paths(&self.typedef_path, base_path).unwrap())
.write(&mut typeimpl_writer)?;
// This is likely not necessary
// self.typedef_types
// .values()
Expand Down

0 comments on commit e8797b9

Please sign in to comment.