Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove helper traits #7401

Merged
merged 5 commits into from Aug 27, 2015
Merged

Remove helper traits #7401

merged 5 commits into from Aug 27, 2015

Commits on Aug 27, 2015

  1. Remove helper traits

    Now that JSRef<T> is gone, there is no need to have helper traits.
    
    On components/script/*.rs:
    
        # Remove imports.
        /^ *use dom::[a-z]+::\{.*Helpers/ {
            s/\{(Raw[^L]|[^L][^a])[a-zA-Z]+Helpers, /\{/
            s/, (Raw[^L]|[^L][^a])[a-zA-Z]+Helpers([,}])/\2/g
            s/\{([a-zA-Z]+)\}/\1/
            /\{\}/d
            s/::self;$/;/
        }
        /^ *use dom::[a-z]+::\{?(Raw[^L]|[^L][^a])[a-zA-Z]+Helpers\}?;$/d
    
    On components/script/dom/*.rs:
    
        # Ignore layout things.
        /^(pub )?(impl|trait).*Layout.* \{/,/^}$/ { P; D; }
    
        # Delete helpers traits.
        /^(pub )?trait ([^L][^ ]|L[^a])[^ ]+Helpers(<'a>)? \{$/,/^\}$/D
    
        # Patch private helpers.
        /^impl.*Private.*Helpers/,/^\}$/ {
            s/^impl<'a> Private([^L][^ ]|L[^a])[^ ]+Helpers(<'a>)? for &'a ([^ ]+) \{$/impl \3 {/
            /^ *(unsafe )?fn .*\(self.*[<&]'a/ {
                s/&'a /\&/g
                s/<'a, /</g
            }
            /^ *(unsafe )?fn /s/\(self([,)])/\(\&self\1/
        }
    
        # Patch public helpers.
        /^impl.*Helpers/,/^\}$/ {
            s/^impl(<'a>)? ([^L][^ ]|L[^a])[^ ]+Helpers(<'a>)? for (&'a )?([^ ]+) \{$/impl \5 {/
            /^ *(unsafe )?fn .*\(self.*[<&]'a/ {
                s/&'a /\&/g
                s/<'a, /</g
            }
            /^ *(unsafe )?fn .*\(&?self[,)]/s/(unsafe )?fn/pub &/
            /^ *pub (unsafe )?fn /s/\(self([,)])/\(\&self\1/
        }
    
    The few error cases were then fixed by hand.
    nox committed Aug 27, 2015
  2. Remove SinkHelpers

    Method get_or_create() is now directly on servohtmlparser::Sink.
    nox committed Aug 27, 2015
  3. Remove AttributeHandlers

    On components/script/*.rs:
    
        # Remove imports.
        /^ *use dom::element::\{.*AttributeHandlers/ {
            s/\{AttributeHandlers, /\{/
            s/, AttributeHandlers//g
            s/\{([a-zA-Z]+)\}/\1/
            /\{\}/d
            s/::self;$/;/
        }
        /^ *use dom::element::\{?AttributeHandlers\}?;$/d
    
        # Remove AttributeHandlers.
        /^pub trait AttributeHandlers \{$/,/^\}$/D
    
        # Patch AttributeHandlers methods.
        /^impl<'a> AttributeHandlers for &'a Element \{/,/^\}$/ {
            s/^impl<'a> AttributeHandlers for &'a Element \{/impl Element {/
            /^ *fn /s/\(self([,)])/\(\&self\1/
    	/^ *fn.*\(&self/s/fn/pub fn/
        }
    
    The few error cases were then fixed by hand.
    nox committed Aug 27, 2015
You can’t perform that action at this time.