A JavaScript to C/Cocoa bridge
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
FJSTestApp
fmjs.xcodeproj
fmjs
junk
tests
tool
.gitignore
LICENSE
README.md

README.md

FMJS

An incomplete and experimental JavaScript to C/Cocoa bridge

Code borrowed liberally from the Mocha project: https://github.com/logancollins/Mocha

Planned Conversions (not all implemented yet)

Bridging from C to JavaScript:

  • To JS String: NSString + subclasses, selectors, char pointers (_C_CHARPTR)
  • To JS Boolean: BOOL, bool
  • To JS Number: char, short, int, long, long long, float, double
  • To JS Object: NSObject, Class,

Not handled (yet?): Blocks, structs, out pointers

JavaScript to C:

If runtime information is available, we'll try and do the right conversions. If no runtime info is available, this is what will happen:

  • From JS String: NSString
  • From JS Boolean: BOOL
  • From JS Number: long (NSInteger)
  • From JS Objects NSDictionary?
  • From JS Null: nil
  • From JS Function: Not handled
  • From JS Undefined: Not handled

Notes

Q: Why is the framework called FMJS, but the class prefixes FJS?
A: I hate four letter prefixes, and having it "FJS" always makes me think it stands for "F'n JavaScript".

Random Todos:

Other Random Notes:

If /usr/bin/gen_bridge_metadata isn't working because it can't find @rpath/libclang.dylib, you can symlink it to /usr/local/lib/: sudo mkdir /usr/local/lib cd /usr/local/lib/ sudo ln -s /Library/Developer/CommandLineTools/usr/lib/libclang.dylib

gen_bridge_metadata -c '-lffi' ~/Projects/fmjs/fmjsTests/FJSSimpleTests.h

Code Usage

FMJS utilizes code and ideas from the following projects:

Files are marked appropriately when code it utilized in complete or near-complete duplicate from these awesome projects.