Skip to content

Commit

Permalink
Refactor Foundation fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
madsmtm committed Dec 8, 2022
1 parent d1ae521 commit 1c4c875
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 99 deletions.
13 changes: 13 additions & 0 deletions crates/icrate/src/Foundation/fixes/NSDecimal.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
use std::ffi::c_ushort;

extern_struct!(
pub struct NSDecimal {
// signed int _exponent:8;
// unsigned int _length:4;
// unsigned int _isNegative:1;
// unsigned int _isCompact:1;
// unsigned int _reserved:18;
_inner: i32,
_mantissa: [c_ushort; 8],
}
);
47 changes: 47 additions & 0 deletions crates/icrate/src/Foundation/fixes/NSObject.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
objc2::__inner_extern_class! {
@__inner
pub struct (NSObject) {}

unsafe impl () for NSObject {
INHERITS = [objc2::runtime::Object];
}
}

unsafe impl objc2::ClassType for NSObject {
type Super = objc2::runtime::Object;
const NAME: &'static str = "NSObject";

#[inline]
fn class() -> &'static objc2::runtime::Class {
objc2::class!(NSObject)
}

fn as_super(&self) -> &Self::Super {
&self.__inner
}

fn as_super_mut(&mut self) -> &mut Self::Super {
&mut self.__inner
}
}

impl PartialEq for NSObject {
fn eq(&self, _other: &Self) -> bool {
todo!()
}
}

impl Eq for NSObject {}

impl std::hash::Hash for NSObject {
#[inline]
fn hash<H: std::hash::Hasher>(&self, _state: &mut H) {
todo!()
}
}

impl std::fmt::Debug for NSObject {
fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
todo!()
}
}
53 changes: 53 additions & 0 deletions crates/icrate/src/Foundation/fixes/NSProxy.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
use core::fmt;
use core::hash;

use objc2::runtime::{Class, Object};
use objc2::{ClassType, __inner_extern_class};

__inner_extern_class! {
@__inner
pub struct (NSProxy) {}

unsafe impl () for NSProxy {
INHERITS = [Object];
}
}

unsafe impl ClassType for NSProxy {
type Super = Object;
const NAME: &'static str = "NSProxy";

#[inline]
fn class() -> &'static Class {
objc2::class!(NSProxy)
}

fn as_super(&self) -> &Self::Super {
&self.__inner
}

fn as_super_mut(&mut self) -> &mut Self::Super {
&mut self.__inner
}
}

impl PartialEq for NSProxy {
fn eq(&self, _other: &Self) -> bool {
todo!()
}
}

impl Eq for NSProxy {}

impl hash::Hash for NSProxy {
#[inline]
fn hash<H: hash::Hasher>(&self, _state: &mut H) {
todo!()
}
}

impl fmt::Debug for NSProxy {
fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result {
todo!()
}
}
7 changes: 7 additions & 0 deletions crates/icrate/src/Foundation/fixes/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
mod NSDecimal;
mod NSObject;
mod NSProxy;

pub use self::NSDecimal::*;
pub use self::NSObject::*;
pub use self::NSProxy::*;
101 changes: 2 additions & 99 deletions crates/icrate/src/Foundation/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
mod fixes;
#[allow(unused_imports)]
#[path = "../generated/Foundation/mod.rs"]
mod generated;
Expand All @@ -6,103 +7,5 @@ pub use objc2::ffi::NSIntegerMax;
pub use objc2::foundation::{CGFloat, CGPoint, CGRect, CGSize, NSZone};
pub use objc2::ns_string;

objc2::__inner_extern_class! {
@__inner
pub struct (NSObject) {}

unsafe impl () for NSObject {
INHERITS = [objc2::runtime::Object];
}
}

unsafe impl objc2::ClassType for NSObject {
type Super = objc2::runtime::Object;
const NAME: &'static str = "NSObject";

#[inline]
fn class() -> &'static objc2::runtime::Class {
objc2::class!(NSObject)
}

fn as_super(&self) -> &Self::Super {
&self.__inner
}

fn as_super_mut(&mut self) -> &mut Self::Super {
&mut self.__inner
}
}
impl PartialEq for NSObject {
fn eq(&self, _other: &Self) -> bool {
todo!()
}
}
impl Eq for NSObject {}
impl std::hash::Hash for NSObject {
#[inline]
fn hash<H: std::hash::Hasher>(&self, _state: &mut H) {
todo!()
}
}
impl std::fmt::Debug for NSObject {
fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
todo!()
}
}

objc2::__inner_extern_class! {
@__inner
pub struct (NSProxy) {}

unsafe impl () for NSProxy {
INHERITS = [objc2::runtime::Object];
}
}
unsafe impl objc2::ClassType for NSProxy {
type Super = objc2::runtime::Object;
const NAME: &'static str = "NSProxy";

#[inline]
fn class() -> &'static objc2::runtime::Class {
objc2::class!(NSProxy)
}

fn as_super(&self) -> &Self::Super {
&self.__inner
}

fn as_super_mut(&mut self) -> &mut Self::Super {
&mut self.__inner
}
}
impl PartialEq for NSProxy {
fn eq(&self, _other: &Self) -> bool {
todo!()
}
}
impl Eq for NSProxy {}
impl std::hash::Hash for NSProxy {
#[inline]
fn hash<H: std::hash::Hasher>(&self, _state: &mut H) {
todo!()
}
}
impl std::fmt::Debug for NSProxy {
fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
todo!()
}
}

extern_struct!(
pub struct NSDecimal {
// signed int _exponent:8;
// unsigned int _length:4;
// unsigned int _isNegative:1;
// unsigned int _isCompact:1;
// unsigned int _reserved:18;
_inner: i32,
_mantissa: [std::ffi::c_ushort; 8],
}
);

pub use self::fixes::*;
pub use self::generated::*;

0 comments on commit 1c4c875

Please sign in to comment.