[Rubycocoa-devel 1035] Re: BOOL type encoding coflict objc <=> bridgesupport?

Back to archive index

Laurent Sansonetti lsans****@apple*****
Fri Jun 29 00:26:31 JST 2007


It's surely a regression in RubyCocoa, but it's normal that the bridge  
support files mention 'B' instead of 'c'. gen_bridge_metadata  
automatically uses 'B' instead of 'c' for real boolean types (BOOL,  
bool, etc...) so that RubyCocoa can differentiate real booleans (BOOL)  
than char types. Because @encode(BOOL) == @encode(char).

I will investigate the regression nevertheless. Thanks for the report.

Laurent

On Jun 28, 2007, at 5:13 PM, kimura wataru wrote:

> Hi,
>
> I received a bug report [rubycocoa:0434](ja). This mail
> says an informal protocol method whose return type is BOOL
> do not works fine.
>
> I wrote a test code.
>
> ---
> require 'osx/cocoa'
> require 'test/unit'
>
> class MyClass < OSX::NSObject
>  attr_accessor :bool
>  def control_textView_doCommandBySelector(control, textView, sel)
>    return @bool
>  end
>  #objc_method 'control:textView:doCommandBySelector:', 'c@:@@:' # (1)
> end
>
> class TCBool < Test::Unit::TestCase
>  def test_informal_protocol
>    rcv = MyClass.alloc.init
>    rcv.bool = false
>    val = rcv.ocm_send(
>      'control:textView:doCommandBySelector:', nil,
>      nil, nil, '')
>    assert(!val) # fail on ppc Mac
>    rcv.bool = true
>    #$DEBUG = true
>    val = rcv.ocm_send(
>      'control:textView:doCommandBySelector:', nil,
>      nil, nil, '')
>    $DEBUG = false
>    assert(val)
>  end
>  def test_ruby
>    rcv = MyClass.alloc.init
>    rcv.bool = false
>    val = rcv.control_textView_doCommandBySelector(nil, nil, '')
>    assert(!val)
>    rcv.bool = true
>    val = rcv.control_textView_doCommandBySelector(nil, nil, '')
>    assert(val)
>  end
> end
> ---
>
> This code fails with RubyCocoa trunk(r1853) and MacOSX 10.4.8ppc.
> (succeeds on intel)
> * add invoking objc_method (1), then the all of tests were passed
> * edit AppKit.bridgesupport and modify the type encoding
>  "B20 at 0:4 at 8@12:16" -> "c20 at 0:4 at 8@12:16" ("B" -> "c"), then
>  the all of tests were passed
>
> I think the conflict of type encoding between objc-runtime and
> bridgesupport file causes this problem.
>
> ObjC BOOL is described as type encoding "c", not "B".
> "c" means signed char, and "B" means unsigned int.
>
> -- 
> kimura wataru
>
> _______________________________________________
> Rubycocoa-devel mailing list
> Rubyc****@lists*****
> http://lists.sourceforge.jp/mailman/listinfo/rubycocoa-devel




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