[Rubycocoa-devel 956] Re: suggestion: dup method of NSPoint, NSSize, NSPoint and NSRange

Back to archive index

kimura wataru kimur****@i*****
Wed Jun 6 00:07:23 JST 2007


like this, Laurent?

=== framework/src/ruby/osx/objc/oc_types.rb
==================================================================
--- framework/src/ruby/osx/objc/oc_types.rb	(revision 166)
+++ framework/src/ruby/osx/objc/oc_types.rb	(local)
@@ -37,3 +37,12 @@
   alias_method :old_to_a, :to_a # To remove a warning.
   def to_a; [origin.to_a, size.to_a]; end
 end
+
+class OSX::Boxed
+
+  def dup
+    values = self.class.fields.map {|sym| self.send(sym)}
+    self.class.new(*values)
+  end
+
+end

On Tue, 5 Jun 2007 08:02:24 -0700, Laurent Sansonetti wrote:
> Hi Satoshi-san,
> 
> Good suggestion. I will add a general OSX::Boxed#dup method. All boxed  
> structures inherit from OSX::Boxed.
> 
> Laurent
> 
> On Jun 5, 2007, at 7:30 AM, Satoshi Nakagawa wrote:
> 
>> Hi.
>> 
>> Currently when I wrote some drawing code, I often want to dup  
>> NSRect, NSSize and NSPoint.
>> 
-- 
kimura wataru




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