Appendix B Creating Wrapped Classes

B.3 The Wrap Script and the Macintosh

The wrapper generates code for the Macintosh. This involves three things:

1) #pragma once goes in the generated .h file as follows:

#ifdef macintosh
#pragma once
#endif // macintosh

2) The three random code blocks (notice, source, and header) go in the code in the following template:

#ifdef macintosh
macSection
#else // macintosh
normalSection
#endif // macintosh

The wrap script writes normalSection in the .wrp file, and treats macSection the same, with the include statements corrected for the Macintosh. This correction involves dropping all directory specifications in the lines of the include statement, except for those of the Rogue Wave(TM) class library. For example:

#include <utils/UTtypes.h> becomes #include <UTtypes.h>
#include <UTtypes.h>
remains #include <UTtypes.h>
#include <rw/cstring.h>
remains #include <rw/cstring.h>

3) The wrap script adds #pragma segment commands to the generated .cc file. The default segment for all methods in the file is the same as the name of the wrapped class. The wrapper adds the following to the top of each generated .cc file (with the correct name substituted for XFbuttonRO).

#ifdef macintosh
#pragma segment XFbuttonRO
#endif // macintosh

To handle future optimization on the Macintosh, you can specify a segment for each method by preceding the signature with the desired name enclosed in square brackets. For example:

[yourSegmentNameHere] UThandle requestContainer(UThandle hParent)

Note that the segment names set this way have effect only for that particular method.

B.3.1 Command Line Interface

The following is an example of using the wrapper. The command line:


$(TOOLS_DIR)/wrap $(WRAPFLAGS) XFbuttonRO.wrp $(WRAP_H_DIR) $(WRAP_CC_DIR)
causes the wrapper to generate:

$(WRAP_H_DIR)/XFbuttonRO.h 
$(WRAP_CC_DIR)/XFbuttonRO.cc
The wrapper exits with zero status if it completes successfully, and with a non-zero status if there is a problem. The remaining sections cover the legal flags for the wrap script: +depend, -l, -mac, and +Wdirectory.

+depend

The wrapper does not generate its usual C++ header and source files when given the +depend flag. Instead, it outputs make-style dependencies for the source file it would have generated. For instance, the wrapper generates the following dependencies for the generated XFbuttonRO.cc file.

	./XFbuttonRO.cc: ../../generic/src/ActivityManagerRO.wrp 
	./XFbuttonRO.cc: ../../generic/src/AttributeManagerRO.wrp 
	./XFbuttonRO.cc: ./XFwidgetRO.wrp 
	./XFbuttonRO.cc: ./XFcontainableRO.wrp 
	./XFbuttonRO.cc: ./XFsimpleRO.wrp 
	./XFbuttonRO.cc: ./XFfontableRO.wrp 
	./XFbuttonRO.cc: ./XFlabelRO.wrp 
	./XFbuttonRO.cc: XFbuttonRO.wrp

-l

The wrap script attempts to trick the compiler into reporting errors related to the .wrp file, although this mechanism is not always perfect. If you really cannot see the problem at a line, you may use the -l flag to turn off line numbering. With the -l flag, the compiler reports errors where it thinks they occur in the generated .h and .cc files. Note that you have to rewrap the file for the this flag to be useful.

-mac

By default, the wrapper creates code for the Macintosh platform. Using the -mac flag suppresses this behavior in case you ever have to read the generated files.

+Wdirectory

The +Wdirectory argument appends directory to the search path that the wrap scripts uses when it tries to find files describing superclass descriptions. It is the analog of the -I flag used by C/C++ compilers.

B.3.1 - Command Line Interface
+depend
-l
-mac
+Wdirectory

AM2 Documentation - 19 NOV 1996

Generated with Harlequin WebMaker