Creates a CustomFunction. The result calls a given native function with the specified return type and argument types and auto-generated argument names. Args: func: The native function to wrap. return_type: The type of the return value, either as a string or a clas
(
func: Callable[[Any], Any], return_type: Any, arg_types: Any
)
| 97 | |
| 98 | @staticmethod |
| 99 | def create( |
| 100 | func: Callable[[Any], Any], return_type: Any, arg_types: Any |
| 101 | ) -> CustomFunction: |
| 102 | """Creates a CustomFunction. |
| 103 | |
| 104 | The result calls a given native function with the specified return type and |
| 105 | argument types and auto-generated argument names. |
| 106 | |
| 107 | Args: |
| 108 | func: The native function to wrap. |
| 109 | return_type: The type of the return value, either as a string or a |
| 110 | class reference. |
| 111 | arg_types: The types of the arguments, either as strings or class |
| 112 | references. |
| 113 | |
| 114 | Returns: |
| 115 | The constructed CustomFunction. |
| 116 | """ |
| 117 | |
| 118 | def StringifyType(t: Any) -> str: |
| 119 | return t if isinstance(t, str) else ee_types.classToName(t) |
| 120 | |
| 121 | args = [{'name': None, 'type': StringifyType(i)} for i in arg_types] |
| 122 | signature = { |
| 123 | 'name': '', |
| 124 | 'returns': StringifyType(return_type), |
| 125 | 'args': args |
| 126 | } |
| 127 | return CustomFunction(signature, func) |
| 128 | |
| 129 | @staticmethod |
| 130 | def _resolveNamelessArgs(signature: Any, variables: Any, body: Any) -> Any: |