diff --git a/types/objc/type_encoding.go b/types/objc/type_encoding.go index 39a9b53..3e64c5c 100644 --- a/types/objc/type_encoding.go +++ b/types/objc/type_encoding.go @@ -492,17 +492,27 @@ func skipFirstType(typStr string) string { typ := []byte(typStr) for { switch typ[i] { + case '+': /* gnu register */ + fallthrough + case 'A': /* _Atomic */ + fallthrough + case 'N': /* inout */ + fallthrough case 'O': /* bycopy */ fallthrough + case 'R': /* byref */ + fallthrough + case 'V': /* oneway */ + fallthrough + case 'j': /* _Complex */ + fallthrough case 'n': /* in */ fallthrough case 'o': /* out */ fallthrough - case 'N': /* inout */ - fallthrough case 'r': /* const */ fallthrough - case 'V': /* oneway */ + case '|': /* gc invisible */ fallthrough case '^': /* pointers */ i++ @@ -573,17 +583,27 @@ func CutType(typStr string) (string, string, bool) { typ := []byte(typStr) for { switch typ[i] { + case '+': /* gnu register */ + fallthrough + case 'A': /* _Atomic */ + fallthrough + case 'N': /* inout */ + fallthrough case 'O': /* bycopy */ fallthrough + case 'R': /* byref */ + fallthrough + case 'V': /* oneway */ + fallthrough + case 'j': /* _Complex */ + fallthrough case 'n': /* in */ fallthrough case 'o': /* out */ fallthrough - case 'N': /* inout */ - fallthrough case 'r': /* const */ fallthrough - case 'V': /* oneway */ + case '|': /* gc invisible */ fallthrough case '^': /* pointers */ i++ diff --git a/types/objc/type_encoding_test.go b/types/objc/type_encoding_test.go index e1443a7..01b94be 100644 --- a/types/objc/type_encoding_test.go +++ b/types/objc/type_encoding_test.go @@ -14,9 +14,9 @@ func Test_decodeType(t *testing.T) { { name: "Test all", args: args{ - encType: "^{OutterStruct=(InnerUnion=q{InnerStruct=ii})b1b2b10b1q[2^v]^![4,8c]}", + encType: "^{OutterStruct=(InnerUnion=q{InnerStruct=ii})b1b2b10b1q[2^v]^![4,8c]AQ}", }, - want: "struct OutterStruct { union InnerUnion { long long x0; struct InnerStruct { int x0; int x1; } x1; } x0; unsigned int x1:1; unsigned int x2:2; unsigned int x3:10; unsigned int x4:1; long long x5; void *x6[2]; signed char *x7 __attribute__((aligned(8), vector_size(4))); } *", + want: "struct OutterStruct { union InnerUnion { long long x0; struct InnerStruct { int x0; int x1; } x1; } x0; unsigned int x1:1; unsigned int x2:2; unsigned int x3:10; unsigned int x4:1; long long x5; void *x6[2]; signed char *x7 __attribute__((aligned(8), vector_size(4))); _Atomic unsigned long long x8; } *", }, { name: "Test array", @@ -67,6 +67,13 @@ func Test_decodeType(t *testing.T) { }, want: "void * /* struct */", }, + { + name: "Test struct 4", + args: args{ + encType: "{__CFRuntimeBase=QAQ}", + }, + want: "struct __CFRuntimeBase { unsigned long long x0; _Atomic unsigned long long x1; }", + }, { name: "Test union 0", args: args{