Skip to content

Commit b23b771

Browse files
authored
change i8/u8 type to c_char for arm64 (#59)
On arm64 platform these types are u8 while they are i8 on other platforms. Changing them to c_char works on all platforms.
1 parent eea378a commit b23b771

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

yaobow/shared/src/openswd5/scripting.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::{cell::RefCell, collections::HashMap, rc::Rc};
1+
use std::{cell::RefCell, collections::HashMap, rc::Rc, os::raw::c_char};
22

33
use crosscom::ComRc;
44
use encoding::{DecoderTrap, Encoding};
@@ -303,7 +303,7 @@ impl SWD5Context {
303303
.map(|source| source.borrow_mut().stop());
304304
}
305305

306-
fn storymsg(&mut self, text: *const i8) {
306+
fn storymsg(&mut self, text: *const c_char) {
307307
let text = decode_big5(text);
308308
let [width, height] = self.ui.ui().io().display_size;
309309

@@ -313,14 +313,14 @@ impl SWD5Context {
313313
});
314314
}
315315

316-
fn talkmsg(&mut self, name: *const i8, text: *const i8) {
316+
fn talkmsg(&mut self, name: *const c_char, text: *const c_char) {
317317
let name = decode_big5(name);
318318
let text = decode_big5(text);
319319

320320
self.talk_msg = Some(TalkMsg { name, text });
321321
}
322322

323-
fn storymsgpos(&mut self, text: *const i8, x: f64, y: f64) {
323+
fn storymsgpos(&mut self, text: *const c_char, x: f64, y: f64) {
324324
let text = decode_big5(text);
325325
let (start, size) = calc_43_box(self.ui.ui());
326326
let x = x as f32 / 960. * size[0];
@@ -477,7 +477,7 @@ extern "C" fn sleep(state: *mut lua_State) -> i32 {
477477
}
478478
}
479479

480-
fn decode_big5(s: *const i8) -> String {
480+
fn decode_big5(s: *const c_char) -> String {
481481
let str = unsafe { std::ffi::CStr::from_ptr(s) };
482482
let str = encoding::all::BIG5_2003.decode(str.to_bytes(), DecoderTrap::Ignore);
483483
match str {

yaobow/shared/src/scripting/lua50_32/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::{cell::RefCell, rc::Rc};
1+
use std::{cell::RefCell, rc::Rc, os::raw::c_char};
22

33
use anyhow::bail;
44
use encoding::{DecoderTrap, Encoding};
@@ -29,9 +29,9 @@ impl<TContext> Lua5032Vm<TContext> {
2929

3030
let ret = lua50_32_sys::luaL_loadbuffer(
3131
lua,
32-
lib.as_ptr() as *const i8,
32+
lib.as_ptr() as *const c_char,
3333
lib.len(),
34-
b"main\0".as_ptr() as *const i8,
34+
b"main\0".as_ptr() as *const c_char,
3535
);
3636

3737
if ret > 0 {

0 commit comments

Comments
 (0)