mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-04-13 07:36:07 +00:00
parent
8df5ea7084
commit
06664b34ce
@ -908,7 +908,7 @@ impl syn::synom::Synom for BindgenAttr {
|
|||||||
call!(term, "getter") >>
|
call!(term, "getter") >>
|
||||||
val: option!(do_parse!(
|
val: option!(do_parse!(
|
||||||
punct!(=) >>
|
punct!(=) >>
|
||||||
s: syn!(syn::Ident) >>
|
s: call!(term2ident) >>
|
||||||
(s)
|
(s)
|
||||||
)) >>
|
)) >>
|
||||||
(val)
|
(val)
|
||||||
@ -918,7 +918,7 @@ impl syn::synom::Synom for BindgenAttr {
|
|||||||
call!(term, "setter") >>
|
call!(term, "setter") >>
|
||||||
val: option!(do_parse!(
|
val: option!(do_parse!(
|
||||||
punct!(=) >>
|
punct!(=) >>
|
||||||
s: syn!(syn::Ident) >>
|
s: call!(term2ident) >>
|
||||||
(s)
|
(s)
|
||||||
)) >>
|
)) >>
|
||||||
(val)
|
(val)
|
||||||
@ -931,7 +931,7 @@ impl syn::synom::Synom for BindgenAttr {
|
|||||||
do_parse!(
|
do_parse!(
|
||||||
call!(term, "js_namespace") >>
|
call!(term, "js_namespace") >>
|
||||||
punct!(=) >>
|
punct!(=) >>
|
||||||
ns: syn!(syn::Ident) >>
|
ns: call!(term2ident) >>
|
||||||
(ns)
|
(ns)
|
||||||
)=> { BindgenAttr::JsNamespace }
|
)=> { BindgenAttr::JsNamespace }
|
||||||
|
|
|
|
||||||
@ -952,7 +952,7 @@ impl syn::synom::Synom for BindgenAttr {
|
|||||||
do_parse!(
|
do_parse!(
|
||||||
call!(term, "js_name") >>
|
call!(term, "js_name") >>
|
||||||
punct!(=) >>
|
punct!(=) >>
|
||||||
ns: syn!(syn::Ident) >>
|
ns: call!(term2ident) >>
|
||||||
(ns)
|
(ns)
|
||||||
)=> { BindgenAttr::JsName }
|
)=> { BindgenAttr::JsName }
|
||||||
));
|
));
|
||||||
@ -995,6 +995,19 @@ fn term<'a>(cursor: syn::buffer::Cursor<'a>, name: &str) -> syn::synom::PResult<
|
|||||||
syn::parse_error()
|
syn::parse_error()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn term2ident<'a>(cursor: syn::buffer::Cursor<'a>)
|
||||||
|
-> syn::synom::PResult<'a, syn::Ident>
|
||||||
|
{
|
||||||
|
if let Some((term, next)) = cursor.term() {
|
||||||
|
let n = term.to_string();
|
||||||
|
if !n.starts_with("'") {
|
||||||
|
let i = syn::Ident::new(&n, term.span());
|
||||||
|
return Ok((i, next));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
syn::parse_error()
|
||||||
|
}
|
||||||
|
|
||||||
fn assert_no_lifetimes(decl: &mut syn::FnDecl) {
|
fn assert_no_lifetimes(decl: &mut syn::FnDecl) {
|
||||||
struct Walk;
|
struct Walk;
|
||||||
|
|
||||||
|
@ -429,3 +429,38 @@ fn versions() {
|
|||||||
"#)
|
"#)
|
||||||
.test();
|
.test();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn rust_keyword() {
|
||||||
|
project()
|
||||||
|
.file("src/lib.rs", r#"
|
||||||
|
#![feature(proc_macro, wasm_custom_section, wasm_import_module)]
|
||||||
|
|
||||||
|
extern crate wasm_bindgen;
|
||||||
|
|
||||||
|
use wasm_bindgen::prelude::*;
|
||||||
|
|
||||||
|
#[wasm_bindgen(module = "./test")]
|
||||||
|
extern {
|
||||||
|
#[wasm_bindgen(js_name = self)]
|
||||||
|
fn foo() -> u32;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[wasm_bindgen]
|
||||||
|
pub fn run() {
|
||||||
|
assert_eq!(foo(), 2);
|
||||||
|
}
|
||||||
|
"#)
|
||||||
|
.file("test.ts", r#"
|
||||||
|
import { run } from "./out";
|
||||||
|
|
||||||
|
export function self() {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function test() {
|
||||||
|
run();
|
||||||
|
}
|
||||||
|
"#)
|
||||||
|
.test();
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user