Skip to content

Commit

Permalink
Merge pull request java-native-access#1234 from joerg1985/variant
Browse files Browse the repository at this point in the history
Minor improvements to code related to Variants
  • Loading branch information
dbwiddis authored Jul 20, 2020
2 parents 083a2fe + 70035ce commit b8443b8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@ public static VARIANT toVariant(Object value) {
}

public static Object toJavaObject(VARIANT value, Class<?> targetClass, ObjectFactory factory, boolean addReference, boolean freeValue) {
if (null == value
|| value.getVarType().intValue() == VT_EMPTY
|| value.getVarType().intValue() == VT_NULL) {
int varType = (value != null) ? value.getVarType().intValue() : VT_NULL;

if (varType == VT_EMPTY || varType == VT_NULL) {
return null;
}

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

VARIANT inputValue = value;

if (value.getVarType().intValue() == (VT_BYREF | VT_VARIANT)) {
if (varType == (VT_BYREF | VT_VARIANT)) {
value = (VARIANT) value.getValue();
varType = value.getVarType().intValue();
}

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

targetClass = null;

int varType = value.getVarType().intValue();

switch (value.getVarType().intValue()) {
switch (varType) {
case VT_UI1:
case VT_I1:
targetClass = Byte.class;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,6 @@ private void setProperty(DISPID dispID, Object... args) {
for (int i = 0; i < vargs.length; ++i) {
vargs[i] = Convert.toVariant(args[i]);
}
Variant.VARIANT.ByReference result = new Variant.VARIANT.ByReference();
WinNT.HRESULT hr = this.oleMethod(OleAuto.DISPATCH_PROPERTYPUT, null, this.getRawDispatch(), dispID, vargs);

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

0 comments on commit b8443b8

Please sign in to comment.