Skip to content

Conversation

bdash
Copy link
Contributor

@bdash bdash commented Aug 26, 2025

This does two main things:

  1. Fixes the parsing of @? which is used to represent a block argument. Since we do not have type system support for blocks and blocks can be treated as Objective-C objects, they are mapped to id.

  2. Fixes some incorrect handling of integer and floating point types, particularly on 32-bit platforms.

    q, Q and d were being mapped to NSInteger, NSUInteger and CGFloat respectively. While this works for 64-bit platforms, the type aliases refer to 32-bit types on 32-bit platforms. These type encodings are explicitly for 64-bit types. To address this q, Q and d are now mapped to int64_t, uint64_t and double respectively.

    l and L were incorrectly being interpreted as int64_t and uint64_t. While long is a 64-bit type on 64-bit Apple platforms, the l / L type encodings always refer to a 32-bit type.

    S was mistakenly being mapped to uint8_t. It is now uint16_t as intended.

@bdash bdash force-pushed the objc-method-type-encodings branch from de408e1 to de0397e Compare August 27, 2025 19:28
bdash added 2 commits August 27, 2025 15:19
The compiler represents block parameters as `@?` in the method type
encoding string. We had been parsing this as two separate parameters
(one `id` and one unknown type that was mapped to `void*`), resulting in
some Objective-C method implementations incorrectly having an extra
parameter.

We cannot represent a Clang block (e.g., `void (^)()`) in the type
system at present. Since these are Objective-C compatible types the
simplest solution for now is to represent them as `id`.
Incorrect parsing of method type encoding strings was causing incorrect
function types to be applied to Objective-C method implementations. In
some cases this would result in confusion about which stack locations
specific parameters resided at.

`q`, `Q` and `d` were being mapped to `NSInteger`, `NSUInteger` and
`CGFloat` respectively. While this works for 64-bit platforms, the type
aliases refer to 32-bit types on 32-bit platforms.  These type encodings
are explicitly for 64-bit types. To address this `q`, `Q` and `d` are
now mapped to `int64_t`, `uint64_t` and `double` respectively.

`l` and `L` were incorrectly being interpreted as `int64_t` and
`uint64_t`. While `long` is a 64-bit type on 64-bit Apple platforms, the
`l` / `L` type encodings always refer to a 32-bit type.

`S` was mistakenly being mapped to `uint8_t`. It is now `uint16_t` as
intended.
@bdash bdash force-pushed the objc-method-type-encodings branch from de0397e to 8697436 Compare August 27, 2025 22:58
@bdash bdash merged commit 8697436 into dev Aug 27, 2025
1 check passed
@bdash bdash deleted the objc-method-type-encodings branch August 27, 2025 22:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant