Z3
Z3Object.java
Go to the documentation of this file.
1 
18 package com.microsoft.z3;
19 
24 public class Z3Object extends IDisposable
25 {
29  protected void finalize()
30  {
31  dispose();
32  }
33 
37  public void dispose()
38  {
39  if (m_n_obj != 0)
40  {
41  decRef(m_n_obj);
42  m_n_obj = 0;
43  }
44 
45  if (m_ctx != null)
46  {
47  m_ctx.m_refCount--;
48  m_ctx = null;
49  }
50  }
51 
52  private Context m_ctx = null;
53  private long m_n_obj = 0;
54 
55  Z3Object(Context ctx)
56  {
57  ctx.m_refCount++;
58  m_ctx = ctx;
59  }
60 
61  Z3Object(Context ctx, long obj)
62  {
63  ctx.m_refCount++;
64  m_ctx = ctx;
65  incRef(obj);
66  m_n_obj = obj;
67  }
68 
69  void incRef(long o)
70  {
71  }
72 
73  void decRef(long o)
74  {
75  }
76 
77  void checkNativeObject(long obj)
78  {
79  }
80 
81  long getNativeObject()
82  {
83  return m_n_obj;
84  }
85 
86  void setNativeObject(long value)
87  {
88  if (value != 0)
89  {
90  checkNativeObject(value);
91  incRef(value);
92  }
93  if (m_n_obj != 0)
94  {
95  decRef(m_n_obj);
96  }
97  m_n_obj = value;
98  }
99 
100  static long getNativeObject(Z3Object s)
101  {
102  if (s == null)
103  return 0;
104  return s.getNativeObject();
105  }
106 
107  Context getContext()
108  {
109  return m_ctx;
110  }
111 
112  static long[] arrayToNative(Z3Object[] a)
113  {
114  if (a == null)
115  return null;
116  long[] an = new long[a.length];
117  for (int i = 0; i < a.length; i++)
118  an[i] = (a[i] == null) ? 0 : a[i].getNativeObject();
119  return an;
120  }
121 
122  static int arrayLength(Z3Object[] a)
123  {
124  return (a == null) ? 0 : a.length;
125  }
126 }