-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
171 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[package] | ||
name = "ligen-python-exporter" | ||
version = "0.1.0" | ||
edition.workspace = true | ||
description.workspace = true | ||
authors.workspace = true | ||
license.workspace = true | ||
documentation.workspace = true | ||
readme.workspace = true | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
ligen-ir.workspace = true | ||
ligen-traits.workspace = true | ||
ligen-common.workspace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
pub mod prelude; | ||
use std::{path::PathBuf, str::FromStr}; | ||
|
||
use ligen_ir::{Module, Library}; | ||
use prelude::*; | ||
|
||
use ligen_traits::generator::file_generator::{TemplateRegister, Template, TemplateBasedGenerator}; | ||
|
||
|
||
#[derive(Debug, Default)] | ||
pub struct PythonGenerator; | ||
|
||
impl TemplateRegister for PythonGenerator { | ||
fn register_templates(&self, _template: &mut Template) -> Result<()> { | ||
// register_templates!(template, identifier, arguments, implementation, method, function, module, object, parameters, library); | ||
Ok(()) | ||
} | ||
} | ||
|
||
impl TemplateBasedGenerator for PythonGenerator { | ||
fn register_functions(&self, _library: &Library, _template: &mut Template) { | ||
//register_functions!(template, mapped_type, marshal_output); | ||
} | ||
|
||
fn base_path(&self) -> PathBuf { | ||
PathBuf::from("python".to_string()) | ||
} | ||
|
||
fn module_generation_path(&self, _library: &Library, _module: &Module) -> PathBuf { | ||
// let is_root_module = library.root_module == *module; | ||
// let name = if is_root_module { "lib.rs" } else { "mod.rs" }; | ||
let path = PathBuf::from_str("src").unwrap(); | ||
// path = path.join(PathBuf::from(module.path.clone().without_first())); | ||
// path = path.join(name); | ||
// FIXME: This is not working. | ||
println!("{}", path.display()); | ||
path | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub use ligen_common::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
tools/editor/src/gui/ui/layout/editor/generators/generator.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
use ligen_traits::generator::file_generator::FileGenerator; | ||
|
||
use crate::prelude::*; | ||
use crate::gui::ui::editor::{widget::Widget, settings::Settings}; | ||
|
||
pub struct Generator { | ||
generator: Box<dyn FileGenerator> | ||
} | ||
|
||
impl Generator { | ||
pub fn new<T: FileGenerator + 'static>(generator: T) -> Self { | ||
let generator = Box::new(generator); | ||
Self { generator } | ||
} | ||
} | ||
|
||
impl Widget for Generator { | ||
type Input = ligen_ir::Library; | ||
fn show(&mut self, settings: &Settings, ui: &mut egui::Ui, input: &mut Self::Input) { | ||
ui.label("Generator"); | ||
if ui.button("Generate").clicked() { | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
pub mod generator; | ||
pub use generator::*; | ||
use ligen_python_exporter::PythonGenerator; | ||
|
||
use crate::gui::ui::panes::{Pane, PaneManager}; | ||
|
||
use super::{settings::Settings, widget::Widget}; | ||
|
||
pub struct Generators { | ||
generators: Vec<Generator> | ||
} | ||
|
||
impl Default for Generators { | ||
fn default() -> Self { | ||
let generators = vec![ | ||
Generator::new(PythonGenerator::default()) | ||
]; | ||
Self { generators } | ||
} | ||
} | ||
|
||
impl Generators { | ||
pub fn new() -> Self { | ||
Default::default() | ||
} | ||
} | ||
|
||
impl Widget for Generators { | ||
type Input = ligen_ir::Library; | ||
fn show(&mut self, settings: &Settings, ui: &mut ligen_gui_runtime::egui::Ui, input: &mut Self::Input) { | ||
for (index, generator) in self.generators.iter_mut().enumerate() { | ||
ui.push_id(index, |ui| { | ||
generator.show(&settings, ui, input); | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters