feat(dart/transform): Generate ChangeDetector classes

Use the `ProtoViewDto` created by the render `Compiler` to create a
`ChangeDetectorDefinition`.

From there, generate a subclass of `AbstractChangeDetector` for each
`ChangeDetectorDefinition`.

Run some basic unit tests for the dynamic and JIT change detectors on
pre-generated change detectors.
This commit is contained in:
Tim Blasi
2015-05-14 13:14:45 -07:00
parent 383f0a1f30
commit 8a3b0b366f
15 changed files with 1105 additions and 217 deletions
@@ -1,5 +1,8 @@
library bar.ng_deps.dart;
import 'package:angular2/src/change_detection/pregen_proto_change_detector.dart'
as _gen;
import 'bar.dart';
import 'package:angular2/src/core/annotations_impl/annotations.dart';
import 'package:angular2/src/core/annotations_impl/view.dart';
@@ -18,3 +21,48 @@ void initReflector(reflector) {
]
});
}
class _MyComponent_ChangeDetector0 extends _gen.AbstractChangeDetector {
final dynamic _dispatcher;
final _gen.PipeRegistry _pipeRegistry;
final _gen.List<_gen.ProtoRecord> _protos;
final _gen.List<_gen.DirectiveRecord> _directiveRecords;
dynamic _locals = null;
dynamic _context = _gen.ChangeDetectionUtil.uninitialized();
_MyComponent_ChangeDetector0(this._dispatcher, this._pipeRegistry,
this._protos, this._directiveRecords)
: super();
void detectChangesInRecords(throwOnChange) {
var context = null;
var change_context = false;
var isChanged = false;
var currentProto;
var changes = null;
context = _context;
}
void callOnAllChangesDone() {}
void hydrate(context, locals, directives) {
mode = 'ALWAYS_CHECK';
_context = context;
_locals = locals;
}
void dehydrate() {
_context = _gen.ChangeDetectionUtil.uninitialized();
_locals = null;
}
hydrated() =>
!_gen.looseIdentical(_context, _gen.ChangeDetectionUtil.uninitialized());
static _gen.ProtoChangeDetector newProtoChangeDetector(
_gen.PipeRegistry registry, _gen.ChangeDetectorDefinition def) {
return new _gen.PregenProtoChangeDetector(
(a, b, c, d) => new _MyComponent_ChangeDetector0(a, b, c, d), registry,
def);
}
}