Now with formatting available
This commit is contained in:
@@ -11,8 +11,10 @@ fn main() {
|
||||
.flag("-Os")
|
||||
.compile("sword_rs");
|
||||
|
||||
println!("cargo:rerun-if-changed=src/mgr.rs");
|
||||
println!("cargo:rerun-if-changed=src/cxx/mod.rs");
|
||||
println!("cargo:rerun-if-changed=src/cxx/mgr.cc");
|
||||
println!("cargo:rerun-if-changed=src/cxx/mgr.h");
|
||||
println!("cargo:rerun-if-changed=src/cxx/module.cc");
|
||||
println!("cargo:rerun-if-changed=src/cxx/module.h");
|
||||
println!("cargo:rustc-link-lib=sword");
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ pub mod ffi {
|
||||
type Module;
|
||||
|
||||
fn get_name(self: &Module) -> String;
|
||||
fn render_text(self: Pin<&mut Module>) -> String;
|
||||
fn set_key_text(self: Pin<&mut Module>, key_text: &String) -> ();
|
||||
fn strip_text(self: Pin<&mut Module>) -> String;
|
||||
}
|
||||
|
||||
+10
-4
@@ -7,13 +7,19 @@ namespace sword_rs {
|
||||
return rust::String(this->module->getName());
|
||||
}
|
||||
|
||||
rust::String Module::render_text() {
|
||||
return std::string(
|
||||
(const char*) this->module->renderText()
|
||||
);
|
||||
}
|
||||
|
||||
void Module::set_key_text(const rust::String& keyText) {
|
||||
this->module->setKeyText(std::string(keyText).c_str());
|
||||
}
|
||||
|
||||
rust::String Module::strip_text() {
|
||||
return std::string(
|
||||
(const char*) this->module->stripText()
|
||||
);
|
||||
}
|
||||
|
||||
void Module::set_key_text(const rust::String& keyText) {
|
||||
this->module->setKeyText(std::string(keyText).c_str());
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -15,8 +15,10 @@ namespace sword_rs {
|
||||
|
||||
rust::String get_name() const;
|
||||
|
||||
rust::String strip_text();
|
||||
rust::String render_text();
|
||||
|
||||
void set_key_text(const rust::String& keyText);
|
||||
|
||||
rust::String strip_text();
|
||||
};
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,8 +1,8 @@
|
||||
use rand::Rng;
|
||||
use sword_rs::mgr::Mgr;
|
||||
use sword_rs::mgr::{Format, Mgr};
|
||||
|
||||
fn main() {
|
||||
let mut mgr = Mgr::new();
|
||||
let mut mgr = Mgr::new_with_format(Format::HTMLHref);
|
||||
for mod_name in mgr.get_modules() {
|
||||
let mut module = mgr.get_module(&mod_name);
|
||||
println!("Module: {}", module.get_name());
|
||||
@@ -12,7 +12,7 @@ fn main() {
|
||||
println!(
|
||||
"Text John 3:{} is \"{}\"",
|
||||
random_number,
|
||||
module.strip_text()
|
||||
module.render_text()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
+6
-2
@@ -14,11 +14,15 @@ impl Module {
|
||||
self.module.get_name()
|
||||
}
|
||||
|
||||
pub fn strip_text(&mut self) -> String {
|
||||
self.module.pin_mut().strip_text()
|
||||
pub fn render_text(&mut self) -> String {
|
||||
self.module.pin_mut().render_text()
|
||||
}
|
||||
|
||||
pub fn set_key_text(&mut self, key_text: &String) {
|
||||
self.module.pin_mut().set_key_text(key_text);
|
||||
}
|
||||
|
||||
pub fn strip_text(&mut self) -> String {
|
||||
self.module.pin_mut().strip_text()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user