From 86974363659160a4fa5ff1818e8e1317c74c9a0a Mon Sep 17 00:00:00 2001 From: Mark Rowe Date: Mon, 25 Aug 2025 19:37:04 -0700 Subject: [ObjC] Fix parsing method type encoding strings for 32-bit platforms 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. --- objectivec/objc.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'objectivec/objc.cpp') diff --git a/objectivec/objc.cpp b/objectivec/objc.cpp index 1da2cb34..a30a9ab6 100644 --- a/objectivec/objc.cpp +++ b/objectivec/objc.cpp @@ -295,7 +295,7 @@ std::vector ObjCProcessor::ParseEncodedType(const std::stri nameOrType.type = Type::IntegerType(2, true); break; case 'S': - nameOrType.type = Type::IntegerType(1, false); + nameOrType.type = Type::IntegerType(2, false); break; case 'i': nameOrType.type = Type::IntegerType(4, true); @@ -304,27 +304,27 @@ std::vector ObjCProcessor::ParseEncodedType(const std::stri nameOrType.type = Type::IntegerType(4, false); break; case 'l': - nameOrType.type = Type::IntegerType(8, true); + nameOrType.type = Type::IntegerType(4, true); break; case 'L': + nameOrType.type = Type::IntegerType(4, false); + break; + case 'q': nameOrType.type = Type::IntegerType(8, true); break; + case 'Q': + nameOrType.type = Type::IntegerType(8, false); + break; case 'f': - nameOrType.type = Type::IntegerType(4, true); + nameOrType.type = Type::FloatType(4); + break; + case 'd': + nameOrType.type = Type::FloatType(8); break; case 'b': case 'B': nameOrType.type = Type::BoolType(); break; - case 'q': - qualifiedName = "NSInteger"; - break; - case 'Q': - qualifiedName = "NSUInteger"; - break; - case 'd': - qualifiedName = "CGFloat"; - break; case '*': nameOrType.type = Type::PointerType(m_data->GetAddressSize(), Type::IntegerType(1, true)); break; -- cgit v1.3.1