| 1 | <!--- |
|---|
| 2 | Fusebox Software License |
|---|
| 3 | Version 1.0 |
|---|
| 4 | |
|---|
| 5 | Copyright (c) 2003, 2004, 2005, 2006 The Fusebox Corporation. All rights reserved. |
|---|
| 6 | |
|---|
| 7 | Redistribution and use in source and binary forms, with or without modification, are permitted |
|---|
| 8 | provided that the following conditions are met: |
|---|
| 9 | |
|---|
| 10 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions |
|---|
| 11 | and the following disclaimer. |
|---|
| 12 | |
|---|
| 13 | 2. Redistributions in binary form or otherwise encrypted form must reproduce the above copyright |
|---|
| 14 | notice, this list of conditions and the following disclaimer in the documentation and/or other |
|---|
| 15 | materials provided with the distribution. |
|---|
| 16 | |
|---|
| 17 | 3. The end-user documentation included with the redistribution, if any, must include the following |
|---|
| 18 | acknowledgment: |
|---|
| 19 | |
|---|
| 20 | "This product includes software developed by the Fusebox Corporation (http://www.fusebox.org/)." |
|---|
| 21 | |
|---|
| 22 | Alternately, this acknowledgment may appear in the software itself, if and wherever such |
|---|
| 23 | third-party acknowledgments normally appear. |
|---|
| 24 | |
|---|
| 25 | 4. The names "Fusebox" and "Fusebox Corporation" must not be used to endorse or promote products |
|---|
| 26 | derived from this software without prior written (non-electronic) permission. For written |
|---|
| 27 | permission, please contact fusebox@fusebox.org. |
|---|
| 28 | |
|---|
| 29 | 5. Products derived from this software may not be called "Fusebox", nor may "Fusebox" appear in |
|---|
| 30 | their name, without prior written (non-electronic) permission of the Fusebox Corporation. For |
|---|
| 31 | written permission, please contact fusebox@fusebox.org. |
|---|
| 32 | |
|---|
| 33 | If one or more of the above conditions are violated, then this license is immediately revoked and |
|---|
| 34 | can be re-instated only upon prior written authorization of the Fusebox Corporation. |
|---|
| 35 | |
|---|
| 36 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|---|
| 37 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
|---|
| 38 | DISCLAIMED. IN NO EVENT SHALL THE FUSEBOX CORPORATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY |
|---|
| 39 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|---|
| 40 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
|---|
| 41 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
|---|
| 42 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|---|
| 43 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|---|
| 44 | |
|---|
| 45 | ------------------------------------------------------------------------------- |
|---|
| 46 | |
|---|
| 47 | This software consists of voluntary contributions made by many individuals on behalf of the |
|---|
| 48 | Fusebox Corporation. For more information on Fusebox, please see <http://www.fusebox.org/>. |
|---|
| 49 | |
|---|
| 50 | ---> |
|---|
| 51 | <cfcomponent output="false" hint="I am a factory object that creates verb objects."> |
|---|
| 52 | |
|---|
| 53 | <cffunction name="init" returntype="fuseboxFactory" access="public" output="false" |
|---|
| 54 | hint="I am the constructor."> |
|---|
| 55 | |
|---|
| 56 | <cfset variables.lexCompPool = 0 /> |
|---|
| 57 | <cfset variables.verbLexPool = 0 /> |
|---|
| 58 | |
|---|
| 59 | <cfset variables.fuseboxLexicon = structNew()/> |
|---|
| 60 | <cfset variables.fuseboxLexicon.namespace = "$fusebox" /> |
|---|
| 61 | <cfset variables.fuseboxLexicon.path = "verbs/" /> |
|---|
| 62 | |
|---|
| 63 | <cfreturn this /> |
|---|
| 64 | |
|---|
| 65 | </cffunction> |
|---|
| 66 | |
|---|
| 67 | <cffunction name="create" returntype="any" access="public" output="false" |
|---|
| 68 | hint="I create a verb object."> |
|---|
| 69 | <cfargument name="verb" type="string" required="true" |
|---|
| 70 | hint="I am the name of the verb to create." /> |
|---|
| 71 | <cfargument name="action" type="any" required="true" |
|---|
| 72 | hint="I am the enclosing fuseaction object." /> |
|---|
| 73 | <cfargument name="attributes" type="struct" required="true" |
|---|
| 74 | hint="I am the attributes of this verb." /> |
|---|
| 75 | <cfargument name="children" type="any" required="true" |
|---|
| 76 | hint="I am the XML representation of this verb's children." /> |
|---|
| 77 | <cfargument name="global" type="boolean" default="false" |
|---|
| 78 | hint="I indicate whether this is part of a regular fuseaction (false) or a global fuseaction (true)." /> |
|---|
| 79 | |
|---|
| 80 | <cfset var verbObject = "" /> |
|---|
| 81 | |
|---|
| 82 | <!--- global pre/post process is a special case: ---> |
|---|
| 83 | <cfif arguments.global> |
|---|
| 84 | <cfif listFind("do,fuseaction",arguments.verb)> |
|---|
| 85 | <!--- this is OK, do is deprecated ---> |
|---|
| 86 | <cfif arguments.verb is "do" and arguments.action.getCircuit().getApplication().strictMode> |
|---|
| 87 | <cfthrow type="fusebox.badGrammar.deprecated" |
|---|
| 88 | message="Deprecated feature" |
|---|
| 89 | detail="Using the 'do' verb in a global pre/post process was deprecated in Fusebox 4.1." /> |
|---|
| 90 | </cfif> |
|---|
| 91 | <cfelse> |
|---|
| 92 | <!--- no other verbs are allowed ---> |
|---|
| 93 | <cfthrow type="fusebox.badGrammar.illegalVerb" |
|---|
| 94 | message="Illegal verb encountered" |
|---|
| 95 | detail="The '#arguments.verb#' verb is illegal in a global pre/post process." /> |
|---|
| 96 | </cfif> |
|---|
| 97 | <cfelse> |
|---|
| 98 | <cfif listFind("fuseaction",arguments.verb)> |
|---|
| 99 | <!--- verbs that are only legal in global pre/post process ---> |
|---|
| 100 | <cfthrow type="fusebox.badGrammar.illegalVerb" |
|---|
| 101 | message="Illegal verb encountered" |
|---|
| 102 | detail="The '#arguments.verb#' verb is only legal in a global pre/post process." /> |
|---|
| 103 | </cfif> |
|---|
| 104 | </cfif> |
|---|
| 105 | <cfif listLen(arguments.verb,".:") eq 2> |
|---|
| 106 | <!--- must be namespace.verb or namespace:verb ---> |
|---|
| 107 | <cfset verbObject = createObject("component","fuseboxVerb") |
|---|
| 108 | .init(arguments.action, arguments.verb, arguments.attributes, arguments.children) /> |
|---|
| 109 | <cfelseif listFind("do,fuseaction",arguments.verb)> |
|---|
| 110 | <!--- built-in verbs that cannot be implemented as a lexicon ---> |
|---|
| 111 | <cfset verbObject = createObject("component","fuseboxDoFuseaction") |
|---|
| 112 | .init(arguments.action,arguments.attributes,arguments.children,arguments.verb) /> |
|---|
| 113 | <cfelse> |
|---|
| 114 | <!--- builtin verb implemented as a lexicon ---> |
|---|
| 115 | <cfset verbObject = createObject("component","fuseboxVerb") |
|---|
| 116 | .init(arguments.action, variables.fuseboxLexicon.namespace & ":" & arguments.verb, |
|---|
| 117 | arguments.attributes, arguments.children) /> |
|---|
| 118 | </cfif> |
|---|
| 119 | <cfreturn verbObject /> |
|---|
| 120 | |
|---|
| 121 | </cffunction> |
|---|
| 122 | |
|---|
| 123 | <cffunction name="createLexiconCompiler" returntype="any" access="public" output="false" |
|---|
| 124 | hint="I return a lexicon compiler context (either from the pool or a newly created instance)."> |
|---|
| 125 | |
|---|
| 126 | <cfset var obj = 0 /> |
|---|
| 127 | |
|---|
| 128 | <cfif isSimpleValue(variables.lexCompPool)> |
|---|
| 129 | <cfset obj = createObject("component","fuseboxLexiconCompiler") /> |
|---|
| 130 | <cfelse> |
|---|
| 131 | <cfset obj = variables.lexCompPool /> |
|---|
| 132 | <cfset variables.lexCompPool = obj._next /> |
|---|
| 133 | </cfif> |
|---|
| 134 | |
|---|
| 135 | <cfreturn obj /> |
|---|
| 136 | |
|---|
| 137 | </cffunction> |
|---|
| 138 | |
|---|
| 139 | <cffunction name="freeLexiconCompiler" returntype="void" access="public" output="false" |
|---|
| 140 | hint="I return the lexicon compiler context to the pool."> |
|---|
| 141 | <cfargument name="lexComp" type="any" required="false" |
|---|
| 142 | hint="I am the lexicon compiler context to be returned. I am required but it's faster to specify that I am not required." /> |
|---|
| 143 | |
|---|
| 144 | <cfset arguments.lexComp._next = variables.lexCompPool /> |
|---|
| 145 | <cfset variables.lexCompPool = arguments.lexComp /> |
|---|
| 146 | |
|---|
| 147 | </cffunction> |
|---|
| 148 | |
|---|
| 149 | <cffunction name="getBuiltinLexicon" returntype="any" access="public" output="false" |
|---|
| 150 | hint="I return the (magic) builtin lexicon."> |
|---|
| 151 | |
|---|
| 152 | <cfreturn variables.fuseboxLexicon /> |
|---|
| 153 | |
|---|
| 154 | </cffunction> |
|---|
| 155 | |
|---|
| 156 | </cfcomponent> |
|---|