Skip to content

Commit 5e8f8b3

Browse files
committed
Remove Truffle::Interop#{import_without_conversion,export_without_conversion}
* There is no more valid usage of those.
1 parent 0f106ea commit 5e8f8b3

File tree

4 files changed

+7
-41
lines changed

4 files changed

+7
-41
lines changed

doc/contributor/interop.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ conversion for `EXECUTE` using `Truffle::Interop.execute_without_conversion`,
128128
for `READ` using `Truffle::Interop.read_without_conversion`, and for `UNBOX`
129129
using `Truffle::Interop.unbox_without_conversion`.
130130

131-
Import also converts `byte/short/float`, and has a `import_without_conversion` counterpart.
131+
`Polyglot.import` also converts `byte/short/float`.
132132

133133
## Import and export
134134

spec/truffle/interop/export_spec.rb

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -53,23 +53,7 @@
5353
it "does not convert to Java when exporting a Ruby string" do
5454
ruby_string = 'hello'
5555
Truffle::Interop.export :exports_a_string_with_conversion, ruby_string
56-
imported = Truffle::Interop.import_without_conversion(:exports_a_string_with_conversion)
57-
Truffle::Interop.should_not.java_string?(imported)
58-
imported.should.equal?(ruby_string)
59-
end
60-
61-
it "can export a string without conversion to Java" do
62-
ruby_string = 'hello'
63-
Truffle::Interop.export_without_conversion :exports_a_string_without_conversion, ruby_string
64-
imported = Truffle::Interop.import_without_conversion(:exports_a_string_without_conversion)
65-
Truffle::Interop.should_not.java_string?(imported)
66-
imported.should.equal?(ruby_string)
67-
end
68-
69-
it "can import a string without conversion from Java" do
70-
ruby_string = 'hello'
71-
Truffle::Interop.export :imports_a_string_without_conversion, ruby_string
72-
imported = Truffle::Interop.import_without_conversion(:imports_a_string_without_conversion)
56+
imported = Truffle::Interop.import(:exports_a_string_with_conversion)
7357
Truffle::Interop.should_not.java_string?(imported)
7458
imported.should.equal?(ruby_string)
7559
end

src/main/java/org/truffleruby/interop/InteropNodes.java

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -188,16 +188,6 @@ protected Object proxyForeignObject(Object delegate, Object logger) {
188188
return new ProxyForeignObject(delegate, logger);
189189
}
190190
}
191-
192-
@Primitive(name = "foreign_to_ruby")
193-
public abstract static class ForeignToRubyPrimitive extends PrimitiveArrayArgumentsNode {
194-
195-
@Specialization
196-
protected Object foreignToRuby(Object value,
197-
@Cached ForeignToRubyNode foreignToRubyNode) {
198-
return foreignToRubyNode.executeConvert(value);
199-
}
200-
}
201191
// endregion
202192

203193
// region eval
@@ -1518,9 +1508,9 @@ protected Object export(String name, Object object) {
15181508
}
15191509
}
15201510

1521-
@CoreMethod(names = "import_without_conversion", onSingleton = true, required = 1)
1511+
@CoreMethod(names = "import", onSingleton = true, required = 1)
15221512
@NodeChild(value = "name", type = RubyNode.class)
1523-
public abstract static class ImportWithoutConversionNode extends CoreMethodNode {
1513+
public abstract static class ImportNode extends CoreMethodNode {
15241514

15251515
@CreateCast("name")
15261516
protected RubyNode coerceNameToString(RubyNode name) {
@@ -1529,10 +1519,11 @@ protected RubyNode coerceNameToString(RubyNode name) {
15291519

15301520
@Specialization
15311521
protected Object importObject(String name,
1532-
@Cached BranchProfile errorProfile) {
1522+
@Cached BranchProfile errorProfile,
1523+
@Cached ForeignToRubyNode foreignToRubyNode) {
15331524
final Object value = doImport(name);
15341525
if (value != null) {
1535-
return value;
1526+
return foreignToRubyNode.executeConvert(value);
15361527
} else {
15371528
errorProfile.enter();
15381529
throw new RaiseException(getContext(), coreExceptions().nameErrorImportNotFound(name, this));

src/main/ruby/truffleruby/core/truffle/interop.rb

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,6 @@ def self.export_method(name)
8888
export(name.to_s, Object.method(name.to_sym))
8989
end
9090

91-
# For compatibility TODO keep or not?
92-
def self.export_without_conversion(name, value)
93-
export name, value
94-
end
95-
96-
def self.import(name)
97-
Primitive.foreign_to_ruby(import_without_conversion(name))
98-
end
99-
10091
def self.get_members_implementation(object, internal)
10192
keys = []
10293

0 commit comments

Comments
 (0)