Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #35
This is a very Proof of Concept execution of this feature. Notable limitations:
proc_macro2
to be the wasm-side feature checkstatic mut
as opposed to a more principled shared globalBut this implementation does work!
Simple overview of how the feature information flows into the wasm module:
WasmMacro
is created withwatt::wasm_macro_features!
. This takes the wasm binary to wrap as well as a list of feature strings.WasmMacro::new_with_features
. This function, while necessarily public to be called by the macro, is hidden and not public API. This is so that the only named bits of information injected are the enabled (and opted-in) cargo features.WasmMacro
just holds the list of features that it has been told are enabled.__watt_publish_feature
function of the wasm library with the FNV-1a hash of all enabled feature strings.__watt_publish_feature
takes a single 32 bit integer as input and stores it in astatic mut
sorted vector of enabled feature hashes.proc_macro2::features::check("feature_name")
While the details of an impl may change, the rough shape will stay the same:
The wasm interface types proposal could potentially allow passing an "abstract string" more simply, but for the time being, we have to compress the feature string into a 32 bit or 64 bit integer via some hash function.