[Rubycocoa-devel 302] Re: message dispatch syntaxes

Back to archive index

Laurent Sansonetti lsans****@apple*****
Wed Jun 21 07:58:04 JST 2006


Hi,

We just discussed this topic Jonathan and I, and here are what we  
propose.

First, new public APIs:

	OSX.relaxed_syntax = true|false

This flag would enable or not the relaxed/friendly/cool syntaxes. It  
could be enabled according to a flag in the install.rb config phase,  
and the default could be true.

	OSX.register_syntax_mapper { |receiver, message, args | ... } # -> id
	OSX.unregister_syntax_mapper(id)

The first method would register a new mapper in the system, as a Proc  
object. The block will be called at runtime with the receiver object,  
message and arguments from the context. The block can return a  
selector value (a String), or nil if it cannot do the mapping.

The second method can be used to unregister a mapper, given its ID.  
The ID is returned by the first method.

Internally, mappers would just be added in an internal Array.

By default, we would propose 3 mappers:

	- one for removing the trailing '_' if necessary ;
	- one for the symbol/value... syntax
	- one for the inline Hash syntax

Additional mappers would be stacked in an Array.

#analyze_method would be modified to:

	- remove oc_ prefix and check predicate
	- consult additional mappers if OSX.relaxed_syntax is true
	- if mappers return nil (or OSX.relaxed_syntax is false), do the  
default mapper
	- return the translated selector

Ideas?

Cheers,
Laurent



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