20using System.Diagnostics;
22using System.Threading;
23using System.Collections.Generic;
47 if (m_n_obj != IntPtr.Zero)
50 m_n_obj = IntPtr.Zero;
55 if (Interlocked.Decrement(ref m_ctx.refCount) == 0)
56 GC.ReRegisterForFinalize(m_ctx);
60 GC.SuppressFinalize(
this);
63 #region Object Invariant
65 private void ObjectInvariant()
67 Debug.Assert(this.m_ctx !=
null);
74 private IntPtr m_n_obj = IntPtr.Zero;
78 Debug.Assert(ctx !=
null);
80 Interlocked.Increment(ref ctx.refCount);
84 internal Z3Object(
Context ctx, IntPtr obj)
86 Debug.Assert(ctx !=
null);
88 Interlocked.Increment(ref ctx.refCount);
94 internal virtual void IncRef(IntPtr o) { }
95 internal virtual void DecRef(IntPtr o) { }
97 internal virtual void CheckNativeObject(IntPtr obj) { }
99 internal virtual IntPtr NativeObject
101 get {
return m_n_obj; }
104 if (value != IntPtr.Zero) { CheckNativeObject(value); IncRef(value); }
105 if (m_n_obj != IntPtr.Zero) { DecRef(m_n_obj); }
110 internal static IntPtr GetNativeObject(Z3Object s)
112 if (s ==
null)
return new IntPtr();
113 return s.NativeObject;
127 internal static IntPtr[] ArrayToNative(
Z3Object[] a)
130 if (a ==
null)
return null;
131 IntPtr[] an =
new IntPtr[a.Length];
132 for (uint i = 0; i < a.Length; i++)
133 if (a[i] !=
null) an[i] = a[i].NativeObject;
137 internal static uint ArrayLength(Z3Object[] a)
139 return (a ==
null)?0:(uint)a.Length;
The main interaction with Z3 happens via the Context.
Internal base class for interfacing with native Z3 objects. Should not be used externally.
void Dispose()
Disposes of the underlying native Z3 object.
Context Context
Access Context object