forked from dart-archive/angular.dart
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
177 additions
and
194 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,27 @@ | ||
part of angular.watch_group; | ||
|
||
class PrototypeMap<K, V> implements Map<K,V> { | ||
final Map<K, V> prototype; | ||
final Map<K, V> self = new Map(); | ||
// todo(vicb) rename to ContextLocals + rename the file | ||
class LocalContext { | ||
// todo(vicb) _parentContext | ||
final Object parent; | ||
final Map _locals = <String, Object>{}; | ||
|
||
PrototypeMap(this.prototype); | ||
|
||
void operator []=(name, value) { | ||
self[name] = value; | ||
LocalContext(this.parent, [Map<String, Object> locals = null]) { | ||
if (locals != null) _locals.addAll(locals); | ||
_locals[r'$parent'] = parent; | ||
} | ||
V operator [](name) => self.containsKey(name) ? self[name] : prototype[name]; | ||
|
||
bool get isEmpty => self.isEmpty && prototype.isEmpty; | ||
bool get isNotEmpty => self.isNotEmpty || prototype.isNotEmpty; | ||
// todo(vbe) include prototype keys ? | ||
Iterable<K> get keys => self.keys; | ||
// todo(vbe) include prototype values ? | ||
Iterable<V> get values => self.values; | ||
int get length => self.length; | ||
static LocalContext wrapper(context, Map<String, Object> locals) => | ||
new LocalContext(context, locals); | ||
|
||
bool hasProperty(String prop) => _locals.containsKey(prop); | ||
|
||
void forEach(fn) { | ||
// todo(vbe) include prototype ? | ||
self.forEach(fn); | ||
void operator[]=(String prop, value) { | ||
_locals[prop] = value; | ||
} | ||
V remove(key) => self.remove(key); | ||
clear() => self.clear; | ||
// todo(vbe) include prototype ? | ||
bool containsKey(key) => self.containsKey(key); | ||
// todo(vbe) include prototype ? | ||
bool containsValue(key) => self.containsValue(key); | ||
void addAll(map) { | ||
self.addAll(map); | ||
|
||
dynamic operator[](String prop) { | ||
assert(hasProperty(prop)); | ||
return _locals[prop]; | ||
} | ||
// todo(vbe) include prototype ? | ||
V putIfAbsent(key, fn) => self.putIfAbsent(key, fn); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.