Skip to content

Commit

Permalink
Merge pull request #451 from mitkola/patch-1
Browse files Browse the repository at this point in the history
Add support for BYTE and CHAR to VARIANT
  • Loading branch information
twall committed Aug 30, 2015
2 parents 5d4e193 + 93372e8 commit c4b033f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
21 changes: 21 additions & 0 deletions contrib/platform/src/com/sun/jna/platform/win32/Variant.java
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,24 @@ public VARIANT(DATE value) {
this.setValue(VT_DATE, value);
}

public VARIANT(byte value) {
this(new BYTE(value));
}

public VARIANT(BYTE value) {
this();
this.setValue(Variant.VT_UI1, value);
}

public VARIANT(char value) {
this(new CHAR(value));
}

public VARIANT(CHAR value) {
this();
this.setValue(Variant.VT_I1, value);
}

public VARIANT(short value) {
this();
this.setValue(VT_I2, new SHORT(value));
Expand Down Expand Up @@ -259,6 +277,9 @@ public void setValue(int vt, Object value) {

public void setValue(VARTYPE vt, Object value) {
switch (vt.intValue()) {
case VT_UI1:
this._variant.__variant.writeField("bVal", value);
break;
case VT_I2:
this._variant.__variant.writeField("iVal", value);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ public void testVariantRecord() {

public void testVariantConstructors() {
VARIANT variant = new VARIANT((short) 1);
variant = new VARIANT((byte) 1);
variant = new VARIANT('1');
variant = new VARIANT((int) 1);
variant = new VARIANT((long) 1);
variant = new VARIANT((float) 1);
Expand Down

0 comments on commit c4b033f

Please sign in to comment.