Skip to content

Commit ae45a06

Browse files
committed
refactor: InteropBehavior - allow all methods to accept either a constant boolean or a pure python function
- handle CastToJava? conversions by raising a TypeError python exception if the returned type does not match the expected interop message type
1 parent f14bdf2 commit ae45a06

File tree

16 files changed

+775
-517
lines changed

16 files changed

+775
-517
lines changed

docs/user/Interoperability.md

Lines changed: 62 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -276,66 +276,68 @@ An example in this sense are the `numpy` numeric types (e.g., `numpy.int32`) whi
276276

277277
#### Supported messages
278278

279-
The naming convention for the `register_interop_behavior` keyword arguments follows _snake_case_ naming, i.e.: the Truffle Interop `fitsInLong` message
280-
becomes `fits_in_long`. Following is the list of currently supported interop messages:
281-
282-
| Truffle Message | Extension argument name | Argument type |
283-
|:-------------------------|:----------------------------|---------------|
284-
| isBoolean | is_boolean | bool |
285-
| isDate | is_date | bool |
286-
| isDuration | is_duration | bool |
287-
| isIterator | is_iterator | bool |
288-
| isNumber | is_number | bool |
289-
| isString | is_string | bool |
290-
| isTime | is_time | bool |
291-
| isTimeZone | is_time_zone | bool |
292-
| isExecutable | is_executable | bool |
293-
| fitsInBigInteger | fits_in_big_integer | function |
294-
| fitsInByte | fits_in_byte | function |
295-
| fitsInDouble | fits_in_double | function |
296-
| fitsInFloat | fits_in_float | function |
297-
| fitsInInt | fits_in_int | function |
298-
| fitsInLong | fits_in_long | function |
299-
| fitsInShort | fits_in_short | function |
300-
| asBigInteger | as_big_integer | function |
301-
| asBoolean | as_boolean | function |
302-
| asByte | as_byte | function |
303-
| asDate | as_date | function |
304-
| asDouble | as_double | function |
305-
| asDuration | as_duration | function |
306-
| asFloat | as_float | function |
307-
| asInt | as_int | function |
308-
| asLong | as_long | function |
309-
| asShort | as_short | function |
310-
| asString | as_string | function |
311-
| asTime | as_time | function |
312-
| asTimeZone | as_time_zone | function |
313-
| execute | execute | function |
314-
| readArrayElement | read_array_element | function |
315-
| getArraySize | get_array_size | function |
316-
| hasArrayElements | has_array_elements | bool |
317-
| isArrayElementReadable | is_array_element_readable | function |
318-
| isArrayElementModifiable | is_array_element_modifiable | function |
319-
| isArrayElementInsertable | is_array_element_insertable | function |
320-
| isArrayElementRemovable | is_array_element_removable | function |
321-
| removeArrayElement | remove_array_element | function |
322-
| writeArrayElement | write_array_element | function |
323-
| hasIterator | has_iterator | bool |
324-
| hasIteratorNextElement | has_iterator_next_element | function |
325-
| getIterator | get_iterator | function |
326-
| getIteratorNextElement | get_iterator_next_element | function |
327-
| hasHashEntries | has_hash_entries | bool |
328-
| getHashEntriesIterator | get_hash_entries_iterator | function |
329-
| getHashKeysIterator | get_hash_keys_iterator | function |
330-
| getHashSize | get_hash_size | function |
331-
| getHashValuesIterator | get_hash_values_iterator | function |
332-
| isHashEntryReadable | is_hash_entry_readable | function |
333-
| isHashEntryModifiable | is_hash_entry_modifiable | function |
334-
| isHashEntryInsertable | is_hash_entry_insertable | function |
335-
| isHashEntryRemovable | is_hash_entry_removable | function |
336-
| readHashValue | read_hash_value | function |
337-
| writeHashEntry | write_hash_entry | function |
338-
| removeHashEntry | remove_hash_entry | function |
279+
The majority (with some exceptions) of the Truffle Interop messages are supported by the interop behavior extension API, as seen in the table below.
280+
The naming convention for the `register_interop_behavior` keyword arguments follows the _snake_case_ naming convention, i.e.: the Truffle Interop `fitsInLong` message
281+
becomes `fits_in_long` and so on. Each message can be extended with a **pure python function** (default keyword arguments, free vars and cell vars are not allowed) or a **boolean constant**.
282+
Following is the list of currently supported interop messages:
283+
284+
| Truffle Message | Extension argument name |
285+
|:-------------------------|:----------------------------|
286+
| isBoolean | is_boolean |
287+
| isDate | is_date |
288+
| isDuration | is_duration |
289+
| isIterator | is_iterator |
290+
| isNumber | is_number |
291+
| isString | is_string |
292+
| isTime | is_time |
293+
| isTimeZone | is_time_zone |
294+
| isExecutable | is_executable |
295+
| fitsInBigInteger | fits_in_big_integer |
296+
| fitsInByte | fits_in_byte |
297+
| fitsInDouble | fits_in_double |
298+
| fitsInFloat | fits_in_float |
299+
| fitsInInt | fits_in_int |
300+
| fitsInLong | fits_in_long |
301+
| fitsInShort | fits_in_short |
302+
| asBigInteger | as_big_integer |
303+
| asBoolean | as_boolean |
304+
| asByte | as_byte |
305+
| asDate | as_date |
306+
| asDouble | as_double |
307+
| asDuration | as_duration |
308+
| asFloat | as_float |
309+
| asInt | as_int |
310+
| asLong | as_long |
311+
| asShort | as_short |
312+
| asString | as_string |
313+
| asTime | as_time |
314+
| asTimeZone | as_time_zone |
315+
| execute | execute |
316+
| readArrayElement | read_array_element |
317+
| getArraySize | get_array_size |
318+
| hasArrayElements | has_array_elements |
319+
| isArrayElementReadable | is_array_element_readable |
320+
| isArrayElementModifiable | is_array_element_modifiable |
321+
| isArrayElementInsertable | is_array_element_insertable |
322+
| isArrayElementRemovable | is_array_element_removable |
323+
| removeArrayElement | remove_array_element |
324+
| writeArrayElement | write_array_element |
325+
| hasIterator | has_iterator |
326+
| hasIteratorNextElement | has_iterator_next_element |
327+
| getIterator | get_iterator |
328+
| getIteratorNextElement | get_iterator_next_element |
329+
| hasHashEntries | has_hash_entries |
330+
| getHashEntriesIterator | get_hash_entries_iterator |
331+
| getHashKeysIterator | get_hash_keys_iterator |
332+
| getHashSize | get_hash_size |
333+
| getHashValuesIterator | get_hash_values_iterator |
334+
| isHashEntryReadable | is_hash_entry_readable |
335+
| isHashEntryModifiable | is_hash_entry_modifiable |
336+
| isHashEntryInsertable | is_hash_entry_insertable |
337+
| isHashEntryRemovable | is_hash_entry_removable |
338+
| readHashValue | read_hash_value |
339+
| writeHashEntry | write_hash_entry |
340+
| removeHashEntry | remove_hash_entry |
339341

340342
### Usage Example
341343

0 commit comments

Comments
 (0)