[Swift] FlatBuffers createMonster method doesn't treat struct properly (#5992)
* [Swift] FlatBuffers createMonster method doesn't treat struct properly This PR fixed a issue where a struct is not treated properly when use create inside. A example would be the pos inside Monster. The createMonster method takes an Offset for pos. However, FlatBuffersBuilder.add(struct:) doesn't really take Offset argument. That means we don't really add a struct at all for Monster. It will show up as the pos never set. This doesn't show up in FlatBuffersMonsterWriterTests.swift because it implements its own createMonster method, which happens do the dance properly (i.e. first call create(struct) and then immediately call add:). This PR modified the `add(pos:)` interface such that it takes the UnsafeMutableRawPointer directly, calling `create(struct:)` under the hood. I can add unit tests once the direction of this PR approved. * Fix object api pack method codegen. * Add unit tests that uses Monster.createMonster method to serialize. * Updated sample_binary.swift
Showing
想要评论请 注册 或 登录