Repository: servo/servo
File: components/script_bindings/codegen/codegen.py (Python)

Code before:
            # are both exposed. In this case the code generation for the binding maps to the same
            # attribute name, so we can skip the second one in the trait.
            used_names = set()

            for m in descriptor.interface.members:
                if (m.isMethod()
                        and not m.isMaplikeOrSetlikeOrIterableMethod()
                        and (not m.isIdentifierLess() or (m.isStringifier() and not m.underlyingAttr))
                        and not m.isDefaultToJSON()):
                    name = CGSpecializedMethod.makeNativeName(descriptor, m)
                    infallible = 'infallible' in descriptor.getExtendedAttributes(m)
                    for idx, (rettype, arguments) in enumerate(m.signatures()):
                        rettype = cast(IDLType, rettype)
                        arguments = cast(list[IDLArgument], arguments)
                        arguments = method_arguments(descriptor, rettype, arguments,
                                                     cx_no_gc=name in descriptor.cx_no_gcMethods,
                                                     cx=name in descriptor.cxMethods,
                                                     realm=name in descriptor.realmMethods,
                                                     inRealm=name in descriptor.inRealmMethods,
                                                     canGc=name in descriptor.canGcMethods)
                        rettype = return_type(descriptor, rettype, infallible)
                        yield f"{name}{'_' * idx}", arguments, rettype, m.isStatic()
                elif m.isAttr():
                    name = CGSpecializedGetter.makeNativeName(descriptor, m)

                    # If this attribute is a repetition due to capitalization differnces in the JavaScript
                    # name, just skip the subsequent ones.
                    if name in used_names:
                        continue
                    used_names.add(name)

                    infallible = 'infallible' in descriptor.getExtendedAttributes(m, getter=True)
                    yield (name,
                           attribute_arguments(
                               m.type,
                               cx_no_gc=name in descriptor.cx_no_gcMethods,
                               cx=name in descriptor.cxMethods,
                               realm=name in descriptor.realmMethods,
                               inRealm=name in descriptor.inRealmMethods,
                               canGc=name in descriptor.canGcMethods,
                               retval=True
                           ),
                           return_type(descriptor, m.type, infallible),
                           m.isStatic())

                    if not m.readonly:
                        name = CGSpecializedSetter.makeNativeName(descriptor, m)
                        infallible = 'infallible' in descriptor.getExtendedAttributes(m, setter=True)
                        if infallible:
                            rettype = "()"
                        else:

Review comment (suggestion):
```suggestion
                    # If this attribute is a repetition due to capitalization differences in the JavaScript
```

Code after:
            # are both exposed. In this case the code generation for the binding maps to the same
            # attribute name, so we can skip the second one in the trait.
            used_names = set()

            for m in descriptor.interface.members:
                if (m.isMethod()
                        and not m.isMaplikeOrSetlikeOrIterableMethod()
                        and (not m.isIdentifierLess() or (m.isStringifier() and not m.underlyingAttr))
                        and not m.isDefaultToJSON()):
                    name = CGSpecializedMethod.makeNativeName(descriptor, m)
                    infallible = 'infallible' in descriptor.getExtendedAttributes(m)
                    for idx, (rettype, arguments) in enumerate(m.signatures()):
                        rettype = cast(IDLType, rettype)
                        arguments = cast(list[IDLArgument], arguments)
                        arguments = method_arguments(descriptor, rettype, arguments,
                                                     cx_no_gc=name in descriptor.cx_no_gcMethods,
                                                     cx=name in descriptor.cxMethods,
                                                     realm=name in descriptor.realmMethods,
                                                     inRealm=name in descriptor.inRealmMethods,
                                                     canGc=name in descriptor.canGcMethods)
                        rettype = return_type(descriptor, rettype, infallible)
                        yield f"{name}{'_' * idx}", arguments, rettype, m.isStatic()
                elif m.isAttr():
                    name = CGSpecializedGetter.makeNativeName(descriptor, m)

                    # If this attribute is a repetition due to capitalization differences in the JavaScript
                    # name, just skip the subsequent ones.
                    if name in used_names:
                        continue
                    used_names.add(name)

                    infallible = 'infallible' in descriptor.getExtendedAttributes(m, getter=True)
                    yield (name,
                           attribute_arguments(
                               m.type,
                               cx_no_gc=name in descriptor.cx_no_gcMethods,
                               cx=name in descriptor.cxMethods,
                               realm=name in descriptor.realmMethods,
                               inRealm=name in descriptor.inRealmMethods,
                               canGc=name in descriptor.canGcMethods,
                               retval=True
                           ),
                           return_type(descriptor, m.type, infallible),
                           m.isStatic())

                    if not m.readonly:
                        name = CGSpecializedSetter.makeNativeName(descriptor, m)
                        infallible = 'infallible' in descriptor.getExtendedAttributes(m, setter=True)
                        if infallible:
                            rettype = "()"
                        else: