1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
---|
2 | /* ***** BEGIN LICENSE BLOCK *****
|
---|
3 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
---|
4 | *
|
---|
5 | * The contents of this file are subject to the Mozilla Public License Version
|
---|
6 | * 1.1 (the "License"); you may not use this file except in compliance with
|
---|
7 | * the License. You may obtain a copy of the License at
|
---|
8 | * http://www.mozilla.org/MPL/
|
---|
9 | *
|
---|
10 | * Software distributed under the License is distributed on an "AS IS" basis,
|
---|
11 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
---|
12 | * for the specific language governing rights and limitations under the
|
---|
13 | * License.
|
---|
14 | *
|
---|
15 | * The Original Code is the Mozilla.org code.
|
---|
16 | *
|
---|
17 | * The Initial Developer of the Original Code is
|
---|
18 | * innotek GmbH.
|
---|
19 | * Portions created by the Initial Developer are Copyright (C) 2003
|
---|
20 | * the Initial Developer. All Rights Reserved.
|
---|
21 | *
|
---|
22 | * Contributor(s):
|
---|
23 | * innotek GmbH / Knut St. Osmundsen
|
---|
24 | *
|
---|
25 | * Alternatively, the contents of this file may be used under the terms of
|
---|
26 | * either the GNU General Public License Version 2 or later (the "GPL"), or
|
---|
27 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
---|
28 | * in which case the provisions of the GPL or the LGPL are applicable instead
|
---|
29 | * of those above. If you wish to allow use of your version of this file only
|
---|
30 | * under the terms of either the GPL or the LGPL, and not to allow others to
|
---|
31 | * use your version of this file under the terms of the MPL, indicate your
|
---|
32 | * decision by deleting the provisions above and replace them with the notice
|
---|
33 | * and other provisions required by the GPL or the LGPL. If you do not delete
|
---|
34 | * the provisions above, a recipient may use your version of this file under
|
---|
35 | * the terms of any one of the MPL, the GPL or the LGPL.
|
---|
36 | *
|
---|
37 | * ***** END LICENSE BLOCK ***** */
|
---|
38 |
|
---|
39 | /*
|
---|
40 | * This module contains wrappers for a handful of XPCOM methods which someone
|
---|
41 | * have been so kind as to link their plugins against. This module will only
|
---|
42 | * provide the minimum of what necessary to make legacy plugins work with
|
---|
43 | * the GCC based mozilla. Luckily this only means the IBM oji JAVA plugins.
|
---|
44 | *
|
---|
45 | * Actually, I haven't seen npoji6 calling any of these yet.
|
---|
46 | */
|
---|
47 |
|
---|
48 | /*******************************************************************************
|
---|
49 | * Defined Constants And Macros *
|
---|
50 | *******************************************************************************/
|
---|
51 | /** @group Visual Age for C++ v3.6.5 target (OS/2). */
|
---|
52 | /* @{ */
|
---|
53 | /** Indicate Visual Age for C++ v3.6.5 target */
|
---|
54 | #define VFT_VAC365 1
|
---|
55 | /** VFTable/Interface Calling Convention for Win32. */
|
---|
56 | #define VFTCALL _Optlink
|
---|
57 | /** First Entry which VAC uses. */
|
---|
58 | #define VFTFIRST_DECL unsigned uFirst[2]
|
---|
59 | #define VFTFIRST_VAL() {0, 0},
|
---|
60 | /** This deltas which VAC uses. */
|
---|
61 | #define VFTDELTA_DECL(n) unsigned uDelta##n
|
---|
62 | #define VFTDELTA_VAL() 0,
|
---|
63 | /** @} */
|
---|
64 |
|
---|
65 |
|
---|
66 | /*******************************************************************************
|
---|
67 | * Header Files *
|
---|
68 | *******************************************************************************/
|
---|
69 | #include "nscore.h"
|
---|
70 | #include "nsIServiceManagerUtils.h"
|
---|
71 |
|
---|
72 |
|
---|
73 | /*******************************************************************************
|
---|
74 | * Structures and Typedefs *
|
---|
75 | *******************************************************************************/
|
---|
76 | #ifndef __cplusplus
|
---|
77 | typedef struct nsID
|
---|
78 | {
|
---|
79 | PRUint32 m0;
|
---|
80 | PRUint16 m1;
|
---|
81 | PRUint16 m2;
|
---|
82 | PRUint8 m3[8];
|
---|
83 | } nsID, nsCID, nsIID;
|
---|
84 | #define REFNSIID const nsIID *
|
---|
85 |
|
---|
86 | typedef PRUint32 nsrefcnt;
|
---|
87 | #endif
|
---|
88 |
|
---|
89 |
|
---|
90 | /**
|
---|
91 | * nsISupports vftable.
|
---|
92 | */
|
---|
93 | typedef struct vftable_nsISupports
|
---|
94 | {
|
---|
95 | VFTFIRST_DECL;
|
---|
96 | nsresult (*VFTCALL QueryInterface)(void *pvThis, REFNSIID aIID, void** aInstancePtr);
|
---|
97 | VFTDELTA_DECL(QueryInterface);
|
---|
98 | nsrefcnt (*VFTCALL AddRef)(void *pvThis);
|
---|
99 | VFTDELTA_DECL(AddRef);
|
---|
100 | nsrefcnt (*VFTCALL Release)(void *pvThis);
|
---|
101 | VFTDELTA_DECL(Release);
|
---|
102 | } VFTnsISupports;
|
---|
103 |
|
---|
104 | /**
|
---|
105 | * nsGetServiceByCID::nsCOMPtr_helper vftable.
|
---|
106 | */
|
---|
107 | typedef struct vftable_nsGetServiceByCID_nsCOMPtr_helper
|
---|
108 | {
|
---|
109 | VFTFIRST_DECL;
|
---|
110 | /* virtual nsresult operator()( const nsIID&, void** ) const; */
|
---|
111 | nsresult (*VFTCALL __operator_paratheses)(void *pvThis, REFNSIID aIID, void** aInstancePtr);
|
---|
112 | VFTDELTA_DECL(__operator_paratheses);
|
---|
113 | void * (*VFTCALL __destructor)(void *pvThis, unsigned __dtorFlags, unsigned __vtt);
|
---|
114 | VFTDELTA_DECL(__destructor);
|
---|
115 | } VFTnsGetServiceByCID_nsCOMPtr_helper;
|
---|
116 |
|
---|
117 | /**
|
---|
118 | * nsQueryInterface::nsCOMPtr_helper vftable.
|
---|
119 | */
|
---|
120 | typedef struct vftable_nsQueryInterface_nsCOMPtr_helper
|
---|
121 | {
|
---|
122 | VFTFIRST_DECL;
|
---|
123 | nsresult (*VFTCALL __operator_paratheses)(void *pvThis, REFNSIID aIID, void** aInstancePtr);
|
---|
124 | VFTDELTA_DECL(__operator_paratheses);
|
---|
125 | } VFTnsQueryInterface_nsCOMPtr_helper;
|
---|
126 |
|
---|
127 |
|
---|
128 |
|
---|
129 |
|
---|
130 | /**
|
---|
131 | * nsISupport object.
|
---|
132 | */
|
---|
133 | typedef struct obj_nsISupports
|
---|
134 | {
|
---|
135 | VFTnsISupports *pVFT;
|
---|
136 | } obj_nsISupports;
|
---|
137 |
|
---|
138 | /**
|
---|
139 | * nsCOMPtr_base object.
|
---|
140 | */
|
---|
141 | typedef struct obj_nsCOMPtr_base
|
---|
142 | {
|
---|
143 | obj_nsISupports *mRawPtr;
|
---|
144 | } obj_nsCOMPtr_base;
|
---|
145 |
|
---|
146 | /**
|
---|
147 | * nsGetServiceByCID_nsCOMPtr_helper object.
|
---|
148 | */
|
---|
149 | typedef struct obj_nsGetServiceByCID_nsCOMPtr_helper
|
---|
150 | {
|
---|
151 | VFTnsGetServiceByCID_nsCOMPtr_helper *pVFT; /* ?? */
|
---|
152 | nsID *mCID; /* const nsCID& */
|
---|
153 | void *mServiceManager;/* nsCOMPtr<nsIServiceManager> */
|
---|
154 | nsresult *mErrorPtr;
|
---|
155 | } obj_nsGetServiceByCID_nsCOMPtr_helper;
|
---|
156 |
|
---|
157 | /**
|
---|
158 | * nsQueryInterface_nsCOMPtr_helper object.
|
---|
159 | */
|
---|
160 | typedef struct obj_nsQueryInterface_nsCOMPtr_helper
|
---|
161 | {
|
---|
162 | VFTnsQueryInterface_nsCOMPtr_helper *pVFT; /* ?? */
|
---|
163 | obj_nsISupports *mRawPtr; /* const nsCID& */
|
---|
164 | nsresult *mErrorPtr;
|
---|
165 | } obj_nsQueryInterface_nsCOMPtr_helper;
|
---|
166 |
|
---|
167 |
|
---|
168 |
|
---|
169 |
|
---|
170 | /**
|
---|
171 | * nsCOMPtr_base::~nsCOMPtr_base()
|
---|
172 | *
|
---|
173 | * @remark This guys doing the oji plugin have been very unfortunate to link in this
|
---|
174 | * without any similar new operator. The object is thus created in the plugin
|
---|
175 | * but freed by xpcom.dll. As the plugin and mozilla have different CRTs this
|
---|
176 | * is a good way of asking for trouble. But, they guys've been lucky, the VAC
|
---|
177 | * CRT might just handle this ok.
|
---|
178 | * However, we cannot perform this delete as we have no VAC CRT around, and
|
---|
179 | * hence we will leak this object.
|
---|
180 | * ----
|
---|
181 | * assembly:
|
---|
182 | public __dt__13nsCOMPtr_baseFv
|
---|
183 | __dt__13nsCOMPtr_baseFv proc
|
---|
184 | push ebp
|
---|
185 | mov ebp,esp
|
---|
186 | sub esp,08h
|
---|
187 | mov [ebp+08h],eax; this
|
---|
188 | mov [ebp+0ch],edx; __dtorFlags
|
---|
189 |
|
---|
190 | ; 63 if ( mRawPtr )
|
---|
191 | mov eax,[ebp+08h]; this
|
---|
192 | cmp dword ptr [eax],0h
|
---|
193 | je @BLBL4
|
---|
194 |
|
---|
195 | ; 64 NSCAP_RELEASE(this, mRawPtr);
|
---|
196 | mov ecx,[ebp+08h]; this
|
---|
197 | mov ecx,[ecx]
|
---|
198 | mov ecx,[ecx]
|
---|
199 | mov eax,[ebp+08h]; this
|
---|
200 | mov eax,[eax]
|
---|
201 | add eax,[ecx+01ch]
|
---|
202 | mov ecx,[ebp+08h]; this
|
---|
203 | mov ecx,[ecx]
|
---|
204 | mov ecx,[ecx]
|
---|
205 | call dword ptr [ecx+018h]
|
---|
206 | @BLBL4:
|
---|
207 |
|
---|
208 | ; 65 }
|
---|
209 | test byte ptr [ebp+0ch],01h; __dtorFlags
|
---|
210 | je @BLBL6
|
---|
211 | mov eax,[ebp+08h]; this
|
---|
212 | call __dl__FPv
|
---|
213 | @BLBL6:
|
---|
214 | mov eax,[ebp+08h]; this
|
---|
215 | add esp,08h
|
---|
216 | pop ebp
|
---|
217 | ret
|
---|
218 | __dt__13nsCOMPtr_baseFv endp
|
---|
219 | */
|
---|
220 | extern "C" void * VFTCALL __dt__13nsCOMPtr_baseFv(void *pvThis, unsigned __dtorFlags)
|
---|
221 | {
|
---|
222 | obj_nsCOMPtr_base *pThis = (obj_nsCOMPtr_base*)pvThis;
|
---|
223 | //asm("int $3");
|
---|
224 | if (pThis->mRawPtr)
|
---|
225 | {
|
---|
226 | /* NSCAP_RELEASE(this, mRawPtr); */
|
---|
227 | pThis->mRawPtr->pVFT->Release((char*)pThis->mRawPtr + pThis->mRawPtr->pVFT->uDeltaRelease);
|
---|
228 | }
|
---|
229 |
|
---|
230 | /*
|
---|
231 | * Delete the object...
|
---|
232 | * (As memtioned before we'll rather leak this.)
|
---|
233 | */
|
---|
234 | #if 0
|
---|
235 | if (!(__dtorFlags & 1))
|
---|
236 | __dl__FPv(this)
|
---|
237 | #endif
|
---|
238 |
|
---|
239 | return pvThis;
|
---|
240 | }
|
---|
241 |
|
---|
242 | /** workaround for _Optlink bug.. */
|
---|
243 | extern "C" void * VFTCALL _dt__13nsCOMPtr_baseFv(void *pvThis, unsigned __dtorFlags)
|
---|
244 | {
|
---|
245 | return __dt__13nsCOMPtr_baseFv(pvThis, __dtorFlags);
|
---|
246 | }
|
---|
247 |
|
---|
248 |
|
---|
249 |
|
---|
250 | /**
|
---|
251 | *
|
---|
252 | * -----
|
---|
253 | * assembly:
|
---|
254 | ; 92 nsGetServiceByCID::operator()( const nsIID& aIID, void** aInstancePtr ) const
|
---|
255 | align 010h
|
---|
256 |
|
---|
257 | public __cl__17nsGetServiceByCIDCFRC4nsIDPPv
|
---|
258 | __cl__17nsGetServiceByCIDCFRC4nsIDPPv proc
|
---|
259 | push ebp
|
---|
260 | mov ebp,esp
|
---|
261 | sub esp,014h
|
---|
262 | push ebx
|
---|
263 | sub esp,08h
|
---|
264 | mov [ebp+08h],eax; this
|
---|
265 | mov [ebp+0ch],edx; aIID
|
---|
266 | mov [ebp+010h],ecx; aInstancePtr
|
---|
267 |
|
---|
268 | ; 94 nsresult status = NS_ERROR_FAILURE;
|
---|
269 | mov dword ptr [ebp-04h],080004005h; status
|
---|
270 |
|
---|
271 | ; 95 if ( mServiceManager ) {
|
---|
272 | mov eax,[ebp+08h]; this
|
---|
273 | add eax,08h
|
---|
274 | call __opP13nsDerivedSafeXT17nsIServiceManager___8nsCOMPtrXT17nsIServiceManager_CFv
|
---|
275 | test eax,eax
|
---|
276 | je @BLBL13
|
---|
277 |
|
---|
278 | ; 96 status = mServiceManager->GetService(mCID, aIID, (void**)aInstancePtr);
|
---|
279 | mov eax,[ebp+08h]; this
|
---|
280 | add eax,08h
|
---|
281 | call __rf__8nsCOMPtrXT17nsIServiceManager_CFv
|
---|
282 | mov [ebp-08h],eax; __212
|
---|
283 | mov eax,[ebp+010h]; aInstancePtr
|
---|
284 | push eax
|
---|
285 | mov ecx,[ebp+0ch]; aIID
|
---|
286 | mov edx,[ebp+08h]; this
|
---|
287 | mov edx,[edx+04h]
|
---|
288 | mov ebx,[ebp-08h]; __212
|
---|
289 | mov ebx,[ebx]
|
---|
290 | mov eax,[ebp-08h]; __212
|
---|
291 | add eax,[ebx+024h]
|
---|
292 | sub esp,0ch
|
---|
293 | mov ebx,[ebp-08h]; __212
|
---|
294 | mov ebx,[ebx]
|
---|
295 | call dword ptr [ebx+020h]
|
---|
296 | add esp,010h
|
---|
297 | mov [ebp-04h],eax; status
|
---|
298 |
|
---|
299 | ; 97 } else {
|
---|
300 | jmp @BLBL14
|
---|
301 | align 010h
|
---|
302 | @BLBL13:
|
---|
303 |
|
---|
304 | ; 95 if ( mServiceManager ) {
|
---|
305 |
|
---|
306 | ; 98 nsCOMPtr<nsIServiceManager> mgr;
|
---|
307 | lea eax,[ebp-0ch]; mgr
|
---|
308 | call __ct__8nsCOMPtrXT17nsIServiceManager_Fv
|
---|
309 |
|
---|
310 | ; 99 NS_GetServiceManager(getter_AddRefs(mgr));
|
---|
311 | lea edx,[ebp-0ch]; mgr
|
---|
312 | lea eax,[ebp-010h]; __216
|
---|
313 | call getter_AddRefs__FR8nsCOMPtrXT17nsIServiceManager_
|
---|
314 | sub esp,04h
|
---|
315 | lea eax,[ebp-010h]; __216
|
---|
316 | sub esp,04h
|
---|
317 | call __opPP17nsIServiceManager__15nsGetterAddRefsXT17nsIServiceManager_Fv
|
---|
318 | add esp,08h
|
---|
319 | call NS_GetServiceManager
|
---|
320 | mov edx,02h
|
---|
321 | lea eax,[ebp-010h]; __216
|
---|
322 | call __dt__15nsGetterAddRefsXT17nsIServiceManager_Fv
|
---|
323 |
|
---|
324 | ; 100 if (mgr)
|
---|
325 | lea eax,[ebp-0ch]; mgr
|
---|
326 | call __opP13nsDerivedSafeXT17nsIServiceManager___8nsCOMPtrXT17nsIServiceManager_CFv
|
---|
327 | test eax,eax
|
---|
328 | je @BLBL15
|
---|
329 |
|
---|
330 | ; 101 status = mgr->GetService(mCID, aIID, (void**)aInstancePtr);
|
---|
331 | lea eax,[ebp-0ch]; mgr
|
---|
332 | call __rf__8nsCOMPtrXT17nsIServiceManager_CFv
|
---|
333 | mov [ebp-014h],eax; __217
|
---|
334 | mov eax,[ebp+010h]; aInstancePtr
|
---|
335 | push eax
|
---|
336 | mov ecx,[ebp+0ch]; aIID
|
---|
337 | mov edx,[ebp+08h]; this
|
---|
338 | mov edx,[edx+04h]
|
---|
339 | mov ebx,[ebp-014h]; __217
|
---|
340 | mov ebx,[ebx]
|
---|
341 | mov eax,[ebp-014h]; __217
|
---|
342 | add eax,[ebx+024h]
|
---|
343 | sub esp,0ch
|
---|
344 | mov ebx,[ebp-014h]; __217
|
---|
345 | mov ebx,[ebx]
|
---|
346 | call dword ptr [ebx+020h]
|
---|
347 | add esp,010h
|
---|
348 | mov [ebp-04h],eax; status
|
---|
349 | @BLBL15:
|
---|
350 |
|
---|
351 | ; 102 }
|
---|
352 | mov edx,02h
|
---|
353 | lea eax,[ebp-0ch]; mgr
|
---|
354 | call __dt__8nsCOMPtrXT17nsIServiceManager_Fv
|
---|
355 | @BLBL14:
|
---|
356 |
|
---|
357 | ; 103 if ( NS_FAILED(status) )
|
---|
358 | test byte ptr [ebp-01h],080h; status
|
---|
359 | je @BLBL16
|
---|
360 |
|
---|
361 | ; 104 *aInstancePtr = 0;
|
---|
362 | mov eax,[ebp+010h]; aInstancePtr
|
---|
363 | mov dword ptr [eax],0h
|
---|
364 | @BLBL16:
|
---|
365 |
|
---|
366 | ; 106 if ( mErrorPtr )
|
---|
367 | mov eax,[ebp+08h]; this
|
---|
368 | cmp dword ptr [eax+0ch],0h
|
---|
369 | je @BLBL17
|
---|
370 |
|
---|
371 | ; 107 *mErrorPtr = status;
|
---|
372 | mov eax,[ebp+08h]; this
|
---|
373 | mov eax,[eax+0ch]
|
---|
374 | mov ebx,[ebp-04h]; status
|
---|
375 | mov [eax],ebx
|
---|
376 | @BLBL17:
|
---|
377 |
|
---|
378 | ; 108 return status;
|
---|
379 | mov eax,[ebp-04h]; status
|
---|
380 | add esp,08h
|
---|
381 | pop ebx
|
---|
382 | mov esp,ebp
|
---|
383 | pop ebp
|
---|
384 | ret
|
---|
385 | __cl__17nsGetServiceByCIDCFRC4nsIDPPv endp
|
---|
386 |
|
---|
387 | * -----
|
---|
388 | * C++ Code:
|
---|
389 | nsresult
|
---|
390 | nsGetServiceByCID::operator()( const nsIID& aIID, void** aInstancePtr ) const
|
---|
391 | {
|
---|
392 | nsresult status = NS_ERROR_FAILURE;
|
---|
393 | if ( mServiceManager ) {
|
---|
394 | status = mServiceManager->GetService(mCID, aIID, (void**)aInstancePtr);
|
---|
395 | } else {
|
---|
396 | nsCOMPtr<nsIServiceManager> mgr;
|
---|
397 | NS_GetServiceManager(getter_AddRefs(mgr));
|
---|
398 | if (mgr)
|
---|
399 | status = mgr->GetService(mCID, aIID, (void**)aInstancePtr);
|
---|
400 | }
|
---|
401 | if ( NS_FAILED(status) )
|
---|
402 | *aInstancePtr = 0;
|
---|
403 |
|
---|
404 | if ( mErrorPtr )
|
---|
405 | *mErrorPtr = status;
|
---|
406 | return status;
|
---|
407 | }
|
---|
408 | */
|
---|
409 | extern "C" nsresult VFTCALL GSBC_COM__operator_paratheses(void *pvThis, REFNSIID aIID, void** aInstancePtr)
|
---|
410 | {
|
---|
411 | obj_nsGetServiceByCID_nsCOMPtr_helper *pThis = (obj_nsGetServiceByCID_nsCOMPtr_helper *)pvThis;
|
---|
412 | nsresult status = NS_ERROR_FAILURE;
|
---|
413 | //asm("int $3");
|
---|
414 |
|
---|
415 | /* For convenience we don't use mServiceManager here because it's a wrapped object.
|
---|
416 | * We ASSUME that there is only one service manager floating around....
|
---|
417 | */
|
---|
418 | nsCOMPtr<nsIServiceManager> mgr;
|
---|
419 | NS_GetServiceManager(getter_AddRefs(mgr));
|
---|
420 | if (mgr)
|
---|
421 | status = mgr->GetService(*pThis->mCID, aIID, (void**)aInstancePtr);
|
---|
422 |
|
---|
423 | if (NS_FAILED(status))
|
---|
424 | *aInstancePtr = 0;
|
---|
425 |
|
---|
426 | if (pThis->mErrorPtr)
|
---|
427 | *pThis->mErrorPtr = status;
|
---|
428 | return status;
|
---|
429 | }
|
---|
430 |
|
---|
431 | /**
|
---|
432 | * Just a destructor.
|
---|
433 | * -----
|
---|
434 | * assembly:
|
---|
435 | ; 59 virtual ~nsGetServiceByCID() {};
|
---|
436 | align 010h
|
---|
437 |
|
---|
438 | __dt__17nsGetServiceByCIDFv proc
|
---|
439 | push ebp
|
---|
440 | mov ebp,esp
|
---|
441 | sub esp,08h
|
---|
442 | mov [ebp+08h],eax; this
|
---|
443 | mov [ebp+0ch],edx; __dtorFlags
|
---|
444 | mov [ebp+010h],ecx; __vtt
|
---|
445 | mov eax,[ebp+08h]; this
|
---|
446 | mov dword ptr [eax],offset FLAT:__vft17nsGetServiceByCID15nsCOMPtr_helper
|
---|
447 | mov edx,02h
|
---|
448 | mov eax,[ebp+08h]; this
|
---|
449 | add eax,08h
|
---|
450 | call __dt__8nsCOMPtrXT17nsIServiceManager_Fv
|
---|
451 | test byte ptr [ebp+0ch],01h; __dtorFlags
|
---|
452 | je @BLBL24
|
---|
453 | mov eax,[ebp+08h]; this
|
---|
454 | call __dl__FPv
|
---|
455 | @BLBL24:
|
---|
456 | mov eax,[ebp+08h]; this
|
---|
457 | add esp,08h
|
---|
458 | pop ebp
|
---|
459 | ret
|
---|
460 | __dt__17nsGetServiceByCIDFv endp
|
---|
461 | */
|
---|
462 | extern "C" void * VFTCALL GSBC_COM__destructor(void *pvThis, unsigned __dtorFlags, unsigned __vtt)
|
---|
463 | {
|
---|
464 | obj_nsGetServiceByCID_nsCOMPtr_helper *pThis = (obj_nsGetServiceByCID_nsCOMPtr_helper *)pvThis;
|
---|
465 | //asm("int $3");
|
---|
466 |
|
---|
467 | /*
|
---|
468 | * Because previously mentioned issues with VAC heaps, we'll
|
---|
469 | * not do anything in here.
|
---|
470 | * (We will then skip destruction of all parents and such, but
|
---|
471 | * I don't think that will hurt anyone.)
|
---|
472 | */
|
---|
473 | __dtorFlags = __dtorFlags;
|
---|
474 | __vtt = __vtt;
|
---|
475 | return pThis;
|
---|
476 | }
|
---|
477 |
|
---|
478 |
|
---|
479 | /**
|
---|
480 | * VFT for nsGetServiceByCID::nsCOMPtr_helper or something like that.
|
---|
481 | * It's just implementing an operator() and the destructor.
|
---|
482 | *
|
---|
483 | * @remark We need to skip an underscore to get the name right.
|
---|
484 | * ----
|
---|
485 | * assembly:
|
---|
486 | __vft17nsGetServiceByCID15nsCOMPtr_helper dd 0
|
---|
487 | db 0h,0h,0h,0h
|
---|
488 | dd offset FLAT:__cl__17nsGetServiceByCIDCFRC4nsIDPPv
|
---|
489 | db 0h,0h,0h,0h
|
---|
490 | dd offset FLAT:__dt__17nsGetServiceByCIDFv
|
---|
491 | db 0h,0h,0h,0h
|
---|
492 | */
|
---|
493 | extern const VFTnsGetServiceByCID_nsCOMPtr_helper _vft17nsGetServiceByCID15nsCOMPtr_helper =
|
---|
494 | {
|
---|
495 | VFTFIRST_VAL()
|
---|
496 | GSBC_COM__operator_paratheses, VFTDELTA_VAL()
|
---|
497 | GSBC_COM__destructor, VFTDELTA_VAL()
|
---|
498 | };
|
---|
499 |
|
---|
500 |
|
---|
501 |
|
---|
502 | /**
|
---|
503 | *
|
---|
504 | * -----
|
---|
505 | * assembly
|
---|
506 | ; 42 nsQueryInterface::operator()( const nsIID& aIID, void** answer ) const
|
---|
507 | align 010h
|
---|
508 |
|
---|
509 | public __cl__16nsQueryInterfaceCFRC4nsIDPPv
|
---|
510 | __cl__16nsQueryInterfaceCFRC4nsIDPPv proc
|
---|
511 | push ebp
|
---|
512 | mov ebp,esp
|
---|
513 | sub esp,08h
|
---|
514 | push ebx
|
---|
515 | sub esp,0ch
|
---|
516 | mov [ebp+08h],eax; this
|
---|
517 | mov [ebp+0ch],edx; aIID
|
---|
518 | mov [ebp+010h],ecx; answer
|
---|
519 |
|
---|
520 | ; 45 if ( mRawPtr )
|
---|
521 | mov eax,[ebp+08h]; this
|
---|
522 | cmp dword ptr [eax+04h],0h
|
---|
523 | je @BLBL1
|
---|
524 |
|
---|
525 | ; 46 {
|
---|
526 | ; 47 status = mRawPtr->QueryInterface(aIID, answer);
|
---|
527 | mov ecx,[ebp+010h]; answer
|
---|
528 | mov edx,[ebp+0ch]; aIID
|
---|
529 | mov ebx,[ebp+08h]; this
|
---|
530 | mov ebx,[ebx+04h]
|
---|
531 | mov ebx,[ebx]
|
---|
532 | mov eax,[ebp+08h]; this
|
---|
533 | mov eax,[eax+04h]
|
---|
534 | add eax,[ebx+0ch]
|
---|
535 | mov ebx,[ebp+08h]; this
|
---|
536 | mov ebx,[ebx+04h]
|
---|
537 | mov ebx,[ebx]
|
---|
538 | call dword ptr [ebx+08h]
|
---|
539 | mov [ebp-04h],eax; status
|
---|
540 |
|
---|
541 | ; 48 #ifdef NSCAP_FEATURE_TEST_NONNULL_QUERY_SUCCEEDS
|
---|
542 | ; 49 NS_WARN_IF_FALSE(NS_SUCCEEDED(status), "interface not found---were you expecting that?");
|
---|
543 | ; 50 #endif
|
---|
544 | ; 51 }
|
---|
545 | jmp @BLBL2
|
---|
546 | align 010h
|
---|
547 | @BLBL1:
|
---|
548 |
|
---|
549 | ; 45 if ( mRawPtr )
|
---|
550 |
|
---|
551 | ; 53 status = NS_ERROR_NULL_POINTER;
|
---|
552 | mov dword ptr [ebp-04h],080004003h; status
|
---|
553 | @BLBL2:
|
---|
554 |
|
---|
555 | ; 55 if ( mErrorPtr )
|
---|
556 | mov eax,[ebp+08h]; this
|
---|
557 | cmp dword ptr [eax+08h],0h
|
---|
558 | je @BLBL3
|
---|
559 |
|
---|
560 | ; 56 *mErrorPtr = status;
|
---|
561 | mov eax,[ebp+08h]; this
|
---|
562 | mov eax,[eax+08h]
|
---|
563 | mov ebx,[ebp-04h]; status
|
---|
564 | mov [eax],ebx
|
---|
565 | @BLBL3:
|
---|
566 |
|
---|
567 | ; 57 return status;
|
---|
568 | mov eax,[ebp-04h]; status
|
---|
569 | add esp,0ch
|
---|
570 | pop ebx
|
---|
571 | mov esp,ebp
|
---|
572 | pop ebp
|
---|
573 | ret
|
---|
574 | __cl__16nsQueryInterfaceCFRC4nsIDPPv endp
|
---|
575 |
|
---|
576 | * -----
|
---|
577 | * C++ Code:
|
---|
578 | nsresult
|
---|
579 | nsQueryInterface::operator()( const nsIID& aIID, void** answer ) const
|
---|
580 | {
|
---|
581 | nsresult status;
|
---|
582 | if ( mRawPtr )
|
---|
583 | {
|
---|
584 | status = mRawPtr->QueryInterface(aIID, answer);
|
---|
585 | #ifdef NSCAP_FEATURE_TEST_NONNULL_QUERY_SUCCEEDS
|
---|
586 | NS_WARN_IF_FALSE(NS_SUCCEEDED(status), "interface not found---were you expecting that?");
|
---|
587 | #endif
|
---|
588 | }
|
---|
589 | else
|
---|
590 | status = NS_ERROR_NULL_POINTER;
|
---|
591 |
|
---|
592 | if ( mErrorPtr )
|
---|
593 | *mErrorPtr = status;
|
---|
594 | return status;
|
---|
595 | }
|
---|
596 | */
|
---|
597 | extern "C" nsresult VFTCALL QI_COM__operator_paratheses(void *pvThis, REFNSIID aIID, void** aInstancePtr)
|
---|
598 | {
|
---|
599 | obj_nsQueryInterface_nsCOMPtr_helper *pThis = (obj_nsQueryInterface_nsCOMPtr_helper *)pvThis;
|
---|
600 | nsresult status = NS_ERROR_NULL_POINTER;
|
---|
601 | //asm("int $3");
|
---|
602 |
|
---|
603 | if (pThis->mRawPtr)
|
---|
604 | {
|
---|
605 | status = pThis->mRawPtr->pVFT->QueryInterface(pThis->mRawPtr, aIID, aInstancePtr);
|
---|
606 | /* don't care about warnings, do we? */
|
---|
607 | }
|
---|
608 |
|
---|
609 | if (pThis->mErrorPtr)
|
---|
610 | *pThis->mErrorPtr = status;
|
---|
611 | return status;
|
---|
612 | }
|
---|
613 |
|
---|
614 |
|
---|
615 |
|
---|
616 | /**
|
---|
617 | * VFT for nsQueryInterface::nsCOMPtr_helper or something like that.
|
---|
618 | * No destructor, only an operator().
|
---|
619 | *
|
---|
620 | * @remark We need to skip an underscore to get the name right.
|
---|
621 | * -----
|
---|
622 | * assembly:
|
---|
623 | __vft16nsQueryInterface15nsCOMPtr_helper dd 0
|
---|
624 | db 0h,0h,0h,0h
|
---|
625 | dd offset FLAT:__cl__16nsQueryInterfaceCFRC4nsIDPPv
|
---|
626 | db 0h,0h,0h,0h
|
---|
627 | */
|
---|
628 | extern const VFTnsQueryInterface_nsCOMPtr_helper _vft16nsQueryInterface15nsCOMPtr_helper =
|
---|
629 | {
|
---|
630 | VFTFIRST_VAL()
|
---|
631 | QI_COM__operator_paratheses, VFTDELTA_VAL()
|
---|
632 | };
|
---|
633 |
|
---|
634 | /**
|
---|
635 | *
|
---|
636 | * -----
|
---|
637 | * C++ Code:
|
---|
638 | void
|
---|
639 | assign_assuming_AddRef( nsISupports* newPtr )
|
---|
640 | {
|
---|
641 | / *
|
---|
642 | |AddRef()|ing the new value (before entering this function) before
|
---|
643 | |Release()|ing the old lets us safely ignore the self-assignment case.
|
---|
644 | We must, however, be careful only to |Release()| _after_ doing the
|
---|
645 | assignment, in case the |Release()| leads to our _own_ destruction,
|
---|
646 | which would, in turn, cause an incorrect second |Release()| of our old
|
---|
647 | pointer. Thank <waterson@netscape.com> for discovering this.
|
---|
648 | * /
|
---|
649 | nsISupports* oldPtr = mRawPtr;
|
---|
650 | mRawPtr = newPtr;
|
---|
651 | NSCAP_LOG_ASSIGNMENT(this, newPtr);
|
---|
652 | NSCAP_LOG_RELEASE(this, oldPtr);
|
---|
653 | if ( oldPtr )
|
---|
654 | NSCAP_RELEASE(this, oldPtr);
|
---|
655 | }
|
---|
656 | */
|
---|
657 | extern "C" void VFTCALL assign_assuming_AddRef__13nsCOMPtr_baseFP11nsISupports(void *pvThis, obj_nsISupports *newPtr)
|
---|
658 | {
|
---|
659 | obj_nsCOMPtr_base *pThis = (obj_nsCOMPtr_base *)pvThis;
|
---|
660 | obj_nsISupports *oldPtr;
|
---|
661 |
|
---|
662 | oldPtr = pThis->mRawPtr;
|
---|
663 | pThis->mRawPtr = newPtr;
|
---|
664 | if (oldPtr)
|
---|
665 | {
|
---|
666 | /* NSCAP_RELEASE(this, oldPtr); */
|
---|
667 | pThis->mRawPtr->pVFT->Release(oldPtr + oldPtr->pVFT->uDeltaRelease);
|
---|
668 | }
|
---|
669 | }
|
---|
670 |
|
---|
671 |
|
---|
672 |
|
---|
673 |
|
---|
674 | /**
|
---|
675 | *
|
---|
676 | * -----
|
---|
677 | * Assembly:
|
---|
678 | ; 77 nsCOMPtr_base::assign_from_helper( const nsCOMPtr_helper& helper, const nsIID& iid )
|
---|
679 | align 010h
|
---|
680 |
|
---|
681 | public assign_from_helper__13nsCOMPtr_baseFRC15nsCOMPtr_helperRC4nsID
|
---|
682 | assign_from_helper__13nsCOMPtr_baseFRC15nsCOMPtr_helperRC4nsID proc
|
---|
683 | push ebp
|
---|
684 | mov ebp,esp
|
---|
685 | sub esp,08h
|
---|
686 | push ebx
|
---|
687 | sub esp,0ch
|
---|
688 | mov [ebp+08h],eax; this
|
---|
689 | mov [ebp+0ch],edx; helper
|
---|
690 | mov [ebp+010h],ecx; iid
|
---|
691 |
|
---|
692 | ; 80 if ( NS_FAILED( helper(iid, NS_REINTERPRET_CAST(void**, &newRawPtr)) ) )
|
---|
693 | lea ecx,[ebp-04h]; newRawPtr
|
---|
694 | mov edx,[ebp+010h]; iid
|
---|
695 | mov ebx,[ebp+0ch]; helper
|
---|
696 | mov ebx,[ebx]
|
---|
697 | mov eax,[ebp+0ch]; helper
|
---|
698 | add eax,[ebx+0ch]
|
---|
699 | mov ebx,[ebp+0ch]; helper
|
---|
700 | mov ebx,[ebx]
|
---|
701 | call dword ptr [ebx+08h]
|
---|
702 | test eax,080000000h
|
---|
703 | je @BLBL8
|
---|
704 |
|
---|
705 | ; 81 newRawPtr = 0;
|
---|
706 | mov dword ptr [ebp-04h],0h; newRawPtr
|
---|
707 | @BLBL8:
|
---|
708 |
|
---|
709 | ; 82 assign_assuming_AddRef(newRawPtr);
|
---|
710 | mov edx,[ebp-04h]; newRawPtr
|
---|
711 | mov eax,[ebp+08h]; this
|
---|
712 | call assign_assuming_AddRef__13nsCOMPtr_baseFP11nsISupports
|
---|
713 | add esp,0ch
|
---|
714 | pop ebx
|
---|
715 | mov esp,ebp
|
---|
716 | pop ebp
|
---|
717 | ret
|
---|
718 | assign_from_helper__13nsCOMPtr_baseFRC15nsCOMPtr_helperRC4nsID endp
|
---|
719 |
|
---|
720 | * -----
|
---|
721 | * C Code:
|
---|
722 | void
|
---|
723 | nsCOMPtr_base::assign_from_helper( const nsCOMPtr_helper& helper, const nsIID& iid )
|
---|
724 | {
|
---|
725 | nsISupports* newRawPtr;
|
---|
726 | if ( NS_FAILED( helper(iid, NS_REINTERPRET_CAST(void**, &newRawPtr)) ) )
|
---|
727 | newRawPtr = 0;
|
---|
728 | assign_assuming_AddRef(newRawPtr);
|
---|
729 | }
|
---|
730 | */
|
---|
731 | extern "C" void VFTCALL assign_from_helper__13nsCOMPtr_baseFRC15nsCOMPtr_helperRC4nsID(
|
---|
732 | void *pvThis, void * helper, REFNSIID iid)
|
---|
733 | {
|
---|
734 | obj_nsCOMPtr_base *pThis = (obj_nsCOMPtr_base *)pvThis;
|
---|
735 | obj_nsISupports* newRawPtr = NULL;
|
---|
736 | nsresult status = NS_ERROR_FAILURE;
|
---|
737 | //asm("int $3");
|
---|
738 |
|
---|
739 | /* this may or may not be correct but the layout is the same. */
|
---|
740 | obj_nsQueryInterface_nsCOMPtr_helper * pHelper = (obj_nsQueryInterface_nsCOMPtr_helper*)helper;
|
---|
741 |
|
---|
742 | /* if ( NS_FAILED( helper(iid, NS_REINTERPRET_CAST(void**, &newRawPtr)) ) ) */
|
---|
743 | status = pHelper->pVFT->__operator_paratheses((char*)pHelper + pHelper->pVFT->uDelta__operator_paratheses,
|
---|
744 | iid, (void**)&newRawPtr);
|
---|
745 | if (NS_FAILED(status))
|
---|
746 | newRawPtr = 0;
|
---|
747 |
|
---|
748 | /* assign_assuming_AddRef(newRawPtr); */
|
---|
749 | assign_assuming_AddRef__13nsCOMPtr_baseFP11nsISupports(pThis, newRawPtr);
|
---|
750 | }
|
---|
751 |
|
---|
752 |
|
---|
753 |
|
---|