Mercurial > pub > ImplabJs
annotate src/implab/declare/override.js @ 33:8af8e840dd49
added return fn
author | nickolay |
---|---|
date | Wed, 05 Jun 2019 17:44:17 +0300 |
parents | 9663631cbdb9 |
children |
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 () {}; | |
13 | |
5
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
14 return method.apply(me, [function () { |
0 | 15 return inherited.apply(me, arguments); |
16 }].concat(slice.apply(arguments))); | |
17 }; | |
18 | |
19 proxy.method = method; | |
20 proxy.overrides = true; | |
21 | |
22 return proxy; | |
23 }; | |
5
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
24 |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
25 override.before = function (method) { |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
26 var proxy; |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
27 |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
28 /** @this target object */ |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
29 proxy = function () { |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
30 var me = this; |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
31 var inherited = (this.getInherited && this.getInherited(proxy.nom, { |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
32 callee: proxy |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
33 })) || function () {}; |
6 | 34 |
35 | |
5
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
36 method.apply(me, arguments); |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
37 return inherited.apply(me, arguments); |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
38 }; |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
39 |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
40 proxy.method = method; |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
41 proxy.overrides = true; |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
42 |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
43 return proxy; |
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 |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
46 override.after = function (method) { |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
47 var proxy; |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
48 |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
49 /** @this target object */ |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
50 proxy = function () { |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
51 var me = this; |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
52 var inherited = (this.getInherited && this.getInherited(proxy.nom, { |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
53 callee: proxy |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
54 })) || function () {}; |
6 | 55 |
5
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
56 inherited.apply(me, arguments); |
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 return method.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 |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
61 proxy.method = method; |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
62 proxy.overrides = true; |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
63 |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
64 return proxy; |
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 |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
67 override.hide = function (method) { |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
68 method.overrides = false; |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
69 return method; |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
70 }; |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
71 |
3d124d0b9078
improved declare/override, added override.before, override.after, override.hide,
cin
parents:
0
diff
changeset
|
72 return override; |
0 | 73 }); |