1 11 package org.eclipse.swt.internal.ole.win32; 12 13 14 import org.eclipse.swt.internal.win32.OS; 15 16 public class ITypeInfo extends IUnknown 17 { 18 19 public ITypeInfo(int address) { 20 super(address); 21 } 22 public int GetDocumentation(int index, String [] name, String [] docString, int[] pdwHelpContext, String [] helpFile ) { 23 int [] pBstrName = null; 24 if (name != null) pBstrName = new int [1]; 25 int [] pBstrDocString = null; 26 if (docString != null) pBstrDocString = new int [1]; 27 int [] pBstrHelpFile = null; 28 if (helpFile != null) pBstrHelpFile = new int [1]; 29 int rc = COM.VtblCall(12, address, index, pBstrName, pBstrDocString, pdwHelpContext, pBstrHelpFile); 30 if (name != null && pBstrName[0] != 0) { 31 int size = COM.SysStringByteLen(pBstrName[0]); 32 if (size > 0){ 33 char[] buffer = new char[(size + 1) /2]; COM.MoveMemory(buffer, pBstrName[0], size); 36 name[0] = new String (buffer); 37 int subindex = name[0].indexOf("\0"); 38 if (subindex > 0) 39 name[0] = name[0].substring(0, subindex); 40 } 41 COM.SysFreeString(pBstrName[0]); 42 } 43 if (docString != null && pBstrDocString[0] != 0) { 44 int size = COM.SysStringByteLen(pBstrDocString[0]); 45 if (size > 0){ 46 char[] buffer = new char[(size + 1) /2]; COM.MoveMemory(buffer, pBstrDocString[0], size); 49 docString[0] = new String (buffer); 50 int subindex = docString[0].indexOf("\0"); 51 if (subindex > 0) 52 docString[0] = docString[0].substring(0, subindex); 53 } 54 COM.SysFreeString(pBstrDocString[0]); 55 } 56 if (helpFile != null && pBstrHelpFile[0] != 0) { 57 int size = COM.SysStringByteLen(pBstrHelpFile[0]); 58 if (size > 0){ 59 char[] buffer = new char[(size + 1) /2]; COM.MoveMemory(buffer, pBstrHelpFile[0], size); 62 helpFile[0] = new String (buffer); 63 int subindex = helpFile[0].indexOf("\0"); 64 if (subindex > 0) 65 helpFile[0] = helpFile[0].substring(0, subindex); 66 } 67 COM.SysFreeString(pBstrHelpFile[0]); 68 } 69 return rc; 70 } 71 public int GetFuncDesc(int index, int [] ppFuncDesc) { 72 return COM.VtblCall(5, address, index, ppFuncDesc); 73 } 74 public int GetIDsOfNames(String [] rgszNames, int cNames, int[] pMemId) { 75 76 char[] buffer; 77 int size = rgszNames.length; 78 79 int hHeap = OS.GetProcessHeap(); 81 int ppNames = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, size * OS.PTR_SIZEOF); 82 int [] memTracker = new int [size]; 83 84 try { 85 87 for (int i=0; i<size; i++){ 88 int nameSize = rgszNames[i].length(); 90 buffer = new char[nameSize +1]; 91 rgszNames[i].getChars(0, nameSize, buffer, 0); 92 int pName = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, buffer.length * 2); 94 OS.MoveMemory(pName, buffer, buffer.length * 2); 95 COM.MoveMemory(ppNames + OS.PTR_SIZEOF * i, new int []{pName}, OS.PTR_SIZEOF); 97 memTracker[i] = pName; 99 } 100 101 return COM.VtblCall(10, address, ppNames, cNames, pMemId); 102 103 } finally { 104 for (int i=0; i<memTracker.length; i++){ 106 OS.HeapFree(hHeap, 0, memTracker[i]); 107 } 108 OS.HeapFree(hHeap, 0, ppNames); 109 } 110 } 111 112 public int GetImplTypeFlags(int index, int[] pImplTypeFlags) { 113 return COM.VtblCall(9, address, index, pImplTypeFlags); 114 } 115 public int GetNames(int memid, String [] names, int cMaxNames, int[] pcNames){ 116 117 int nameSize = names.length; 118 int [] rgBstrNames = new int [nameSize]; 119 int rc = COM.VtblCall(7, address, memid, rgBstrNames, nameSize, pcNames); 120 121 if (rc == COM.S_OK) { 122 for (int i = 0; i < pcNames[0]; i++) { 123 int size = COM.SysStringByteLen(rgBstrNames[i]); 124 if (size > 0){ 125 char[] buffer = new char[(size + 1) /2]; COM.MoveMemory(buffer, rgBstrNames[i], size); 128 names[i] = new String (buffer); 129 int subindex = names[i].indexOf("\0"); 130 if (subindex > 0) 131 names[i] = names[i].substring(0, subindex); 132 } 133 COM.SysFreeString(rgBstrNames[i]); 134 } 135 } 136 137 return rc; 138 } 139 public int GetRefTypeInfo(int hRefType, int [] ppTInfo) { 140 return COM.VtblCall(14, address, hRefType, ppTInfo); 141 } 142 public int GetRefTypeOfImplType(int index, int[] pRefType) { 143 return COM.VtblCall(8, address, index, pRefType); 144 } 145 public int GetTypeAttr(int [] ppTypeAttr) { 146 return COM.VtblCall(3, address, ppTypeAttr); 147 } 148 public int GetVarDesc(int index, int [] ppVarDesc ) { 149 return COM.VtblCall(6, address, index, ppVarDesc); 150 } 151 public int ReleaseFuncDesc(int pFuncDesc ) { 152 return COM.VtblCall(20, address, pFuncDesc); 153 } 154 public int ReleaseTypeAttr(int pTypeAttr) { 155 return COM.VtblCall(19, address, pTypeAttr); 156 } 157 public int ReleaseVarDesc(int pVarDesc ) { 158 return COM.VtblCall(21, address, pVarDesc); 159 } 160 } 161 | Popular Tags |