summaryrefslogtreecommitdiff
path: root/NET/worlds/console/IUnknown.java
blob: 3a80b206d1e979b29f0cc734415b2534ab18effd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
package NET.worlds.console;

import java.io.IOException;

public class IUnknown {
   protected int _pInterface = 0;
   protected int _refs = 0;
   private static final String IID_IUnknown = "{00000000-0000-0000-c000-000000000046}";

   public IUnknown() throws IOException {
   }

   protected synchronized void init(int pInterface) throws IOException {
      assert pInterface != 0;

      ActiveX.init(this);
      this._pInterface = pInterface;
      this._refs = 1;
   }

   public IUnknown(String svrID) throws IOException {
      if ((ActiveX.getDebugLevel() & 2) > 0) {
         System.out.println(this + ": constructor: svrID = " + svrID);
      }

      ActiveX.init(this);

      try {
         try {
            this._pInterface = ActiveX.getClassFClsID(svrID, "{00000000-0000-0000-c000-000000000046}");
            this._refs++;
         } catch (IOException var3) {
            this._pInterface = ActiveX.getClassFProgID(svrID, "{00000000-0000-0000-c000-000000000046}");
            this._refs++;
         }
      } catch (IOException var4) {
         ActiveX.uninit(this);
         throw var4;
      }

      if ((ActiveX.getDebugLevel() & 2) > 0) {
         System.out.println("IUnknown: constructed " + this);
      }
   }

   public IUnknown(String svrID, String intfID) throws IOException {
      if ((ActiveX.getDebugLevel() & 2) > 0) {
         System.out.println(this + ": constructor: svrID = " + svrID + ", intfID = " + intfID);
      }

      this.init(svrID, intfID);
      if ((ActiveX.getDebugLevel() & 2) > 0) {
         System.out.println("IUnknown: constructed " + this);
      }
   }

   protected synchronized void init(String svrID, String intfID) throws IOException {
      ActiveX.init(this);

      try {
         try {
            this._pInterface = ActiveX.getClassFClsID(svrID, intfID);
            this._refs++;
         } catch (IOException var4) {
            this._pInterface = ActiveX.getClassFProgID(svrID, intfID);
            this._refs++;
         }
      } catch (IOException var5) {
         ActiveX.uninit(this);
         throw var5;
      }
   }

   public IUnknown(IUnknown parent, String intfID) throws IOException, OLEInvalidObjectException {
      if ((ActiveX.getDebugLevel() & 2) > 0) {
         System.out.println(this + ": constructor: parent = " + parent + ", intfID = " + intfID);
      }

      this.init(parent, intfID);
      if ((ActiveX.getDebugLevel() & 2) > 0) {
         System.out.println("IUnknown: constructed " + this);
      }
   }

   protected synchronized void init(IUnknown parent, String intfID) throws IOException, OLEInvalidObjectException {
      assert parent != null;

      ActiveX.init(this);

      try {
         this._pInterface = parent.QueryInterface(intfID);
         this._refs = 1;
      } catch (IOException var4) {
         ActiveX.uninit(this);
         throw var4;
      } catch (OLEInvalidObjectException var5) {
         ActiveX.uninit(this);
         throw var5;
      }
   }

   public synchronized void Release() throws OLEInvalidObjectException {
      if ((ActiveX.getDebugLevel() & 4) > 0) {
         System.out.println(this + ": Releasing");
      }

      if (this._pInterface == 0) {
         throw new OLEInvalidObjectException();
      } else {
         if (this._pInterface != 0 && this._refs > 0) {
            this.true_Release();
         }

         this._refs--;
         if (this._refs == 0) {
            this._pInterface = 0;
            ActiveX.uninit(this);
         }
      }
   }

   @Override
   public void finalize() {
      if (this._pInterface != 0) {
         while (this._refs > 0) {
            try {
               this.Release();
            } catch (OLEInvalidObjectException var2) {
               System.out.println("DEBUG: " + this);

               assert false;
            }
         }
      }
   }

   public synchronized void AddRef() throws OLEInvalidObjectException {
      if ((ActiveX.getDebugLevel() & 4) > 0) {
         System.out.println(this + ": AddingRef");
      }

      if (this._pInterface == 0) {
         throw new OLEInvalidObjectException();
      } else {
         this._refs++;
         this.true_AddRef();
      }
   }

   public native void true_AddRef();

   public native int QueryInterface(String var1) throws IOException, OLEInvalidObjectException;

   public native void true_Release() throws OLEInvalidObjectException;

   protected native int getPtr() throws OLEInvalidObjectException;

   public String internalData() {
      return "_pInterface=" + this._pInterface + ", _refs=" + this._refs;
   }

   @Override
   public String toString() {
      return "IUnknown(" + this.internalData() + ")";
   }
}