2022-12-07 18:27:07 +03:00
|
|
|
mod addin1;
|
2022-12-11 16:52:11 +03:00
|
|
|
mod addin2;
|
2022-12-07 18:27:07 +03:00
|
|
|
mod ffi;
|
|
|
|
|
|
|
|
use std::{
|
2022-12-11 16:52:11 +03:00
|
|
|
ffi::{c_int, c_long, c_void},
|
2022-12-07 18:27:07 +03:00
|
|
|
sync::atomic::{AtomicI32, Ordering},
|
|
|
|
};
|
|
|
|
|
|
|
|
use addin1::Addin1;
|
|
|
|
use ffi::{destroy_component, AttachType};
|
|
|
|
use utf16_lit::utf16_null;
|
|
|
|
|
2022-12-11 16:52:11 +03:00
|
|
|
use crate::{addin2::Addin2, ffi::create_component};
|
2022-12-07 18:27:07 +03:00
|
|
|
|
|
|
|
pub static mut PLATFORM_CAPABILITIES: AtomicI32 = AtomicI32::new(-1);
|
|
|
|
|
|
|
|
#[allow(non_snake_case)]
|
|
|
|
#[no_mangle]
|
2022-12-11 16:52:11 +03:00
|
|
|
pub unsafe extern "C" fn GetClassObject(name: *const u16, component: *mut *mut c_void) -> c_long {
|
|
|
|
match *name as u8 {
|
|
|
|
b'1' => {
|
|
|
|
let addin = Addin1::new();
|
|
|
|
create_component(component, addin)
|
|
|
|
}
|
|
|
|
b'2' => {
|
|
|
|
let addin = Addin2::new();
|
|
|
|
create_component(component, addin)
|
|
|
|
}
|
|
|
|
_ => 0,
|
2022-12-07 18:27:07 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[allow(non_snake_case)]
|
|
|
|
#[no_mangle]
|
2022-12-11 16:52:11 +03:00
|
|
|
pub unsafe extern "C" fn DestroyObject(component: *mut *mut c_void) -> c_long {
|
|
|
|
destroy_component(component)
|
2022-12-07 18:27:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#[allow(non_snake_case)]
|
|
|
|
#[no_mangle]
|
|
|
|
pub extern "C" fn GetClassNames() -> *const u16 {
|
2022-12-11 16:52:11 +03:00
|
|
|
// small strings for performance
|
|
|
|
utf16_null!("1|2").as_ptr()
|
2022-12-07 18:27:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#[allow(non_snake_case)]
|
|
|
|
#[no_mangle]
|
2022-12-11 16:52:11 +03:00
|
|
|
pub extern "C" fn SetPlatformCapabilities(capabilities: c_int) -> c_int {
|
2022-12-07 18:27:07 +03:00
|
|
|
unsafe {
|
|
|
|
PLATFORM_CAPABILITIES.store(capabilities, Ordering::Relaxed);
|
|
|
|
}
|
|
|
|
3
|
|
|
|
}
|
|
|
|
|
|
|
|
#[allow(non_snake_case)]
|
|
|
|
#[no_mangle]
|
|
|
|
pub extern "C" fn GetAttachType() -> AttachType {
|
|
|
|
AttachType::CanAttachAny
|
|
|
|
}
|