-
Notifications
You must be signed in to change notification settings - Fork 0
JRuby and Truffle Interop
JRuby supports standard Truffle interop messages. This document explains what it does when it receives them, how to get it to explicitly send them, how to get it to send them using more idiomatic Ruby, and how what messages it sends for normal Ruby operations on foreign objects.
Interop ignores visibility entirely.
Returns true only for instances of Method and Proc.
Calls either a Method or Proc, passing the arguments as you'd expect. Doesn't pass a block.
Calls the method with the name you provided, passing the arguments as you'd expect. Doesn't pass a block.
Returns true only for instances of Array, Hash and String.
Call size on the object.
Returns true only for instances of String with a length of 1, which allows them to be unboxed as a character.
For a String, returns the first character. Unboxing empty strings is not supported and will cause an UnsupportedMessageException. For all other objects returns the object.
Returns true only for the nil object.
The label must be a Java int or String, or a Ruby String or Symbol.
If the receiver is a Ruby String and the label is an integer, read a byte from the string, ignoring the encoding. If the index is out of range you'll get 0.
For the following conditions the label cannot be a Java int.
Otherwise, if the label starts with @, read it as an instance variable.
Otherwise, if there isn't a method defined on the object with the same name as the label, and there is a method defined on the object called [], call [] with the label as the argument.
Otherwise, perform a method call using the label as the called method name.
In all cases where a call is made no block is passed.
The label must be a Java String, or a Ruby String or Symbol.
If the label starts with @, write it as an instance variable.
Otherwise, if there isn't a method defined on the object with the same name as the label, and there is a method defined on the object called []=, call []= with the label and value as the two arguments.
Otherwise, perform a method call using the label appended with = as the called method name, and the value as the argument.
In all cases where a call is made no block is passed.
Truffle::Interop.executable?(value)
Truffle::Interop.execute(receiver, *args)
Truffle::Interop.invoke(receiver, identifier, *args)
identifier can be a String or Symbol.
Truffle::Interop.size?(value)
Truffle::Interop.size(value)
Truffle::Interop.boxed?(value)
Truffle::Interop.unbox(value)
Truffle::Interop.null?(value)
Truffle::Interop.read(object, label)
If label is a String or Symbol it will be converted into a Java String.
Truffle::Interop.read(object, label, value)
If label is a String or Symbol it will be converted into a Java String.
Todo
Todo
Todo
Todo
Todo
Todo
Todo
Todo
Todo
Todo
Todo