home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Snippets / MyGestaltValue / MyGestaltValue.h < prev    next >
Encoding:
Text File  |  1994-11-11  |  1.4 KB  |  22 lines  |  [TEXT/MMCC]

  1. // This code was written by François Pottier (pottier@dmi.ens.fr). You can use it freely.
  2. // Please let me know if you find bugs in it or improve on it.
  3.  
  4. // Lots of extensions need to install a custom Gestalt selector in order to access their globals. The recommended way to do
  5. // it is to use Apple's GestaltValue library. It's better because GestaltValue installs a trap whose code is then used by all
  6. // GestaltValue-aware extensions, thus saving memory.
  7. // But there is a catch : GestaltValue is only available as a MPW .o file, and when CodeWarrior converts this file into a
  8. // CodeWarrior library file, it reorders the routines inside it. The GestaltValue are written in such a way that they break
  9. // when reordered (yech!). Bottom line : we can't use GestaltValue with CodeWarrior.
  10.  
  11. // By the way, note that all these problems arise only on 68k macs. On a PowerPC writing a custom Gestalt selector is trivial
  12. // since all fragments have globals automatically.
  13.  
  14. // The routine below is a replacement for GestaltValue's NewGestaltValue routine. It assumes the presence of the 'GSel' 0
  15. // resource (which can be built using the Selector.µ project).
  16. // It works in a simple (and dirty) way : it loads the 'GSel' 0 resource, which contains the selector's code, pokes the desired
  17. // value into it and then installs it as a Gestalt selector. On a 040 the caches are flushed for safety.
  18.  
  19. #pragma once
  20.  
  21. OSErr InstallGestaltValue (OSType signature, long value);
  22.