Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: opal/opal
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 961416a7dd2e
Choose a base ref
...
head repository: opal/opal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 63bfdd23baa9
Choose a head ref
  • 6 commits
  • 2 files changed
  • 1 contributor

Commits on Oct 23, 2013

  1. Cleanup String#rjust

    meh committed Oct 23, 2013
    Copy the full SHA
    abff25f View commit details
  2. Cleanup String#rstrip

    meh committed Oct 23, 2013
    Copy the full SHA
    9526e8d View commit details
  3. Cleanup Module#alias_method

    meh committed Oct 23, 2013
    Copy the full SHA
    c2f2f86 View commit details
  4. Cleanup Module#alias_native

    meh committed Oct 23, 2013
    Copy the full SHA
    f181bb1 View commit details
  5. Cleanup Module#ancestors

    meh committed Oct 23, 2013
    Copy the full SHA
    7ea107e View commit details
  6. Cleanup Module#append_features

    meh committed Oct 23, 2013
    Copy the full SHA
    63bfdd2 View commit details
Showing with 19 additions and 20 deletions.
  1. +10 −9 corelib/module.rb
  2. +9 −11 corelib/string.rb
19 changes: 10 additions & 9 deletions corelib/module.rb
Original file line number Diff line number Diff line change
@@ -59,7 +59,7 @@ def <(other)

def alias_method(newname, oldname)
%x{
#{self}._proto['$' + newname] = #{self}._proto['$' + oldname];
self._proto['$' + newname] = self._proto['$' + oldname];
if (self._methods) {
$opal.donate(self, ['$' + newname ])
@@ -69,12 +69,12 @@ def alias_method(newname, oldname)
end

def alias_native(mid, jsid = mid)
`#{self}._proto['$' + mid] = #{self}._proto[jsid]`
`self._proto['$' + mid] = self._proto[jsid]`
end

def ancestors
%x{
var parent = #{self},
var parent = self,
result = [];
while (parent) {
@@ -90,24 +90,25 @@ def ancestors

def append_features(klass)
%x{
var module = #{self}, included = klass.__inc__;
var module = self,
included = klass.__inc__;
// check if this module is already included in the klass
for (var idx = 0, length = included.length; idx < length; idx++) {
if (included[idx] === module) {
for (var i = 0, length = included.length; i < length; i++) {
if (included[i] === module) {
return;
}
}
included.push(module);
module.__dep__.push(klass);
// iclass
var iclass = {
_proto: module._proto,
__parent: klass.__parent,
name: module._name,
_proto: module._proto,
__parent: klass.__parent,
__iclass: true
};
20 changes: 9 additions & 11 deletions corelib/string.rb
Original file line number Diff line number Diff line change
@@ -545,22 +545,20 @@ def rindex(search, offset = undefined)
end

def rjust(width, padstr = ' ')
return self if `width <= self.length`

%x{
if (width <= #{self}.length) {
return #{self};
}
else {
var n_chars = Math.floor(width - #{self}.length)
var n_patterns = Math.floor(n_chars/padstr.length);
var result = Array(n_patterns + 1).join(padstr);
var remaining = n_chars - result.length;
return result + padstr.slice(0, remaining) + #{self};
}
var chars = Math.floor(width - self.length),
patterns = Math.floor(chars / padstr.length),
result = Array(patterns + 1).join(padstr),
remaining = chars - result.length;
return result + padstr.slice(0, remaining) + self;
}
end

def rstrip
`#{self}.replace(/\\s*$/, '')`
`self.replace(/\\s*$/, '')`
end

def scan(pattern, &block)