ppc login works in mme main

This commit is contained in:
Sebastian Moser
2026-11-01 14:49:38 +01:00
parent 66b8713e3a
commit 6eedb1826a
68 changed files with 4123 additions and 1467 deletions

View File

@@ -59,13 +59,13 @@ impl ConfigOptId {
opt.fun = Some(fun);
self.clone()
}
pub fn method<F: Fn(ItemData) -> MizeResult<ItemData> + Send + Sync + 'static>(self, name: &str, fun: F) -> ConfigOptId {
pub fn method<F: Fn(ItemData) -> MizeResult<ItemData> + Send + Sync + 'static>(self, name: &str, signature: &str, fun: F) -> ConfigOptId {
let mize = get_global_mize().unwrap();
let mut cur_part = self.id.clone();
let id = cur_part.join(name).unwrap();
// in generate mode: record method metadata, skip normal registration
if mize.is_generate_mode().unwrap_or(false) {
mize.record_method(name, id.clone(), "method").ok();
mize.record_method(name, id.clone(), "method", signature).ok();
return self.clone();
}
let mut opts = mize.config_opts.lock().unwrap();
@@ -118,13 +118,13 @@ pub fn opt(name: &str) -> crate::config::ConfigOptId {
ConfigOptId { id }
}
pub fn method<F: Fn(ItemData) -> MizeResult<ItemData> + Send + Sync + 'static>(name: &str, fun: F) -> ConfigOptId {
pub fn method<F: Fn(ItemData) -> MizeResult<ItemData> + Send + Sync + 'static>(name: &str, signature: &str, fun: F) -> ConfigOptId {
let mize = get_global_mize().unwrap();
let mut cur_part = mize.cur_eval_part.lock().unwrap().clone().unwrap();
let id = cur_part.join(name).unwrap();
// in generate mode: record method metadata, skip normal registration
if mize.is_generate_mode().unwrap_or(false) {
mize.record_method(name, id.clone(), "method").ok();
mize.record_method(name, id.clone(), "method", signature).ok();
return ConfigOptId { id };
}
let mut opts = mize.config_opts.lock().unwrap();
@@ -146,7 +146,7 @@ pub fn effect<F: Fn(ItemData) -> MizeResult<ItemData> + Send + Sync + 'static>(n
let id = cur_part.join(name).unwrap();
// in generate mode: record effect metadata, skip normal registration
if mize.is_generate_mode().unwrap_or(false) {
mize.record_method(name, id.clone(), "effect").ok();
mize.record_method(name, id.clone(), "effect", "").ok();
return ConfigOptId { id };
}
let mut opts = mize.config_opts.lock().unwrap();
@@ -168,7 +168,7 @@ pub fn thread<F: Fn(ItemData) -> MizeResult<ItemData> + Send + Sync + 'static>(n
let id = cur_part.join(name).unwrap();
// in generate mode: record thread metadata, skip normal registration
if mize.is_generate_mode().unwrap_or(false) {
mize.record_method(name, id.clone(), "thread").ok();
mize.record_method(name, id.clone(), "thread", "").ok();
return ConfigOptId { id };
}
let mut opts = mize.config_opts.lock().unwrap();
@@ -199,11 +199,15 @@ pub mod c_api {
super::opt(&string)
}
}
pub extern "C" fn method(name: *const c_char, c_fun: CFun) -> ConfigOptId {
pub extern "C" fn method(name: *const c_char, signature: *const c_char, c_fun: CFun) -> ConfigOptId {
unsafe {
let c_str = CStr::from_ptr(name);
let string = c_str.to_string_lossy();
super::method(&string, move |args| {
let name_str = CStr::from_ptr(name).to_string_lossy();
let sig_str = if signature.is_null() {
String::new()
} else {
CStr::from_ptr(signature).to_string_lossy().into_owned()
};
super::method(&name_str, &sig_str, move |args| {
let raw_ptr = Box::into_raw(Box::new(args));
let ret_ptr = c_fun(raw_ptr);
let data = *Box::from_raw(ret_ptr);