The class ExeCont represent the execution context and contains most of the state information relevent to document execution. It also abstracts functionality relating to event and prompt counts, form item variables, and interactions with the ECMAScript context.
The class GInfo represents information relating to a particular grammar including its scope, grammar handle (as returned by recLoadGrammar, and its target (in the case of a <link> or <choice> grammar). This class also contains most of the methods for building grammars for menus and option lists.
Aside from these three, there is a utility class mediating XML attribute access, and a few utility classes local to the prompt processing section (VXI_prompt.cpp).
The document loop loads and executes documents - each iteration of the loop produces the next document to load. When no new doc is to be loaded, the loop exits.
The dialog loop is called for each document (possibly with a dialog name). It looks for the proper dialog to execute and enters it. Generally, this loop only has one iterate as the executed dialog typically determines the next document/dialog/item to run. If no next is produced by the current dialog, the dialog loop exits.
The item loop is essentially the FIA. It iterates over the form-items in a dialog and ends when all form items are complete or a new target (item, dialog, or url) is specified. Note: Event handling is primarily done in loop and catch handlers result in either continuation of this loop or produces a new target. The new target is passed up the enclosing loops and processed in the appropriate loop depending on target type (items in FIA, dialogs (url fragments) in dialog loop, URLs is doc loop).
Communication in and out of the three control loops is handled by the execution context (class ExeCont) and a return code. Each loop returns a return code to its caller as well as handling those from inner loops. Based on these return codes and value in the execution context, control is passed up to the proper level. The return codes are enumerated in vxi.hpp and are:
Each iteration through the loop checks for pending events. If an event is found, it is processed, with control either resuming in the FIA loop or transferring due to a <goto> etc.
If no events are pending, the loop checks for field results, either from recognition, subdialog calls, or other field item execution. If a result is pending, it is processed (see Result Processing) with control again either continuing the the FIA or explicitly transferred.
If no events or results are pending, the FIA loop selects a form item to process. If a target item has been specified by a control element (<goto> etc.), this item is selected. Otherwise, the field item variables and guard conditions of each item are tested and the first unfilled and enabled item is selected. If no item is selected, the loop exits.
If an item is selected, the "collect phase" for that item is performed. Most form items (except <block> have a similar collect phase which consists of
Executable content occurs inside <block>, <filled> and <catch> elements and recursively inside <if> elements. Processing of these elements is straightforward. The <var>,<assign>,<script>,<clear>, and <reprompt> produce side-effects in either the ECMAscript environment or the execution context (class ExeCont). The <exit>,<throw>,<goto>,<submit>, and <return> element cause control to leave the executable content. In the current release, control transfers out of executable content sections are implemented by a C++ throw() of a VXI return code (see VXI.hpp for enumeration). It could equally well be implemented by checking ordinary return values at each execution step, though this would be tedious. In consequence, those places in the code that can invoke executable content are wrapped in try{}catch(){} blocks. These are three main control loops, as well as the initial document download and setup (which can invoke <catch> elements through download failure or other errors). Control transfer are caught and handled as describe in the sections above.
Descriptions of the implementation of individual executable elements can be found in comments within the source code.
VoiceXML is a Trademark of the VoiceXML
forum.
Copyright 2000, 2001. SpeechWorks International, Inc. All rights reserved.
Distributed under SpeechWorks Open
Document License, v1.0