[#28561] Ruby::DL vs Ruby::FFI — Aston <blackapache512-ticket@...>

Ruby.DL and FFI libraries are great for programmers like me who are not internet programmers, but are more interested in scientific and number processing etc.

11 messages 2010/03/08

[#28686] trunk (26947) build fail with msys/mingw/vista — Jon <jon.forums@...>

I get the following build failure when msysgit's "c:\git\cmd" dir is on PATH.

8 messages 2010/03/16

[#28687] [Bug #2973] rb_bug - Segmentation fault - error.c:213 — rudolf gavlas <redmine@...>

Bug #2973: rb_bug - Segmentation fault - error.c:213

10 messages 2010/03/16

[#28735] [Bug #2982] Ruby tries to link with both openssl and readline — Lucas Nussbaum <redmine@...>

Bug #2982: Ruby tries to link with both openssl and readline

16 messages 2010/03/18

[#28736] [Bug #2983] Ruby (GPLv2 only) tries to link to with readline (now GPLv3) — Lucas Nussbaum <redmine@...>

Bug #2983: Ruby (GPLv2 only) tries to link to with readline (now GPLv3)

10 messages 2010/03/18

[#28907] [Bug #3000] Open SSL Segfaults — Christian Höltje <redmine@...>

Bug #3000: Open SSL Segfaults

19 messages 2010/03/23

[#28924] [Bug #3005] Ruby core dump - [BUG] rb_sys_fail() - errno == 0 — Sebastian YEPES <redmine@...>

Bug #3005: Ruby core dump - [BUG] rb_sys_fail() - errno == 0

10 messages 2010/03/24

[#28954] [Feature #3010] slow require gems in ruby 1.9.1 — Miao Jiang <redmine@...>

Feature #3010: slow require gems in ruby 1.9.1

15 messages 2010/03/24

[#29179] [Bug #3071] Convert rubygems and rdoc to use psych — Aaron Patterson <redmine@...>

Bug #3071: Convert rubygems and rdoc to use psych

10 messages 2010/03/31

[ruby-core:28700] Re: [Feature #1400] Please add a method to enumerate fields in OpenStruct

From: "Andrew Choi" <achoi@...>
Date: 2010-03-16 21:12:58 UTC
List: ruby-core #28700
unsubscribe




-----Original Message-----
From: "Dan Rathbun" [redmine@ruby-lang.org]
Date: 03/16/2010 04:39 PM
To: ruby-core@ruby-lang.org
Subject: Re: [ruby-core:28699] [Feature #1400] Please add a method to enumerate fields in OpenStruct

Note: Original message sent as attachment

------------------------------------------------------------
Home Improvement Projects
Click here to find experienced pros to help with your home improvement project.
http://216.21.215.31/c?cp=QDUzL5DtxXzfSbgdUgxN8wAAKZVY5T0TJO72Jl_bl7CO2arfAAYAAAAAAAAAAAAAAAAAAADNAAAAAAAAAAAAAAAAAAAShK6NZeY=
--1912791164-1268773977=:23085
Content-transfer-encoding: quoted-printable
Content-Type: text/html; charset=UTF-8

unsubscribe<br>
<br>
<br>
<br>
<br>
-----Original Message-----<br>
From: &quot;Dan Rathbun&quot; [redmine@ruby-lang.org]<br>
Date: 03/16/2010 04:39 PM<br>
To: ruby-core@ruby-lang.org<br>
Subject: Re: [ruby-core:28699] [Feature #1400] Please add a method to enumer=
ate fields in OpenStruct<br>
<br>
Note: Original message sent as attachment<hr style=3D" border: 0px; border-t=
op: thin solid grey; margin-top: 15px; padding-top: 5px;"><TABLE height=3D58=
 width=3D500 cellborder=3D0 cellpadding=3D0 cellspacing=3D0 border=3D0  =

      =

    style=3Dcursor:pointer; > =

<TR> =

   =

  <TD valign=3Dcenter> =

     =

    <TABLE cellborder=3D0 cellpadding=3D0 cellspacing=3D0 border=3D0> =

      <TR> =

        <TD rowspan=3D3>&nbsp;&nbsp;</TD> =

        <TD><SPAN><a href=3D"http://216.21.215.31/c?cp=3DQDUzL5DtxXzfSbgdUgx=
N8wAAKZVY5T0TJO72Jl_bl7CO2arfAAYAAAAAAAAAAAAAAAAAAADNAAAAAAAAAAAAAAAAAAAShK6=
NZeY=3D" target=3D"_blank" style=3Dtext-decoration:underline;font-size:12pt;=
font-family:Arial;color:green;cursor:pointer;>Home Improvement Projects</a><=
/SPAN></TD> =

      </TR> =

      <TR> =

        <TD><SPAN><a href=3D"http://216.21.215.31/c?cp=3DQDUzL5DtxXzfSbgdUgx=
N8wAAKZVY5T0TJO72Jl_bl7CO2arfAAYAAAAAAAAAAAAAAAAAAADNAAAAAAAAAAAAAAAAAAAShK6=
NZeY=3D" target=3D"_blank" style=3Dtext-decoration:none;font-size:8pt;font-f=
amily:Arial;color:black;cursor:pointer;>Click here to find experienced pros =
to help with your home improvement project.</a></SPAN></TD> =

      </TR> =

      <TR> =

        <TD><SPAN><a href=3D"http://216.21.215.31/c?cp=3DQDUzL5DtxXzfSbgdUgx=
N8wAAKZVY5T0TJO72Jl_bl7CO2arfAAYAAAAAAAAAAAAAAAAAAADNAAAAAAAAAAAAAAAAAAAShK6=
NZeY=3D" target=3D"_blank" style=3Dtext-decoration:underline;font-size:8pt;f=
ont-family:Arial;color:#FD0000;cursor:pointer;>Click Here For More Informati=
on</a></SPAN></TD> =

      </TR> =

    </TABLE> =

  </TD> =

</TR> =

<TR> =

  <TD colspan=3D2>&nbsp;</TD> =

</TR> =

</TABLE>
--1912791164-1268773977=:23085--

--1913079234-1268773977=:23085
Content-Type: message/rfc822; charset=UTF-8; name="0riginal_message"
Content-Disposition: attachment; filename="0riginal_message"
x-btFieldFwd: Yes

Return-Path: <ruby-core-admin@ruby-lang.org>
X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on
	aspam007.roc2.bluetie.com
X-Spam-Level: 
X-Spam-Status: No, score=0.1 required=5.0 tests=RDNS_NONE autolearn=disabled
	version=3.2.5
X-Original-To: achoi.myway@masc011.roc2.bluetie.com
Delivered-To: achoi.myway@masc011.roc2.bluetie.com
Received: from inbound005.roc2.bluetie.com (btroc2-lb.roc2.bluetie.com [10.200.2.8])
	by mas000.roc2.bluetie.com (Postfix) with ESMTP id 58688D60121
	for <achoi.myway@masc011.roc2.bluetie.com>; Tue, 16 Mar 2010 16:39:37 -0400 (EDT)
Received: from carbon.ruby-lang.org ([221.186.184.68])
	by inbound005.roc2.bluetie.com with inbound005
	id twfY1d00Y1UxlsV01wfZvk; Tue, 16 Mar 2010 16:39:35 -0400
X-CMAE-Category: X-CMAE-Score: 0.00
X-CMAE-Analysis: v=1.1 cv=RpqRin20EikNPFC0NhhZyb7qtlqqDp4huBytcwwpogY= c=1
 sm=1 a=ArQbOOmHeV8A:10 a=ICSgjsODHzIA:10 a=IkcTkHD0fZMA:10
 a=fsK9XiHaSW3i/zTWbPYSMA==:17 a=w2PP7KgtAAAA:8 a=n_fk8HZggZt73Jy_5SkA:9
 a=nCiXqMp3NW-viTWGPe0A:7 a=yVpoqy3WzZe-EXTlJ8zh8IQGiRMA:4 a=QEXdDO2ut3YA:10
 a=Gq-bTBa4UauwmX4M:21 a=0YMPf0GKTFsJXbk3:21 a=fsK9XiHaSW3i/zTWbPYSMA==:117
Received: from beryllium.ruby-lang.org (beryllium.ruby-lang.org [127.0.0.1])
	by carbon.ruby-lang.org (Postfix) with ESMTP id 7F5163C227284;
	Wed, 17 Mar 2010 05:39:25 +0900 (JST)
Received: from svn.ruby-lang.org (svn.ruby-lang.org [210.251.121.215])
	by carbon.ruby-lang.org (Postfix) with ESMTP id 6E7C03C21EB88
	for <ruby-core@ruby-lang.org>; Wed, 17 Mar 2010 05:39:20 +0900 (JST)
Received: from ruby-lang.org (localhost [127.0.0.1])
	by svn.ruby-lang.org (8.13.8+Sun/8.13.8) with ESMTP id o2GKdKEn023711
	for <ruby-core@ruby-lang.org>; Wed, 17 Mar 2010 05:39:20 +0900 (JST)
Delivered-To: ruby-core@ruby-lang.org
Date: Wed, 17 Mar 2010 05:39:20 +0900
Posted: Wed, 17 Mar 2010 05:39:20 +0900
From: Dan Rathbun <redmine@ruby-lang.org>
Reply-To: ruby-core@ruby-lang.org
Subject: [ruby-core:28699] [Feature #1400] Please add a method to enumerate fields in OpenStruct
To: ruby-core@ruby-lang.org
Message-Id: <4b9fec7854f4b_999c76fc303843@redmine.ruby-lang.org>
X-ML-Name: ruby-core
X-Mail-Count: 28699
X-MLServer: fml [fml 4.0.3 release (20011202/4.0.3)]; post only (only members can post)
X-ML-Info: If you have a question, send e-mail with the body
	"help" (without quotes) to the address ruby-core-ctl@ruby-lang.org;
	help=<mailto:ruby-core-ctl@ruby-lang.org?body=help>
X-Mailer: Redmine
X-Redmine-Issue-Author: tpo
X-Redmine-Issue-Id: 1400
X-Redmine-Journal-Id: 9022
X-Redmine-Project: ruby
X-Redmine-Site: Ruby Issue Tracking System
X-Redmine-Host: redmine.ruby-lang.org
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Precedence: bulk
Lines: 32
List-Id: ruby-core.ruby-lang.org
List-Software: fml [fml 4.0.3 release (20011202/4.0.3)]
List-Post: <mailto:ruby-core@ruby-lang.org>
List-Owner: <mailto:ruby-core-admin@ruby-lang.org>
List-Help: <mailto:ruby-core-ctl@ruby-lang.org?body=help>
List-Unsubscribe: <mailto:ruby-core-ctl@ruby-lang.org?body=unsubscribe>
X-BtMT: Tue, 16 Mar 2010 16:39:37 -0400 (EDT)

Issue #1400 has been updated by Dan Rathbun.


This can be done right now. In several ways.
# obj is an class OpenStruct which some number of members.
ary = obj.methods(false).sort -> Array of attr getters and setters
keys=[]
ary.each {|i| keys.push(i) unless i.include?('=') }
# keys is now an Array of fieldnames

Also using existing method .marshal_dump which is really an attribute getter for @table (having a name different than the attribute.)
Just noticed .table as a attribute getter alias of .marshal_dump, BUT .table is set protected, while .marshal_dump is not?
Why is THAT?

# obj is an class OpenStruct which some number of members.
obj.marshal_dump.keys -> Array of keys
obj.marshal_dump.values -> Array of values
obj.marshal_dump.each {|k,v| ... }

The danger in accessing the Hash directly is someone's going to modify it without removing the attr getter and setter methods defined in the class instance. Which by the way is a bug in the current OpenStruct. It's delete_field method does just that, lea
ving the accessor methods without a key/value pair in @table.

There is also an opposite bug. IF an attempt is made, to create a field who's name is already used as a method (without the '='); new_ostruct_member does NOT create the accessor methods, BUT does NOT return a indicator of success, so method_missing just 
goes ahead and adds the field to @table.
Ex:
obj.inspect='Sherlock Holmes'
The unless block (line 72) in new_ostruct_member needs an else clause thats raises a NameError Exception "#{name} is already in use as a method of #{self}."

Additionally, .marshal_load is flawed. It wipes out @table instead of appending; and puts everything in @table before checking it. The arg x should be typechecked as an OpenStruct or Hash; it should be put first in a temp reference. Looks like another ar
gument may be needed for overwrite/ignore of matching keys.
----------------------------------------
http://redmine.ruby-lang.org/issues/show/1400

----------------------------------------
http://redmine.ruby-lang.org

AdGFib
--1913079234-1268773977=:23085--

In This Thread

Prev Next