File: programming/cocoa/MachoCFM.zip/MachoCFM/MachOCFMGlue.c


/* =============================================================================
	PROJECT:	Cubix (PB1)
	FILE:		MachOCFMGlue.c
	
    PURPOSE:	Code that does the magic needed to call MachO functions
				from CFM and CFM functions from Carbon.
    
    COPYRIGHT:	Copyright (c) 2002 by M. Uli Kusterer, all rights reserved.
				Thanks to George Warner, Chris Silverberg and Ricky Sharp for
				clues on how to do this and implementation snippets.
    
    REVISIONS:
        Fri Jul 26 2002	witness	Created.
   ========================================================================== */
 
/* -----------------------------------------------------------------------------
    Headers:
   -------------------------------------------------------------------------- */
 
#include <Carbon/Carbon.h>
#include "MachOCFMGlue.h"
 
 
/* -----------------------------------------------------------------------------
    Globals:
   -------------------------------------------------------------------------- *//* -----------------------------------------------------------------------------
    CFMFunctionPointerForMachOFunctionPointer:
        Creates a fake Transition Vector that lets a CFM code fragment call a
		MachO function.
		
	TAKES:
		machOFP	-	ProcPtr to the MachO function you want to make CFM-callable.
	
	GIVeS:
		void*	-	Pointer to the transition vector to pass to the CFM fragment
					as the ProcPtr. When you're done with this, dispose of it
					using DisposeCFMFunctionPointer().
    
    REVISIONS:
        Fri Jul 26 2002	witness	Created.
   -------------------------------------------------------------------------- */// ignored
/* -----------------------------------------------------------------------------
    DisposeCFMFunctionPointer:
        Disposes of the fake TVector created by
		CFMFunctionPointerForMachOFunctionPointer().
		
    REVISIONS:
        Fri Jul 26 2002	witness	Created.
   -------------------------------------------------------------------------- *//* -----------------------------------------------------------------------------
    MachOFunctionPointerForCFMFunctionPointer:
       This function allocates a block of CFM glue code which contains the
	   instructions to call a CFM routine from a MachO application.
	   
	   Syntax analogous to CFMFunctionPointerForMachOFunctionPointer().
		
    REVISIONS:
        Fri Jul 26 2002	witness	Created.
   -------------------------------------------------------------------------- */// sizeof() really returns the data size here, not the size of a pointer. Trust me.
/* -----------------------------------------------------------------------------
    DisposeMachOFunctionPointer:
        Disposes of the fake TVector created by
		CFMFunctionPointerForMachOFunctionPointer().
		
    REVISIONS:
        Fri Jul 26 2002	witness	Created.
   -------------------------------------------------------------------------- */

This code uses the PclZip Zip File reading code, which is subject to the GNU LGPL. It also uses the GeSHi syntax highlighter, subject to the GPL. Ask if you want this for your own web site, it's free.