MPW Oberon includes the following new features expanding the power and flexibility of Oberon programming:
Note: The interface files supplied with MPW Oberon are not the universal
interface files needed to develop code for the PowerPC. The universal interface
files will be made available with a subsequent release of MPW Oberon.
Using interface files
The interface files for the Oberon and MPW libraries as well as the Macintosh
ROMs are in the {OInterfaces} directory. You can determine which interface files
to use for a specific routine or data type by finding out which library or
Macintosh Manager the routine or data type belongs to. You can also find out the
library or Manager name by searching the {OInterfaces} directory for the routine
or type name with the MPW Search command.
The compiler searches several directories for interface files, until the specified file is found. It searches the directory containing the source file, directories specified using the -i option to the compiler, and directories specified in the Shell variable {OInterfaces}.
You specify the modules needed for your module by the IMPORT statement:
IMPORT module, module, …;The compiler assumes that a `module' will be found in the file `module.mod'. This is the file for which it then searches.
Note: Variant records are not supported by Oberon, so the variant record types defined in Inside Macintosh were adapted for MPW Oberon. Each variant is defines in a separate record. Type extension is used to declare the common fields. The data types GrafPort, WindowRecord, and DialogsRecord are also defined using type inheritance where DialogRecord is an extension of WindowRecord which is an extension of GrafPort.
Warning: The replacement of variant records with records defined using type extension creates no problems in many cases. An incompatibility arises when array of variant records are considered. Pascal allocates enough memory for each element to accommodate the largest variant. The same declaration is accepted by Oberon but the compiler does not reserve enough space for each element. Fortunately this construct is not used very often-once-with the interface files supplied with MPW Oberon.
Warning: You may cause system crashes when you are not using the proper variant (extended type) of a parameter block. Most of the routines accept a parameter of type ParmBlkPtr. The following fragment shows an example where a block with the wrong size is passed to PBOpen.
VAR block: OSUtils.ParamBlockRec; … error:=PBOpen(SYSTEM.ADR(block), TRUE);PBOpen expects a pointer parameter block pointing to at least 50 bytes (IOParam). The block passed to PBOpen is not large enough since ParamBlockRec defines only the fields common to all parameter blocks. Check out the interface files for further information.
Every MPW Oberon program must be linked with the libraries Runtime.o, Interface.o and OberonLib.o. Others are required for different operations. For further information about using the libraries, see the documentation of MPW.
Note: The libraries included with MPW Oberon are not yet final. Some
library modules for accessing files within the MPW Shell were implemented using
routines from the Pascal library. This will be fixed in a subsequent version of
MPW Oberon.
About the Oberon examples
The Oberon files consist of eight sample Oberon programs included with MPW
Oberon: an application, a tool, a desk accessory, and a program that demonstrates
the use of the performance tools. In addition, the makefiles, containing the
commands needed to build each of the examples are provided in the same folders.
These files are in {OExamples}. The following table lists these files.
| Makefile | Makefile for building sample programs. |
| Instuctions | Instructions for build sample programs. |
| Sample.mod | Sample Oberon application. This is the sample application described in "A Simple Example Program" in Chapter 1 of Inside Macintosh, Volume 1. The source code was adapted to be MultiFinder-aware. |
| TESample.mod | Simple MultiFinder-aware TextEdit application |
| SillyBalls.mod | Simple Color Quickdraw sample application |
| TubeTest.mod | Simple Color Quickdraw and Palette Manager application |
| ResEqual.mod | Sample MPW Tool |
| Memory.mod | Sample desk accessory. The Memory desk accessory display the current free space in the application and system heaps, the free space on the default volume, and the name of the default volume. This information is updated every 5 seconds. When Memory is first opened, it calls _MaxMem to purge memory, thus showing the upper bounds on free space in both heaps. |
| EditCdev.mod | Sample Control Panel device with a TextEdit item |
| TestPerf.mod | Sample program using the Performance Measurement tools |
In addition to the samples describes above showing standard Macintosh programming, eleven sample programs are included with MPW Oberon written in Oberon, Pascal, and C. These programs are contained in the folder JMLCSamples and were used to compare the code generation of MPW Oberon with MPW Pascal and MPW C. The results of this comparison were presented at the Joint Modular Languages Conference 1994 in Ulm. The following table lists the targets of the Makefile which may be used for producing reports.
| CSize | Report size of compiled programs |
| CSpeed | Report compilation times |
| ESpeed | Report execution times |
| Report | Create a complete report showing size of compiled code and source text, compilation time, and execution time |
| SLines | Report number of source lines |
Note: The first generation of a report may take a while since all programs must be build.
Most of the examples in the test suite above were adapted from textbooks. For
"standardized" testing the folder Hennessy contains the standard Hennessy
benchmark suite. This suite is provided in Oberon, Pascal and C. You will notice
that MPW Oberon performs equally well in both test suites.
Installing MPW Oberon
MPW Oberon may be installed by copying the Oberon files to the proper places.
Install MPW Oberon with these steps:
| {Commands} | A comma-separated list of directories containing tools and applications. The directory containing the Oberon compiler should appear in that list. |
| {OInterfaces} | A comma-separated list of directories to search for Oberon interface files. This should include the OInterfaces directory. |
| {OLibraries} | The directory containing OLibraries files. This should be the pathname of the OLibraries directory. |
This section outlines the steps for building an application in MPW Oberon. The
Instructions files in the OExamples folder describe some of the tools that can be
used to automate to processes. The Makefile file in the OExamples folder
illustrates the use of some of the tools. See the MPW documentation for further
details about these tools.
Building an application
The easiest way to build any program in MPW is to use the Build menu. To build
Sample, an application in the OExamples folder, set the directory to the
OExamples folder using the Directory menu. Select Build from the Build menu and
type the name of the program to build: Sample.
You will see something like this on the screen:
# 10:22:49 Uhr ----- Build of Sample. # 10:22:49 Uhr ----- Analyzing dependencies. # 10:22:51 Uhr ----- Executing build commands. Oberon Sample.mod -o Sample.mod.o Link -o Sample Sample.mod.o ∂ "Yogi:Libraries:Libraries:"Runtime.o∂ "Yogi:Libraries:Libraries:"Interface.o ∂ "Yogi:Libraries:OLibraries:"OberonLib.o SetFile Sample -t APPL -c 'MOOS' -a B Rez -rd -o Sample Sample.r -append # 10:23:03 Uhr ----- Done. SampleThe Build command compiles and links the applications. For details to compile and link the application independently, see the sections "Compiling an application" and "Linking an application" below.
Oberon -p Sample.modCompiles the source file Sample.mod, producing the object file Sample.mod.o. The -p option specifies that progress information should be written to diagnostic output. This information appears after the command line.
{Libraries}Interfaces.o
{Libraries}Runtime.o
{OLibraries}OberonLib.o
In Oberon there is no main program. Use the $MAIN directive to declare the
initialization part of a specific module as the program's main entry point. Only
one module may be declared as the main module. Otherwise the linker will report
an error.
Tools are executed by entering an MPW command. The parameter specified in the command line are passed as parameters to the main program. The exported Shell variables can be accessed using the procedure IntEnv.getenv from the Oberon library. To access these parameters use the IntEnv module.
Tools have direct access to MPW Shell windows and selections. The variables
stdin, stdout and stderr refer to MPW' standard input, standard output, and
diagnostic output. Any files opened by tools read and write to windows, if the
file specified is open in a window. The contents of the window are read or
written in place of the file's data fork. Selection in windows can also be read
and written as if they were files by the adding the suffix .§ to the
filename.
Compiling a tool
You compile a tool in exactly the same way as you compile an application. All
information regarding import-file search rules, segmentation, and resources
applies equally.
Linking a tool
The MPW Shell recognizes a tool by its type and creator. Specify the following
options when linking a tool:
Link -t MPST -c "MPS " …The command specified the file type and creator of an MPW tool. Follow the same library linking rules for tools as for applications. In addition, if your tool call any of the spinning cursor or error manager routines, link with the following libraries:
{Libraries}Stubs.o
{Libraries}ToolLibs.o
The file Stubs.o contains a collection of "stubs", or dummy routines, that are
defined in the run-time library but unnecessary for MPW tools running under the
MPW Shell.
ΔΔElaborateΔΔ
Creating code for different models of the
Macintosh
Using MPW Oberon, you can create applications running on all models of the
Macintosh. This section outlines the compatibilities among the machines and the
strategies for writing and compiling code running on the different models.
Note: Programs written in MPW Oberon will execute on the PowerPC. The
PowerPC models will emulate an MC68LC040 processor. Floating-point operations
must be performed using the SANE because FPU instructions are not emulated. Do
not use the -mc68881 option when writing programs using floating-point that
should execute in the PowerPC environment.
Interface files
A set of interface files provided with MPW Oberon gives you access from Oberon to
the Macintosh Toolbox and Macintosh Operating System routines built into the
Macintosh ROMs. These routines are documented in Inside Macintosh.
Many routines described in Inside Macintosh are not available on certain models
of the Macintosh, because they make use of hardware options that are not
available on other models. You can import all of the interface-file definitions
in code for use on any model, but you cannot call ROM routines that are not
present on the machine that will the compiled code.
Compiler options
The code produced by MPW Oberon will execute only on models of the Macintosh
equipped with a MC68020 or better. All machines not equipped with such a
processor will not be able to execute code produced by MPW Oberon. To ensure
compatibility with as many models as possible you should rely on the SANE package
for floating-point operations, because not all models of the Macintosh are
equipped with a FPU.
Use the -mc68881 option for programs which do a lot of computation involving floating-point numbers. If this option is given to the compiler, it will not generate call to the SANE package but generate opcodes of the MC68881. A large number of transcendental functions is provided by the FPU which can be used with MPW Oberon. See "Arithmetic procedures and functions" for a list of arithmetic functions provided by MPW Oberon.
Note: Some transcendental functions implemented in the SANE package are slightly more accurate that their counterparts provided by the FPU. MPW Oberon is designed for maximum speed, so it will generate direct call for the FPU.
Warning: The type LONGREAL occupies 10 bytes if code for SANE is generated and 12 bytes if code for the MC68881 is generated. Keep this in mind if you want to read files containing binary floating-point numbers.