Now with increment and decrement
This commit is contained in:
@@ -14,7 +14,9 @@ pub mod ffi {
|
|||||||
|
|
||||||
type Module;
|
type Module;
|
||||||
|
|
||||||
|
fn decrement(self: Pin<&mut Module>);
|
||||||
fn get_name(self: &Module) -> String;
|
fn get_name(self: &Module) -> String;
|
||||||
|
fn increment(self: Pin<&mut Module>);
|
||||||
fn render_text(self: Pin<&mut 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;
|
||||||
|
|||||||
@@ -3,10 +3,18 @@
|
|||||||
namespace sword_rs {
|
namespace sword_rs {
|
||||||
Module::Module(sword::SWModule* module) : module(module) { }
|
Module::Module(sword::SWModule* module) : module(module) { }
|
||||||
|
|
||||||
|
void Module::decrement() {
|
||||||
|
this->module->decrement();
|
||||||
|
}
|
||||||
|
|
||||||
rust::String Module::get_name() const {
|
rust::String Module::get_name() const {
|
||||||
return rust::String(this->module->getName());
|
return rust::String(this->module->getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Module::increment() {
|
||||||
|
this->module->increment();
|
||||||
|
}
|
||||||
|
|
||||||
rust::String Module::render_text() {
|
rust::String Module::render_text() {
|
||||||
return std::string(
|
return std::string(
|
||||||
(const char*) this->module->renderText()
|
(const char*) this->module->renderText()
|
||||||
|
|||||||
@@ -13,8 +13,12 @@ namespace sword_rs {
|
|||||||
public:
|
public:
|
||||||
Module(sword::SWModule* module);
|
Module(sword::SWModule* module);
|
||||||
|
|
||||||
|
void decrement();
|
||||||
|
|
||||||
rust::String get_name() const;
|
rust::String get_name() const;
|
||||||
|
|
||||||
|
void increment();
|
||||||
|
|
||||||
rust::String render_text();
|
rust::String render_text();
|
||||||
|
|
||||||
void set_key_text(const rust::String& keyText);
|
void set_key_text(const rust::String& keyText);
|
||||||
|
|||||||
+9
-5
@@ -9,10 +9,14 @@ fn main() {
|
|||||||
let random_number: i32 = rand::rng().random_range(1..=20);
|
let random_number: i32 = rand::rng().random_range(1..=20);
|
||||||
let random_number_str = format!("John.3.{}", random_number);
|
let random_number_str = format!("John.3.{}", random_number);
|
||||||
module.set_key_text(&random_number_str);
|
module.set_key_text(&random_number_str);
|
||||||
println!(
|
for i in 0..10 {
|
||||||
"Text John 3:{} is \"{}\"",
|
module.increment();
|
||||||
random_number,
|
println!(
|
||||||
module.render_text()
|
"Text John 3:{} is \"{}\"",
|
||||||
);
|
random_number + i,
|
||||||
|
module.render_text()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
println!("==============================");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,10 +10,18 @@ impl Module {
|
|||||||
Self { module: module }
|
Self { module: module }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn decrement(&mut self) {
|
||||||
|
self.module.pin_mut().decrement();
|
||||||
|
}
|
||||||
|
|
||||||
pub fn get_name(&self) -> String {
|
pub fn get_name(&self) -> String {
|
||||||
self.module.get_name()
|
self.module.get_name()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn increment(&mut self) {
|
||||||
|
self.module.pin_mut().increment();
|
||||||
|
}
|
||||||
|
|
||||||
pub fn render_text(&mut self) -> String {
|
pub fn render_text(&mut self) -> String {
|
||||||
self.module.pin_mut().render_text()
|
self.module.pin_mut().render_text()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user