yash-agarwa-l commented on PR #3776:
URL: https://github.com/apache/fory/pull/3776#issuecomment-4826220289

   Hi @chaokunyang, small update and one thing I'd like your call on.
   
   The Swift gRPC codegen is done and Swift↔Swift round-trips fine, but 
Java↔Swift interop fails. After digging in, it looks like a gap in the Fory 
Swift core serializer, not the gRPC code.
   
   When refTracking is on, Swift writes `NOT_NULL_VALUE` (0xff) for a struct 
message, while Java/Python/Rust write `REF_VALUE` (0x00) and reserve a ref 
slot. (Go reaches `REF_VALUE` only because grpc-go marshals a pointer; its 
value-struct path opts out like Swift.) Without the reserved slot, the ref-id 
counters drift and Java's decode hits Index -1. I checked it's just that one 
flag byte by flipping it. The reason is that Swift structs are `isRefType` = 
`false`, so `foryWrite` skips tracking even when it's on. This might be on 
purpose, since structs are value types. Rust handles the same case by writing 
`REF_VALUE` + `reserve_ref_id()` for value-type structs under tracking.
   
   If that sounds right to you, I'd like to do the same for Swift. One thing to 
flag: it changes tracking-mode output for all Swift structs, not just gRPC. 
Tracking is opt-in and off by default, so the impact should be small, but it's 
a core wire-format change, so I wanted to ask first. No gRPC module changes; 
the contract stays refTracking:true.
   
   Two questions:
   1. Would it be fine to make Swift value-type structs take part in ref 
tracking?
   2. Is the current opt-out on purpose, or just not done yet? Want to be sure 
I'm not missing a reason it writes `NOT_NULL_VALUE`.
   
   Since it's a wire-format change, I'm happy to do whatever works best for you 
here, a separate issue or PR, or just keep it on this PR. Let me know.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to