1 11 package org.eclipse.swt.browser; 12 13 import org.eclipse.swt.internal.C; 14 import org.eclipse.swt.internal.mozilla.*; 15 16 class DownloadFactory_1_8 { 17 XPCOMObject supports; 18 XPCOMObject factory; 19 int refCount = 0; 20 21 public DownloadFactory_1_8 () { 22 createCOMInterfaces (); 23 } 24 25 int AddRef () { 26 refCount++; 27 return refCount; 28 } 29 30 void createCOMInterfaces () { 31 32 supports = new XPCOMObject (new int[] {2, 0, 0}) { 33 public int method0 (int [] args) {return QueryInterface (args[0], args[1]);} 34 public int method1 (int [] args) {return AddRef ();} 35 public int method2 (int [] args) {return Release ();} 36 }; 37 38 factory = new XPCOMObject (new int[] {2, 0, 0, 3, 1}) { 39 public int method0 (int [] args) {return QueryInterface (args[0], args[1]);} 40 public int method1 (int [] args) {return AddRef ();} 41 public int method2 (int [] args) {return Release ();} 42 public int method3 (int [] args) {return CreateInstance (args[0], args[1], args[2]);} 43 public int method4 (int [] args) {return LockFactory (args[0]);} 44 }; 45 } 46 47 void disposeCOMInterfaces () { 48 if (supports != null) { 49 supports.dispose (); 50 supports = null; 51 } 52 if (factory != null) { 53 factory.dispose (); 54 factory = null; 55 } 56 } 57 58 int getAddress () { 59 return factory.getAddress (); 60 } 61 62 int QueryInterface (int riid, int ppvObject) { 63 if (riid == 0 || ppvObject == 0) return XPCOM.NS_ERROR_NO_INTERFACE; 64 nsID guid = new nsID (); 65 XPCOM.memmove (guid, riid, nsID.sizeof); 66 67 if (guid.Equals (nsISupports.NS_ISUPPORTS_IID)) { 68 XPCOM.memmove (ppvObject, new int [] {supports.getAddress ()}, C.PTR_SIZEOF); 69 AddRef (); 70 return XPCOM.NS_OK; 71 } 72 if (guid.Equals (nsIFactory.NS_IFACTORY_IID)) { 73 XPCOM.memmove (ppvObject, new int [] {factory.getAddress ()}, C.PTR_SIZEOF); 74 AddRef (); 75 return XPCOM.NS_OK; 76 } 77 78 XPCOM.memmove (ppvObject, new int [] {0}, C.PTR_SIZEOF); 79 return XPCOM.NS_ERROR_NO_INTERFACE; 80 } 81 82 int Release () { 83 refCount--; 84 if (refCount == 0) disposeCOMInterfaces (); 85 return refCount; 86 } 87 88 89 90 public int CreateInstance (int aOuter, int iid, int result) { 91 Download_1_8 download = new Download_1_8 (); 92 download.AddRef (); 93 XPCOM.memmove (result, new int [] {download.getAddress ()}, C.PTR_SIZEOF); 94 return XPCOM.NS_OK; 95 } 96 97 public int LockFactory (int lock) { 98 return XPCOM.NS_OK; 99 } 100 } 101 | Popular Tags |