Skip to content

Commit b8443b8

Browse files
authored
Merge pull request #1234 from joerg1985/variant
Minor improvements to code related to Variants
2 parents 083a2fe + 70035ce commit b8443b8

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

contrib/platform/src/com/sun/jna/platform/win32/COM/util/Convert.java

+6-7
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,9 @@ public static VARIANT toVariant(Object value) {
144144
}
145145

146146
public static Object toJavaObject(VARIANT value, Class<?> targetClass, ObjectFactory factory, boolean addReference, boolean freeValue) {
147-
if (null == value
148-
|| value.getVarType().intValue() == VT_EMPTY
149-
|| value.getVarType().intValue() == VT_NULL) {
147+
int varType = (value != null) ? value.getVarType().intValue() : VT_NULL;
148+
149+
if (varType == VT_EMPTY || varType == VT_NULL) {
150150
return null;
151151
}
152152

@@ -163,8 +163,9 @@ public static Object toJavaObject(VARIANT value, Class<?> targetClass, ObjectFac
163163

164164
VARIANT inputValue = value;
165165

166-
if (value.getVarType().intValue() == (VT_BYREF | VT_VARIANT)) {
166+
if (varType == (VT_BYREF | VT_VARIANT)) {
167167
value = (VARIANT) value.getValue();
168+
varType = value.getVarType().intValue();
168169
}
169170

170171
// Passing null or Object.class as targetClass switch to default
@@ -173,9 +174,7 @@ public static Object toJavaObject(VARIANT value, Class<?> targetClass, ObjectFac
173174

174175
targetClass = null;
175176

176-
int varType = value.getVarType().intValue();
177-
178-
switch (value.getVarType().intValue()) {
177+
switch (varType) {
179178
case VT_UI1:
180179
case VT_I1:
181180
targetClass = Byte.class;

contrib/platform/src/com/sun/jna/platform/win32/COM/util/ProxyObject.java

-1
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,6 @@ private void setProperty(DISPID dispID, Object... args) {
387387
for (int i = 0; i < vargs.length; ++i) {
388388
vargs[i] = Convert.toVariant(args[i]);
389389
}
390-
Variant.VARIANT.ByReference result = new Variant.VARIANT.ByReference();
391390
WinNT.HRESULT hr = this.oleMethod(OleAuto.DISPATCH_PROPERTYPUT, null, this.getRawDispatch(), dispID, vargs);
392391

393392
for (int i = 0; i < vargs.length; i++) {

0 commit comments

Comments
 (0)