Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Automatic Struct Layout
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
rogerdpack  
View profile  
 More options Dec 17 2009, 6:41 pm
From: rogerdpack <rogerpack2...@gmail.com>
Date: Thu, 17 Dec 2009 15:41:28 -0800 (PST)
Local: Thurs, Dec 17 2009 6:41 pm
Subject: re: Automatic Struct Layout
Question.
Shouldn't ffi be calculating the offsets automagically for us, since
all that is distributed is ruby code, and "automatic struct layout"
thence not be necessary?  I would have expected that...
Thanks.
-r

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Wayne Meissner  
View profile  
 More options Dec 17 2009, 7:41 pm
From: Wayne Meissner <wmeiss...@gmail.com>
Date: Fri, 18 Dec 2009 10:41:39 +1000
Local: Thurs, Dec 17 2009 7:41 pm
Subject: Re: [ruby-ffi] re: Automatic Struct Layout
2009/12/18 rogerdpack <rogerpack2...@gmail.com>:

> Question.
> Shouldn't ffi be calculating the offsets automagically for us, since
> all that is distributed is ruby code, and "automatic struct layout"
> thence not be necessary?  I would have expected that...

It does, the wiki just hasn't been updated ... in about a year - so
feel free to fix it up.

Basically, to have FFI calculate offsets for you, you drop off the
offset out of the triplet.

i.e. instead of
class Foo < FFI::Struct
  layout :a, :long, 0, :b, :int, 4
end

You would use:
class Foo < FFI::Struct
  layout :a, :long, :b, :int
end

That will calculate the offset of :b automatically for you, and take
into account 32bit vs 64bit, minimum alignments, tail padding, etc.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jon  
View profile  
 More options Dec 18 2009, 9:13 am
From: Jon <jon.for...@gmail.com>
Date: Fri, 18 Dec 2009 09:13:48 -0500
Local: Fri, Dec 18 2009 9:13 am
Subject: Re: [ruby-ffi] re: Automatic Struct Layout
On Fri, 18 Dec 2009 10:41:39 +1000

We need a Struct wiki page similar to what jacius did for Enums anyway.

Is there any reason why Wayne shouldn't just delete the automatic struct layout page once the struct page exists?

Jon


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
rogerdpack  
View profile  
 More options Dec 18 2009, 1:04 pm
From: rogerdpack <rogerpack2...@gmail.com>
Date: Fri, 18 Dec 2009 10:04:05 -0800 (PST)
Local: Fri, Dec 18 2009 1:04 pm
Subject: Re: Automatic Struct Layout

> It does, the wiki just hasn't been updated ... in about a year - so
> feel free to fix it up.

Cool, thanks.

> That will calculate the offset of :b automatically for you, and take
> into account 32bit vs 64bit, minimum alignments, tail padding, etc.

Question
How does ffi deal with #pragma pack in msvc?

ex:
gc.c:#pragma pack(push, 1) /* magic for reducing sizeof(RVALUE): 24 ->
20 */
Just wondering.
Thanks.
-r


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Evan Phoenix  
View profile  
 More options Dec 18 2009, 1:13 pm
From: Evan Phoenix <e...@fallingsnow.net>
Date: Fri, 18 Dec 2009 10:13:01 -0800
Local: Fri, Dec 18 2009 1:13 pm
Subject: Re: [ruby-ffi] Re: Automatic Struct Layout

On Dec 18, 2009, at 10:04 AM, rogerdpack wrote:

>> It does, the wiki just hasn't been updated ... in about a year - so
>> feel free to fix it up.

> Cool, thanks.

>> That will calculate the offset of :b automatically for you, and take
>> into account 32bit vs 64bit, minimum alignments, tail padding, etc.

> Question
> How does ffi deal with #pragma pack in msvc?

It does not. It uses some basic rules that work in most cases. If these rules don't work for your struct, you need to specify the offsets manually.

 - Evan


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »