From: Aaron Patterson Date: 2012-07-19T03:45:15+09:00 Subject: [ruby-core:46551] Re: [ruby-trunk - Bug #6724][Open] waaaaaaant! ( --EuxKj2iCbKjpUGkD Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jul 18, 2012 at 09:13:45AM +0900, Luis Lavena wrote: > On Tue, Jul 17, 2012 at 6:27 PM, Aaron Patterson > wrote: > > > > class RubyVM > > class InstructionSequence > > address =3D DL::Handle::DEFAULT['rb_iseq_load'] > > func =3D Fiddle::Function.new(address, [DL::TYPE_VOIDP] * 3, DL= ::TYPE_VOIDP) > > > > define_singleton_method(:load) do |data, parent =3D nil, opt = =3D nil| > > func.call(DL.dlwrap(data), parent, opt).to_value > > end > > end > > end > > >=20 > For some reason ::DEFAULT doesn't work on windows, so a bit of tweak: >=20 > require 'rbconfig' > require 'dl' > require 'fiddle' > require 'minitest/autorun' >=20 > class RubyVM > class InstructionSequence > handle =3D DL::Handle.new(RbConfig::CONFIG["RUBY_SO_NAME"]) > address =3D handle['rb_iseq_load'] > func =3D Fiddle::Function.new(address, [DL::TYPE_VOIDP] * 3, > DL::TYPE_VOIDP) >=20 > define_singleton_method(:load) do |data, parent =3D nil, opt =3D = nil| > func.call(DL.dlwrap(data), parent, opt).to_value > end > end > end >=20 > class TestISeq < MiniTest::Unit::TestCase > def test_load > ins =3D RubyVM::InstructionSequence.new '5 + 10' > other =3D RubyVM::InstructionSequence.load ins.to_a > assert_equal ins.eval, other.eval > end > end >=20 > That or simply: DL::Handle.new (no argument) which will resolve to librub= y DLL. Glad we could get this working on windows! ;-) As a side note, maybe we should fix DEFAULT? Any ideas what's wrong on windows? --=20 Aaron Patterson http://tenderlovemaking.com/ --EuxKj2iCbKjpUGkD Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (Darwin) iQEcBAEBAgAGBQJQBwQ0AAoJEJUxcLy0/6/GL24H/2OXxMVt7uTz4mAiKi8/EnPZ ZclX5oqc2mLeN3lGgUrw1gCJRfPbQNOEi8ZRjDDS14q+0E/yZIC1taKekPYpjPFw +rjpIO8FitvozvvluKg7ROugwLoaJ4nc/QQwUUYwYgTrwMeywk40hHPYDFEQ0FvQ wUt2vbDKklw/T9uvaU23oChrn4ptH9ezBqP5DFIGbfZQjZHtasRnldgkBNL3JMOI C2sJF373E8MoQEiW6VujGMeZ2tPMOiNAaBVdUycB9aOZzZuO264e1NmNkpxAzADX orToVHQNaylQh2f66y5Y/DMaDCBcL0OX3fWbF52/iEnqDXopS4x++/QcjAtO6wI= =QgyP -----END PGP SIGNATURE----- --EuxKj2iCbKjpUGkD--