Skip to content

Commit

Permalink
[runtime] Add support for additional type encodings. Fixes xamarin#18562
Browse files Browse the repository at this point in the history
.

Fixes xamarin#18562.
  • Loading branch information
rolfbjarne committed Apr 17, 2024
1 parent e8cccd8 commit 0cf420d
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
21 changes: 21 additions & 0 deletions runtime/runtime.m
Original file line number Diff line number Diff line change
Expand Up @@ -1473,6 +1473,27 @@ -(void) xamarinSetFlags: (enum XamarinGCHandleFlags) flags;
// COOP: no managed memory access: any mode
switch (type [0]) {
case _C_ID:
type++;
if (*type == '"') {
// https://github.com/xamarin/xamarin-macios/issues/18562
// @"..." is an object with the class name inside the quotes.
// https://github.com/llvm/llvm-project/blob/24a082878f7baec3651de56d54e5aa2b75a21b5f/clang/lib/AST/ASTContext.cpp#L8505-L8516
type++;
while (*type && *type != '"')
type++;
type++;
} else if (*type == '?' && type [1] == '<') {
// https://github.com/xamarin/xamarin-macios/issues/18562
// @?<...> is a block pointer
// https://github.com/llvm/llvm-project/blob/24a082878f7baec3651de56d54e5aa2b75a21b5f/clang/lib/AST/ASTContext.cpp#L8405-L8426
type += 2;
do {
type = objc_skip_type (type);
} while (*type && *type != '>');
if (*type)
type++;
}
return type;
case _C_CLASS:
case _C_SEL:
case _C_CHR:
Expand Down
14 changes: 14 additions & 0 deletions runtime/trampolines.m
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,20 @@
if (desc [1] == '?') {
// Example: [AVAssetImageGenerator generateCGImagesAsynchronouslyForTimes:completionHandler:] = 'v16@0:4@8@?12'
length = 2;
if (desc [2] == '<') {
length = 3;
do {
int nestedLength = get_type_description_length (desc + length);
length += nestedLength;
} while (desc [length] && desc [length] != '>');
if (desc [length] == '>')
length++;
}
} else if (desc [1] == '"') {
length = 2;
while (desc [length] && desc [length] != '"')
length++;
length++;
} else {
length = 1;
}
Expand Down

0 comments on commit 0cf420d

Please sign in to comment.