diff --git a/crates/web-sys/tests/wasm/element.js b/crates/web-sys/tests/wasm/element.js index 3f34bc5f..38d1f517 100644 --- a/crates/web-sys/tests/wasm/element.js +++ b/crates/web-sys/tests/wasm/element.js @@ -152,6 +152,9 @@ export function new_title() { } export function new_webgl_rendering_context() { + const foo = document.createElement('canvas'); + console.log('Does get context work? ' + foo.getContext('webgl')); + const canvas = document.createElement('canvas'); return canvas.getContext('webgl'); } diff --git a/crates/webidl-tests/lib.rs b/crates/webidl-tests/lib.rs index 7d245db2..ef346239 100644 --- a/crates/webidl-tests/lib.rs +++ b/crates/webidl-tests/lib.rs @@ -1,3 +1 @@ -// intentionally left blank - -// QUESTION FOR REVIEWER: WHY? (I'll include this context in the comment) +// Intentionally left blank in order for Cargo to work diff --git a/crates/webidl/src/util.rs b/crates/webidl/src/util.rs index 56f8cf26..2f82288e 100644 --- a/crates/webidl/src/util.rs +++ b/crates/webidl/src/util.rs @@ -12,6 +12,8 @@ use weedle::literal::{ConstValue, FloatLit, IntegerLit}; use first_pass::{FirstPassRecord, OperationData, OperationId, Signature}; use idl_type::{IdlType, ToIdlType}; +// TODO: Remove.. just using this to see what idl types I need to change.. +use std::io::Write; /// For variadic operations an overload with a `js_sys::Array` argument is generated alongside with /// `operation_name_0`, `operation_name_1`, `operation_name_2`, ..., `operation_name_n` overloads @@ -434,7 +436,7 @@ impl<'src> FirstPassRecord<'src> { signatures.push((signature, idl_args.clone())); } - let idl_type = arg.ty.to_idl_type(self); + let mut idl_type = arg.ty.to_idl_type(self); let idl_type = maybe_adjust(idl_type, id); idl_args.push(idl_type); } @@ -719,16 +721,30 @@ pub fn public() -> syn::Visibility { /// /// Here we implement a whitelist for those cases. This whitelist is currently /// maintained by hand. -fn maybe_adjust<'a> (idl_type: IdlType<'a>, id: &'a OperationId) -> IdlType<'a> { +fn maybe_adjust<'a> (mut idl_type: IdlType<'a>, id: &'a OperationId) -> IdlType<'a> { +// let mut file = ::std::fs::OpenOptions::new().append(true).create(true).open("foo").unwrap(); + match id { - // TODO: `match op` and return an adjusted idl_type if necessary OperationId::Operation(Some(op)) => { match *op { -// "vertexAttrib1fv" => { -// IdlType::Float32Array { immutable: true} -// } - _ => idl_type - } + "vertexAttrib1fv" => { +// TODO: Remove.. just using this to see what idl types I need to change.. +// file.write( +// format!("{:#?}", idl_type).as_bytes() +// ); +// file.write(r#" +// "#.as_bytes()); + + if let IdlType::Union(ref mut union) = idl_type { + if let IdlType::Float32Array { ref mut immutable } = union[0] { + *immutable = true; + } + } + } + _ => {} + }; + + return idl_type } _ => idl_type }