ladybird icon indicating copy to clipboard operation
ladybird copied to clipboard

LibWeb+LibGC: Teach Swift about GC::Cell, and start writing a Swift class in LibWeb that is gc-allocated

Open ADKaster opened this issue 11 months ago • 1 comments

Add the proper annotations for the Cell and Cell::Visitor classes to be visible in Swift. This lets us remove some OpaquePointer shinangians in the Swift bindings.

In the meantime, work around two swift issues:

Boolean bitfield fields are improperly imported: https://github.com/swiftlang/swift/issues/80182 Imported derived classes cannot be cast to Base*: https://github.com/swiftlang/swift/issues/80231

There's another issue I worked around but haven't quite reported yet:

On GC::Cell::Visitor, we have these 4 methods:

void visit(Cell* cell);
void visit(Cell const* cell);
void visit(Cell& cell);
void visit(Cell const& cell);

The versions that take const& and const* are imported in an ambiguous way, and the compiler can't figure out which one to call when using a GC::Cell reference from Swift.

.. There's also the fact that calling visitor.visitUnsafe(parser.ptr()) from my speculative parser's visitEdges ICE's the frontend in IRGen.

cc @etcwilde @egorzhdan @Xazax-hun

ADKaster avatar Mar 23 '25 01:03 ADKaster

n.b.: https://forums.swift.org/t/ladybird-gc-and-imported-class-hierarchies/78790

ADKaster avatar Mar 24 '25 22:03 ADKaster

Your pull request has conflicts that need to be resolved before it can be reviewed and merged. Make sure to rebase your branch on top of the latest master.

github-actions[bot] avatar Apr 03 '25 11:04 github-actions[bot]