Skip to content

Objective-c method generation uses implementation variable names #1705

Open
@simlay

Description

@simlay

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 )
    }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions