Carbonizing
Pascal Programs
Ken
Beath, Shareware
Author
Carbonizing Pascal
Programs
11-17-00
With Mac OS X, the big question for Pascal programmers writing code for the Mac is whether our Pascal applications can be ported to OS X so that they will run native. This process is known as Carbonizing your app, and there have been a few posts to the MacPascal mailing list outlining the steps for doing this using CodeWarrior Pascal. The most detailed list of instructions to date was offered by Ken Beath, and those steps are outlined below. In addition to these steps, Ken also included a CarbonStuff unit that you can use with your programs to support old toolbox calls.
Metrowerks has announced that work has begun on the final update for CodeWarrior Pascal which should streamline the process of carbonizing your Pascal programs, but there is no clear picture yet as to exactly what will be released. If you have success carbonizing your Pascal apps, please consider contributing your tales of success to the Pascal community so that we can all learn from your experience. I'm also looking for source code submissions of sample projects which have been carbonized. To contact me or submit source code, visit the Pascal Central Submit page.
I obtained a replacement for
MSL C.PPC.Lib from CW Pro 5. From the CW Pro 5 Reference folder Pre-Release:Carbon
& MacOS X Development:Carbonized MSL, copy the appropriate files into the Bin
folder in MSL. I just copied the LIBS. Change MSL C.PPC.Lib to MSL C.Carbon.Lib in
your project. In Ishandle, I have replaced
the {$setc
TARGET_API_MAC_CARBON := true}
{$setc CALL_NOT_IN_CARBON := false}
There are several new things in the Universal Interfaces which may also have to be
defined (especially if using CarbonLib 3.4). I've found that the following switches
work
{$setc
TYPED_FUNCTION_POINTERS := false}
{$setc GENERATINGCFM := true}
{$setc PM_USE_SESSION_APIS := false}
{$setc OPAQUE_UPP_TYPES := false}
I didn't replace MSL RuntimePPC.Lib as replacing it with the only thing that looked
sensible from CW Pro 5 gave me a link error.
I didn't need SIOUX so I replaced it with console.stubs.c.
I have been using the old Pascal.PPC.Lib (making this fully Carbon seems messy and
for most people unneccessary). This uses some old names so I set up routines which
call the correct names. Just link and fix up the undefineds.
EXAMPLE:
{$ifc TARGET_API_MAC_CARBON}
PROCEDURE IUDatePString(dateTime: LONGINT;
longFlag: ByteParameter;
VAR result: Str255;
intlHandle: Handle);
begin
DateString(dateTime, longFlag, result,intlHandle);
end;
{$endc}
You will get some previously
defined messages but as long as the message is ignored in Pascal.PPC.Lib this is
OK. Otherwise, changing the build order should work.
if
HandleZone(h) <> LMGetApplZone then
section with an isHandle
:= true;.