swiftwasm / WebAPIKit

Access the DOM and other Web APIs from Swift! (Very much a WIP)
MIT License
62 stars 8 forks source link

Cleanup unused code, fix event handlers crash #4

Closed MaxDesiatov closed 3 years ago

MaxDesiatov commented 3 years ago

Some weird names and typealiases were cleaned up (I don't think that Int8ArrayOrInt16ArrayOrInt32ArrayOrUint8ArrayOrUint16ArrayOrUint32ArrayOrUint8ClampedArrayOrFloat32ArrayOrFloat64ArrayOrDataView or typealias VoidFunction = (() -> Void) could be useful in any way). GlobalEventHandlers protocol which was only inherited by a single concrete type was removed with its extension becoming the extension of the corresponding class.

I've also cleaned up event handlers to retain and release closures when needed, which makes our single basic test pass in browsers. Basic CI config to verify that is added here.

A few other uses of JSClosure were updated accordingly to fix memory management. Unused ClosureHandler property wrapper is removed, leaving only OptionalClosureHandler.

MaxDesiatov commented 3 years ago

Great point! I'm going to submit another PR to the generator soon to provide better tokenizer diagnostics, as I'm getting inscrutable errors with some other spec files. I hope I'm more familiar with the codebase by then to find a way to avoid overwriting manually updated files.