[comp.sys.mac.programmer] THINK Pascal saving A4 for Objects in CODE resource

a_dent@vaxa.uwa.oz (03/28/90)

I am working on a Quickmail bridge which requires a CODE resource.
The THINK documentation says you can't use globals in CODE resources but it
would be LOTS easier to write if I could use Object Pascal.  Am I correct in
assuming that Object Pascal can be used if you can save and restore A4?

Noting that CODE resources use the same library (DRVRRuntime.lib) as drivers.

Reading between the lines, I think the only objection is that there isn't
anywhere to stash A4.  However, this particular environment maintains a 
globals resource for me so I could save and restore A4 there.

What are my chances of writing a routine to do this?  If I'm saving and         
restoring A4 before I use any globals or Object Pascal will that work and will
it continue to work under version 3.0?


Andy Dent                     A.D. Software phone 09 249 2719
Mac & VAX programmer          94 Bermuda Dve, Ballajura
a_dent@vaxa.uwa.oz            Western Australia  6066
Please note I am no longer associated with Schox Corporation!

siegel@endor.harvard.edu (Rich Siegel) (03/29/90)

In article <1645.2610e886@vaxa.uwa.oz> a_dent@vaxa.uwa.oz writes:
>I am working on a Quickmail bridge which requires a CODE resource.
>The THINK documentation says you can't use globals in CODE resources but it
>would be LOTS easier to write if I could use Object Pascal.  Am I correct in
>assuming that Object Pascal can be used if you can save and restore A4?

	Right now, you can't write code resources in Object Pascal, because
you need a jump table to support the method dispatches, and no mechanism is
supported for the jump table at this time.

R.


~~~~~~~~~~~~~~~
 Rich Siegel
 Staff Software Developer
 Symantec Corporation, Language Products Group
 Internet: siegel@endor.harvard.edu
 UUCP: ..harvard!endor!siegel

"When someone who makes four hundred and fifty dollars an hour wants to
tell you something for free, it's a good idea to listen."

~~~~~~~~~~~~~~~

a_dent@vaxa.uwa.oz (03/29/90)

In article <2377@husc6.harvard.edu>, siegel@endor.harvard.edu (Rich Siegel) writes:
> In article <1645.2610e886@vaxa.uwa.oz> a_dent@vaxa.uwa.oz (ME) writes:
>>I am working on a Quickmail bridge which requires a CODE resource.
>>The THINK documentation says you can't use globals in CODE resources but it
>>would be LOTS easier to write if I could use Object Pascal.  Am I correct in
>>assuming that Object Pascal can be used if you can save and restore A4?
> 
> 	Right now, you can't write code resources in Object Pascal, because
> you need a jump table to support the method dispatches, and no mechanism is
> supported for the jump table at this time.
> 
WOW - thanks for the speed of response.  I'm still not entirely convinced that
I can't hack a way round this.  On page 131 of the manual it states that 
"If your driver uses Object Pascal, you must check the Multi-segment option..."

So, your driver glue somehow can fake having a jump table (that's also why
multiple segments work, for those who were wondering).  Now, in this Quickmail
environment, I CAN have other resources providing their numbering corresponds
to a base address from the CODE resource.  

Is there any way I can actually compile a DRIVER and then hack it?  How secret
is your driver glue and particularly the bits setting up the jump table?  I'm
prepared to dissassemble code if I have to but don't want to write a commercial
product that violates any patents or stuff. 

Andy Dent                     A.D. Software phone 09 249 2719
Mac & VAX programmer          94 Bermuda Dve, Ballajura
a_dent@vaxa.uwa.oz            Western Australia  6066