Jens-G opened a new pull request, #3612:
URL: https://github.com/apache/thrift/pull/3612

   ## Summary
   
   - Adds `function Equal(const other: I{Name}): Boolean` to every generated 
Delphi struct interface and its implementation class
   - Overrides `function Equals(Obj: TObject): Boolean` on the implementation 
class to delegate to `Equal` via interface check
   - Overrides `Equals(Obj: TObject)` on generated exception wrapper classes 
(`T{Name}`) to compare the inner `FData` struct
   - Implements field-by-field comparison respecting `__isset` semantics for 
optional fields and recursing into all container/struct types
   
   ## Detail
   
   The generator gains two new methods:
   
   **`generate_equal_container`** — recursive helper that emits comparison code 
for any field type into a pair of `ostringstream` buffers (`code` and `vars`). 
Uses the boolean-variable pattern (`_eqN := True; ... if not _eqN then 
Exit(False)`) so comparison never uses `Exit` inside loops, supporting 
arbitrary nesting depth. Strategies per type:
   - Scalar: direct `<>` comparison
   - Binary (`TBytes` / `IThriftBytes`): length check then 
`System.SysUtils.CompareMem`
   - Struct: `.Equal()` recursive call
   - List: indexed element loop
   - Set with scalar elements: `Contains()` (O(n), value-hash equality)
   - Set with interface-typed elements: O(n²) scan calling `.Equal()` on each 
pair
   - Map with scalar keys: `ContainsKey()` + value comparison
   - Map with interface-typed keys: O(n²) key scan
   
   **`generate_delphi_struct_equality_impl`** — walks all struct fields. For 
optional/unqualified fields emits `__isset` guard first (mismatch ⇒ 
`Exit(False)`); required fields compare values directly with no isset check.
   
   ## Tests
   
   Extended `TTestSerializer.Test_Equal` in 
`lib/delphi/test/serializer/TestSerializer.Tests.pas`:
   - Unqualified scalar fields with isset guards (Bonk)
   - Optional fields: isset mismatch, both-unset, both-set 
(TupleProtocolTestStruct)
   - Nil vs non-nil nested struct, structural mismatch (Nesting)
   - List count mismatch and element mismatch (OneOfEach.Byte_list)
   - Set-of-scalar match/count-mismatch/element-mismatch 
(CompactProtoTestStruct.I32_set)
   - Set-of-struct match/nil-vs-non-nil (CompactProtoTestStruct.Struct_set)
   - Map match/missing-key/value-mismatch (CompactProtoTestStruct.Byte_byte_map)
   - Binary field match/content-mismatch/length-mismatch (Base64.B1, COM and 
non-COM branches)
   - `Equals(TObject)` compatible type, value mismatch, incompatible type 
(TBonkImpl)
   - Exception wrapper equality/mismatch/incompatible type (TMutableException)
   
   ## Test plan
   
   - [ ] CI Delphi build passes
   - [ ] `TTestSerializer.Test_Equal` assertions all pass
   - [ ] `make style` clean
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   
   Co-Authored-By: Claude Sonnet 4.6 <[email protected]>


-- 
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]

Reply via email to