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: 08c9b0ec4dca
Choose a base ref
...
head repository: opal/opal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: f7227ee833d8
Choose a head ref
  • 12 commits
  • 7 files changed
  • 2 contributors

Commits on May 19, 2015

  1. Support recv.JS.js_method syntax for calling javascript methods

    This adds a way to call native javascript methods from ruby using
    valid ruby syntax, so it will work with existing tooling.
    
    This will only break working ruby code that defines a method named
    JS that will accept no arguments, and uses that method in a method
    chain.
    
    This makes it much easier to use javascript objects inside ruby
    code without wrapping them using Native(), and provides a work
    around for edge cases where Native(obj) returns obj, such as
    when using strings.  This syntax will handle many cases where
    you currently need to drop down to raw javascript using backticks.
    jeremyevans committed May 19, 2015
    Copy the full SHA
    50a0965 View commit details
  2. Fix spec description

    jeremyevans committed May 19, 2015
    Copy the full SHA
    6aa0169 View commit details

Commits on May 20, 2015

  1. Make the recv.JS.js_method syntax optional and off by default

    This adds js_prefix attributes to the lexer and parser, and
    uses a :js_prefix compiler option.  It is supported in
    bin/opal using the --js_prefix flag.
    
    The lexer currently supports custom prefixes, in case people
    are already using a method named JS.  This isn't currently
    supported by bin/opal, but can be enabled manually by using
    a string as the :js_prefix compiler option value.
    jeremyevans committed May 20, 2015
    Copy the full SHA
    ec105e5 View commit details
  2. Copy the full SHA
    75c07cb View commit details
  3. Support accessing javascript properties via foo.JS.prop

    To call javascript functions with no arguments , you now need to
    use parentheses (e.g. foo.JS.func()).
    jeremyevans committed May 20, 2015
    Copy the full SHA
    213039c View commit details
  4. Copy the full SHA
    b072744 View commit details

Commits on May 21, 2015

  1. Copy the full SHA
    5ccaf74 View commit details
  2. Support direct javascript setters via .JS.prop = and .JS[arg] =

    This causes 8 reduce/reduce conflicts in the grammar, but I haven't
    yet figured out how to eliminate that.
    jeremyevans committed May 21, 2015
    Copy the full SHA
    607b78f View commit details
  3. Copy the full SHA
    32bd3d3 View commit details

Commits on May 28, 2015

  1. Support calling javascript methods as commands

    This changes the grammar to support calling javascript methods
    without parentheses:
    
      a.JS.b 1, 2
    
    and with blocks:
    
      a.JS.b { |v| ...}
      a.JS.b(1) { |v| ...}
      a.JS.b do |v| ... end
      a.JS.b(1) do |v| ... end
      a.JS.b 1 do |v| ... end
    
    This changes the previous behavior for method calls without
    parentheses.  Previously, they returned the javascript property
    instead of doing a method call.  Now using .JS. always does a
    method call.  If you want to return a property, use a.JS[:b]
    Similarly, you can no longer set properties via a.JS.b = 1,
    you now need to use a.JS[:b] = 1.
    
    This eliminates the reduce/reduce conflicts that the addition
    of property setters added.  One thing this doesn't support is
    syntax like:
    
      foo.JS[:b] += 1
    
    I had to specifically add support to the grammar to handle that
    syntax in order to eliminate the reduce/reduce conflicts, but
    now it just raises an error.  I think raising an error is the
    correct behavior in this case.  This would desugar to:
    
      foo.JS[:b] = foo.JS[:b].+(1)
    
    which would only make sense if foo was a javascript object with
    a property b that was a ruby object.  That seems fairly unlikely
    in practice, but support could probably be added to handle that
    case.  I think adding such support could confuse people, since
    they may expect it to operate the same as:
    
      `foo["b"] += 1`
    
    To support calling javascript methods with blocks, I had to copy
    the implementation of CallNode#default_compile to JsCallNode,
    and then modify it.  It may be possible to refactor
    CallNode#default_compile to split it up into more methods, and
    reduce the duplication, but I'm not sure it is worth it.
    jeremyevans committed May 28, 2015
    Copy the full SHA
    6d75196 View commit details

Commits on May 29, 2015

  1. Remove code related to removed recv.JS.prop = syntax

    Since the javascript property setter syntax was limited to
    recv.JS['prop'] = , this code can be removed.
    jeremyevans committed May 29, 2015
    Copy the full SHA
    4290c95 View commit details

Commits on Jun 3, 2015

  1. Merge pull request #879 from jeremyevans/jscall2

    Support recv.JS.js_method syntax for calling javascript methods
    elia committed Jun 3, 2015
    Copy the full SHA
    f7227ee View commit details
Loading