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

Back to archive index

Satoshi Nakagawa snaka****@infot*****
Fri Jun 29 20:30:57 JST 2007


Hi.

As I reported in rubycocoa:0434,
BOOL type conversions for informal protocol methods seem not to work well.

I have done an overall testing for the BridgeSupport type conversions
around boolean values.

You can see the result at:

  http://limechat.net/rubycocoa/bridge_test.html

Kimura-san's test cases are for the cases of:

  - Ruby to Obj-C convertion (control_textView_doCommandBySelector)
  - no objc_method informal protocol

on the results table.

It shows if you replace "B" for "C" of 'control:textView:doCommandBySelector:',
the conversion works normally (except a problem, 0 should be considered true).

--
Satoshi Nakagawa


On 2007/06/29, at 0:26, Laurent Sansonetti wrote:

> 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




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