CP2ObjC :Cappuccino/Objective-C bridge client part

Posted: March 7, 2009 in IT/Dev
Tags: , , , , ,

Following Cappuccino/J2EE CP2JavaWS bridge, the client part of a Cappuccino/Objective-C bridge is available here. Parameters (call arguments and return) have been encoded/decoded in plist format (using CPKeyedArchiver/Unarchiver). For the server part (Objective-C), we could simply define a custom WORequestHandler for example (if using WebObjects) : in the handleRequest method we just have to extract call parameters from the WORequest, decode them (using NSKeyedUnarchiver corresponding class), and then invoke the Objective-C service whose name (interface/protocol) has been provided (also method name).
We could also encode the whole CPInvocation object (see OBJRPCClient/Server from Tom Robinson – the server part however is made in Objective-J, and is accessed through Jack), but we still have to check if _CPKeyedArchiverEncodeObject function in CPKeyedArchiver is compatible with NSKeyedUnarchive, as it wraps javascript primitive values into _CPKeyedArchiverValue.

Advertisements
Comments
  1. An updated CP2ObjC.zip archive is available (replaces the previous one). It now works correctly, except for CPDate arguments.
    I found that in CPObject, hash method returns __address field. But there isn’t such field in CPDate. And in CPKeyedArchiver code, CPDate are considered as objects (they own an isa field), but then there is an error when the _CPKeyedArchiverEncodeObject function tries to call var hash = objj_msgSend(anObject, “hash”),
    –> jumps (doesn’t follow remaining breakpoints) and displays “ReferenceError: Can’t find variable: __address”
    It took me time to find out that 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s