init
This commit is contained in:
14
codegen/lib/java.py
Normal file
14
codegen/lib/java.py
Normal file
@@ -0,0 +1,14 @@
|
||||
def java_float(value: float) -> str:
|
||||
return f"{value}f"
|
||||
|
||||
|
||||
def java_static_invoke(closure: str, option_name: str) -> str:
|
||||
"""Turns a "com.example.MyMod::method" closure reference into a zero-arg
|
||||
static method call expression, for APIs that need an already-computed
|
||||
value (e.g. Block) rather than a functional-interface reference."""
|
||||
if "::" not in closure:
|
||||
raise ValueError(f"{option_name}: closure must be of the form 'pkg.Class::method', got: {closure!r}")
|
||||
owner, _, method = closure.partition("::")
|
||||
return f"{owner}.{method}()"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user