Skip to content

Commit 8018777

Browse files
committed
add javadoc for GuestTypeConversion interface
1 parent f3a8bdf commit 8018777

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

espresso/src/com.oracle.truffle.espresso.polyglot/src/com/oracle/truffle/espresso/polyglot/GuestTypeConversion.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0
@@ -40,6 +40,23 @@
4040
*/
4141
package com.oracle.truffle.espresso.polyglot;
4242

43+
/**
44+
* This interface must be implemented by a custom defined type converter that is declared as context
45+
* builder input using the 'java.PolyglotTypeConverters' option. If a polyglot object that is passed
46+
* into Espresso has a declared meta name that matches the declaration used for the GuestConversion,
47+
* the toGuest method is invoked. This invocation is responsible for returning a guest object
48+
* matching the parameterized type.
49+
* </p>
50+
* Note that, in the case where the target type, e.g. a method parameter type in the guest, is not
51+
* assignable from the returned instance of the toGuest method, the converted value is ignored.
52+
* Hence, other custom or internal type mappings might be attempted in sequence in response to such
53+
* incompatible conversion. For example, the built-in collection type mappings
54+
* (java.BuiltInPolyglotCollections) might be compatible for the incoming polyglot object, or there
55+
* might be custom interface mapping (java.PolyglotInterfaceMappings).
56+
*
57+
* @param <T> the guest type this converter is converting an interop meta name-mapped polyglot
58+
* instance to.
59+
*/
4360
public interface GuestTypeConversion<T> {
4461
T toGuest(Object polyglotInstance);
4562
}

0 commit comments

Comments
 (0)