| 1 |
dojo.provide("dojox.lang.oo.aop"); |
| 2 |
|
| 3 |
dojo.require("dojox.lang.oo.Decorator"); |
| 4 |
dojo.require("dojox.lang.oo.general"); |
| 5 |
|
| 6 |
(function(){ |
| 7 |
var oo = dojox.lang.oo, md = oo.makeDecorator, oog = oo.general, ooa = oo.aop, |
| 8 |
isF = dojo.isFunction; |
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
ooa.before = oog.before; |
| 14 |
ooa.around = oog.wrap; |
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
ooa.afterReturning = md(function(name, newValue, oldValue){ |
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
return isF(oldValue) ? |
| 41 |
function(){ |
| 42 |
var ret = oldValue.apply(this, arguments); |
| 43 |
newValue.call(this, ret); |
| 44 |
return ret; |
| 45 |
} : function(){ newValue.call(this); }; |
| 46 |
}); |
| 47 |
|
| 48 |
ooa.afterThrowing = md(function(name, newValue, oldValue){ |
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
return isF(oldValue) ? |
| 53 |
function(){ |
| 54 |
var ret; |
| 55 |
try{ |
| 56 |
ret = oldValue.apply(this, arguments); |
| 57 |
}catch(e){ |
| 58 |
newValue.call(this, e); |
| 59 |
throw e; |
| 60 |
} |
| 61 |
return ret; |
| 62 |
} : oldValue; |
| 63 |
}); |
| 64 |
|
| 65 |
ooa.after = md(function(name, newValue, oldValue){ |
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
return isF(oldValue) ? |
| 70 |
function(){ |
| 71 |
var ret; |
| 72 |
try{ |
| 73 |
ret = oldValue.apply(this, arguments); |
| 74 |
}finally{ |
| 75 |
newValue.call(this); |
| 76 |
} |
| 77 |
return ret; |
| 78 |
} : function(){ newValue.call(this); } |
| 79 |
}); |
| 80 |
})(); |