1

I'm developing an app in a language other than Objective-C and I came across newBoxWithDimensions. It uses the vector_float3 type which comes from the SIMD API.

I can not encode this function because of the vector_float3 type.

I've found Why can't gcc or clang properly @encode SIMD vector types?; the problem here is when @encode does not encode the SIMD types, then it can not create a proper form for those functions that use SIMD types and then the message sending verification fails. How can I bypass this encoding problem in message sending verification?

4

2 回答 2

1

As an experiment, I requested the method signature for +newBoxWithDimensions:segments:geometryType:inwardNormals:allocator:, using:

NSMethodSignature* sig = [MDLMesh methodSignatureForSelector:@selector(newBoxWithDimensions:segments:geometryType:inwardNormals:allocator:)];

I then enumerated its arguments and their type encodings. It turns out that the signature just skips the two vector arguments. It shows a total of 5 arguments, which includes the implicit self and _cmd arguments, when there should be 7. The encodings are "@", ":", "q", "c", "@", the first two of which correspond to self and _cmd and the last three of which match the last three arguments of the method.

I think your safest approach is to write an Objective-C module that exports a function wrapping this method but where the vector components are passed separately (i.e. three float arguments for the dimensions and three unsigned int arguments for the segments). It would construct the vector arguments from those individual arguments and call through to the class method, returning its result.

于 2017-06-17T22:55:05.680 回答
0

Work-around solution for Rust

For those who are using Rust and have the same problem, I found the work around for bypassing the errors, but keep in mind the problem still exists and my solution will make the developer blind in their debugging process.

  • If you are using objc crate, try to remove the verify_message feature from your crate, else do not do message verifying.
  • Use simd representation for your vector data and put your data in your message without any encoding.
  • In this case you are insanely blind in your development, one way I can suggest is to take your debugging in to Xcode (this is not good too!).
于 2017-06-22T22:29:42.153 回答