Add renaming of conflicting constructors and operations (#579)

* Add renaming of conflicting constructors and operations

* Rename conflicting to overloaded

* Fix newlines

* Use or_insert_with, add a comment to TypeToString

* Use more Rust-like names

* Use opt instead of nullable

* Use argument names instead of argument types if possible

* Drop new for overloaded constructots

* Remove extra newline

* Move WebIDL files from unavailable_overloaded_fn

* Move RTCDataChannel, RTCPeerConnection and Selection to unavailable_option_primitive
This commit is contained in:
afdw
2018-07-30 17:41:22 +03:00
committed by Alex Crichton
parent 457ed3ffcb
commit 7fda07f797
24 changed files with 400 additions and 46 deletions

View File

@ -75,7 +75,7 @@ fn parse(webidl_source: &str) -> Result<backend::ast::Program> {
};
let mut first_pass_record = Default::default();
definitions.first_pass(&mut first_pass_record)?;
definitions.first_pass(&mut first_pass_record, ())?;
let mut program = Default::default();
definitions.webidl_parse(&mut program, &first_pass_record, ())?;
@ -309,7 +309,7 @@ impl WebidlParse<()> for webidl::ast::PartialInterface {
return Ok(());
}
if !first_pass.interfaces.contains(&self.name) {
if !first_pass.interfaces.contains_key(&self.name) {
warn!(
"Partial interface {} missing non-partial interface",
self.name
@ -332,6 +332,12 @@ impl<'a> WebidlParse<&'a webidl::ast::NonPartialInterface> for webidl::ast::Exte
interface: &'a webidl::ast::NonPartialInterface,
) -> Result<()> {
let mut add_constructor = |arguments: &[webidl::ast::Argument], class: &str| {
let (overloaded, same_argument_names) = first_pass.get_operation_overloading(
arguments,
::first_pass::OperationId::Constructor,
&interface.name,
);
let self_ty = ident_ty(rust_ident(camel_case_ident(&interface.name).as_str()));
let kind = backend::ast::ImportFunctionKind::Method {
@ -359,6 +365,8 @@ impl<'a> WebidlParse<&'a webidl::ast::NonPartialInterface> for webidl::ast::Exte
first_pass
.create_function(
"new",
overloaded,
same_argument_names,
arguments
.iter()
.map(|arg| (&*arg.name, &*arg.type_, arg.variadic)),