freemansoft / jacob-project

JACOB is a JAVA-COM Bridge that allows you to call COM Automation components from Java. It uses JNI to make native calls to the COM libraries. JACOB runs on x86 and x64 environments supporting 32 bit and 64 bit JVMs. This repository was migrated from Sourceforge 2020 Sep
GNU Lesser General Public License v2.1
521 stars 117 forks source link

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

Open EJP286CRSKW opened 12 months ago

EJP286CRSKW commented 12 months ago

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.

freemansoft commented 6 months ago

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.