Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Objective-c method generation uses implementation variable names #1705

Open
simlay opened this issue Jan 5, 2020 · 1 comment
Open

Objective-c method generation uses implementation variable names #1705

simlay opened this issue Jan 5, 2020 · 1 comment

Comments

@simlay
Copy link
Contributor

simlay commented Jan 5, 2020

I'm on the fence for filing this issue because after testing out all of the iOS frameworks on my system, I've had this issue happen twice but I figure it's useful for documentation purposes if it doesn't get fixed.

According to the apple developer docs:

- (void)someMethodWithValue:(SomeType)value;
Note: The value1 and value2 value names used above aren’t strictly part of the method declaration, which means it’s not necessary to use exactly the same value names in the declaration as you do in the implementation. The only requirement is that the signature matches, which means you must keep the name of the method as well as the parameter and return types exactly the same.

As an example, this method has the same signature as the one shown above:
- (void)someMethodWithFirstValue:(SomeType)info1 secondValue:(AnotherType)info2;

This is also against apples guidelines I'm quite sure (cause why would it not).

Anyway, this is an issue because the headers for translateInCameraSpaceByX:Y:Z from SCNCameraController in SceneKit and dividerImageForLeftSegmentState:rightSegmentState from UIStepper in UIKit have the same name (state and deltaX respectively).

Ideally, the method names in the generation are from the sender name variable name. This is also related to #1703 because method headers that don't have sender names require the existing functionality.

Input Objective-C Header

@interface CAMediaTimingFunction
- (float *)dividerImageForLeftSegmentState:(float)state
                         rightSegmentState:(float)state;
@end

Bindgen Invocation

$ bindgen input.h -- -x objective-c

Actual Results

use objc;
#[allow(non_camel_case_types)]
pub type id = *mut objc::runtime::Object;
pub trait CAMediaTimingFunction {
    unsafe fn dividerImageForLeftSegmentState_rightSegmentState_(
        self,
        state: f32,
        state: f32,
    ) -> *mut f32;
}
impl CAMediaTimingFunction for id {
    unsafe fn dividerImageForLeftSegmentState_rightSegmentState_(
        self,
        state: f32,
        state: f32,
    ) -> *mut f32 {
        msg_send ! ( self , dividerImageForLeftSegmentState : state rightSegmentState : state )
    }
}

Expected Results

pub trait CAMediaTimingFunction {
    unsafe fn dividerImageForLeftSegmentState_rightSegmentState_(
        self,
        state: f32,
        rightSegmentState: f32,
    ) -> *mut f32;
}
impl CAMediaTimingFunction for id {
    unsafe fn dividerImageForLeftSegmentState_rightSegmentState_(
        self,
        state: f32,
        rightSegmentState: f32,
    ) -> *mut f32 {
        msg_send ! ( self , dividerImageForLeftSegmentState : state rightSegmentState : rightSegmentState )
    }
}
@emilio
Copy link
Contributor

emilio commented Jan 5, 2020

I'm not very familiar with objective C, but if we can switch to use the sender name variable name for this I'd be happy to take a patch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants