Package-level declarations

Types

Link copied to clipboard

The shared implementation of invoke_$suffix/3 (first arg: a Ref or $Alias expression; second: the Method(Arg1, ..., ArgN) Struct to invoke; third: unified with whatever getInvocationResult extracts from the invocation's Result), backing both invoke_method/3 (InvokeMethod) and invoke_strict/3 (InvokeStrict) -- the two only differ in whether the returned value is converted to a plain Term or kept as an it.unibo.tuprolog.solve.libs.oop.ObjectRef.

Link copied to clipboard

The shared implementation of ${iterable}_items/2, converting between a Prolog List of items and a JVM/Kotlin collection type T wrapped in an ObjectRef -- letting Prolog code build a java.util.ArrayList/array/java.util.LinkedHashSet (see ArrayItems, ListItems, SetItems) from a logic list, or read one back out of an ObjectRef as a logic list, without going through new_object/3 and repeated invoke_method/3 calls.

Link copied to clipboard

array_items(?ArrayRef, ?Items): converts between a Prolog list Items and an it.unibo.tuprolog.solve.libs.oop.ObjectRef ArrayRef wrapping a JVM Object[] array holding the same (converted) elements, in either direction -- see AbstractIterableItems.

Link copied to clipboard

assign(+Ref, +PropertyName, +Value): assigns Value to the mutable property named PropertyName (an it.unibo.tuprolog.core.Atom) on Ref -- an it.unibo.tuprolog.solve.libs.oop.ObjectRef, it.unibo.tuprolog.solve.libs.oop.TypeRef, or $Alias expression -- resolving Value itself as a $Alias expression first, if it looks like one. Succeeds deterministically if the assignment was performed.

Link copied to clipboard

cast(?Term, ?Type, ?ObjectRef): converts Term into an instance of Type (a it.unibo.tuprolog.solve.libs.oop.TypeRef, a type-name atom, or a $Alias expression resolving to a it.unibo.tuprolog.solve.libs.oop.TypeRef), unifying ObjectRef with an it.unibo.tuprolog.solve.libs.oop.ObjectRef wrapping the result. Backs the as/2 operator (X as 'java.lang.Long'), used to disambiguate overload resolution when the automatically inferred type is not the intended one -- e.g. forcing an integer literal to be converted to a Long rather than the default Int.

Link copied to clipboard

invoke_method(+Ref, +Method(Args...), ?Result): invokes Method (with Args, converted via termToObjectConverter) on Ref -- an it.unibo.tuprolog.solve.libs.oop.ObjectRef, it.unibo.tuprolog.solve.libs.oop.TypeRef, or $Alias expression -- unifying Result with the invocation's return value converted to a plain Term (e.g. a JVM String becomes a Prolog atom). Use InvokeStrict instead to keep the result as an it.unibo.tuprolog.solve.libs.oop.ObjectRef regardless of its type.

Link copied to clipboard

invoke_strict(+Ref, +Method(Args...), ?Result): like InvokeMethod, but always unifying Result with an it.unibo.tuprolog.solve.libs.oop.ObjectRef wrapping the invocation's return value, instead of converting it to a plain Term when possible. Useful when the caller needs to keep invoking further members on the result reflectively, rather than getting e.g. a bare Prolog integer back.

Link copied to clipboard

list_items(?ListRef, ?Items): converts between a Prolog list Items and an it.unibo.tuprolog.solve.libs.oop.ObjectRef ListRef wrapping a Kotlin/Java List holding the same (converted) elements, in either direction -- see AbstractIterableItems.

Link copied to clipboard

new_object(+Type, +Arguments, ?ObjectRef): constructs a new instance of Type (a it.unibo.tuprolog.solve.libs.oop.TypeRef, type-name atom, or $Alias expression) by invoking whichever public constructor best matches the Prolog list Arguments, unifying ObjectRef with an it.unibo.tuprolog.solve.libs.oop.ObjectRef wrapping the freshly created instance. See it.unibo.tuprolog.solve.libs.oop.rules.NewObject2 for the no-arguments new_object/2 sugar.

Link copied to clipboard
Link copied to clipboard

object_ref(?Term): succeeds iff Term is an it.unibo.tuprolog.solve.libs.oop.ObjectRef.

Link copied to clipboard

register(+Ref, +Alias): registers Ref -- an it.unibo.tuprolog.solve.libs.oop.ObjectRef or it.unibo.tuprolog.solve.libs.oop.TypeRef -- under the ground alias term Alias, by adding a matching it.unibo.tuprolog.solve.libs.oop.rules.Alias fact to the current solver's static knowledge base. Once registered, Ref can be referred to as $Alias anywhere a reference is expected. See Unregister for removing an alias again.

Link copied to clipboard

set_items(?SetRef, ?Items): converts between a Prolog list Items and an it.unibo.tuprolog.solve.libs.oop.ObjectRef SetRef wrapping a Kotlin/Java Set holding the same (converted, duplicate-free) elements, in either direction -- see AbstractIterableItems.

Link copied to clipboard

type(?TypeName, ?TypeRef): converts between a type-name it.unibo.tuprolog.core.Atom TypeName (the type's simple name, see it.unibo.tuprolog.solve.libs.oop.name) and a it.unibo.tuprolog.solve.libs.oop.TypeRef TypeRef, in either direction, using it.unibo.tuprolog.solve.libs.oop.TypeFactory.default to resolve names to types.

Link copied to clipboard

type_ref(?Term): succeeds iff Term is a it.unibo.tuprolog.solve.libs.oop.TypeRef.

Link copied to clipboard

unregister(+Alias): removes every it.unibo.tuprolog.solve.libs.oop.rules.Alias fact matching the ground alias term Alias from the current solver's static knowledge base, undoing a previous Register.

Properties

Link copied to clipboard

A TermToObjectConverter wired to resolve $Alias dealiasing expressions against this request's current knowledge base (via findRefFromAlias/findRefFromAliasOrNull) -- the converter every primitive in :oop-lib should use in place of TermToObjectConverter.default.

Functions

Link copied to clipboard
inline fun <C : ExecutionContext, Req : Solve.Request<C>, R> Req.catchingOopExceptions(action: Req.() -> R): R

Runs action, converting any it.unibo.tuprolog.solve.libs.oop.exceptions.OopException it throws into the it.unibo.tuprolog.solve.exception.LogicError this request's solver actually expects (via it.unibo.tuprolog.solve.libs.oop.exceptions.OopException.toLogicError), and any other unexpected Throwable into an it.unibo.tuprolog.solve.exception.error.SystemError.forUncaughtException. Every primitive in :oop-lib wraps its logic with this to turn reflection failures into well-formed Prolog errors.

Link copied to clipboard

Like isAliasRegistered, but throwing instead of returning false.

Link copied to clipboard

Like ensuringArgumentIsRef, but requiring the argument to be (or resolve, via $Alias, to) an ObjectRef.

Link copied to clipboard

Ensures the argument at index is a Ref -- resolving it first if it is a $Alias dealiasing expression -- returning this request for chaining, as the other ensuringArgumentIs* helpers in it.unibo.tuprolog.solve.primitive.PrimitiveWrapper do.

Link copied to clipboard

Like ensuringArgumentIsRef, but requiring the argument to be (or resolve, via $Alias, to) a TypeRef.

Link copied to clipboard

Resolves the well-formed $Alias dealiasing expression alias into the Ref it currently points to.

Link copied to clipboard

Resolves the argument at index into a TypeRef, accepting it directly as a TypeRef, as an it.unibo.tuprolog.core.Atom naming a type (via TypeFactory.default), or as a $Alias dealiasing expression -- returning null if resolution fails for one of these forms.

Link copied to clipboard

Whether alias (the Alias argument of a well-formed $Alias expression) is currently registered, i.e. whether an it.unibo.tuprolog.solve.libs.oop.rules.Alias fact for it can be found in the current knowledge base.