1 /*******************************************************************************
2 * Copyright (c) 2000, 2017 IBM Corporation and others.
4 * This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License 2.0
6 * which accompanies this distribution, and is available at
7 * https://www.eclipse.org/legal/epl-2.0/
9 * SPDX-License-Identifier: EPL-2.0
12 * IBM Corporation - initial API and implementation
13 *******************************************************************************/
14 package org.eclipse.swt.internal.ole.win32;
17 import org.eclipse.swt.internal.win32.*;
19 public class ITypeInfo extends IUnknown
22 public ITypeInfo(long address) {
25 public int GetDocumentation(int index, String[] name, String[] docString, int[] pdwHelpContext, String[] helpFile ) {
26 long[] pBstrName = null;
27 if (name != null) pBstrName = new long[1];
28 long[] pBstrDocString = null;
29 if (docString != null) pBstrDocString = new long[1];
30 long[] pBstrHelpFile = null;
31 if (helpFile != null) pBstrHelpFile = new long[1];
32 int rc = COM.VtblCall(12, address, index, pBstrName, pBstrDocString, pdwHelpContext, pBstrHelpFile);
33 if (name != null && pBstrName[0] != 0) {
34 int size = COM.SysStringByteLen(pBstrName[0]);
36 // get the unicode character array from the global memory and create a String
37 char[] buffer = new char[(size + 1) /2]; // add one to avoid rounding errors
38 OS.MoveMemory(buffer, pBstrName[0], size);
39 name[0] = new String(buffer);
40 int subindex = name[0].indexOf("\0");
42 name[0] = name[0].substring(0, subindex);
44 COM.SysFreeString(pBstrName[0]);
46 if (docString != null && pBstrDocString[0] != 0) {
47 int size = COM.SysStringByteLen(pBstrDocString[0]);
49 // get the unicode character array from the global memory and create a String
50 char[] buffer = new char[(size + 1) /2]; // add one to avoid rounding errors
51 OS.MoveMemory(buffer, pBstrDocString[0], size);
52 docString[0] = new String(buffer);
53 int subindex = docString[0].indexOf("\0");
55 docString[0] = docString[0].substring(0, subindex);
57 COM.SysFreeString(pBstrDocString[0]);
59 if (helpFile != null && pBstrHelpFile[0] != 0) {
60 int size = COM.SysStringByteLen(pBstrHelpFile[0]);
62 // get the unicode character array from the global memory and create a String
63 char[] buffer = new char[(size + 1) /2]; // add one to avoid rounding errors
64 OS.MoveMemory(buffer, pBstrHelpFile[0], size);
65 helpFile[0] = new String(buffer);
66 int subindex = helpFile[0].indexOf("\0");
68 helpFile[0] = helpFile[0].substring(0, subindex);
70 COM.SysFreeString(pBstrHelpFile[0]);
74 public int GetFuncDesc(int index, long[] ppFuncDesc) {
75 return COM.VtblCall(5, address, index, ppFuncDesc);
77 public int GetImplTypeFlags(int index, int[] pImplTypeFlags) {
78 return COM.VtblCall(9, address, index, pImplTypeFlags);
80 public int GetNames(int memid, String[] names, int cMaxNames, int[] pcNames){
82 int nameSize = names.length;
83 long[] rgBstrNames = new long[nameSize];
84 int rc = COM.VtblCall(7, address, memid, rgBstrNames, nameSize, pcNames);
87 for (int i = 0; i < pcNames[0]; i++) {
88 int size = COM.SysStringByteLen(rgBstrNames[i]);
90 // get the unicode character array from the global memory and create a String
91 char[] buffer = new char[(size + 1) /2]; // add one to avoid rounding errors
92 OS.MoveMemory(buffer, rgBstrNames[i], size);
93 names[i] = new String(buffer);
94 int subindex = names[i].indexOf("\0");
96 names[i] = names[i].substring(0, subindex);
98 COM.SysFreeString(rgBstrNames[i]);
104 public int GetRefTypeInfo(int hRefType, long[] ppTInfo) {
105 return COM.VtblCall(14, address, hRefType, ppTInfo);
107 public int GetRefTypeOfImplType(int index, int[] pRefType) {
108 return COM.VtblCall(8, address, index, pRefType);
110 public int GetTypeAttr(long[] ppTypeAttr) {
111 return COM.VtblCall(3, address, ppTypeAttr);
113 public int GetVarDesc(int index, long[] ppVarDesc ) {
114 return COM.VtblCall(6, address, index, ppVarDesc);
116 public int ReleaseFuncDesc(long pFuncDesc ) {
117 return COM.VtblCall(20, address, pFuncDesc);
119 public int ReleaseTypeAttr(long pTypeAttr) {
120 return COM.VtblCall(19, address, pTypeAttr);
122 public int ReleaseVarDesc(long pVarDesc ) {
123 return COM.VtblCall(21, address, pVarDesc);