Skip to content

Commit

Permalink
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions stdlib/native.rb
Original file line number Diff line number Diff line change
@@ -64,6 +64,32 @@ def self.call(obj, key, *args, &block)
}
end

def self.proc(&block)
raise LocalJumpError, "no block given" unless block

Kernel.proc {|*args|
args.map! { |arg| Native(arg) }
instance = Native(`this`)

%x{
// if global is current scope, run the block in the scope it was defined
if (this === Opal.global) {
return block.apply(self, #{args});
}
var self_ = block.$$s;
block.$$s = null;
try {
return block.apply(#{instance}, #{args});
}
finally {
block.$$s = self_;
}
}
}
end

module Helpers
def alias_native(new, old = new, options = {})
if old.end_with? ?=

0 comments on commit a592c83

Please sign in to comment.