Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

implement dart:js for ddc #168

Closed
vsmenon opened this issue May 7, 2015 · 10 comments
Closed

implement dart:js for ddc #168

vsmenon opened this issue May 7, 2015 · 10 comments

Comments

@vsmenon
Copy link
Contributor

vsmenon commented May 7, 2015

Angular uses this statically, although the hello world sample does not hit it.

@jacob314

@jmesserly jmesserly self-assigned this Jun 12, 2015
@jmesserly
Copy link
Contributor

https://codereview.chromium.org/1179643005/ adds code to the build, we need to go through it and make sure it actually works though :)

jmesserly pushed a commit that referenced this issue Jun 12, 2015
the code most likely does not work yet. But this gets it in so we can iterate more easily, from a clean baseline.

[email protected]

Review URL: https://codereview.chromium.org/1179643005.
@jmesserly
Copy link
Contributor

it looks like we have almost no dart:js tests in the Dart SDK(!) ... going to write some tests, and also review the code we pulled in ...

@jacob314
Copy link
Contributor

There are about 1000 lines of tests for dart:js in the sdk:
tests/html/js_test.dart

On Mon, Jun 15, 2015 at 11:24 AM, John Messerly [email protected]
wrote:

it looks like we have almost no dart:js tests in the Dart SDK(!) ... going
to write some tests, and also review the code we pulled in ...


Reply to this email directly or view it on GitHub
#168 (comment)
.

@jmesserly
Copy link
Contributor

oh, nice! I kind of assumed that was mostly the dart:html integration side, but yeah, it looks like some bits in that can be stolen, like the JsArray tests.

@jacob314
Copy link
Contributor

Yeah those tests barely have to do with dart:html integration. They are in
that directory mainly because we never bothered to create a separate
directory.

On Mon, Jun 15, 2015 at 1:07 PM, John Messerly [email protected]
wrote:

oh, nice! I kind of assumed that was mostly the dart:html integration
side, but yeah, it looks like some bits in that can be stolen, like the
JsArray tests. Nice!


Reply to this email directly or view it on GitHub
#168 (comment)
.

@jmesserly jmesserly added the task label Jun 16, 2015
@jmesserly
Copy link
Contributor

update: I'm getting closer to having the code+tests working. amusingly, hitting problems just getting package:test to work (e.g. #226 and #227) ... once that's clear I'll see how the tests are doing.

The strange thing: for now, we'll continue to proxy generic Dart and JS objects when crossing the boundary, including Arrays, even though that's totally useless to do in DDC (especially for Array). That should give API compatibility with existing apps, though. Otherwise, you'd never be able to get a JsObject/JsArray instances.

An alternative design would be to make all JS objects and Arrays "pretend" to have JsObject implemented. We could support calling those members on all objects. Looking over the interface:

class JsObject {
  callMethod(method, [List args]);
  void deleteProperty(property);
  bool hasProperty(property);
  bool instanceof(JsFunction type);
  void operator[](property);
  void operator[]=(property, value);
}

It wouldn't be too bad to just have those methods on there. Naturally, you'd get a static error trying to call them, unless the target type is dynamic or JsObject. @jacob314 is that along the lines of what you were thinking for the existing dart:js package?

@jacob314
Copy link
Contributor

That is what I was thinking. Having those extension methods on all JS
objects is a little annoying but i think is something we could live with if
need be and would give a better compatibility story with existing code.

On Wed, Jun 17, 2015 at 9:43 AM, John Messerly [email protected]
wrote:

update: I'm getting closer to having the code+tests working. amusingly,
hitting problems just getting package:test to work (e.g. #226
#226 and #227
#227) ... once that's
clear I'll see how the tests are doing.

The strange thing: for now, we'll continue to proxy generic Dart and JS
objects when crossing the boundary, including Arrays, even though that's
totally useless to do in DDC (especially for Array). That should give API
compatibility with existing apps, though. Otherwise, you'd never be able to
get a JsObject/JsArray instances.

An alternative design would be to make all JS objects and Arrays "pretend"
to have JsObject implemented. We could support calling those members on all
objects. Looking over the interface:

class JsObject {
callMethod(method, [List args]);
void deleteProperty(property);
bool hasProperty(property);
bool instanceof(JsFunction type);
void operator;
void operator[]=(property, value);
}

It wouldn't be too bad to just have those methods on there. Naturally,
you'd get a static error trying to call them, unless the target type is
dynamic or JsObject. @jacob314 https://github.com/jacob314 is that
along the lines of what you were thinking for the existing dart:js package?


Reply to this email directly or view it on GitHub
#168 (comment)
.

@jmesserly
Copy link
Contributor

also just fixed #231 ... still fixing out unrelated issues to see if I can get my tests passing.
Leaning towards a two-step approach here:

  • implement dart:js that is fully compatible with existing one
  • implement dart:js that passes arrays/JS objects transparently, but still supports the JsObject interface on them via dynamic invoke

Ideally we can do the second step at the same time that dart2js and dartium do, so we aren't losing compatibility those implementations.

@jmesserly
Copy link
Contributor

this is proving harder than I thought ... had to make my own lightweight test functions since we can't run package:test yet. I'm down to a handful of test failures though.

@jmesserly
Copy link
Contributor

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

3 participants