Skip to content

Commit

Permalink
Turns out we need to call our _embedded_default_resource_values() fun…
Browse files Browse the repository at this point in the history
…ction
  • Loading branch information
Michael-F-Bryan committed Aug 31, 2021
1 parent 74bf4f3 commit 0aea527
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
41 changes: 21 additions & 20 deletions crates/codegen/src/code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,27 +64,27 @@ fn embed_inline_resources(
initializers.push(tokens);
}

Ok(quote! {
/// Default values for resources as defined in the Runefile.
///
/// These resources are embedded in a WebAssembly custom section
/// and located at runtime.
///
/// # Note to Implementors
///
/// We put the `static` variables inside an exported function
/// instead of their own module because of [#56639 - *Custom section
/// generation under wasm32-unknown-unknown is inconsistent and
/// unintuitive*](https://github.com/rust-lang/rust/issues/56639)
#[allow(bad_style)]
#[doc(hidden)]
#[no_mangle]
pub extern "C" fn _embedded_default_resource_values() {
use hotg_rune_core::InlineResource;
Ok(quote! {
/// Default values for resources as defined in the Runefile.
///
/// These resources are embedded in a WebAssembly custom section
/// and located at runtime.
///
/// # Note to Implementors
///
/// We put the `static` variables inside an exported function
/// instead of their own module because of [#56639 - *Custom section
/// generation under wasm32-unknown-unknown is inconsistent and
/// unintuitive*](https://github.com/rust-lang/rust/issues/56639)
#[allow(bad_style)]
#[doc(hidden)]
#[no_mangle]
pub extern "C" fn _embedded_default_resource_values() {
use hotg_rune_core::InlineResource;

#( #initializers )*
}
})
#( #initializers )*
}
})
}

fn inline_resource_from_disk(
Expand Down Expand Up @@ -814,6 +814,7 @@ mod tests {
let should_be = quote! {
#[no_mangle]
pub extern "C" fn _manifest() -> u32 {
_embedded_default_resource_values();
let _setup = runicos_base_wasm::SetupGuard::default();
let mut audio = runicos_base_wasm::Sound::default();
audio.set_parameter("hz", 16000i32);
Expand Down
3 changes: 1 addition & 2 deletions crates/rune-core/src/resources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ use core::fmt::{self, Formatter, Debug};
/// let resource = InlineResource::new(*b"Name", *b"Some Value");
/// let bytes = resource.as_bytes();
///
/// let (name, value, rest) = inline_resource_from_bytes(bytes)?;
/// let (name, value, rest) = inline_resource_from_bytes(bytes).unwrap();
///
/// assert_eq!(name, "Name");
/// assert_eq!(value, b"Some Value");
/// assert!(rest.is_empty());
/// # Ok(())
/// ```
pub fn inline_resource_from_bytes(
bytes: &[u8],
Expand Down

0 comments on commit 0aea527

Please sign in to comment.