profile
viewpoint
Emilio Cobos Álvarez emilio @mozilla Berlin, Germany / Salamanca, Spain https://crisal.io

emilio/asm6809-boats 2

Juego de los barquitos en ensamblador, para computadores II

emilio/asm6809-matrix 2

Matrix multiplication in 6809 assembler

emilio/clang-format-merge 2

A git merge driver for clang-format.

emilio/base-blogger-template 1

Plantilla básica para blogger con un compilador incluído (en php)

emilio/bindgen-talk 1

https://www.meetup.com/Rust-Berlin/events/252872742/

ACM-USAL/taller-git 0

Contenidos para el taller de git

emilio/acm-sig-bot 0

Bot for ACM SIG groups

issue commentmozilla/rr

Frequent "Assertion `!counting_period || interrupt_val <= adjusted_counting_period' failed to hold." after update to Fedora 33

5.8.13-300.fc33.x86_64 / 5.8.15-301.fc33.x86_64 are good, but I restarted with the latest kernel (5.8.16-300.fc33.x86_64) and now tests pass, so it's not clear to me what has to happen in order to make failing reproducible.

When I found it my desktop had been on for a while and gone through a few suspend cycles but other than that... (and yeah, I made sure to apply the zen-specific workarounds after suspend)

emilio

comment created time in an hour

issue commentmozilla/rr

Frequent "Assertion `!counting_period || interrupt_val <= adjusted_counting_period' failed to hold." after update to Fedora 33

For my own future reference, what I'm doing to bisect is doing something like:

for p in kernel kernel-core kernel-modules kernel-modules-extra kernel-modules-internal; do wget https://kojipkgs.fedoraproject.org/packages/kernel/5.8.13/300.fc33/x86_64/$p-5.8.13-300.fc33.x86_64.rpm ;done
sudo dnf install *.rpm
emilio

comment created time in an hour

issue commentmozilla/rr

Frequent "Assertion `!counting_period || interrupt_val <= adjusted_counting_period' failed to hold." after update to Fedora 33

In 5.8.10-300.fc33.x86_64 I got a couple failures in two runs (1.txt, 2.txt), but none of them looked related to this. One seems like ppoll was interrupted (maybe test bug? Happened in both runs). The other tests are a timeout and an assert which looked potentially interesting:

Assertion `checksum == rec_checksum' failed to hold. Divergence in contents of memory segment after 'SYSCALL: openat'

But still nothing like what I'm looking for.

emilio

comment created time in an hour

issue commentmozilla/rr

Frequent "Assertion `!counting_period || interrupt_val <= adjusted_counting_period' failed to hold." after update to Fedora 33

5.8.5-300.fc33.x86_64 shows some ptrace_ failures, but those were an unrelated kernel regression IIRC, so let's call it good.

emilio

comment created time in an hour

issue commentmozilla/rr

Frequent "Assertion `!counting_period || interrupt_val <= adjusted_counting_period' failed to hold." after update to Fedora 33

I installed 5.6.8-300.fc32.x86_64 from here https://kojipkgs.fedoraproject.org//packages/kernel/5.6.8/300.fc32/x86_64/ and all tests pass fwiw.

emilio

comment created time in 2 hours

issue commentmozilla/rr

Frequent "Assertion `!counting_period || interrupt_val <= adjusted_counting_period' failed to hold." after update to Fedora 33

Ah, for reference, kernel is 5.8.16-300.fc33.x86_64, CPU is AMD Ryzen Threadripper 3990X. I'll try to downgrade and confirm tests are passing there.

emilio

comment created time in 3 hours

issue openedmozilla/rr

Frequent "Assertion `!counting_period || interrupt_val <= adjusted_counting_period' failed to hold." after update to Fedora 33

I recently updated my machine to Fedora 33 and I'm seeing a bunch of these test failures.

The rr tests are enough to trigger this fairly frequently.

Verbose log from ctest -VV -j$(nproc): log.txt

created time in 3 hours

Pull request review commentrust-lang/rust-bindgen

Calling overloaded C++ operators from Rust

 If you encounter an error missing from this list, please file an issue or a PR!"      /// Mangles a name so it doesn't conflict with any keyword.     pub fn rust_mangle<'a>(&self, name: &'a str) -> Cow<'a, str> {-        if name.contains("@") ||-            name.contains("?") ||-            name.contains("$") ||+        let subs = [+            ("@", "_"),+            ("?", "_"),+            ("$", "_"),+            ("+", "_plus"),+            ("&", "_bitand"),+            ("|", "_bitor"),+            ("^", "_bitxor"),+            ("/", "_div"),+            ("%", "_rem"),+            ("<<", "shl"),+            (">>", "shr"),+            // Don't forget that "operator-" is both the name of the binary+            // minus and the unary minus operator (a.k.a the negation operator).+            ("-", "_minus"),+            ("=", "_equal"),+            ("[]", "_index"),+            ("!", "_not"),+        ];

I'm a bit concerned about the perf implications of this, but it should be optimizable relatively easily so no need to dig into that if not wanted.

Volker-Weissmann

comment created time in 15 hours

PullRequestReviewEvent
PullRequestReviewEvent

Pull request review commentrust-lang/rust-bindgen

