|
1 | 1 | /*
|
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. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
4 | 4 | *
|
5 | 5 | * The Universal Permissive License (UPL), Version 1.0
|
|
40 | 40 | */
|
41 | 41 | package com.oracle.truffle.espresso.polyglot;
|
42 | 42 |
|
| 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 | + */ |
43 | 60 | public interface GuestTypeConversion<T> {
|
44 | 61 | T toGuest(Object polyglotInstance);
|
45 | 62 | }
|
0 commit comments