3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-08-03 04:33:28 +00:00
z3/src/api/java/ParamDescrs.java
Thomas Haas a3d00ce356
Improved Java phantom references (#7131)
* Reworked phantom reference handling.
 - Replaced IDecRefQueue with a new Z3ReferenceQueue class
 - Z3ReferenceQueue manages custom subclasses of phantom references in a doubly-linked list
 - Replaced all subclasses of IDecRefQueue with subclasses of Z3ReferenceQueue.Reference. These custom reference classes are embedded in the class they reference count.
 - Context now owns a single Z3ReferenceQueue for all types of references.

* Made Statistics.Entry a static subclass

* Made Context.close idempotent (as recommended)

* Update CMakeLists.txt for building the Java API.

* Updated CMakeLists.txt again.

* Use correct SuppressWarning annotation to silence the compiler

* Formatting
2024-02-21 08:39:58 -08:00

116 lines
2.6 KiB
Java

/**
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
ParamDescrs.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;
import com.microsoft.z3.enumerations.Z3_param_kind;
import java.lang.ref.ReferenceQueue;
/**
* A ParamDescrs describes a set of parameters.
**/
public class ParamDescrs extends Z3Object {
/**
* validate a set of parameters.
**/
public void validate(Params p)
{
Native.paramsValidate(getContext().nCtx(), p.getNativeObject(),
getNativeObject());
}
/**
* Retrieve kind of parameter.
**/
public Z3_param_kind getKind(Symbol name)
{
return Z3_param_kind.fromInt(Native.paramDescrsGetKind(
getContext().nCtx(), getNativeObject(), name.getNativeObject()));
}
/**
* Retrieve documentation of parameter.
**/
public String getDocumentation(Symbol name)
{
return Native.paramDescrsGetDocumentation(getContext().nCtx(), getNativeObject(), name.getNativeObject());
}
/**
* Retrieve all names of parameters.
*
* @throws Z3Exception
**/
public Symbol[] getNames()
{
int sz = Native.paramDescrsSize(getContext().nCtx(), getNativeObject());
Symbol[] names = new Symbol[sz];
for (int i = 0; i < sz; ++i)
{
names[i] = Symbol.create(getContext(), Native.paramDescrsGetName(
getContext().nCtx(), getNativeObject(), i));
}
return names;
}
/**
* The size of the ParamDescrs.
**/
public int size()
{
return Native.paramDescrsSize(getContext().nCtx(), getNativeObject());
}
/**
* Retrieves a string representation of the ParamDescrs.
**/
@Override
public String toString() {
return Native.paramDescrsToString(getContext().nCtx(), getNativeObject());
}
ParamDescrs(Context ctx, long obj)
{
super(ctx, obj);
}
@Override
void incRef() {
Native.paramDescrsIncRef(getContext().nCtx(), getNativeObject());
}
@Override
void addToReferenceQueue() {
getContext().getReferenceQueue().storeReference(this, ParamDescrsRef::new);
}
private static class ParamDescrsRef extends Z3ReferenceQueue.Reference<ParamDescrs> {
private ParamDescrsRef(ParamDescrs referent, ReferenceQueue<Z3Object> q) {
super(referent, q);
}
@Override
void decRef(Context ctx, long z3Obj) {
Native.paramDescrsDecRef(ctx.nCtx(), z3Obj);
}
}
}