Calling overloaded C++ operators from Rust

 impl CodeGenerator for CompInfo {     } } +/// This function takes a TokenStream, removes all "const" and replaces all "*"+/// with "&".+///+/// This is a bit hacky, but we need it because type_id_to_rust_type returns+/// something like "const *MyClass" instead of "&MyClass" and the latter is what+/// we need to write into bindgen.rs. The less hacky way would be to make+/// type_id_to_rust_type use "&" instead of "*" when assembling the TokenStream,+/// but doing this is tricky.+fn raw_pointer_to_reference(+    rust_source: proc_macro2::TokenStream+) -> proc_macro2::TokenStream {+    // Todo: Check if the performance of this function is terrible if rust_source is long.+    use proc_macro2::*;+    rust_source+    .into_iter()+    .filter(|elem| {+            match &elem {+                TokenTree::Ident(ident) => {+                    let comp = Ident::new("const", ident.span());+                    if comp == ident.clone() {+                        false+                    } else {+                        true+                    }+                },+                _ => (true),+            }+        }+    )+    .map(|elem| {+            match &elem {+                TokenTree::Punct(punct) => {+                    if punct.as_char() == '*' {+                        TokenTree::Punct(Punct::new('&', Spacing::Alone))+                    } else {+                        elem+                    }+                },+                _ => (elem),+            }+        }+    ).collect()+}++impl Method {+    /// If self is an overloaded operator that this function recognizes, this+    /// function will put the correct wrapper into result and return true. Note+    /// that this function does not need to recognize all overloaded operators+    /// for Bindgen to work correctly, because this function "only" adds some+    /// syntactic sugar to make the Rust code that calls the C++ code using+    /// Bindgen look a bit nicer. A non-exhaustive list of ignored operators:+    /// * `operator[]` - We could translate this C++ operator to Index or+    ///   IndexMut, but in Rust usually the [] operator does the bounds+    ///   checking, but in C++ usually the caller does the bounds checking. This+    ///   might lead to bugs if the Rust caller thinks that the C++ operator+    ///   will do bounds checking.+    /// * `operator<, operator>, operator<=, operator>=` Rust does have the+    ///   "Ord" and "PartialOrd" Traits that are similar to those operators, but+    ///   those operators would require more coding work from the bindgen+    ///   Authors than other operators and I'm lazy.+    /// * `operator!=` In C++ you could (but you probably should not) define a+    ///   != Operator and a == Operator, so that a != b is not !(a == b). You+    ///   cannot do that in Rust, because Rustc translates a != b to !(a == b).+    ///   We ignore the != Operator that the C++ code defined and just use the+    ///   == Operator that the C++ code defined.+    fn try_codegen_operator (+        &self,+        ctx: &BindgenContext,+        ty_for_impl: &proc_macro2::TokenStream,+        result: &mut CodegenResult,+    ) {+        // We start by getting the name of the function.+        let function_item = ctx.resolve_item(self.signature());+        let function = function_item.expect_function();+        let name = function.name().to_owned();+        if !name.starts_with("operator") {+            return;+        }++        // We then get the type of the return value (ret_type) and the type of+        // the second argument (second_arg_type) (if a second argument exists).+        let function_name = ctx.rust_ident(function_item.canonical_name(ctx));+        let signature_item = ctx.resolve_item(function.signature());+        let signature = match *signature_item.expect_type().kind() {+            TypeKind::Function(ref sig) => sig,+            _ => panic!("How in the world?"),+        };+        let return_item = ctx.resolve_item(signature.return_type());+        let ret_type = return_item.to_rust_ty_or_opaque(ctx, &());+        let args = signature.argument_types();+        let second_arg_type = if args.len() < 2 {+            None+        } else {+            dbg!("test");+            let temp = utils::type_id_to_rust_type(ctx, signature.argument_types()[1].1);+            Some(raw_pointer_to_reference(temp))+        };++        // We then check if the function name is in one of the following three+        // arrays or "operator==". If yes, we generate the correct wrapper and+        // add it to result.+        let assignment_operators = [+            ("operator+=", "AddAssign", "add_assign"),+            ("operator&=", "BitAndAssign", "bitand_assign"),+            ("operator|=", "BitOrAssign", "bitor_assign"),+            ("operator^=", "BitXorAssign", "bitxor_assign"),+            ("operator/=", "DivAssign", "div_assign"),+            ("operator%=", "RemAssign", "rem_assign"),+            ("operator<<=", "ShlAssign", "shl_assign"),+            ("operator>>=", "ShrAssign", "shr_assign"),+            ("operator-=", "SubAssign", "sub_assign"),+        ];+        let binary_operators = [+            ("operator+", "Add", "add"),+            ("operator&", "BitAnd", "bitand"),+            ("operator|", "BitOr", "bitor"),+            ("operator^", "BitXor", "bitxor"),+            ("operator/", "Div", "div"),+            ("operator%", "Rem", "rem"),+            ("operator<<", "Shl", "shl"),+            ("operator>>", "Shr", "shr"),+            ("operator-", "Sub", "sub"),+        ];+        let unary_operators = [+            ("operator-", "Neg", "neg"),+            ("operator!", "Not", "not"),+        ];+        if name == "operator==" {+            result.push(quote!(+                impl PartialEq for #ty_for_impl {+                    fn eq(&self, rhs: &Self) -> bool {+                        unsafe {+                            #function_name(self, rhs)+                        }+                    }+                }+            ));+            return;+        }+        for el in assignment_operators.iter() {+            // The args.len() == 2 check shouldn't be neccessary but we still have it.+            if args.len() == 2 && name == el.0 {+                let rhs_type = second_arg_type.unwrap();+                let trait_name = proc_macro2::TokenStream::from_str(el.1).unwrap();+                let func_name = proc_macro2::TokenStream::from_str(el.2).unwrap();+                result.push(quote!(+                    impl std::ops::#trait_name<#rhs_type> for #ty_for_impl {+                        fn #func_name(&mut self, rhs: #rhs_type) {+                            let retptr = unsafe {+                                #function_name(self, rhs)+                            };+                            assert_eq!(retptr, self as *mut #ty_for_impl, "The bindgen authors have no idea how to handle this case.");

Right, my point is that where the object lives is not meaningful is it? Like, a C++ operator can return whatever it wants, but it can't destroy this. So I still don't know why this assert is useful.

Volker-Weissmann

comment created time in 15 hours

PullRequestReviewEvent

Pull request review commentrust-lang/rust-bindgen

