1<!---
2Copyright 2006-2007 TeraTech, Inc. http://teratech.com/
3 4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7 8http://www.apache.org/licenses/LICENSE-2.0
9 10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15--->
16<cfcomponent output="false" hint="I am a factory object that creates verb objects.">
17 18 <cffunction name="init" returntype="fuseboxFactory" access="public" output="false"
19 hint="I am the constructor.">
20 21 <cfset variables.lexCompPool = 0 />
22 <cfset variables.verbLexPool = 0 />
23 24 <cfset variables.fuseboxLexicon = structNew()/>
25 <cfset variables.fuseboxLexicon.namespace = "$fusebox" />
26 <cfset variables.fuseboxLexicon.path = "verbs/" />
27 28 <cfreturn this />
29 30 </cffunction>
31 32 <cffunction name="create" returntype="any" access="public" output="false"
33 hint="I create a verb object.">
34 <cfargument name="verb" type="string" required="true"
35 hint="I am the name of the verb to create." />
36 <cfargument name="action" type="any" required="true"
37 hint="I am the enclosing fuseaction object." />
38 <cfargument name="attributes" type="struct" required="true"
39 hint="I am the attributes of this verb." />
40 <cfargument name="children" type="any" required="true"
41 hint="I am the XML representation of this verb's children." />
42 <cfargument name="global" type="boolean" default="false"
43 hint="I indicate whether this is part of a regular fuseaction (false) or a global fuseaction (true)." />
44 45 <cfset var verbObject = "" />
46 47 <!--- global pre/post process is a special case: --->
48 <cfif arguments.global>
49 <cfif listFind("do,fuseaction",arguments.verb)>
50 <!--- this is OK, do is deprecated --->
51 <cfif arguments.verb is "do" and arguments.action.getCircuit().getApplication().strictMode>
52 <cfthrow type="fusebox.badGrammar.deprecated"
53 message="Deprecated feature"
54 detail="Using the 'do' verb in a global pre/post process was deprecated in Fusebox 4.1." />
55 </cfif>
56 <cfelse>
57 <!--- no other verbs are allowed --->
58 <cfthrow type="fusebox.badGrammar.illegalVerb"
59 message="Illegal verb encountered"
60 detail="The '#arguments.verb#' verb is illegal in a global pre/post process." />
61 </cfif>
62 <cfelse>
63 <cfif listFind("fuseaction",arguments.verb)>
64 <!--- verbs that are only legal in global pre/post process --->
65 <cfthrow type="fusebox.badGrammar.illegalVerb"
66 message="Illegal verb encountered"
67 detail="The '#arguments.verb#' verb is only legal in a global pre/post process." />
68 </cfif>
69 </cfif>
70 <cfif listLen(arguments.verb,".:") eq 2>
71 <!--- must be namespace.verb or namespace:verb --->
72 <cfset verbObject = createObject("component","fuseboxVerb")
73 .init(arguments.action, arguments.verb, arguments.attributes, arguments.children) />
74 <cfelseif listFind("do,fuseaction",arguments.verb)>
75 <!--- built-in verbs that cannot be implemented as a lexicon --->
76 <cfset verbObject = createObject("component","fuseboxDoFuseaction")
77 .init(arguments.action,arguments.attributes,arguments.children,arguments.verb) />
78 <cfelse>
79 <!--- builtin verb implemented as a lexicon --->
80 <cfset verbObject = createObject("component","fuseboxVerb")
81 .init(arguments.action, variables.fuseboxLexicon.namespace & ":" & arguments.verb,
82 arguments.attributes, arguments.children) />
83 </cfif>
84 <cfreturn verbObject />
85 86 </cffunction>
87 88 <cffunction name="createLexiconCompiler" returntype="any" access="public" output="false"
89 hint="I return a lexicon compiler context (either from the pool or a newly created instance).">
90 91 <cfset var obj = 0 />
92 93 <cfif isSimpleValue(variables.lexCompPool)>
94 <cfset obj = createObject("component","fuseboxLexiconCompiler") />
95 <cfelse>
96 <cfset obj = variables.lexCompPool />
97 <cfset variables.lexCompPool = obj._next />
98 </cfif>
99 100 <cfreturn obj />
101 102 </cffunction>
103 104 <cffunction name="freeLexiconCompiler" returntype="void" access="public" output="false"
105 hint="I return the lexicon compiler context to the pool.">
106 <cfargument name="lexComp" type="any" required="false"
107 hint="I am the lexicon compiler context to be returned. I am required but it's faster to specify that I am not required." />
108 109 <cfset arguments.lexComp._next = variables.lexCompPool />
110 <cfset variables.lexCompPool = arguments.lexComp />
111 112 </cffunction>
113 114 <cffunction name="getBuiltinLexicon" returntype="any" access="public" output="false"
115 hint="I return the (magic) builtin lexicon.">
116 117 <cfreturn variables.fuseboxLexicon />
118 119 </cffunction>
120 121</cfcomponent>