Mercurial > pub > ImplabJs
annotate src/implab/declare/override.js @ 5:3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
inherited.arguments.
author | cin |
---|---|
date | Fri, 16 Jun 2017 02:14:25 +0300 |
parents | fc2517695ee1 |
children | 9663631cbdb9 |
rev | line source |
---|---|
0 | 1 "use strict"; |
2 define([], function () { | |
3 var slice = Array.prototype.slice; | |
5
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
4 var override = function (method) { |
0 | 5 var proxy; |
6 | |
7 /** @this target object */ | |
8 proxy = function () { | |
9 var me = this; | |
10 var inherited = (this.getInherited && this.getInherited(proxy.nom, { | |
11 callee: proxy | |
12 })) || function () {}; | |
5
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
13 |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
14 inherited.arguments = arguments; |
0 | 15 |
5
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
16 return method.apply(me, [function () { |
0 | 17 return inherited.apply(me, arguments); |
18 }].concat(slice.apply(arguments))); | |
19 }; | |
20 | |
21 proxy.method = method; | |
22 proxy.overrides = true; | |
23 | |
24 return proxy; | |
25 }; | |
5
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
26 |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
27 override.before = function (method) { |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
28 var proxy; |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
29 |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
30 /** @this target object */ |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
31 proxy = function () { |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
32 var me = this; |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
33 var inherited = (this.getInherited && this.getInherited(proxy.nom, { |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
34 callee: proxy |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
35 })) || function () {}; |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
36 |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
37 |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
38 method.apply(me, arguments); |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
39 return inherited.apply(me, arguments); |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
40 }; |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
41 |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
42 proxy.method = method; |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
43 proxy.overrides = true; |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
44 |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
45 return proxy; |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
46 }; |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
47 |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
48 override.after = function (method) { |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
49 var proxy; |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
50 |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
51 /** @this target object */ |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
52 proxy = function () { |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
53 var me = this; |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
54 var inherited = (this.getInherited && this.getInherited(proxy.nom, { |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
55 callee: proxy |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
56 })) || function () {}; |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
57 |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
58 inherited.apply(me, arguments); |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
59 |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
60 return method.apply(me, arguments); |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
61 }; |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
62 |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
63 proxy.method = method; |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
64 proxy.overrides = true; |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
65 |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
66 return proxy; |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
67 }; |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
68 |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
69 override.hide = function (method) { |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
70 method.overrides = false; |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
71 return method; |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
72 }; |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
73 |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
74 return override; |
0 | 75 }); |