cocos2d / cocos2d-js__old__

cocos2d in JavaScript central repository
14 stars 9 forks source link

Add generic bindings for any Objective-C or Java API #53

Open ricardoquesada opened 11 years ago

ricardoquesada commented 11 years ago

Add a proxy object in JS that can call any object/methods from Objective-C and/or Java, with the ability call callbacks to JS. This can be done since Obective-C and Java have reflection.

eg:

var proxy = JSToObjectiveC.createProxy("FBConnect", "initWithArg1:arg2:arg3:",arg1, arg2, arg3 );
proxy.create(arg); // create is a method for FBConnect
// or
proxy.call("create", arg);

eg2 (with callbacks):

// The correct type of the arguments could be obtained by reflection
var proxy = JSToObjectiveC.createProxy("FBConnect", "initWithCallback:", myCallback);

 var myCallback = function() {
   // to be called from Objective-C
 }