Rev | Line | |
---|
[483] | 1 | dojo.provide("dojox.lang.aspect.cflow"); |
---|
| 2 | |
---|
| 3 | |
---|
| 4 | (function(){ |
---|
| 5 | var aop = dojox.lang.aspect; |
---|
| 6 | |
---|
| 7 | aop.cflow = function(/*Object*/ instance, /*String|RegExp|Array?*/ method){ |
---|
| 8 | // summary: |
---|
| 9 | // Returns true if the context stack contains a context for a given |
---|
| 10 | // instance that satisfies a given method name criteria. |
---|
| 11 | // |
---|
| 12 | // instance: |
---|
| 13 | // An instance to be matched. If null, any context will be examined. |
---|
| 14 | // Otherwise the context should belong to this instance. |
---|
| 15 | // |
---|
| 16 | // method: |
---|
| 17 | // An optional pattern to be matched against a method name. Can be a string, |
---|
| 18 | // a RegExp object or an array of strings and RegExp objects. |
---|
| 19 | // If it is omitted, any name will satisfy the criteria. |
---|
| 20 | |
---|
| 21 | if(arguments.length > 1 && !(method instanceof Array)){ |
---|
| 22 | method = [method]; |
---|
| 23 | } |
---|
| 24 | |
---|
| 25 | var contextStack = aop.getContextStack(); |
---|
| 26 | for(var i = contextStack.length - 1; i >= 0; --i){ |
---|
| 27 | var c = contextStack[i]; |
---|
| 28 | // check if instance matches |
---|
| 29 | if(instance && c.instance != instance){ continue; } |
---|
| 30 | if(!method){ return true; } |
---|
| 31 | var n = c.joinPoint.targetName; |
---|
| 32 | for(var j = method.length - 1; j >= 0; --j){ |
---|
| 33 | var m = method[j]; |
---|
| 34 | if(m instanceof RegExp){ |
---|
| 35 | if(m.test(n)){ return true; } |
---|
| 36 | }else{ |
---|
| 37 | if(n == m){ return true; } |
---|
| 38 | } |
---|
| 39 | } |
---|
| 40 | } |
---|
| 41 | return false; // Boolean |
---|
| 42 | }; |
---|
| 43 | })(); |
---|
Note: See
TracBrowser
for help on using the repository browser.