You can create Smalltalk classes from the data division structure of other
languages using a parser. If you use a VisualAge external function part
to parse a C include file or COBOL copybook file for record structure
definitions, VisualAge stores the information in an internal, temporary object
table. As an alternative, you can use the VisualAge Record Class
Generator. The Record Class Generator parses the file you specify and
permanently creates a class in your hierarchy for each record
structure.
Use the Record Class Generator to break a COBOL or C data division
structure into Smalltalk classes.
The Record Class Generator can parse applications that satisfy all of the
following requirements:
You can use COBOL or C to define the format of the segments that your
program will be reading or modifying. Several segments can exist within
one COBOL or C definition.
For a C header file, all data types declared with typedef or
struct can be used to generate a class. For a COBOL copy
library file, the record formats declared by 01-level declarations can be
used.
The parser generates classes for each first level of segment
definition; that is, each of the highest levels in the structure becomes
a class. The parser also generates the getter and setter methods for
the class; each lower level definition is split into a getter and a
setter method in its class.
To parse C or COBOL structures into Smalltalk classes, do the
following:
In a VisualAge Organizer, select Generate >
Record wrapper from the Parts menu.
The Record Class Generator window opens:
This window is similar to the Record settings page of the C and
COBOL External Function parts.
You will be prompted to enter a class name for the generated
selectors; the default will be the name selected in the Records to
generate list.
If the parsed file contains any constant definitions (level-78 and level-88
items for COBOL; #define items for C), a prompter will appear asking you
to specify the name of a pool dictionary for the generated class. You
can enter a valid global variable name or select Cancel to proceed
with the record generation.
The classes resulting from the parsed structure are subclasses of
OsPtr unless data conversion is requested.
When data conversion is requested, the Record Class Generator generates a
class, that is a subclass of AbtForeignOSObject. If the
class already exists, it will be overwritten in the application in which it
was originally created. If it is a new class, it will be created in the
application that you were browsing when you invoked the Record Class
Generator. The generated class can always be moved to a different
application as needed.
To save a representation of your record for later editing, select
Archival method from the Generate menu of the Record
Class Generator. This adds a class method representing the record to
the class you specify. You can use the method to reconstruct the
selectors of the record.Generating record structure classes
Using the parser
Parsing data division structures
Note: This setting does not apply to the COBOL External Function part.
Note: This setting does not apply to the COBOL External Function part.
When Yes is selected for Translate data?, the fields for
Endian and Code page are enabled.