Skip to content

Commit

Permalink
Put method output inside an extern_methods! call
Browse files Browse the repository at this point in the history
We'll want this no matter what, since it'll allow us to extend things with availability attributes in the future.
  • Loading branch information
madsmtm committed Nov 1, 2022
1 parent 4f33d88 commit b7b9feb
Show file tree
Hide file tree
Showing 168 changed files with 23,293 additions and 21,905 deletions.
2 changes: 1 addition & 1 deletion header-translator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl RustFile {

let tokens = quote! {
#[allow(unused_imports)]
use objc2::{ClassType, extern_class, msg_send, msg_send_id};
use objc2::{ClassType, extern_class, extern_methods, msg_send, msg_send_id};
#[allow(unused_imports)]
use objc2::rc::{Id, Shared};

Expand Down
18 changes: 11 additions & 7 deletions header-translator/src/stmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,9 +442,11 @@ impl ToTokens for Stmt {
}
);

impl #generic_params #type_ {
#(#methods)*
}
extern_methods!(
unsafe impl #generic_params #type_ {
#(#methods)*
}
);
}
}
Self::CategoryDecl {
Expand All @@ -468,10 +470,12 @@ impl ToTokens for Stmt {
.collect();

quote! {
#meta
impl<#(#generics: Message),*> #class_name<#(#generics),*> {
#(#methods)*
}
extern_methods!(
#meta
unsafe impl<#(#generics: Message),*> #class_name<#(#generics),*> {
#(#methods)*
}
);
}
}
Self::ProtocolDecl {
Expand Down
2 changes: 1 addition & 1 deletion icrate/src/Foundation/generated/FoundationErrors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ use crate::Foundation::generated::NSObject::*;
#[allow(unused_imports)]
use objc2::rc::{Id, Shared};
#[allow(unused_imports)]
use objc2::{extern_class, msg_send, msg_send_id, ClassType};
use objc2::{extern_class, extern_methods, msg_send, msg_send_id, ClassType};
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ use crate::Foundation::generated::NSObjCRuntime::*;
#[allow(unused_imports)]
use objc2::rc::{Id, Shared};
#[allow(unused_imports)]
use objc2::{extern_class, msg_send, msg_send_id, ClassType};
use objc2::{extern_class, extern_methods, msg_send, msg_send_id, ClassType};
96 changes: 49 additions & 47 deletions icrate/src/Foundation/generated/NSAffineTransform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,58 +4,60 @@ use crate::Foundation::generated::NSObject::*;
#[allow(unused_imports)]
use objc2::rc::{Id, Shared};
#[allow(unused_imports)]
use objc2::{extern_class, msg_send, msg_send_id, ClassType};
use objc2::{extern_class, extern_methods, msg_send, msg_send_id, ClassType};
extern_class!(
#[derive(Debug)]
pub struct NSAffineTransform;
unsafe impl ClassType for NSAffineTransform {
type Super = NSObject;
}
);
impl NSAffineTransform {
pub unsafe fn transform() -> Id<NSAffineTransform, Shared> {
msg_send_id![Self::class(), transform]
extern_methods!(
unsafe impl NSAffineTransform {
pub unsafe fn transform() -> Id<NSAffineTransform, Shared> {
msg_send_id![Self::class(), transform]
}
pub unsafe fn initWithTransform(&self, transform: &NSAffineTransform) -> Id<Self, Shared> {
msg_send_id![self, initWithTransform: transform]
}
pub unsafe fn init(&self) -> Id<Self, Shared> {
msg_send_id![self, init]
}
pub unsafe fn translateXBy_yBy(&self, deltaX: CGFloat, deltaY: CGFloat) {
msg_send![self, translateXBy: deltaX, yBy: deltaY]
}
pub unsafe fn rotateByDegrees(&self, angle: CGFloat) {
msg_send![self, rotateByDegrees: angle]
}
pub unsafe fn rotateByRadians(&self, angle: CGFloat) {
msg_send![self, rotateByRadians: angle]
}
pub unsafe fn scaleBy(&self, scale: CGFloat) {
msg_send![self, scaleBy: scale]
}
pub unsafe fn scaleXBy_yBy(&self, scaleX: CGFloat, scaleY: CGFloat) {
msg_send![self, scaleXBy: scaleX, yBy: scaleY]
}
pub unsafe fn invert(&self) {
msg_send![self, invert]
}
pub unsafe fn appendTransform(&self, transform: &NSAffineTransform) {
msg_send![self, appendTransform: transform]
}
pub unsafe fn prependTransform(&self, transform: &NSAffineTransform) {
msg_send![self, prependTransform: transform]
}
pub unsafe fn transformPoint(&self, aPoint: NSPoint) -> NSPoint {
msg_send![self, transformPoint: aPoint]
}
pub unsafe fn transformSize(&self, aSize: NSSize) -> NSSize {
msg_send![self, transformSize: aSize]
}
pub unsafe fn transformStruct(&self) -> NSAffineTransformStruct {
msg_send![self, transformStruct]
}
pub unsafe fn setTransformStruct(&self, transformStruct: NSAffineTransformStruct) {
msg_send![self, setTransformStruct: transformStruct]
}
}
pub unsafe fn initWithTransform(&self, transform: &NSAffineTransform) -> Id<Self, Shared> {
msg_send_id![self, initWithTransform: transform]
}
pub unsafe fn init(&self) -> Id<Self, Shared> {
msg_send_id![self, init]
}
pub unsafe fn translateXBy_yBy(&self, deltaX: CGFloat, deltaY: CGFloat) {
msg_send![self, translateXBy: deltaX, yBy: deltaY]
}
pub unsafe fn rotateByDegrees(&self, angle: CGFloat) {
msg_send![self, rotateByDegrees: angle]
}
pub unsafe fn rotateByRadians(&self, angle: CGFloat) {
msg_send![self, rotateByRadians: angle]
}
pub unsafe fn scaleBy(&self, scale: CGFloat) {
msg_send![self, scaleBy: scale]
}
pub unsafe fn scaleXBy_yBy(&self, scaleX: CGFloat, scaleY: CGFloat) {
msg_send![self, scaleXBy: scaleX, yBy: scaleY]
}
pub unsafe fn invert(&self) {
msg_send![self, invert]
}
pub unsafe fn appendTransform(&self, transform: &NSAffineTransform) {
msg_send![self, appendTransform: transform]
}
pub unsafe fn prependTransform(&self, transform: &NSAffineTransform) {
msg_send![self, prependTransform: transform]
}
pub unsafe fn transformPoint(&self, aPoint: NSPoint) -> NSPoint {
msg_send![self, transformPoint: aPoint]
}
pub unsafe fn transformSize(&self, aSize: NSSize) -> NSSize {
msg_send![self, transformSize: aSize]
}
pub unsafe fn transformStruct(&self) -> NSAffineTransformStruct {
msg_send![self, transformStruct]
}
pub unsafe fn setTransformStruct(&self, transformStruct: NSAffineTransformStruct) {
msg_send![self, setTransformStruct: transformStruct]
}
}
);
Loading

0 comments on commit b7b9feb

Please sign in to comment.