Eiffel Visitor Factory Tool
Overview
The Eiffel Visitor Factory Tool is a simple command line application to generate Eiffel visitor patterns based on Eiffel classes found at specified folder locations. It can generate an interface (deferred) and/or stub (effective) Eiffel classes in no time.
Command-line Options
By default the tool will look in the current working directory for Eiffel source files (*.e). If you want to specify alternative locations use the -i switch to specify relative or absolute directory or file paths. If you need to exclude files use the -ex switch to specify what files to exclude.
To exclude a files in the current directory that start with status you would call:
vfact -ex "status.*\.e$$" (Windows shell requires $$ to represent $)
You can optionally search all specified directories recursively using the -r switch.
For all other options please read the usage help using the -?
Sample Output
As an example of what the tool generates, imagine the tool running in a directory containing two classes - ERROR_A
and ERROR_B
:
class ERROR_A -- end
class ERROR_B -- end
Running the tool in with the default settings will produce an interface class:
deferred class GENERATED_VISITOR feature -- Processing process_error_a (a_value: ERROR_A) -- Process object `a_error_a'. require a_error_a_attached: error_a /= Void deferred end process_error_b (a_value: ERROR_B) -- Process object `a_error_b'. require a_error_b_attached: error_b /= Void deferred end end -- class {GENERATED_VISITOR}
And a stub class:
class GENERATED_VISITOR_IMPL inherit GENERATED_VISITOR redefine process_error_a, process_error_b end feature -- Processing process_error_a (a_value: ERROR_A) -- Process object `a_error_a'. do check not_impl: False end end process_error_b (a_value: ERROR_B) -- Process object `a_error_b'. do check not_impl: False end end end -- class {GENERATED_VISITOR_IMPL}
You can run the tool with the -n option to change the name of the generated class. Stub classes are always generated with a _IMPL
extension.
Another option, user data, allows you to generate a visitor that is passed a piece of user data. In this case you would use the -ud switch an specify the base class for the user data. Using this approach will generate features that have to be passed an entity to visit upon and a user data entity (this could be void.)
Using the following command line will produce the output below:
vfact -n MY_VISITOR -ud TEXT_PRINTER
deferred class MY_VISITOR [G -> TEXT_PRINTER] feature -- Processing process_error_a (a_value: ERROR_A; a_data: G) -- Process object `a_error_a' using user data `a_data'. require a_error_a_attached: error_a /= Void is_text_printer_valid: is_text_printer_valid (a_data) deferred end process_error_b (a_value: ERROR_B; a_data: G) -- Process object `a_error_b' using user data `a_data'. require a_error_b_attached: error_b /= Void is_text_printer_valid: is_text_printer_valid (a_data) deferred end feature -- Query is_text_printer_valid (a_data: G): BOOLEAN is -- Determines if data `a_data' is valid for Current. do Result := True end
class MY_VISITOR_IMPL [G -> TEXT_PRINTER] inherit MY_VISITOR [G] redefine process_error_a, process_error_b end feature -- Processing process_error_a (a_value: ERROR_A; a_data: G) -- Process object `a_error_a' using user data `a_data'. do check not_impl: False end end process_error_b (a_value: ERROR_B; a_data: G) -- Process object `a_error_b' using user data `a_data'. do check not_impl: False end end end -- class {MY_VISITOR_IMPL}
Information
This tool was developed and maintained by Paulb.
Location: https://origo.ethz.ch/eiffelsoftware/es/trunk/Src/tools/visitor_factory
Change Log
Update: --Paulb 19:44, 22 November 2006 (CET)
- Bug: Fixed crash when scanning large number of files.
- Bug: Fixed multi-pattern excluded file search.
- Added: Ability to exclude directories
Initial Entry: --Paulb 23:54, 21 November 2006 (CET)