[Rubycocoa-devel 870] trunk news

Back to archive index

Laurent Sansonetti lsans****@apple*****
Fri May 11 00:03:32 JST 2007


Hi guys,

It has been a long time since we discussed on the list. I managed to  
work a bit on the trunk, and here are some information regarding the  
latest changes.

1/ BridgeSupport

The bridge support files have finally been extracted from the  
RubyCocoa repository and a new project has been created on MacOSForge.  
The homepage is:

http://trac.macosforge.org/projects/bridgesupport/

A shortcut has been created in RubyCocoa trunk, misc/bridgesupport,  
which points to the MacOSForge trunk. When doing install.rb config,  
the files will be generated as usual.

The bridge support files will be copied inside RubyCocoa.framework  
during the setup phase (in Resources/BridgeSupport).

The config phase "bridge-support" argument has been removed, it is no  
longer possible to specify the directory where the files will be  
installed, it will always be inside the framework.

When building RubyCocoa with these new changes, make sure you do not  
have /Library/Bridgesupport (remove it if necessary), and start from a  
clean context (do: ruby install.rb clean).

2/ PropertyList API

I introduced some new APIs to manage Apple property lists in an easier  
way than dealing directly with the Foundation classes.

#to_plist(format=nil)

This method converts the given object to a property list data string.  
By default the format is XML, but you can chose either old-OpenStep or  
binary format (using the NSPropertyListOpenStepFormat and  
NSPropertyListBinaryFormat_v1_0 constants).

This method is added to the following classes: [Array, Hash, String,  
Numeric, TrueClass, FalseClass, Time]

OSX.load_plist(data)

This method deserializes a given property list data (of any format)  
and returns an appropriate Cocoa object. The method doesn't convert  
the Cocoa objects to native Ruby objects, but it could for some of the  
types (like numeric, booleans or dates).

3/ ObjcPtr#assign and ObjcPtr#[]=

I introduced those methods so that you can now assign a value to a  
given ObjcPtr instance (#assign is for a regular assignment while #[]=  
can let you assign at a specific offset). This could be used when for  
example you override in a subclass a method that returns objects by  
reference.

   def actionOnObject_error(object, errorPtr)
     ...
     if problem
       errorPtr.assign(NSError.alloc.init...)
       return false
     end
     ...
   end

Ideally when overriding such a method, you would like to omit  
declaring the errorPtr argument, and return it with the return value,  
in an Array.

   def actionOnObject_error(object)
     ...
     if problem
       return [false, NSError.alloc.init...]
     end
     ...
   end

But this support isn't implemented yet. So the interim solution is to  
use ObjcPtr#assign.

Enjoy,
Laurent




More information about the Rubycocoa-devel mailing list
Back to archive index