Skip to content

Commit

Permalink
Disable anonymous namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
Fernthedev committed Sep 22, 2023
1 parent 1b776ff commit c031465
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/generate/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ pub struct GenerationConfig {
pub header_path: PathBuf,
pub dst_internals_path: PathBuf,
pub dst_header_internals_file: PathBuf,
pub use_anonymous_namespace: bool
}

impl GenerationConfig {
Expand Down
12 changes: 8 additions & 4 deletions src/generate/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,10 @@ impl CppContext {
.try_for_each(|i| i.write(&mut typeimpl_writer))?;

// anonymous namespace
writeln!(typedef_writer, "namespace {{")?;
writeln!(typeimpl_writer, "namespace {{")?;
if STATIC_CONFIG.use_anonymous_namespace {
writeln!(typedef_writer, "namespace {{")?;
writeln!(typeimpl_writer, "namespace {{")?;
}

// write forward declares
// and includes for impl
Expand Down Expand Up @@ -381,8 +383,10 @@ impl CppContext {
}

// end anonymous namespace
writeln!(typedef_writer, "}} // end anonymous namespace")?;
writeln!(typeimpl_writer, "}} // end anonymous namespace")?;
if STATIC_CONFIG.use_anonymous_namespace {
writeln!(typedef_writer, "}} // end anonymous namespace")?;
writeln!(typeimpl_writer, "}} // end anonymous namespace")?;
}

// write macros
typedef_types
Expand Down
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ pub static STATIC_CONFIG: LazyLock<GenerationConfig> = LazyLock::new(|| Generati
dst_header_internals_file: PathBuf::from(
"./codegen/include/cordl_internals/cordl_internals.hpp",
),
use_anonymous_namespace: false,
});

static INTERNALS_DIR: Dir<'_> = include_dir!("$CARGO_MANIFEST_DIR/cordl_internals");
Expand Down

0 comments on commit c031465

Please sign in to comment.