JSCocoa

Creates a bridge between Cocoa to JavascriptCore.
Download

JSCocoa Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Freeware
  • Price:
  • FREE
  • Publisher Name:
  • Inexdo
  • Publisher web site:
  • http://inexdo.com/
  • Operating Systems:
  • Mac OS X 10.5.5 or later
  • File Size:
  • 1.3 MB

JSCocoa Tags


JSCocoa Description

Creates a bridge between Cocoa to JavascriptCore. JSCocoa bridges Cocoa to JavascriptCore (WebKit's JS engine). It allows you to call C code, ObjC code, use C structs, and build Javascript classes inheriting from ObjC classes.Here are some key features of "JSCocoa":Everywhere dot· Just like in Ruby, call functions with or without parentheses. object.a().b().c() becomes object.a.b.c· Cocoa - NSString* appName = activeApplication] valueForKey:@"NSApplicationName"];· JSCocoa - var appName = NSWorkspace.sharedWorkspace.activeApplication.NSApplicationNameInstance· Tired of the alloc/init dance ? Use instance to get an object allocated, inited, and retained by Javascript's Garbage Collector· Cocoa - initWithFrame:NSMakeRect(0, 0, 100, 40)]; Need to when done· JSCocoa - NSButton.alloc.initWithFrame(NSMakeRect(0, 0, 100, 40)) Need to release() when done· NSButton.instance({ withFrame:NSMakeRect(0, 0, 100, 40) }) Handled by Javascript's GCGet/Set· Instead of calling setVariable(newValue), use Javascript's setter syntax : object.variable = newValue· Cocoa - NSString* title = ; ;· JSCocoa - var title = window.title window.title = 'Hello !'Call· Use a jQuery-like syntax to call multiple parameter methods· Cocoa - ;· JSCocoa - obj.call({ withParam1:'Hello', andParam2:'World' }); obj('Hello', 'World'); obj.callWithParam1_andParam2('Hello', 'World' ) Derive· A hash will define classes in one go, but you can add methods anytime after· Cocoa - In .h @interface MyButton : NSButton { IBOutlet NSButton* myOutlet; } - (IBAction)myAction:(id)sender; @end In .m @implementation MyButton - (IBAction)myAction:(id)sender { ... } @end· JSCocoa - defineClass('MyButton < NSButton', { myOutlet : 'IBOutlet' ,myAction : }) Shorthand Overload· A quick way to overload methods : define a new class, use NSClass = fn to overload methods like drawRect:· To call the parent method, one single syntax : this.Super(arguments) — no need to rewrite the method name !· JSCocoa - MyButtonClass = function(rect) { // super call this.Super(arguments) // Add some custom drawing ... } Integrate in Interface Builder· There's a catch here! JSCocoa works with NIBs, but you'll need to manually add IBOutlets and IBActions while creating your interface. In case you have wondered why there are - and + buttons in the Identity Inspector. What's New in This Release: · Initial release.


JSCocoa Related Software