Skip to content

Commit

Permalink
Simplify structure of C# backend.
Browse files Browse the repository at this point in the history
  • Loading branch information
ralfbiedert committed Feb 1, 2025
1 parent 19e5e9f commit 22fa0fb
Show file tree
Hide file tree
Showing 26 changed files with 679 additions and 738 deletions.
64 changes: 32 additions & 32 deletions crates/backend_c/src/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -524,37 +524,6 @@ impl Interop {
Ok(())
}

fn write_all(&self, w: &mut IndentWriter) -> Result<(), Error> {
self.write_file_header_comments(w)?;
w.newline()?;

self.write_ifndef(w, |w| {
self.write_ifdefcpp(w, |w| {
if self.imports {
self.write_imports(w)?;
w.newline()?;
}

self.write_custom_defines(w)?;
w.newline()?;

self.write_constants(w)?;
w.newline()?;

self.write_type_definitions(w)?;
w.newline()?;

self.write_functions(w)?;

Ok(())
})?;

Ok(())
})?;

Ok(())
}

fn write_braced_declaration_opening(&self, w: &mut IndentWriter, definition: &str) -> Result<(), Error> {
match self.indentation {
Indentation::Allman => {
Expand Down Expand Up @@ -599,10 +568,41 @@ impl Interop {

Ok(())
}

fn write_to(&self, w: &mut IndentWriter) -> Result<(), Error> {
self.write_file_header_comments(w)?;
w.newline()?;

self.write_ifndef(w, |w| {
self.write_ifdefcpp(w, |w| {
if self.imports {
self.write_imports(w)?;
w.newline()?;
}

self.write_custom_defines(w)?;
w.newline()?;

self.write_constants(w)?;
w.newline()?;

self.write_type_definitions(w)?;
w.newline()?;

self.write_functions(w)?;

Ok(())
})?;

Ok(())
})?;

Ok(())
}
}

impl Bindings for Interop {
fn write_to(&self, w: &mut IndentWriter) -> Result<(), Error> {
self.write_all(w)
self.write_to(w)
}
}
2 changes: 1 addition & 1 deletion crates/backend_c/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
//! InventoryBuilder::new()
//! .register(function!(my_function))
//! .validate()
//! .inventory()
//! .build()
//! }
//! ```
//!
Expand Down
4 changes: 2 additions & 2 deletions crates/backend_cpython/src/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ impl Interop {
Ok(())
}

fn write_all(&self, w: &mut IndentWriter) -> Result<(), Error> {
fn write_to(&self, w: &mut IndentWriter) -> Result<(), Error> {
self.write_imports(w)?;
self.write_api_load_fuction(w)?;
w.newline()?;
Expand Down Expand Up @@ -739,6 +739,6 @@ impl Interop {

impl Bindings for Interop {
fn write_to(&self, w: &mut IndentWriter) -> Result<(), Error> {
self.write_all(w)
self.write_to(w)
}
}
2 changes: 1 addition & 1 deletion crates/backend_cpython/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
//! pub fn my_inventory() -> Inventory {
//! InventoryBuilder::new()
//! .register(function!(my_function))
//! .inventory()
//! .build()
//! }
//! ```
//!
Expand Down
127 changes: 0 additions & 127 deletions crates/backend_csharp/src/config.rs

This file was deleted.

Loading

0 comments on commit 22fa0fb

Please sign in to comment.