Subject: Re: [ruby-ffi] Re: struct questions |
From: Shawn Anderson |
Date: 12/20/09 9:12 AM |
To: ruby-ffi@googlegroups.com |
2009/12/20 rogerdpack <rogerpack2005@gmail.com>:
> When I first started using FFI::Struct'sI considered this at one point, but it leads to name clashes with
>
> I anticipated being able to call methods, like
> a = Struct.new
> a.name = "hello there"
>
> (since that's how you access them in C, and they are certainly not
> hashes). Would a patch for such be acceptable?
other methods you might want to call on a Struct instance - so you
have a namespace issue.
layout :size, :int
e.g.
class S < FFI::Struct
end
s = S.new
What does s.size return? The size of the struct, or the contents of
the native field called size?
Using the [] method to access struct fields neatly avoids it.
If you really want it, ffi-swig-generator generates accessor methods
like that for every field, but it should not be a part of ffi itself.