Fmting pass

This commit is contained in:
Ryan McGrath 2022-11-04 15:57:53 -07:00
parent e54a28a110
commit 2e40bb6ae3
No known key found for this signature in database
GPG key ID: DA6CBD9233593DEA
2 changed files with 17 additions and 16 deletions

View file

@ -1,11 +1,11 @@
use std::cell::Cell; use std::cell::Cell;
use std::collections::HashMap;
use std::collections::hash_map::DefaultHasher; use std::collections::hash_map::DefaultHasher;
use std::hash::{Hash, Hasher}; use std::collections::HashMap;
use std::ffi::CString; use std::ffi::CString;
use std::hash::{Hash, Hasher};
use std::sync::{Arc, RwLock};
use std::thread; use std::thread;
use std::time::Instant; use std::time::Instant;
use std::sync::{Arc, RwLock};
use lazy_static::lazy_static; use lazy_static::lazy_static;
use objc::declare::ClassDecl; use objc::declare::ClassDecl;
@ -124,11 +124,7 @@ impl ClassMap {
/// ///
/// There's definitely room to optimize here, but it works for now. /// There's definitely room to optimize here, but it works for now.
#[inline(always)] #[inline(always)]
pub fn load_or_register_class<F>( pub fn load_or_register_class<F>(superclass_name: &'static str, subclass_name: &'static str, config: F) -> *const Class
superclass_name: &'static str,
subclass_name: &'static str,
config: F
) -> *const Class
where where
F: Fn(&mut ClassDecl) + 'static F: Fn(&mut ClassDecl) + 'static
{ {
@ -145,12 +141,17 @@ where
// guarantees that we almost always have a unique name to register with the ObjC runtime). // guarantees that we almost always have a unique name to register with the ObjC runtime).
// //
// For more context, see: https://github.com/ryanmcgrath/cacao/issues/63 // For more context, see: https://github.com/ryanmcgrath/cacao/issues/63
let objc_subclass_name = format!("{}_{}_{}", subclass_name, superclass_name, RNG_SEED.with(|rng| { let objc_subclass_name = format!(
rng.set(rng.get().wrapping_add(0xa0761d6478bd642f)); "{}_{}_{}",
let s = rng.get(); subclass_name,
let t = u128::from(s) * (u128::from(s ^ 0xe7037ed1a0b428db)); superclass_name,
((t >> 64) as u64) ^ (t as u64) RNG_SEED.with(|rng| {
})); rng.set(rng.get().wrapping_add(0xa0761d6478bd642f));
let s = rng.get();
let t = u128::from(s) * (u128::from(s ^ 0xe7037ed1a0b428db));
((t >> 64) as u64) ^ (t as u64)
})
);
match ClassDecl::new(&objc_subclass_name, unsafe { &*superclass }) { match ClassDecl::new(&objc_subclass_name, unsafe { &*superclass }) {
Some(mut decl) => { Some(mut decl) => {

View file

@ -12,7 +12,7 @@ use objc::declare::ClassDecl;
use objc::runtime::{Class, Object, Sel}; use objc::runtime::{Class, Object, Sel};
use objc::{class, msg_send, sel, sel_impl}; use objc::{class, msg_send, sel, sel_impl};
use crate::foundation::{id, nil, NSArray, NSInteger, NSString, NO, YES, load_or_register_class}; use crate::foundation::{id, load_or_register_class, nil, NSArray, NSInteger, NSString, NO, YES};
use crate::webview::actions::{NavigationAction, NavigationResponse}; use crate::webview::actions::{NavigationAction, NavigationResponse};
use crate::webview::{mimetype::MimeType, WebViewDelegate, WEBVIEW_DELEGATE_PTR}; //, OpenPanelParameters}; use crate::webview::{mimetype::MimeType, WebViewDelegate, WEBVIEW_DELEGATE_PTR}; //, OpenPanelParameters};
//use crate::webview::enums::{NavigationPolicy, NavigationResponsePolicy}; //use crate::webview::enums::{NavigationPolicy, NavigationResponsePolicy};