Skip to content

Commit

Permalink
Showing 2 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions truffle/src/main/ruby/core.rb
Original file line number Diff line number Diff line change
@@ -273,6 +273,7 @@ def self.omit(reason)
require_relative 'core/truffle/debug'
require_relative 'core/truffle/runtime'
require_relative 'core/truffle/truffle'
require_relative 'core/truffle/interop'

# Start running Ruby code outside classes

29 changes: 29 additions & 0 deletions truffle/src/main/ruby/core/truffle/interop.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved. This
# code is released under a tri EPL/GPL/LGPL license. You can use it,
# redistribute it and/or modify it under the terms of the:
#
# Eclipse Public License version 1.0
# GNU General Public License version 2
# GNU Lesser General Public License version 2.1

module Truffle

module Interop

def self.import_method(name)
method = import(name.to_s)

Object.class_eval do
define_method(name.to_sym) do |*args|
Truffle::Interop.execute(method, *args)
end
end
end

def self.export_method(name)
export(name.to_s, Object.method(name.to_sym))
end

end

end

0 comments on commit 8e4bd0e

Please sign in to comment.