rubymotion-community / motion-support

Commonly useful extensions to the standard library for RubyMotion
MIT License
132 stars 28 forks source link

Allow block to be specified for cattr_reader, also add default param #49

Open eamonn-webster opened 7 months ago

eamonn-webster commented 7 months ago

My use case is to a reader only class attribute, but then I must be able to specify the initial value with a block or via default:

eamonn-webster commented 7 months ago

@andrewhavens / @wndxlori: the existing specs fail locally for me, something appears broken in the Duration code implementing 2.days.ago. I don't use that code, I'll try to take a look when I get a chance.

wndxlori commented 7 months ago

@andrewhavens / @wndxlori: the existing specs fail locally for me, something appears broken in the Duration code implementing 2.days.ago. I don't use that code, I'll try to take a look when I get a chance.

I seem to remember getting stuck on that issue the last time I was attempting a fix in here. Thanks if you can figure it out!

eamonn-webster commented 7 months ago

@wndxlori I can fix it by making Duration an ordinary class, i.e. drop the inherit from BasicObject. But I have no idea why it is failing. I guess that's a question for @amirrajan

wndxlori commented 7 months ago

@wndxlori I can fix it by making Duration an ordinary class, i.e. drop the inherit from BasicObject. But I have no idea why it is failing. I guess that's a question for @amirrajan

I'm on board with that. If the specs run, let's :shipit:

eamonn-webster commented 7 months ago

This is the error when MotionSupport::Duration inherits from BasicObject

Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   <translation info unavailable>         0x100ee045c ???
1   CoreFoundation                         0x109c798ed __methodDescriptionForSelector + 75
2   CoreFoundation                         0x109c79a5a -[NSObject(NSObject) methodSignatureForSelector:] + 30
3   MotionSupport                          0x10040d960 rb_objc_supports_forwarding + 48
4   MotionSupport                          0x1004290e9 rb_vm_dispatch + 1273
5   MotionSupport                          0x100380d8a coerce_body + 202
6   MotionSupport                          0x10044eca1 rb_rescue2 + 113
7   MotionSupport                          0x100374498 rb_objc_num_coerce_bin + 72
8   MotionSupport                          0x10042a6e3 rb_vm_dispatch + 6899
9   MotionSupport                          0x1000c3abd vm_dispatch + 1325
10  MotionSupport                          0x1000c44ab vm_fast_mult + 795
11  MotionSupport                          0x1000c6625 rb_scope__days__ + 149 (time.rb:46)