Calling overloaded C++ operators from Rust

 mod utils {         }     } +    pub fn type_id_to_rust_type(+        ctx: &BindgenContext,+        ty: crate::ir::context::TypeId,+    ) -> proc_macro2::TokenStream {

Something like this seems to be relatively straight-forward. Should apply on top of your patch.

diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs
index 9eb69f01..00ee92df 100644
--- a/src/codegen/mod.rs
+++ b/src/codegen/mod.rs
@@ -2173,45 +2173,6 @@ impl CodeGenerator for CompInfo {
     }
 }
 
-/// This function takes a TokenStream, removes all "const" and replaces all "*"
-/// with "&".
-///
-/// This is a bit hacky, but we need it because argument_type_id_to_rust_type
-/// returns something like "const *MyClass" instead of "&MyClass" and the latter
-/// is what we need to write into bindgen.rs. The less hacky way would be to
-/// make argument_type_id_to_rust_type use "&" instead of "*" when assembling
-/// the TokenStream, but doing this is tricky.
-fn raw_pointer_to_reference(
-    rust_source: proc_macro2::TokenStream,
-) -> proc_macro2::TokenStream {
-    // Todo: Check if the performance of this function is terrible if rust_source is long.
-    use proc_macro2::*;
-    rust_source
-        .into_iter()
-        .filter(|elem| match &elem {
-            TokenTree::Ident(ident) => {
-                let comp = Ident::new("const", ident.span());
-                if comp == ident.clone() {
-                    false
-                } else {
-                    true
-                }
-            }
-            _ => (true),
-        })
-        .map(|elem| match &elem {
-            TokenTree::Punct(punct) => {
-                if punct.as_char() == '*' {
-                    TokenTree::Punct(Punct::new('&', Spacing::Alone))
-                } else {
-                    elem
-                }
-            }
-            _ => (elem),
-        })
-        .collect()
-}
-
 impl Method {
     /// If self is an overloaded operator that this function recognizes, this
     /// function will put the correct wrapper into result and return true. Note
@@ -2261,11 +2222,11 @@ impl Method {
         let second_arg_type = if args.len() < 2 {
             None
         } else {
-            let temp = utils::argument_type_id_to_rust_type(
+            Some(utils::argument_type_id_to_rust_type(
                 ctx,
                 signature.argument_types()[1].1,
-            );
-            Some(raw_pointer_to_reference(temp))
+                /* pointer_to_ref = */ true
+            ))
         };
 
         // We then check if the function name is in one of the following three
@@ -4617,6 +4578,7 @@ mod utils {
     pub fn argument_type_id_to_rust_type(
         ctx: &BindgenContext,
         ty: crate::ir::context::TypeId,
+        pointer_to_ref: bool,
     ) -> proc_macro2::TokenStream {
         use super::ToPtr;
 
@@ -4641,6 +4603,11 @@ mod utils {
                 stream.to_ptr(ctx.resolve_type(t).is_const())
             }
             TypeKind::Pointer(inner) => {
+                if pointer_to_ref {
+                    let inner = inner.to_rust_ty_or_opaque(ctx, &());
+                    return quote! { &#inner }
+                }
+
                 let inner = ctx.resolve_item(inner);
                 let inner_ty = inner.expect_type();
                 if let TypeKind::ObjCInterface(ref interface) =
@@ -4679,7 +4646,7 @@ mod utils {
                 assert!(!arg_name.is_empty());
                 let arg_name = ctx.rust_ident(arg_name);
 
-                let arg_ty = argument_type_id_to_rust_type(ctx, ty);
+                let arg_ty = argument_type_id_to_rust_type(ctx, ty, /* pointer_to_ref = */ false);
 
                 quote! {
                     #arg_name : #arg_ty
Volker-Weissmann

comment created time in 15 hours

PullRequestReviewEvent

Pull request review commentrust-lang/rust-bindgen

Add dynamic loading support

 pub(crate) fn codegen(             &(),         ); +        // If the set of items to generate dynamic bindings for is nonempty...+        if !context.dyngen_items().is_empty() {

So basically... This is just effectively generating all the functions right now, is that right?

The way I'd have approached this would be something like, maybe:

  • Add an extra field to CodegenResult (dynamic_functions? / whatever)
  • Handle this in CodeGenerator for Function (just something like if ctx.options().dynamic_loading { /* generate appropriate things */ }, and instead of pushing to the regular CodegenResult field, push it to the dynamic functions, which you'd then handle here.

Is there any reason such an approach wouldn't work? It'd handle a lot more edge cases than this (template functions, etc, which this patch doesn't handle), and should also be much simpler / not need extra ItemSets.

joechrisellis

comment created time in 15 hours

Pull request review commentrust-lang/rust-bindgen

Add dynamic loading support

 impl Builder {         self.options.wasm_import_module_name = Some(import_name.into());         self     }++    /// Specify the dynamic library name if we are generating bindings for a shared library.+    pub fn dynamic_library_name<T: Into<String>>(+        mut self,+        dynamic_library_name: T,+    ) -> Self {+        self.options.dynamic_loading = true;

Do you really need to keep track of self.options.dynamic_loading? It seems you really just need a library name, so the dynamic_loading checks could just be self.options.dynamic_library_name.is_some().

joechrisellis

comment created time in 15 hours

Pull request review commentrust-lang/rust-bindgen

Add dynamic loading support

 If you encounter an error missing from this list, please file an issue or a PR!"         }     } +    /// Compute the items for dynamic generation.+    fn compute_dynamic_generation_items(&mut self) {+        assert!(self.in_codegen_phase());+        assert!(self.current_module == self.root_module);+        let _t = self.timer("compute_dynamic_generation_items");++        let dyngen_items = self+            .items()+            // Only consider items that are enabled for codegen.+            .filter(|&(_, item)| item.is_enabled_for_codegen(self))+            .filter(|&(_, item)| {+                // If the user has not chosen to do dynamic loading, then we have nothing to+                // do.+                if !self.options().dynamic_loading {+                    return false;+                }++                let name = item.path_for_whitelisting(self)[1..].join("::");++                // If there is a whitelist and this function is not on it, don't add it.+                if !self.options().whitelisted_functions.is_empty() &&+                    !self.options().whitelisted_functions.matches(&name)+                {

I would expect this to be accounted for via the regular whitelisting mechanism, why is this needed?

joechrisellis

comment created time in 16 hours

Pull request review commentrust-lang/rust-bindgen

Add dynamic loading support

 If you encounter an error missing from this list, please file an issue or a PR!"         }     } +    /// Compute the items for dynamic generation.+    fn compute_dynamic_generation_items(&mut self) {+        assert!(self.in_codegen_phase());+        assert!(self.current_module == self.root_module);+        let _t = self.timer("compute_dynamic_generation_items");++        let dyngen_items = self+            .items()+            // Only consider items that are enabled for codegen.+            .filter(|&(_, item)| item.is_enabled_for_codegen(self))+            .filter(|&(_, item)| {+                // If the user has not chosen to do dynamic loading, then we have nothing to+                // do.+                if !self.options().dynamic_loading {+                    return false;+                }++                let name = item.path_for_whitelisting(self)[1..].join("::");++                // If there is a whitelist and this function is not on it, don't add it.+                if !self.options().whitelisted_functions.is_empty() &&+                    !self.options().whitelisted_functions.matches(&name)+                {+                    return false;+                }++                // If there is a blacklist and this function is on it, don't add it.+                if !self.options().blacklisted_functions.is_empty() &&+                    self.options.blacklisted_functions.matches(&name)+                {

Same about this.

joechrisellis

comment created time in 16 hours

Pull request review commentrust-lang/rust-bindgen

Add dynamic loading support

 If you encounter an error missing from this list, please file an issue or a PR!"         }     } +    /// Compute the items for dynamic generation.+    fn compute_dynamic_generation_items(&mut self) {+        assert!(self.in_codegen_phase());+        assert!(self.current_module == self.root_module);+        let _t = self.timer("compute_dynamic_generation_items");++        let dyngen_items = self+            .items()+            // Only consider items that are enabled for codegen.+            .filter(|&(_, item)| item.is_enabled_for_codegen(self))+            .filter(|&(_, item)| {+                // If the user has not chosen to do dynamic loading, then we have nothing to+                // do.+                if !self.options().dynamic_loading {+                    return false;+                }++                let name = item.path_for_whitelisting(self)[1..].join("::");++                // If there is a whitelist and this function is not on it, don't add it.+                if !self.options().whitelisted_functions.is_empty() &&+                    !self.options().whitelisted_functions.matches(&name)+                {+                    return false;+                }++                // If there is a blacklist and this function is on it, don't add it.+                if !self.options().blacklisted_functions.is_empty() &&+                    self.options.blacklisted_functions.matches(&name)+                {+                    return false;+                }++                // We don't want to include the root module in the list of items to generate+                // dynamic bindings for.+                if item.id() == self.root_module {

We're only generating functions so this check is redundant, right?

joechrisellis

comment created time in 15 hours

PullRequestReviewEvent

Pull request review commentrust-lang/rust-bindgen

Add dynamic loading support

 If you encounter an error missing from this list, please file an issue or a PR!"         }     } +    /// Compute the items for dynamic generation.+    fn compute_dynamic_generation_items(&mut self) {+        assert!(self.in_codegen_phase());+        assert!(self.current_module == self.root_module);+        let _t = self.timer("compute_dynamic_generation_items");++        let dyngen_items = self+            .items()+            // Only consider items that are enabled for codegen.+            .filter(|&(_, item)| item.is_enabled_for_codegen(self))+            .filter(|&(_, item)| {+                // If the user has not chosen to do dynamic loading, then we have nothing to+                // do.+                if !self.options().dynamic_loading {

Seems like this check should really go at the beginning of the function rather than being done for every item.

joechrisellis

comment created time in 16 hours

PullRequestReviewEvent

issue closedeqrion/cbindgen

Allow specifying a profile for `cargo expand`

When parse.expand is enabled, cbindgen invokes Cargo to expand macros in the specified crates. If the dependencies of the crates in question have already been built, Cargo is smart enough to not build them from scratch. However, if the dependencies were only built in release mode, Cargo won't see them as valid build artifacts, and will rebuild everything (using the debug profile) just to do the expansion. If the cargo invocation in cargo_expand.rs allowed passing --release, this extra build could be avoided.

closed time in 16 hours

jrose-signal

issue commenteqrion/cbindgen

Allow specifying a profile for `cargo expand`

Fixed in https://github.com/eqrion/cbindgen/commit/0ba241498e4ceccf052ffa91883d53b7cdfb3a85.

jrose-signal

comment created time in 16 hours

PR closed eqrion/cbindgen

Allow controlling the Cargo profile used for macro expansion

If there's already a release build, it's better for cbindgen to reuse the build artifacts from that to expand macros rather than starting from scratch with a debug build. Controlled with --profile (debug|release) as well as parse.expand.profile in cbindgen.toml, though hardcoding a profile in a config file seems unlikely.

Fixes #603. Happy to adjust per feedback.

+264 -3

1 comment

10 changed files

jrose-signal

pr closed time in 16 hours

pull request commenteqrion/cbindgen

Allow controlling the Cargo profile used for macro expansion

Thanks, I merged it in https://github.com/eqrion/cbindgen/commit/0ba241498e4ceccf052ffa91883d53b7cdfb3a85 with a small follow-up in https://github.com/eqrion/cbindgen/commit/ef05231b5c81d5613762cb41b92e1bb2e987ab01 to remove the duplicate enum.

Thanks!

jrose-signal

comment created time in 16 hours

push eventeqrion/cbindgen

Jordan Rose

commit sha 0ba241498e4ceccf052ffa91883d53b7cdfb3a85

Allow controlling the Cargo profile used for macro expansion If there's already a release build, it's better for cbindgen to reuse the build artifacts from that to expand macros rather than starting from scratch with a debug build. Controlled with --profile (debug|release) as well as parse.expand.profile in cbindgen.toml, though hardcoding a profile in a config file seems unlikely.

view details

Emilio Cobos Álvarez

commit sha ef05231b5c81d5613762cb41b92e1bb2e987ab01

cargo: Remove duplicate Profile enum. use the one from the configuration instead.

view details

push time in 16 hours

push eventeqrion/cbindgen

Vadim Petrochenkov

commit sha 398b28ca301656f0cefd1af52ab0f61e240d83b5

Add an option for converting usize/isize into size_t/ptrdiff_t

view details

push time in 16 hours

PR merged eqrion/cbindgen

Add an option for converting usize/isize into size_t/ptrdiff_t

This PR adds a new global option usize_is_size_t that mirrors size_t_is_usize in bindgen and allows to map usize/isize into the more traditional pair size_t/ptrdiff_t instead of uintptr_t/intptr_t into which they are converted currently.

(I'd personally want to see this as the default, similarly to https://github.com/rust-lang/rust-bindgen/pull/1902, but I didn't change any defaults in this PR.)

cc https://github.com/eqrion/cbindgen/issues/239

+162 -40

0 comment

13 changed files

petrochenkov

pr closed time in 16 hours

PullRequestReviewEvent

Pull request review commenteqrion/cbindgen

Support an annotation for generating bitfield sizes in C code (`: SIZE`)

+use std::io::Write;++use crate::bindgen::cdecl;+use crate::bindgen::config::Config;+use crate::bindgen::ir::{Documentation, Path, Type};+use crate::bindgen::writer::{Source, SourceWriter};++#[derive(Debug, Clone)]+pub struct Field {+    pub name: String,+    pub ty: Type,+    pub documentation: Documentation,+}++impl Field {+    pub fn from_name_and_type(name: String, ty: Type) -> Field {+        Field {+            name,+            ty,+            documentation: Documentation::none(),+        }+    }++    pub fn load(field: &syn::Field, self_path: &Path) -> Result<Option<Field>, String> {+        Ok(if let Some(mut ty) = Type::load(&field.ty)? {+            ty.replace_self_with(self_path);+            Some(Field {+                name: field+                    .ident+                    .as_ref()+                    .ok_or_else(|| "field is missing identifier".to_string())?+                    .to_string(),+                ty,+                documentation: Documentation::load(&field.attrs),+            })+        } else {+            None+        })+    }+}++impl Source for Field {+    fn write<F: Write>(&self, config: &Config, out: &mut SourceWriter<F>) {+        self.documentation.write(config, out);

Ah, nevermind, it's handled in Documentation::write.

petrochenkov

comment created time in 16 hours

Pull request review commenteqrion/cbindgen

Support an annotation for generating bitfield sizes in C code (`: SIZE`)

+use std::io::Write;++use crate::bindgen::cdecl;+use crate::bindgen::config::Config;+use crate::bindgen::ir::{Documentation, Path, Type};+use crate::bindgen::writer::{Source, SourceWriter};++#[derive(Debug, Clone)]+pub struct Field {+    pub name: String,+    pub ty: Type,+    pub documentation: Documentation,+}++impl Field {+    pub fn from_name_and_type(name: String, ty: Type) -> Field {+        Field {+            name,+            ty,+            documentation: Documentation::none(),+        }+    }++    pub fn load(field: &syn::Field, self_path: &Path) -> Result<Option<Field>, String> {+        Ok(if let Some(mut ty) = Type::load(&field.ty)? {+            ty.replace_self_with(self_path);+            Some(Field {+                name: field+                    .ident+                    .as_ref()+                    .ok_or_else(|| "field is missing identifier".to_string())?+                    .to_string(),+                ty,+                documentation: Documentation::load(&field.attrs),+            })+        } else {+            None+        })+    }+}++impl Source for Field {+    fn write<F: Write>(&self, config: &Config, out: &mut SourceWriter<F>) {+        self.documentation.write(config, out);

You need to handle config.documentation here don't you? At least you removed similar checks in a couple places.

petrochenkov

comment created time in 16 hours

Pull request review commenteqrion/cbindgen

Support an annotation for generating bitfield sizes in C code (`: SIZE`)

+[parse.expand]

Instead of making this a nightly-only test via parse.expand you could instead use the defines section with something like "feature = cbindgen" = "CBINDGEN" and #define CBINDGEN in the header to effectively ifdef stuff out, but your call.

petrochenkov

comment created time in 16 hours

PullRequestReviewEvent
PullRequestReviewEvent

push eventemilio/gii-4

Emilio Cobos Álvarez

commit sha bb7237872db95e9fd3e072cf5ccce4571d93a31a

Move shamelessly unfinished Slovenia stuff to a subdirectory.

view details

push time in a day

issue commentw3c/IntersectionObserver

Ability to have automatic rootMargin for all nested scroll containers

FWIW I think implementation-wise this should be pretty easy.

zcorpan

comment created time in a day

issue closedw3c/csswg-drafts

[cssom] Declaration block serialization treats shorthands strangely

The shorthand loop when serializing a declaration block has two odd parts to it:

  • it refers to the longhands array which consists of properties that have not yet been serialized, but that array is only defined before the start of the loop. As written, it's not clear if step 1 of the shorthand loop is supposed to account for properties serialized in previous iterations of the shorthand loop.
  • it's also not clear why it's worth continuing to execute subsequent iterations of the shorthand loop if a shorthand is successfully serialized. Given that shorthands are organized in preferred order, why would we end up serializing a less-preferred shorthand if a more-preferred one was already used?

closed time in 2 days

jdm

issue commentw3c/csswg-drafts

[cssom] Declaration block serialization treats shorthands strangely

This was fixed in https://github.com/w3c/csswg-drafts/pull/5655, second commit in particular.

jdm

comment created time in 2 days

issue commenteqrion/cbindgen

Support splitting a field into multiple fields in a user-defined way

Use case 1: bitfields

I don't think the two pieces of code you linked to are equivalent in MSVC / clang-cl. The equivalent thing would be:

struct S {
    uint64_t foo: 8;
    uint64_t bar: 56;
};

That being said that doesn't invalidate the use-case.

Use case 2: slices (#247)

Is their layout well-defined now? I know https://github.com/rust-lang/unsafe-code-guidelines/blob/master/reference/src/layout/pointers.md, but we've been hesitant on relying on that until a more "official" source was available.

If they're well-defined and reliable, I don't know why we should have annotations, we should just turn slices into a struct.

petrochenkov

comment created time in 3 days

Pull request review commenteqrion/cbindgen

Allow controlling the Cargo profile used for macro expansion

 pub enum Error {     Compile(String), } +/// Which Cargo profile (group) to use when expanding macros.+pub enum Profile {

Any reason to have this enum and the config.rs enum duplicated?

jrose-signal

comment created time in 3 days

PullRequestReviewEvent
PullRequestReviewEvent

issue commentWICG/construct-stylesheets

Should adopting from a Document into its associated inert template document (and vice versa) clear the adoptedStyleSheets?

So to be clear the proposal is to only allow adopts from a document's own template-owner document right? Not between arbitrary template/document pairs.

If so I think that should be ok... Otherwise you could use something like this to effectively move stuff across documents.

templateFromDocumentA.content.appendChild(hostFromDocumentA);
documentB.appendChild(hostFromDocumentA);

But yeah it seems ok, I think. A bit of an odd special case to be fair...

rakina

comment created time in 4 days

create barnchw3c/csswg-drafts

branch : issue/3030

created branch time in 4 days

PullRequestReviewEvent

issue commentw3c/csswg-drafts

[cssom] The way CSSStyleDeclaration exposes properties is not ideal.

(Though not a terrible fan of it it might be the path of least resistance...)

I assume that for stuff that doesn't apply you just always return the empty string?

emilio

comment created time in 5 days

issue commentw3c/csswg-drafts

[cssom] The way CSSStyleDeclaration exposes properties is not ideal.

I could probably live with that too, if people think it's fine to expose something like 'src' in document.body.style.

emilio

comment created time in 5 days

issue openedw3c/csswg-drafts

[cssom] The way CSSStyleDeclaration exposes properties is not ideal.

Right now we only have a single interface that exposes the CSS property names as attributes (CSSStyleDeclaration), but no browser does it right, and the spec behavior is also not great.

In particular, the spec behavior means that you expose stuff like fontFaceRule.style.color, which doesn't quite make sense.

WebKit and Blink (though WebKit may have changed recently) historically use named getters for this (which is also not great, see https://github.com/w3c/csswg-drafts/issues/1089).

Note also that:

  • Per recent discussion with @gsnedders WebKit trunk may have changed behavior?
  • Per spec there's no exposure of descriptors for the rules that have them (but Blink / WebKit expose them as part of the named getters).

Gecko does something which IMO is better. Gecko exposes them as attributes as the spec describes, but on an interface that derives from CSSStyleDeclaration called CSS2Properties which we use for all the "style" declarations (so, inline style declarations, CSSStyleRule.style, getComputedStyle, CSSPageRule.style, and individual keyframe declarations). (link, link). I think something like what Gecko does, but with similar interfaces for the declaration blocks that should have descriptors, like @font-face and @counter-style, would generally be much saner.

Since there's movement around here, and the interop story here is quite sad, I think there's quite a fair amount of room for improvement, and if we can align in a model that is both consistent and useful for developers it'd be great.

Does the thing I described above seem reasonable? Other ideas?

cc @gsnedders @foolip @andruud @xiaochengh @heycam

created time in 5 days

pull request commentweb-platform-tests/wpt

Add test for CSSOM's generation of IDL attributes from CSS properties

FWIW what Gecko implements is a bit different from this, but with a bit of a reason. Basically Gecko has CSSStyleDeclaration, and then CSS2Properties. It's CSS2Properties what has all the relevant IDL attributes.

The reason for this is to avoid exposing stuff like descriptors in style rule declaration blocks, or regular CSS properties in stuff like @font-face.

I think ideally the spec would have a CSSStyleDeclaration without the auto-generated names, and then we'd have stuff like CSS2Properties (terrible name, ideally something like CSSStyleDeclarationProperties or something, and then CSSFontFaceDeclaration, CSSCounterStyleDeclaration etc...). Ideally these should be named *DeclarationBlock rather than *Declaration, but I have no strong feeling about it.

gsnedders

comment created time in 5 days

issue commentw3c/csswg-drafts

[css-conditional-3] define whether/how it matters if namespace prefixes are declared

I'd prefer the "valid when declared" option. Still less special-casey.

dbaron

comment created time in 6 days

push eventw3c/IntersectionObserver

Marcos Cáceres

commit sha 11eed835487a44eae8532a44821bac8c2a17fd2d

chore: fix bikeshed issues

view details

push time in 7 days

PR merged w3c/IntersectionObserver

chore: fix bikeshed issues

Closes #462

<!-- This comment and the below content is programatically generated. You may add a comma-separated list of anchors you'd like a direct link to below (e.g. #idl-serializers, #idl-sequence):

Don't remove this comment or modify anything below this line.
If you don't want a preview generated for this pull request,
just replace the whole of this comment's content by "no preview"
and remove what's below.

-->


<a href="https://pr-preview.s3.amazonaws.com/w3c/IntersectionObserver/pull/463.html" title="Last updated on Oct 21, 2020, 4:41 AM UTC (a6a377a)">Preview</a> | <a href="https://pr-preview.s3.amazonaws.com/w3c/IntersectionObserver/463/5164ecc...a6a377a.html" title="Last updated on Oct 21, 2020, 4:41 AM UTC (a6a377a)">Diff</a>

+2 -2

0 comment

1 changed file

marcoscaceres

pr closed time in 7 days

issue closedw3c/IntersectionObserver

Automatic publication issues

Automatic publication is failing for the following small issues:

✗ Echidna failed to publish undefined for the following reasons:

The file has been retrieved. The metadata have been extracted. The document failed Specberus. 👎 Error code “latest-is-not-previous”. ⮡ cf https://www.w3.org/pubrules/doc/rules/?profile=WD#docIDFormat 👎 Text not allowed in element “ul” in this context. ⮡ cf https://www.w3.org/pubrules/doc/rules/?profile=WD#valideHTML 👎 Element “var” not allowed as child of element “ul” in this context. (Suppressing further errors from this subtree.) ⮡ cf https://www.w3.org/pubrules/doc/rules/?profile=WD#valideHTML 👎 Text not allowed in element “ul” in this context. ⮡ cf https://www.w3.org/pubrules/doc/rules/?profile=WD#valideHTML 👎 Element “a” not allowed as child of element “ul” in this context. (Suppressing further errors from this subtree.) ⮡ cf https://www.w3.org/pubrules/doc/rules/?profile=WD#valideHTML 👎 Text not allowed in element “ul” in this context. ⮡ cf https://www.w3.org/pubrules/doc/rules/?profile=WD#valideHTML

closed time in 7 days

marcoscaceres
PullRequestReviewEvent

delete branch emilio/web-platform-tests

delete branch : csswg/5627

delete time in 7 days

issue commentw3c/csswg-drafts

[css-contain] Computed value of shortcut values

FWIW Firefox Nightly doesn't give the results from the OP, it gives contain both for specified and computed value.

Loirooriol

comment created time in 7 days

issue commenteqrion/cbindgen

Allow specifying a profile for `cargo expand`

Hmm, that's a good point... Yeah, then probably a CLI option or such would be ok.

jrose-signal

comment created time in 7 days

push eventeqrion/cbindgen

Vadim Petrochenkov

commit sha 3a7e24d2d784d447ed6fd9f7168eeafe19d0a98f

test suite: Do not generate identical expectation files

view details

Vadim Petrochenkov

commit sha 050863a249f765f56b70683b0f76b2361e388405

test suite: Remove existing duplicate expectation files

view details

push time in 7 days

PR merged eqrion/cbindgen

test suite: Do not generate identical expectation files

For C code the test suite runs cbindgen multiple times with different settings of --cpp-compat and --style. These runs may generate identical code if the original Rust file doesn't have language constructions relevant to those options.

With this PR we no longer save duplicate cbindgen outputs into files and don't run C or C++ compiler on them. This saves some testing time (around 10% on my machine) and makes reviewing of new test cases easier, new tests are less likely to add a wall of text half of which is duplicated.

It will also help to add less test files in https://github.com/eqrion/cbindgen/pull/590 (--style makes sense for Cython too).

+43 -2714

2 comments

189 changed files

petrochenkov

pr closed time in 7 days

PullRequestReviewEvent

push eventeqrion/cbindgen

Vadim Petrochenkov

commit sha 9f00f6fdc579fa01783d4963480c9244a06231de

Remove artificial restriction on lifetime parameters on enums

view details

push time in 7 days

PR merged eqrion/cbindgen

Remove artificial restriction on lifetime parameters on enums

Fixes https://github.com/eqrion/cbindgen/issues/485

+126 -16

0 comment

9 changed files

petrochenkov

pr closed time in 7 days

issue closedeqrion/cbindgen

References in enum fields not supported?

The docs say references are supported and translated to pointer types, but it does not say under which conditions that is the case. I am trying to expose the following tagged union:

#[repr(C)]
pub enum BoolOp<'a> {
    Lit {value: bool},
    And {left: &'a BoolOp<'a>, right: &'a BoolOp<'a>},
}

This generates nothing in the exported header, not even an opaque type. The type only shows up in function parameters and return types.

I'd rather not replace the references with pointers and ruin the ergonomics on the Rust side of things. What should I do?

closed time in 7 days

drlagos
PullRequestReviewEvent
PullRequestReviewEvent

push eventmozsearch/mozsearch

Kartikaya Gupta

commit sha d3c7ae324acce8dad9630c9a9e92ce9c85805fe5

Bug 1672004 - Format mjs files as JS

view details

push time in 7 days

PullRequestReviewEvent

issue closedw3c/csswg-drafts

[cssom] [mediaqueries] Media query serialization doesn't work for newer spec features

I recently became confused because WebKit / Blink sorted the media features in media query lists, but @lilles did point out to me that https://drafts.csswg.org/cssom/#serialize-a-media-query does say that:

  1. Sort the media features in lexicographical order.

But this has gone very out of date with newer mediaqueries features (like nested expressions, etc), which for now only Gecko supports. This also gets more interesting when we support the multi-value expression syntax in https://github.com/w3c/csswg-drafts/issues/2791...

Gecko has never implemented the sorting step, so I'd propose to drop it: we don't know of any compat issue due to that, it was just that I was looking at interop around MediaQueryList as a result of a Gecko bug. Also, Gecko's behavior is more intuitive to me but maybe I'm biased :)

If we don't drop it, we need to define how the sorting works for stuff like nested expressions and such. Basically, we'd need to define sorting among two arbitrary <media-condition>s.

Thoughts?

closed time in 7 days

emilio

push eventweb-platform-tests/wpt

Emilio Cobos Álvarez

commit sha 3a2ec8e80160b0004a7a7e04e1b7efed12e1bbd3

[cssom] Add a test for media query serialization quirks. See https://github.com/w3c/csswg-drafts/issues/5627#issuecomment-712475204

view details

push time in 7 days

PR merged web-platform-tests/wpt

Reviewers
[cssom] Add a test for media query serialization quirks. cssom wg-css

See https://github.com/w3c/csswg-drafts/issues/5627#issuecomment-712475204

+16 -61

2 comments

2 changed files

emilio

pr closed time in 7 days

issue commentrust-lang/rust-bindgen

Bindgen doesn't generate "stdcall" calling convention on x86_64-pc-windows-msvc

We're using clang_getFunctionTypeCallingConv to get the right calling convention, the relevant functions return the C calling convention.

It does the right thing if you specify i686-pc-windows-msvc, so presumably something is wrong inside libclang.

AndrewGaspar

comment created time in 8 days

issue closedmozilla/wg-decisions

[cssom] [mediaqueries] Media query serialization doesn't work for newer spec features

A resolution was made for csswg-drafts/#5627.

[cssom] [mediaqueries] Media query serialization doesn't work for newer spec features

  • RESOLVED: Do not sort or dedup MQs when serializing

Discussion.


To file a bug automatically for these resolutions, add the bug label to the issue.

If no bug is needed, the issue can be closed.

closed time in 8 days

mozilla-apprentice

pull request commentweb-platform-tests/wpt

[cssom] Add a test for media query serialization quirks.

Hi,

Should we update these tests too? https://github.com/web-platform-tests/wpt/blob/master/css/cssom/medialist-interfaces-003.html#L44-L57

Indeed, done.

emilio

comment created time in 8 days

push eventemilio/web-platform-tests

Emilio Cobos Álvarez

commit sha 9c0deb50dc5579844ac6d30967473b1f2e0ccdb7

[cssom] Add a test for media query serialization quirks. See https://github.com/w3c/csswg-drafts/issues/5627#issuecomment-712475204

view details

push time in 8 days

PullRequestReviewEvent

delete branch mozsearch/mozsearch

delete branch : copy-to-clipboard-button

delete time in 8 days

push eventmozsearch/mozsearch

Emilio Cobos Álvarez

commit sha 5b956b669364d297b299e4656ed76dda1ad260db

Add a "copy to clipboard" button to (some) panel entries.

view details

push time in 8 days

PR merged mozsearch/mozsearch

Add a "copy to clipboard" button to (some) panel entries.

More explicit alternative to #368.

+107 -13

4 comments

8 changed files

emilio

pr closed time in 8 days

pull request commentmozsearch/mozsearch

Add a "copy to clipboard" button to (some) panel entries.

(Assuming that with that fixed there's no objection to this)

emilio

comment created time in 8 days

PullRequestReviewEvent

pull request commentmozsearch/mozsearch

Add a "copy to clipboard" button to (some) panel entries.

So it's up on dev.searchfox.org now (thanks @asuth!) and I noticed that if I click on the icon for the permalink, it just copies it to the clipboard. But if I click on the icon for e.g. the log or raw links, it also navigates to the link after copying. It's not clear to me why the behaviour is different for the permalink link vs the other ones.

Yup, noticed that too, that's because the permalink is handled in JS. Added a patch that should address that (and live-edited the server so if you shift-reload you should see that fixed).

emilio

comment created time in 8 days

delete branch w3c/csswg-drafts

delete branch : mq-serialize

delete time in 8 days

push eventmozsearch/mozsearch

Emilio Cobos Álvarez

commit sha fa001dfd88246da1032c072e66953acc8734375d

Add a "copy to clipboard" button to (some) panel entries.

view details

push time in 8 days

push eventmozsearch/mozsearch

Emilio Cobos Álvarez

commit sha 4bdbf5c434501a8c5db16eaf9a60c2a807bff542

Add a "copy to clipboard" button to (some) panel entries.

view details

push time in 8 days

push eventw3c/csswg-drafts

Emilio Cobos Álvarez

commit sha 588bc62234e510df0ac6c55b19df89b3c0f17747

[cssom-1] Drop sorting and deduplication from media query serialization. Per https://github.com/w3c/csswg-drafts/issues/5627#issuecomment-712475204

view details

push time in 8 days

PR merged w3c/csswg-drafts

[cssom-1] Drop sorting and deduplication from media query serialization.

Per https://github.com/w3c/csswg-drafts/issues/5627#issuecomment-712475204

+2 -6

0 comment

1 changed file

emilio

pr closed time in 8 days

push eventw3c/csswg-drafts

Emilio Cobos Álvarez

commit sha b304f6500cd464e70682f72bc54e4ef69f904758

[cssom-1] Drop sorting and deduplication from media query serialization. Per https://github.com/w3c/csswg-drafts/issues/5627#issuecomment-712475204

view details

push time in 8 days

create barnchemilio/web-platform-tests

branch : csswg/5627

created branch time in 8 days

push eventw3c/csswg-drafts

Emilio Cobos Álvarez

commit sha e6192b0d9c1cf16a84895b6553312201fa0f0915

[cssom-1] Drop sorting and deduplication from media query serialization. Per https://github.com/w3c/csswg-drafts/issues/5627#issuecomment-712475204

view details

push time in 8 days

PR opened w3c/csswg-drafts

[cssom-1] Drop sorting and deduplication from media query serialization.

Per https://github.com/w3c/csswg-drafts/issues/5627#issuecomment-712475204

+3 -5

0 comment

1 changed file

pr created time in 8 days

PR opened web-platform-tests/wpt

[cssom] Add a test for media query serialization quirks.

See https://github.com/w3c/csswg-drafts/issues/5627#issuecomment-712475204

+16 -0

0 comment

1 changed file

pr created time in 8 days

push eventemilio/web-platform-tests

Emilio Cobos Álvarez

commit sha 272a4544985ed9a156c742a4bef3fdfcacbf50d0

[cssom] Add a test for media query serialization quirks. See https://github.com/w3c/csswg-drafts/issues/5627#issuecomment-712475204

view details

push time in 8 days

create barnchw3c/csswg-drafts

branch : mq-serialize

created branch time in 8 days

delete branch w3c/csswg-drafts

delete branch : serialize-keyframes

delete time in 8 days

push eventw3c/csswg-drafts

Emilio Cobos Álvarez

commit sha 6b2c5465cdf6771e0c94ff3c0a47edca37b8f22a

[cssom] Define the serialization of CSSKeyframesRule and CSSKeyframesRule Part of https://github.com/w3c/csswg-drafts/issues/4828.

view details

push time in 8 days

more