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