jacob-project icon indicating copy to clipboard operation
jacob-project copied to clipboard

Char/VT_UI16 support missing from Variant.java/.cpp and VariantUtilities

Open EJP286CRSKW opened this issue 1 year ago • 1 comments

VT_UI16 maps naturally to Java char or java.lang.Character.

It is possible to create a Variant of type VT_UI2, by passing the value 18.

However that's it. You can't do anything else with this Variant except use it without a value. The following members are missing from Variant.java/.cpp:

public static final short VariantChar = 18;

public Variant(char c)
public char getChar()
public char getVariantChar()
public void putChar(char c)
public void putCharRef(char c)
private native void putVariantChar(char c)
private native void putVariantCharRef(char c)

and whatever is needed in the JNI to support them.

The Java code required is trivial, the same as for any other type, mutatis mutandis. Sadly I don't have the means to modify the JNI as my C++ compiler is too old, otherwise I would provide tested code in both Java and C++.

VariantUtilities also needs to deal with VT_UI16 and java.lang.Character, in variantToObject() and objectToVariant(), in the obvious ways.

This omission is curious given that SafeArray supports arrays of char in both 1D and 2D.

EJP286CRSKW avatar Oct 10 '23 04:10 EJP286CRSKW

The free version of Visual studio comes with the correct libraries and compilers

These oddities came about because many of the updates were built by people who solved just their problem.

freemansoft avatar Mar 18 '24 03:03 freemansoft