Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert from stdweb to wasm-bindgen #333

Merged
merged 188 commits into from
Mar 13, 2023
Merged

Convert from stdweb to wasm-bindgen #333

merged 188 commits into from
Mar 13, 2023

Conversation

shanemadden
Copy link
Collaborator

@shanemadden shanemadden commented Nov 20, 2020

Resolves #329. 🎊
Resolves #156, resolves #246, resolves #287, resolves #308, resolves #316, resolves #328, resolves #331

See the temporary readme file added in the root for how to get started using this branch; there's some manual steps to hack the wasm-pack output for now.

Remaining to-do items:

  • Return codes - negative values aren't natively supported by bindgen for enums, so we're taking all return code returning functions as i8 right now. Implement better conversion for ReturnCode and change i8 function returns.
  • Logging - currently just referencing web-sys's console functions, get a good example going with fern.
  • Market - a bunch of return types need struct conversions instead of raw Object, and MarketResourceType conversion from JsString
  • Memory root - need to figure out how to get bindgen to return this object directly from the global scope fresh on each access, which is.. surprisingly confounding to figure out how to do? Document using the thing, and its children from creep/room/etc getters, using Reflect.
  • portal destinations - return type needs struct conversion
  • Room event logs - return types need struct conversion
  • Typed find/look_for calls
  • final - For all object prototype functions where it's safe, add the bindgen final keyword to link the functions more efficiently
  • structural - opposite of final, mark everything on the Game object, which gets re-created every tick, as explicitly structural even though that's currently the default
  • RoomVisual
  • MapVisual
  • Builds - let's move to GH actions as we move to new wasm-pack testing toolchain, since travis has been problematic.
  • Typed Object IDs - currently handling IDs as JsString without a local representation yet, work out how to deal with storing an object type along with an Id and resolving properly, preferably with support for at least both 24-char and 15-char 0-padded IDs (add to tests)
  • Structure typing - we have an enum on structureType that can be used to get the object type as an enum, but not yet as way to get a Structure as the narrowly typed structure within it
  • Chaining - types that support chaining in js like visual inputs should support chained calls
  • Code deployment - update cargo-screeps to support build/deploy of bindgen codebases (the hacks currently enshrined in the temporary readme) Convert from cargo-web to wasm-pack cargo-screeps#24
  • More doc examples - especially of 'tricky' stuff like passing Uint8Array::view() into a CostMatrix unsafely
  • Anything else I added a todo comment on and forgot about

Maybe:

  • Trait implementations - bindgen has opinions about how it hooks into the js inheritance hierarchy, does it make sense to re-implement our traits against the child object types or just expect passing a parent type AsRef as the API is now?
  • Terrain local representation, similar to the CostMatrix one, providing a fast rust-native interface to a Vec<u8> terrain buffer from js (notably with x/y flipped vs costmatrix pos_as_idx)

Cargo.toml Outdated
Comment on lines 39 to 37
stdweb = "0.4"
stdweb-derive = "0.5"
wasm-bindgen = { version = "0.2", features = ["serde-serialize"] }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

@shanemadden shanemadden marked this pull request as ready for review March 5, 2023 03:00
@shanemadden shanemadden merged commit 6a7d44d into master Mar 13, 2023
@shanemadden shanemadden deleted the bindgen branch March 13, 2023 19:58
@ASalvail
Copy link
Collaborator

I missed this! What an incredible milestone!
I might be tempted to give screeps another try now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment