mirror of
https://github.com/maplibre/maplibre-rs.git
synced 2025-12-08 19:05:57 +00:00
Mark functions unsafe
This commit is contained in:
parent
ab97855ef3
commit
1edd31b9a6
@ -31,7 +31,7 @@ export const startMapLibre = async (wasmPath: string | undefined, workerPath: st
|
||||
const memory = new WebAssembly.Memory({initial: 1024, maximum: MEMORY / PAGES, shared: true})
|
||||
await maplibre.default(wasmPath, memory)
|
||||
|
||||
await maplibre.run(await maplibre.create_map(() => {
|
||||
maplibre.run(await maplibre.create_map(() => {
|
||||
return workerPath ? new Worker(workerPath, {
|
||||
type: 'module'
|
||||
}) : MultithreadedPoolWorker();
|
||||
@ -61,6 +61,6 @@ export const startMapLibre = async (wasmPath: string | undefined, workerPath: st
|
||||
maplibre.singlethreaded_main_entry(clonedMap, message.data[0], new Uint8Array(message.data[1]))
|
||||
}
|
||||
|
||||
await maplibre.run(map)
|
||||
maplibre.run(map)
|
||||
}
|
||||
}
|
||||
|
||||
@ -95,8 +95,8 @@ pub async fn create_map(new_worker: js_sys::Function) -> u32 {
|
||||
}
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn clone_map(map_ptr: *const RefCell<MapType>) -> *const RefCell<MapType> {
|
||||
let mut map = unsafe { Rc::from_raw(map_ptr) };
|
||||
pub unsafe fn clone_map(map_ptr: *const RefCell<MapType>) -> *const RefCell<MapType> {
|
||||
let mut map = Rc::from_raw(map_ptr);
|
||||
let rc = map.clone();
|
||||
let cloned = Rc::into_raw(rc);
|
||||
mem::forget(map);
|
||||
@ -105,7 +105,7 @@ pub fn clone_map(map_ptr: *const RefCell<MapType>) -> *const RefCell<MapType> {
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn run(map_ptr: *const RefCell<MapType>) {
|
||||
let mut map = unsafe { Rc::from_raw(map_ptr) };
|
||||
let mut map = Rc::from_raw(map_ptr);
|
||||
|
||||
map.deref().borrow().run();
|
||||
}
|
||||
|
||||
@ -142,13 +142,13 @@ pub async fn singlethreaded_worker_entry(procedure_ptr: u32, input: String) -> R
|
||||
|
||||
/// Entry point invoked by the main thread.
|
||||
#[wasm_bindgen]
|
||||
pub fn singlethreaded_main_entry(
|
||||
pub unsafe fn singlethreaded_main_entry(
|
||||
map_ptr: *const RefCell<MapType>,
|
||||
tag: u32,
|
||||
data: Uint8Array,
|
||||
) -> Result<(), JsValue> {
|
||||
// FIXME (wasm-executor): Can we make this call safe? check if it was cloned before?
|
||||
let mut map = unsafe { Rc::from_raw(map_ptr) };
|
||||
let mut map = Rc::from_raw(map_ptr);
|
||||
|
||||
// FIXME (wasm-executor): remove tag somehow
|
||||
let transferred = match tag {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user