mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-03 16:11:22 +00:00
Rename special to indexing
This commit is contained in:
parent
ef3f086102
commit
e70c9015ff
@ -107,9 +107,9 @@ pub enum OperationKind {
|
|||||||
Regular,
|
Regular,
|
||||||
Getter(Option<Ident>),
|
Getter(Option<Ident>),
|
||||||
Setter(Option<Ident>),
|
Setter(Option<Ident>),
|
||||||
SpecialGetter,
|
IndexingGetter,
|
||||||
SpecialSetter,
|
IndexingSetter,
|
||||||
SpecialDeleter,
|
IndexingDeleter,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq))]
|
#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq))]
|
||||||
@ -372,9 +372,9 @@ impl ImportFunction {
|
|||||||
s.unwrap_or_else(|| self.infer_setter_property()),
|
s.unwrap_or_else(|| self.infer_setter_property()),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
OperationKind::SpecialGetter => shared::OperationKind::SpecialGetter,
|
OperationKind::IndexingGetter => shared::OperationKind::IndexingGetter,
|
||||||
OperationKind::SpecialSetter => shared::OperationKind::SpecialSetter,
|
OperationKind::IndexingSetter => shared::OperationKind::IndexingSetter,
|
||||||
OperationKind::SpecialDeleter => shared::OperationKind::SpecialDeleter,
|
OperationKind::IndexingDeleter => shared::OperationKind::IndexingDeleter,
|
||||||
};
|
};
|
||||||
shared::MethodKind::Operation(shared::Operation { is_static, kind })
|
shared::MethodKind::Operation(shared::Operation { is_static, kind })
|
||||||
}
|
}
|
||||||
|
@ -1841,19 +1841,19 @@ impl<'a, 'b> SubContext<'a, 'b> {
|
|||||||
}}",
|
}}",
|
||||||
location, s
|
location, s
|
||||||
),
|
),
|
||||||
shared::OperationKind::SpecialGetter => format!(
|
shared::OperationKind::IndexingGetter => format!(
|
||||||
"function(y) {{
|
"function(y) {{
|
||||||
return {}[y];
|
return {}[y];
|
||||||
}}",
|
}}",
|
||||||
location
|
location
|
||||||
),
|
),
|
||||||
shared::OperationKind::SpecialSetter => format!(
|
shared::OperationKind::IndexingSetter => format!(
|
||||||
"function(y, z) {{
|
"function(y, z) {{
|
||||||
{}[y] = z;
|
{}[y] = z;
|
||||||
}}",
|
}}",
|
||||||
location
|
location
|
||||||
),
|
),
|
||||||
shared::OperationKind::SpecialDeleter => format!(
|
shared::OperationKind::IndexingDeleter => format!(
|
||||||
"function(y) {{
|
"function(y) {{
|
||||||
delete {}[y];
|
delete {}[y];
|
||||||
}}",
|
}}",
|
||||||
@ -1881,9 +1881,9 @@ impl<'a, 'b> SubContext<'a, 'b> {
|
|||||||
class, location, s,
|
class, location, s,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
shared::OperationKind::SpecialGetter => panic!("getter should be structural"),
|
shared::OperationKind::IndexingGetter => panic!("getter should be structural"),
|
||||||
shared::OperationKind::SpecialSetter => panic!("setter should be structural"),
|
shared::OperationKind::IndexingSetter => panic!("setter should be structural"),
|
||||||
shared::OperationKind::SpecialDeleter => panic!("deleter should be structural"),
|
shared::OperationKind::IndexingDeleter => panic!("deleter should be structural"),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -122,25 +122,25 @@ impl BindgenAttrs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Whether the special getter attributes is present
|
/// Whether the special getter attributes is present
|
||||||
fn special_getter(&self) -> bool {
|
fn indexing_getter(&self) -> bool {
|
||||||
self.attrs.iter().any(|a| match *a {
|
self.attrs.iter().any(|a| match *a {
|
||||||
BindgenAttr::SpecialGetter => true,
|
BindgenAttr::IndexingGetter => true,
|
||||||
_ => false,
|
_ => false,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Whether the special setter attributes is present
|
/// Whether the special setter attributes is present
|
||||||
fn special_setter(&self) -> bool {
|
fn indexing_setter(&self) -> bool {
|
||||||
self.attrs.iter().any(|a| match *a {
|
self.attrs.iter().any(|a| match *a {
|
||||||
BindgenAttr::SpecialSetter => true,
|
BindgenAttr::IndexingSetter => true,
|
||||||
_ => false,
|
_ => false,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Whether the special deleter attributes is present
|
/// Whether the special deleter attributes is present
|
||||||
fn special_deleter(&self) -> bool {
|
fn indexing_deleter(&self) -> bool {
|
||||||
self.attrs.iter().any(|a| match *a {
|
self.attrs.iter().any(|a| match *a {
|
||||||
BindgenAttr::SpecialDeleter => true,
|
BindgenAttr::IndexingDeleter => true,
|
||||||
_ => false,
|
_ => false,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -210,9 +210,9 @@ pub enum BindgenAttr {
|
|||||||
Module(String),
|
Module(String),
|
||||||
Getter(Option<Ident>),
|
Getter(Option<Ident>),
|
||||||
Setter(Option<Ident>),
|
Setter(Option<Ident>),
|
||||||
SpecialGetter,
|
IndexingGetter,
|
||||||
SpecialSetter,
|
IndexingSetter,
|
||||||
SpecialDeleter,
|
IndexingDeleter,
|
||||||
Structural,
|
Structural,
|
||||||
Readonly,
|
Readonly,
|
||||||
JsName(String),
|
JsName(String),
|
||||||
@ -254,11 +254,11 @@ impl syn::synom::Synom for BindgenAttr {
|
|||||||
(val)
|
(val)
|
||||||
)=> { BindgenAttr::Setter }
|
)=> { BindgenAttr::Setter }
|
||||||
|
|
|
|
||||||
call!(term, "special_getter") => { |_| BindgenAttr::SpecialGetter }
|
call!(term, "indexing_getter") => { |_| BindgenAttr::IndexingGetter }
|
||||||
|
|
|
|
||||||
call!(term, "special_setter") => { |_| BindgenAttr::SpecialSetter }
|
call!(term, "indexing_setter") => { |_| BindgenAttr::IndexingSetter }
|
||||||
|
|
|
|
||||||
call!(term, "special_deleter") => { |_| BindgenAttr::SpecialDeleter }
|
call!(term, "indexing_deleter") => { |_| BindgenAttr::IndexingDeleter }
|
||||||
|
|
|
|
||||||
call!(term, "structural") => { |_| BindgenAttr::Structural }
|
call!(term, "structural") => { |_| BindgenAttr::Structural }
|
||||||
|
|
|
|
||||||
@ -414,14 +414,14 @@ impl<'a> ConvertToAst<(BindgenAttrs, &'a Option<String>)> for syn::ForeignItemFn
|
|||||||
if let Some(s) = opts.setter() {
|
if let Some(s) = opts.setter() {
|
||||||
operation_kind = ast::OperationKind::Setter(s);
|
operation_kind = ast::OperationKind::Setter(s);
|
||||||
}
|
}
|
||||||
if opts.special_getter() {
|
if opts.indexing_getter() {
|
||||||
operation_kind = ast::OperationKind::SpecialGetter;
|
operation_kind = ast::OperationKind::IndexingGetter;
|
||||||
}
|
}
|
||||||
if opts.special_setter() {
|
if opts.indexing_setter() {
|
||||||
operation_kind = ast::OperationKind::SpecialSetter;
|
operation_kind = ast::OperationKind::IndexingSetter;
|
||||||
}
|
}
|
||||||
if opts.special_deleter() {
|
if opts.indexing_deleter() {
|
||||||
operation_kind = ast::OperationKind::SpecialDeleter;
|
operation_kind = ast::OperationKind::IndexingDeleter;
|
||||||
}
|
}
|
||||||
|
|
||||||
let kind = if opts.method() {
|
let kind = if opts.method() {
|
||||||
|
@ -69,9 +69,9 @@ pub enum OperationKind {
|
|||||||
Regular,
|
Regular,
|
||||||
Getter(String),
|
Getter(String),
|
||||||
Setter(String),
|
Setter(String),
|
||||||
SpecialGetter,
|
IndexingGetter,
|
||||||
SpecialSetter,
|
IndexingSetter,
|
||||||
SpecialDeleter,
|
IndexingDeleter,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize)]
|
#[derive(Deserialize, Serialize)]
|
||||||
|
@ -42,9 +42,9 @@ pub(crate) struct InterfaceData<'src> {
|
|||||||
pub(crate) enum OperationId<'src> {
|
pub(crate) enum OperationId<'src> {
|
||||||
Constructor,
|
Constructor,
|
||||||
Operation(Option<&'src str>),
|
Operation(Option<&'src str>),
|
||||||
SpecialGetter,
|
IndexingGetter,
|
||||||
SpecialSetter,
|
IndexingSetter,
|
||||||
SpecialDeleter,
|
IndexingDeleter,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
@ -260,9 +260,9 @@ impl<'src> FirstPass<'src, &'src str> for weedle::interface::OperationInterfaceM
|
|||||||
match self.identifier.map(|s| s.0) {
|
match self.identifier.map(|s| s.0) {
|
||||||
None => match self.specials.get(0) {
|
None => match self.specials.get(0) {
|
||||||
None => OperationId::Operation(None),
|
None => OperationId::Operation(None),
|
||||||
Some(weedle::interface::Special::Getter(weedle::term::Getter)) => OperationId::SpecialGetter,
|
Some(weedle::interface::Special::Getter(weedle::term::Getter)) => OperationId::IndexingGetter,
|
||||||
Some(weedle::interface::Special::Setter(weedle::term::Setter)) => OperationId::SpecialSetter,
|
Some(weedle::interface::Special::Setter(weedle::term::Setter)) => OperationId::IndexingSetter,
|
||||||
Some(weedle::interface::Special::Deleter(weedle::term::Deleter)) => OperationId::SpecialDeleter,
|
Some(weedle::interface::Special::Deleter(weedle::term::Deleter)) => OperationId::IndexingDeleter,
|
||||||
Some(weedle::interface::Special::LegacyCaller(weedle::term::LegacyCaller)) => return Ok(()),
|
Some(weedle::interface::Special::LegacyCaller(weedle::term::LegacyCaller)) => return Ok(()),
|
||||||
},
|
},
|
||||||
Some(ref name) => OperationId::Operation(Some(name.clone())),
|
Some(ref name) => OperationId::Operation(Some(name.clone())),
|
||||||
|
@ -651,9 +651,9 @@ fn member_operation<'src>(
|
|||||||
match identifier.map(|s| s.0) {
|
match identifier.map(|s| s.0) {
|
||||||
None if specials.is_empty() => ::first_pass::OperationId::Operation(None),
|
None if specials.is_empty() => ::first_pass::OperationId::Operation(None),
|
||||||
None if specials.len() == 1 => match specials[0] {
|
None if specials.len() == 1 => match specials[0] {
|
||||||
weedle::interface::Special::Getter(weedle::term::Getter) => ::first_pass::OperationId::SpecialGetter,
|
weedle::interface::Special::Getter(weedle::term::Getter) => ::first_pass::OperationId::IndexingGetter,
|
||||||
weedle::interface::Special::Setter(weedle::term::Setter) => ::first_pass::OperationId::SpecialSetter,
|
weedle::interface::Special::Setter(weedle::term::Setter) => ::first_pass::OperationId::IndexingSetter,
|
||||||
weedle::interface::Special::Deleter(weedle::term::Deleter) => ::first_pass::OperationId::SpecialDeleter,
|
weedle::interface::Special::Deleter(weedle::term::Deleter) => ::first_pass::OperationId::IndexingDeleter,
|
||||||
weedle::interface::Special::LegacyCaller(weedle::term::LegacyCaller) => return Ok(()),
|
weedle::interface::Special::LegacyCaller(weedle::term::LegacyCaller) => return Ok(()),
|
||||||
},
|
},
|
||||||
Some(ref name) if specials.is_empty() => ::first_pass::OperationId::Operation(Some(name.clone())),
|
Some(ref name) if specials.is_empty() => ::first_pass::OperationId::Operation(Some(name.clone())),
|
||||||
|
@ -932,9 +932,9 @@ impl<'src> FirstPassRecord<'src> {
|
|||||||
}
|
}
|
||||||
Some(name) => name.to_string(),
|
Some(name) => name.to_string(),
|
||||||
},
|
},
|
||||||
::first_pass::OperationId::SpecialGetter => "get".to_string(),
|
::first_pass::OperationId::IndexingGetter => "get".to_string(),
|
||||||
::first_pass::OperationId::SpecialSetter => "set".to_string(),
|
::first_pass::OperationId::IndexingSetter => "set".to_string(),
|
||||||
::first_pass::OperationId::SpecialDeleter => "delete".to_string(),
|
::first_pass::OperationId::IndexingDeleter => "delete".to_string(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let kind = backend::ast::ImportFunctionKind::Method {
|
let kind = backend::ast::ImportFunctionKind::Method {
|
||||||
@ -945,9 +945,9 @@ impl<'src> FirstPassRecord<'src> {
|
|||||||
kind: match &operation_id {
|
kind: match &operation_id {
|
||||||
::first_pass::OperationId::Constructor => panic!("constructors are unsupported"),
|
::first_pass::OperationId::Constructor => panic!("constructors are unsupported"),
|
||||||
::first_pass::OperationId::Operation(_) => backend::ast::OperationKind::Regular,
|
::first_pass::OperationId::Operation(_) => backend::ast::OperationKind::Regular,
|
||||||
::first_pass::OperationId::SpecialGetter => backend::ast::OperationKind::SpecialGetter,
|
::first_pass::OperationId::IndexingGetter => backend::ast::OperationKind::IndexingGetter,
|
||||||
::first_pass::OperationId::SpecialSetter => backend::ast::OperationKind::SpecialSetter,
|
::first_pass::OperationId::IndexingSetter => backend::ast::OperationKind::IndexingSetter,
|
||||||
::first_pass::OperationId::SpecialDeleter => backend::ast::OperationKind::SpecialDeleter,
|
::first_pass::OperationId::IndexingDeleter => backend::ast::OperationKind::IndexingDeleter,
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
@ -973,9 +973,9 @@ impl<'src> FirstPassRecord<'src> {
|
|||||||
mdn_doc(self_name, Some(&name))
|
mdn_doc(self_name, Some(&name))
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
::first_pass::OperationId::SpecialGetter => Some("The getter\n\n".to_string()),
|
::first_pass::OperationId::IndexingGetter => Some("The getter\n\n".to_string()),
|
||||||
::first_pass::OperationId::SpecialSetter => Some("The setter\n\n".to_string()),
|
::first_pass::OperationId::IndexingSetter => Some("The setter\n\n".to_string()),
|
||||||
::first_pass::OperationId::SpecialDeleter => Some("The deleter\n\n".to_string()),
|
::first_pass::OperationId::IndexingDeleter => Some("The deleter\n\n".to_string()),
|
||||||
};
|
};
|
||||||
|
|
||||||
self.create_function(
|
self.create_function(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user