parmanoir / libffi-iphone

libffi for the iPhone, including source code for simulator and device

This URL has Read+Write access

name age message
file LICENSE Sat Aug 29 21:28:54 -0700 2009 Initial commit [parmanoir]
file README.markdown Sat Aug 29 21:55:07 -0700 2009 Readme update [parmanoir]
file ffi-iphone.c Sat Aug 29 21:28:54 -0700 2009 Initial commit [parmanoir]
file ffi-iphone.h Sat Aug 29 21:28:54 -0700 2009 Initial commit [parmanoir]
file ffi-iphonesimulator.c Sat Aug 29 21:28:54 -0700 2009 Initial commit [parmanoir]
file ffi-iphonesimulator.h Sat Aug 29 21:28:54 -0700 2009 Initial commit [parmanoir]
file ffi.h Sat Aug 29 21:28:54 -0700 2009 Initial commit [parmanoir]
file ffi_common.h Sat Aug 29 21:28:54 -0700 2009 Initial commit [parmanoir]
file fficonfig.h Sat Aug 29 21:28:54 -0700 2009 Initial commit [parmanoir]
file ffitarget-iphone.h Sat Aug 29 21:28:54 -0700 2009 Initial commit [parmanoir]
file ffitarget-iphonesimulator.h Sat Aug 29 21:28:54 -0700 2009 Initial commit [parmanoir]
file ffitarget.h Sat Aug 29 21:28:54 -0700 2009 Initial commit [parmanoir]
file iphone-sysv.S Sat Aug 29 21:28:54 -0700 2009 Initial commit [parmanoir]
file iphonesimulator-darwin.S Sat Aug 29 21:28:54 -0700 2009 Initial commit [parmanoir]
file prep_cif.c Sat Aug 29 21:28:54 -0700 2009 Initial commit [parmanoir]
file raw_api.c Sat Aug 29 21:28:54 -0700 2009 Initial commit [parmanoir]
file types.c Sat Aug 29 21:28:54 -0700 2009 Initial commit [parmanoir]
README.markdown

libffi for the iPhone

libffi allows calling any C-function or ObjC method at runtime.

libffi-iphone is a stripped down version of libffi, tailored just for the iPhone. libffi-iphone includes source code for both the iPhone simulator and the iPhone itself.

Calling functions

Works just like libffi.

Creating ffi closures, new functions created and called at runtime

ffi closures don't work on the iPhone, as mprotect is disabled.

You can however retarget existing functions if you have a function pool. See Tim Burks' post about Nu's method pool, see JSCocoa's Burks Pool for another implementation.

To retarget an ObjC pool method, use the method's hidden _cmd argument (the current selector) and [self class]. This will tell you which method of which class is being called.

License

libffi-iphone uses libffi's license.

Hey

Problems, questions
Patrick Geiller
parmanoir@gmail.com