GithubHelp home page GithubHelp logo

Comments (4)

kou avatar kou commented on June 19, 2024 1

Thanks.
I've implemented.

from fiddle.

kou avatar kou commented on June 19, 2024

Could you show a Ruby script that reproduces this case?

from fiddle.

codykrieger avatar codykrieger commented on June 19, 2024

Sure.

test.rb:

require 'fiddle'
require 'fiddle/import'

module MyModule
  extend Fiddle::Importer

  MyType = struct [
    %q{void (*foo)(const char *value)}
  ]
end

closure = Class.new(Fiddle::Closure) {
  def call(value)
    puts "value! #{value}"
  end
}.new(Fiddle::TYPE_VOID, [Fiddle::TYPE_CONST_STRING])

my_type = MyModule::MyType.malloc
my_type.foo = closure

# ...

fn = Fiddle::Function.new my_type.foo, [Fiddle::TYPE_CONST_STRING], Fiddle::TYPE_VOID
fn.call "bar"

Then:

% ruby test.rb
Traceback (most recent call last):
        1: from test.rb:24:in `<main>'
test.rb:24:in `call': closure args: 10 (RuntimeError)

It seems like the behavior is specific to when closures are wrapped in a Function.

from fiddle.

codykrieger avatar codykrieger commented on June 19, 2024

Thanks @kou!

from fiddle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.