diff --git a/crates/backend/src/ast.rs b/crates/backend/src/ast.rs index 97213216d..406fb0a3c 100644 --- a/crates/backend/src/ast.rs +++ b/crates/backend/src/ast.rs @@ -98,10 +98,6 @@ pub enum ImportFunctionKind { ty: syn::Type, kind: MethodKind, }, - ScopedMethod { - ty: syn::Type, - operation: Operation, - }, Normal, } @@ -432,16 +428,10 @@ impl ImportFunction { } }; Some(shared::MethodData { - class: Some(class.clone()), + class: class.clone(), kind, }) } - ImportFunctionKind::ScopedMethod { ref operation, .. } => { - Some(shared::MethodData { - class: None, - kind: shared::MethodKind::Operation(shared_operation(operation)), - }) - } ImportFunctionKind::Normal => None, }; diff --git a/crates/backend/src/codegen.rs b/crates/backend/src/codegen.rs index 8018c3daa..64c3cb7b2 100644 --- a/crates/backend/src/codegen.rs +++ b/crates/backend/src/codegen.rs @@ -779,9 +779,6 @@ impl TryToTokens for ast::ImportFunction { } class_ty = Some(ty); } - ast::ImportFunctionKind::ScopedMethod { ref ty, .. } => { - class_ty = Some(ty); - } ast::ImportFunctionKind::Normal => {} } let vis = &self.function.rust_vis; diff --git a/crates/backend/src/defined.rs b/crates/backend/src/defined.rs index 8eef37b7f..35ebae370 100644 --- a/crates/backend/src/defined.rs +++ b/crates/backend/src/defined.rs @@ -256,7 +256,6 @@ impl ImportedTypes for ast::ImportFunctionKind { { match self { ast::ImportFunctionKind::Method { ty, .. } => ty.imported_types(f), - ast::ImportFunctionKind::ScopedMethod { ty, .. } => ty.imported_types(f), ast::ImportFunctionKind::Normal => {} } } diff --git a/crates/cli-support/src/js/mod.rs b/crates/cli-support/src/js/mod.rs index e1a9175db..a175cdff6 100644 --- a/crates/cli-support/src/js/mod.rs +++ b/crates/cli-support/src/js/mod.rs @@ -2001,30 +2001,7 @@ impl<'a, 'b> SubContext<'a, 'b> { } }; - let class = match &method_data.class { - Some(class) => self.import_name(info, class)?, - None => { - let op = match &method_data.kind { - shared::MethodKind::Operation(op) => op, - shared::MethodKind::Constructor => { - bail!("\"no class\" methods cannot be constructors") - } - }; - match &op.kind { - shared::OperationKind::Regular => { - return Ok(import.function.name.to_string()) - } - shared::OperationKind::Getter(g) => { - return Ok(format!("(() => {})", g)); - } - shared::OperationKind::Setter(g) => { - return Ok(format!("(v => {} = v)", g)); - } - _ => bail!("\"no class\" methods must be regular/getter/setter"), - } - - } - }; + let class = self.import_name(info, &method_data.class)?; let op = match &method_data.kind { shared::MethodKind::Constructor => return Ok(format!("new {}", class)), shared::MethodKind::Operation(op) => op, diff --git a/crates/macro-support/src/parser.rs b/crates/macro-support/src/parser.rs index dbc63d32b..45702c37e 100644 --- a/crates/macro-support/src/parser.rs +++ b/crates/macro-support/src/parser.rs @@ -510,7 +510,6 @@ impl<'a> ConvertToAst<(BindgenAttrs, &'a Option)> for syn::ForeignItemFn let shim = { let ns = match kind { - ast::ImportFunctionKind::ScopedMethod { .. } | ast::ImportFunctionKind::Normal => (0, "n"), ast::ImportFunctionKind::Method { ref class, .. } => (1, &class[..]), }; diff --git a/crates/shared/src/lib.rs b/crates/shared/src/lib.rs index b2250d6de..3af33c36b 100644 --- a/crates/shared/src/lib.rs +++ b/crates/shared/src/lib.rs @@ -51,7 +51,7 @@ pub struct ImportFunction { #[derive(Deserialize, Serialize)] pub struct MethodData { - pub class: Option, + pub class: String, pub kind: MethodKind, } diff --git a/crates/webidl/src/first_pass.rs b/crates/webidl/src/first_pass.rs index 667620953..c149e1902 100644 --- a/crates/webidl/src/first_pass.rs +++ b/crates/webidl/src/first_pass.rs @@ -44,7 +44,6 @@ pub(crate) struct FirstPassRecord<'src> { pub(crate) struct InterfaceData<'src> { /// Whether only partial interfaces were encountered pub(crate) partial: bool, - pub(crate) global: bool, pub(crate) attributes: Vec<&'src AttributeInterfaceMember<'src>>, pub(crate) consts: Vec<&'src ConstMember<'src>>, pub(crate) operations: BTreeMap, OperationData<'src>>, @@ -373,12 +372,6 @@ fn process_interface_attribute<'src>( false, ); } - ExtendedAttribute::Ident(id) if id.lhs_identifier.0 == "Global" => { - record.interfaces.get_mut(self_name).unwrap().global = true; - } - ExtendedAttribute::IdentList(id) if id.identifier.0 == "Global" => { - record.interfaces.get_mut(self_name).unwrap().global = true; - } _ => {} } } diff --git a/crates/webidl/src/lib.rs b/crates/webidl/src/lib.rs index c79e4e3f2..f88a314cc 100644 --- a/crates/webidl/src/lib.rs +++ b/crates/webidl/src/lib.rs @@ -554,18 +554,11 @@ impl<'src> FirstPassRecord<'src> { None => false, }; - let global = self - .interfaces - .get(self_name) - .map(|interface_data| interface_data.global) - .unwrap_or(false); - for mut import_function in self.create_getter( identifier, &type_.type_, self_name, is_static, - global, attrs, container_attrs, ) { @@ -581,7 +574,6 @@ impl<'src> FirstPassRecord<'src> { &type_.type_, self_name, is_static, - global, attrs, container_attrs, ) { @@ -602,7 +594,7 @@ impl<'src> FirstPassRecord<'src> { op_data: &OperationData<'src>, ) { let import_function_kind = |opkind| { - self.import_function_kind(self_name, data.global, op_data.is_static, opkind) + self.import_function_kind(self_name, op_data.is_static, opkind) }; let kind = match id { OperationId::Constructor(ctor_name) => { diff --git a/crates/webidl/src/util.rs b/crates/webidl/src/util.rs index 05ffd7afd..0c453be6f 100644 --- a/crates/webidl/src/util.rs +++ b/crates/webidl/src/util.rs @@ -316,7 +316,6 @@ impl<'src> FirstPassRecord<'src> { structural, shim: { let ns = match kind { - backend::ast::ImportFunctionKind::ScopedMethod { .. } | backend::ast::ImportFunctionKind::Normal => "", backend::ast::ImportFunctionKind::Method { ref class, .. } => class, }; @@ -334,12 +333,11 @@ impl<'src> FirstPassRecord<'src> { ty: &weedle::types::Type<'src>, self_name: &str, is_static: bool, - global: bool, attrs: &Option, container_attrs: Option<&ExtendedAttributeList>, ) -> Option { let kind = backend::ast::OperationKind::Getter(Some(raw_ident(name))); - let kind = self.import_function_kind(self_name, global, is_static, kind); + let kind = self.import_function_kind(self_name, is_static, kind); let ret = ty.to_idl_type(self)?; self.create_one_function( &name, @@ -361,12 +359,11 @@ impl<'src> FirstPassRecord<'src> { field_ty: &weedle::types::Type<'src>, self_name: &str, is_static: bool, - global: bool, attrs: &Option, container_attrs: Option<&ExtendedAttributeList>, ) -> Option { let kind = backend::ast::OperationKind::Setter(Some(raw_ident(name))); - let kind = self.import_function_kind(self_name, global, is_static, kind); + let kind = self.import_function_kind(self_name, is_static, kind); let field_ty = field_ty.to_idl_type(self)?; self.create_one_function( &name, @@ -384,7 +381,6 @@ impl<'src> FirstPassRecord<'src> { pub fn import_function_kind( &self, self_name: &str, - global: bool, is_static: bool, operation_kind: backend::ast::OperationKind, ) -> backend::ast::ImportFunctionKind { @@ -393,17 +389,10 @@ impl<'src> FirstPassRecord<'src> { kind: operation_kind, }; let ty = ident_ty(rust_ident(camel_case_ident(&self_name).as_str())); - if global { - backend::ast::ImportFunctionKind::ScopedMethod { - ty, - operation, - } - } else { - backend::ast::ImportFunctionKind::Method { - class: self_name.to_string(), - ty, - kind: backend::ast::MethodKind::Operation(operation), - } + backend::ast::ImportFunctionKind::Method { + class: self_name.to_string(), + ty, + kind: backend::ast::MethodKind::Operation(operation), } }