[ANN] FFI 0.1.1 (Foreign Function Interface) for Ruby 1.8.6/7 and1.9 - RUBY

This is a discussion on [ANN] FFI 0.1.1 (Foreign Function Interface) for Ruby 1.8.6/7 and1.9 - RUBY ; Charles Oliver Nutter wrote: > Clifford Heath wrote: >> callback :handle_message, [ oi... >> class Context < FFI:Struct >> layout \ >> :msg_handler, :handle_message, 8, > There's no support at the moment for callbacks-in-structs While I'm on a roll, my ...

+ Reply to Thread
Page 6 of 6 FirstFirst ... 4 5 6
Results 51 to 54 of 54

[ANN] FFI 0.1.1 (Foreign Function Interface) for Ruby 1.8.6/7 and1.9

  1. Default Re: [ANN] FFI 0.1.1 (Foreign Function Interface) for Ruby 1.8.6/7and 1.9

    Charles Oliver Nutter wrote:
    > Clifford Heath wrote:
    >> callback :handle_message, [ oi...
    >> class Context < FFI:Struct
    >> layout \
    >> :msg_handler, :handle_message, 8,

    > There's no support at the moment for callbacks-in-structs


    While I'm on a roll, my example above creates a new type (handle_message),
    and the ability to define other kinds of types similarly would be excellent.
    For example, FreeTDS also has a string struct that contains a char* and a
    length, and it uses that type liberally. A typedef would rock, and the above
    example would just create a function-pointer typedef.

    In a previous life, we implemented a generic structure pack/unpack subsystem.
    It had a table for every type containing the alignment and size of that type.
    Some architectures need more than one table depending on compile options, but
    we supported 30 different architectures using tables whose values were filled
    in by the C compiler. The rule of C don't allow re-ordering structure elements,
    or at least, the require that two structures that start with the same elements
    use the same alignment for those elements.

    You can discover the alignment of a type by declaring a struct z { char x; TYPE y; }
    and asking for offsetof(struct z, y); Mere byte-counting and padding suffices
    to calculate alignment for the members of any structure. Nested structures are
    padded to the largest of either the maximum alignment of the members, or some
    size specific to the architecture. This can also be populated into the alignment
    tables by the C compiler.

    If FFI could include such a facility for Struct definitions, that would be magic,
    as the current system is almost impossible to use for cross-platform support.
    Unless you use the awkward templating system, of course... That requires that
    you have the development versions of the target libraries when you want to gem
    install a wrapper.

    Just some random thoughts, anyhow. I might have time to contribute code to this
    effort in December.

    Clifford Heath.

  2. Default Re: FFI 0.1.1 (Foreign Function Interface) for Ruby 1.8.6/7 and 1.9

    I get the following when I try to compile on windows - any
    suggestions? Not sure what srcdir should be or where I should set it.

    ========================================================================

    C:\ffi>gem install ffi-0.1.0.gem
    Building native extensions. This could take a while...
    ERROR: Error installing ffi-0.1.0.gem:
    ERROR: Failed to build gem native extension.

    C:/ruby/bin/ruby.exe extconf.rb install ffi-0.1.0.gem
    creating Makefile

    nmake

    Microsoft (R) Program Maintenance Utility Version 9.00.30729.01
    Copyright (C) Microsoft Corporation. All rights reserved.

    makefile(182) : fatal error U1052: file '$(srcdir)/ffi.mk' not found
    Stop.


    Gem files will remain installed in C:/ruby/lib/ruby/gems/1.8/gems/
    ffi-0.1.0 for inspection.
    Results logged to C:/ruby/lib/ruby/gems/1.8/gems/ffi-0.1.0/ext/
    gem_make.out

  3. Default Re: [ANN] FFI 0.1.1 (Foreign Function Interface) for Ruby 1.8.6/7and 1.9

    Clifford Heath wrote:
    > Just some random thoughts, anyhow. I might have time to contribute code
    > to this
    > effort in December.


    Sounds like you've dealt with a lot of this stuff before. Can you
    re-post this to the main FFI mailing list?

    - Charlie


  4. Default Re: FFI 0.1.1 (Foreign Function Interface) for Ruby 1.8.6/7 and 1.9

    brett wrote:
    > I get the following when I try to compile on windows - any
    > suggestions? Not sure what srcdir should be or where I should set it.


    There needs to be a pre-built gem for win32, but we haven't published
    one yet. I think someone's working on getting it wired up.

    - Charlie


+ Reply to Thread
Page 6 of 6 FirstFirst ... 4 5 6