iOS13 PostFix #3: Support for @Block member in structs
21 Oct 2019 | fix compiler postfixThis post continues the series of fixes discovered during compilation of CocoaTouch library.
PostFix #3: Adding support @Block members in structs
Other postfixes:
- PostFix #1: Generic class arguments and @Block parameters
- PostFix #2: Adding support for non-static @Bridge method in enums classes
- PostFix #4: Compilation failed on @Bridge annotate covariant return synthetic method
- PostFix #5: Support for Struct.offsetOf in structs
- PostFix #6: Fixes to Network framework bindings
- PostFix #7: bindings for ios13.2
- PostFix #8: workaround for missing objc classes(ObjCClassNotFoundException)
- PostFix #9: experimental and formal bitcode support
- PostFix #10: glkit – missing functions (static inline now)
Issue was discovered while compiling CMBufferHandlers
:
java.lang.IllegalArgumentException: No @Marshaler found for return type of @StructMember method <org.robovm.apple.coremedia.CMBufferHandlers: org.robovm.objc.block.Block1 getGetDecodeTimeStamp()>
at org.robovm.compiler.MarshalerLookup.findMarshalerMethod(MarshalerLookup.java:169)
at org.robovm.compiler.BroMethodCompiler.getStructMemberType(BroMethodCompiler.java:977)
at org.robovm.compiler.BroMethodCompiler.getStructType(BroMethodCompiler.java:677)
at org.robovm.compiler.BroMethodCompiler.getStructType(BroMethodCompiler.java:568)
at org.robovm.compiler.StructMemberMethodCompiler.reset(StructMemberMethodCompiler.java:63)
Root case and fix
Root case and fix is clear from exception: there is no @Marshaller
for @Block
return type at moment StructMemberMethodCompiler
performs reset. And the fix is to provide such.
In details there are several moments and fixes:
- Marshallers for
@Block
affected methods are generated byObjCBlockPlugin
inObjCBlockPlugin.Before
class run. The problem here is thatClassCompiler
invokes it afterStructMemberMethodCompiler.reset
where this marshaller is required (and where exception is happening). The fix is to move reset section of method compilers below invocation of pluginsBefore
. This makes marshallers generated at momentStructMemberMethodCompiler.reset
needs it. - Second moment is that
ObjCBlockPlugin.Before
was not considering @StructMember annotated methods as subject for method transformation and the fix is trivial – extending condition to include the case.
The fix is delivered as PR421
Comments