Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Newbie can't make scripting addition

1 view
Skip to first unread message

Tony Green

unread,
Feb 25, 2002, 2:42:41 PM2/25/02
to
I've written a simple Scripting Addition that I've tested inside a
host app and now I want to turn it into an actual osax. My intent was
to create a PPC code resource, so I have a Code Resource project with
these settings:
Linker: MacOS PPC Linker
Creator: ascr
Type: osax
ResType: RSRC
PPC Linker -> Entry Points -> Initialization: blank
PPC Linker -> Entry Points -> Main: _main
PPC Linker -> Entry Points -> Termination: blank

I included the libraries mentioned in "Targeting Mac OS" for a PPC
resource.

When I choose Make I get "undefined '_main' (descriptor)"
I don't know what this means (newbie). My entry point is a function
called "main":

pascal OSErr main (const AppleEvent *theEvent,
AppleEvent *theReply, UInt32 refCon)

I'm not using any global variables.

Every example Scripting Addition I've seen involves a 68K code
resource, not PPC, so am I barking up the wrong tree with trying to
use PPC? The 68K examples start with EnterCodeResource(); I assume
there is something equivalent for a PPC resource, but don't know what.

I'm using CodeWarrior 6.2 on Mac OS 9.0.4.

Thanks for any help!

Tony Green

meeroh

unread,
Feb 25, 2002, 7:59:14 PM2/25/02
to
In article <1b24e45f.02022...@posting.google.com>,
tony...@mac.com (Tony Green) wrote:

>PPC Linker -> Entry Points -> Initialization: blank
>PPC Linker -> Entry Points -> Main: _main
>PPC Linker -> Entry Points -> Termination: blank

Should be __initialize, main, __terminate

hth

meeroh
--
Hire me: <http://meeroh.org/hire.html>

Tony Green

unread,
Mar 7, 2002, 3:14:58 PM3/7/02
to
meeroh <mac...@meeroh.org> wrote in message news:<macdev-8B2AD4....@senator-bedfellow.mit.edu>...

> In article <1b24e45f.02022...@posting.google.com>,
> tony...@mac.com (Tony Green) wrote:
>
> >PPC Linker -> Entry Points -> Initialization: blank
> >PPC Linker -> Entry Points -> Main: _main
> >PPC Linker -> Entry Points -> Termination: blank
>
> Should be __initialize, main, __terminate
>
> hth
>
> meeroh

Thanks, meeroh, but I still had trouble. With those settings, I got:

"code resource must not have a termination entry-point"

Removing __terminate allowed compile to finish, but the scripting
addition didn't work. Sigh.

Then I discovered Tech Note TN1164, "Native Scripting Additions,"
which explains how to do this. I learned that a native osax is a
shared library, not a code resource, and there is no "Main" entry
point. You write a function that first calls __initialize, passing it
a pointer to a CFragInitBlock. Obtain a AEEventHandlerUPP by calling
NewAEEventHandlerUPP, passing your event handler's name. Then load
your event handler(s) using AEInstallEventHandler. Put this function's
name in PPC Linker -> Entry Points -> Initialization. Write a function
that cleans things up--in this case call AERemoveEventHandler,
DisposeAEEventHandlerUPP, and __terminate() at the end of your
function. Put the function's name in PPC Linker -> Entry Points ->
Termination. This worked fine.

For anyone who's interested, see
<http://developer.apple.com/technotes/tn/tn1164.html>
Also see <http://www.eagrant.com/UniversalOSAX.sit> for Eric Grant's
CodeWarrior post-linker plugin that can create a universal osax that
runs on 68K and PPC from System 7 to OS 10.1. I didn't use the plugin,
but the package includes the source of Marco Piovanelli's "AppleScript
Formatting" osax, which I was able to use as an example. Check out the
Carbon target.

Tony Green

0 new messages