Suite Modeler's Rapid Prototype Code Generation Facility

Perl and PerlObjCBridge
Suite Modeler uses Perl and Apple's PerlObjCBridge.pm to generate source code in Objective-C (Java later?). Suite Modeler makes its Perl modules public in the application's resource bundle, so users can fine-tune them to their purposes.

Note that Suite Modeler does not use CamelBones. (Props to Sherm Pendley, nevertheless.) The issues that weighed in this design trade-off are these: In the end, I determined that to force Suite Modeler users and CamelBones on each other would prove unsatisfactory to all parties. Suite Modeler's public code generation API in Perl permits users to resort to CamelBones if they prefer. After all, in Perl, there is always more than one way to do it. For extensive revision, CamelBones may well prove beneficial.

Code Generation -- a Text Book Case for Perl
Suite Modeler's Rapid Prototype Code Generation Facility follows particularly, the "Jeeves" example of pages 116-119 of Chapter 17, "Template-Driven Code Generation." It relies on an abstract syntax tree (AST). Here, the AST appears as a NSDictionary from Suite Modeler. The Jeeves example uses a template file and for each class of the AST, the driver produces an intermediate file and then emits the final file. Where Jeeves emits files directly, the Suite Modeler Perl API returns an NSDictionary. Each entry in the dictionary is a file name as a key, with the file's contents, as a single string, as the key's value. Suite Modeler then uses typical Cocoa Objective-C API actually to emit the files (in a directory chosen by the user in a Save Panel), adding the *.script* plist files on its own.

Notes on the Abstract Syntax Tree
The AST differs from the Suite Modeler document plist archival form in a few ways: These changes simplify the Perl problem. The first obviates a KVC sort. As for the second, it obviates either cross-document references in the Perl API, or multiple client-server messages. The third provides the fine-grain control, through the drawer view accessible via the ("<") button in the "Classes" tab view.

Overview -- NSDictionary In, NSDictionary Out
Suite Modeler launches a Distributed Objects (DO) server in Perl and connects to it as a client. The client sends to the server an NSDictionary that specifies the code to be generated for a suite. The client receives from the server an NSDictionary that specifies the files to emit. Each entry of the returned dictionary has as its key a file name and as its value the file's contents as a string.

User Control
The Preferences Panel provides coarse-grain control.
A drawer accessible from the "Classes" tab provides fine-grain control.