SF1772783 Added VT_DECIMAL support -- raised compiler warnings to /W3. fixed some of those warnings in VT_DECIMAL code
This commit is contained in:
@@ -280,7 +280,7 @@
|
|||||||
<arg value="/MD"/>
|
<arg value="/MD"/>
|
||||||
<!-- raise the warning level from the default -->
|
<!-- raise the warning level from the default -->
|
||||||
<!-- <arg value="/Wp64"/> -->
|
<!-- <arg value="/Wp64"/> -->
|
||||||
<arg value="/W2" />
|
<arg value="/W3" />
|
||||||
<!-- sets the exception model -->
|
<!-- sets the exception model -->
|
||||||
<arg value="/EHsc" />
|
<arg value="/EHsc" />
|
||||||
<!-- /O2 and /RCT1 are incompatible -->
|
<!-- /O2 and /RCT1 are incompatible -->
|
||||||
@@ -312,7 +312,7 @@
|
|||||||
<arg value="/MD"/>
|
<arg value="/MD"/>
|
||||||
<!-- raise the warning level from the default -->
|
<!-- raise the warning level from the default -->
|
||||||
<!-- <arg value="/Wp64"/> -->
|
<!-- <arg value="/Wp64"/> -->
|
||||||
<arg value="/W2" />
|
<arg value="/W3" />
|
||||||
<!-- sets the exception model -->
|
<!-- sets the exception model -->
|
||||||
<arg value="/EHsc" />
|
<arg value="/EHsc" />
|
||||||
<!-- /O2 and /RCT1 are incompatible -->
|
<!-- /O2 and /RCT1 are incompatible -->
|
||||||
|
|||||||
@@ -1069,7 +1069,7 @@ JNIEXPORT jint JNICALL Java_com_jacob_com_Variant_getVariantVariant
|
|||||||
* Added 1.13M4
|
* Added 1.13M4
|
||||||
* */
|
* */
|
||||||
JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantDecRef
|
JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantDecRef
|
||||||
(JNIEnv *env, jobject _this, jint signum, jint scale, jint lo, jint mid, jint hi)
|
(JNIEnv *env, jobject _this, jint signum, jbyte scale, jint lo, jint mid, jint hi)
|
||||||
{
|
{
|
||||||
VARIANT *v = extractVariant(env, _this);
|
VARIANT *v = extractVariant(env, _this);
|
||||||
if (v) {
|
if (v) {
|
||||||
@@ -1091,7 +1091,7 @@ JNIEXPORT jint JNICALL Java_com_jacob_com_Variant_getVariantVariant
|
|||||||
* Added 1.13M4
|
* Added 1.13M4
|
||||||
* */
|
* */
|
||||||
JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantDec
|
JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantDec
|
||||||
(JNIEnv *env, jobject _this, jint signum, jint scale, jint lo, jint mid, jint hi)
|
(JNIEnv *env, jobject _this, jint signum, jbyte scale, jint lo, jint mid, jint hi)
|
||||||
{
|
{
|
||||||
VARIANT *v = extractVariant(env, _this);
|
VARIANT *v = extractVariant(env, _this);
|
||||||
DECIMAL *d;
|
DECIMAL *d;
|
||||||
@@ -1151,18 +1151,18 @@ jobject extractDecimal
|
|||||||
}
|
}
|
||||||
/* Unfortunately the byte ordering is completely wrong, so we remap it into buffer */
|
/* Unfortunately the byte ordering is completely wrong, so we remap it into buffer */
|
||||||
buffer = (jbyte*)malloc(12);
|
buffer = (jbyte*)malloc(12);
|
||||||
buffer[11] = d->Lo32 & 255;
|
buffer[11] = (byte)(d->Lo32 & 255);
|
||||||
buffer[10] = (d->Lo32 >> 8) & 255;
|
buffer[10] = (byte)((d->Lo32 >> 8) & 255);
|
||||||
buffer[9] = (d->Lo32 >> 16) & 255;;
|
buffer[9] = (byte)((d->Lo32 >> 16) & 255);
|
||||||
buffer[8] = (d->Lo32 >> 24) & 255;;
|
buffer[8] = (byte)((d->Lo32 >> 24) & 255);
|
||||||
buffer[7] = (d->Mid32) & 255;;
|
buffer[7] = (byte)((d->Mid32) & 255);
|
||||||
buffer[6] = (d->Mid32 >> 8) & 255;
|
buffer[6] = (byte)((d->Mid32 >> 8) & 255);
|
||||||
buffer[5] = (d->Mid32 >> 16) & 255;
|
buffer[5] = (byte)((d->Mid32 >> 16) & 255);
|
||||||
buffer[4] = (d->Mid32 >> 24) & 255;
|
buffer[4] = (byte)((d->Mid32 >> 24) & 255);
|
||||||
buffer[3] = (d->Hi32) & 255;
|
buffer[3] = (byte)((d->Hi32) & 255);
|
||||||
buffer[2] = (d->Hi32 >> 8) & 255;
|
buffer[2] = (byte)((d->Hi32 >> 8) & 255);
|
||||||
buffer[1] = (d->Hi32 >> 16) & 255;
|
buffer[1] = (byte)((d->Hi32 >> 16) & 255);
|
||||||
buffer[0] = (d->Hi32 >> 24) & 255;
|
buffer[0] = (byte)((d->Hi32 >> 24) & 255);
|
||||||
/* Load buffer into the actual array */
|
/* Load buffer into the actual array */
|
||||||
env->SetByteArrayRegion(bArray, 0, 12, buffer);
|
env->SetByteArrayRegion(bArray, 0, 12, buffer);
|
||||||
/* then clean up the C array */
|
/* then clean up the C array */
|
||||||
|
|||||||
@@ -519,7 +519,7 @@ JNIEXPORT jint JNICALL Java_com_jacob_com_Variant_getVariantVariant
|
|||||||
* Signature: (Ljava.math.BigDecimal;)V
|
* Signature: (Ljava.math.BigDecimal;)V
|
||||||
*/
|
*/
|
||||||
JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantDecRef
|
JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantDecRef
|
||||||
(JNIEnv *env, jobject _this, jint signum, jint scale, jint lo, jint mid, jint hi);
|
(JNIEnv *env, jobject _this, jint signum, jbyte scale, jint lo, jint mid, jint hi);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -528,7 +528,7 @@ JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantDecRef
|
|||||||
* Signature: (Ljava.math.BigDecimal;)V
|
* Signature: (Ljava.math.BigDecimal;)V
|
||||||
*/
|
*/
|
||||||
JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantDec
|
JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantDec
|
||||||
(JNIEnv *env, jobject _this, jint signum, jint scale, jint lo, jint mid, jint hi);
|
(JNIEnv *env, jobject _this, jint signum, jbyte scale, jint lo, jint mid, jint hi);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -308,10 +308,10 @@ public class Variant extends JacobObject {
|
|||||||
* @param mid middle 32 bits
|
* @param mid middle 32 bits
|
||||||
* @param hi high 32 bits
|
* @param hi high 32 bits
|
||||||
*/
|
*/
|
||||||
private native void putVariantDecRef(int signum, int scale, int lo, int mid, int hi);
|
private native void putVariantDecRef(int signum, byte scale, int lo, int mid, int hi);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the content of this variant to an int (VT_DECIMAL|VT_BYREF)
|
* Set the content of this variant to an decimal (VT_DECIMAL|VT_BYREF)
|
||||||
* This may throw exceptions more often than the caller expects because
|
* This may throw exceptions more often than the caller expects because
|
||||||
* most callers don't manage the scale of their BigDecimal objects.
|
* most callers don't manage the scale of their BigDecimal objects.
|
||||||
* @param in the BigDecimal that will be converted to VT_DECIMAL
|
* @param in the BigDecimal that will be converted to VT_DECIMAL
|
||||||
@@ -320,22 +320,24 @@ public class Variant extends JacobObject {
|
|||||||
public void putDecimalRef(BigDecimal in) {
|
public void putDecimalRef(BigDecimal in) {
|
||||||
// verify we aren't released
|
// verify we aren't released
|
||||||
getvt();
|
getvt();
|
||||||
int scale = in.scale();
|
if (in.scale() > 28) {
|
||||||
if (scale > 28) {
|
|
||||||
// should this really cast to a string and call putStringRef()?
|
// should this really cast to a string and call putStringRef()?
|
||||||
throw new IllegalArgumentException("VT_DECIMAL only supports a scale of 28 and the passed"+
|
throw new IllegalArgumentException(
|
||||||
" in value has a scale of "+scale);
|
"VT_DECIMAL only supports a scale of 28 and the passed"
|
||||||
}
|
+ " in value has a scale of " + in.scale());
|
||||||
else {
|
} else {
|
||||||
|
byte scale = (byte) in.scale();
|
||||||
BigInteger unscaled = in.unscaledValue();
|
BigInteger unscaled = in.unscaledValue();
|
||||||
BigInteger shifted = unscaled.shiftRight(32);
|
BigInteger shifted = unscaled.shiftRight(32);
|
||||||
putVariantDecRef(in.signum(), scale, unscaled.intValue(), shifted.intValue(), shifted.shiftRight(32).intValue());
|
putVariantDecRef(in.signum(), scale, unscaled.intValue(), shifted
|
||||||
|
.intValue(), shifted.shiftRight(32).intValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set the content of this variant to a double (VT_R8|VT_BYREF)
|
* set the content of this variant to a double (VT_R8|VT_BYREF)
|
||||||
|
*
|
||||||
* @param in
|
* @param in
|
||||||
*/
|
*/
|
||||||
private native void putVariantDoubleRef(double in);
|
private native void putVariantDoubleRef(double in);
|
||||||
@@ -806,22 +808,26 @@ public class Variant extends JacobObject {
|
|||||||
return (BigDecimal) (getVariantDec());
|
return (BigDecimal) (getVariantDec());
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalStateException(
|
throw new IllegalStateException(
|
||||||
"getDecimal() only legal on Variants of type VariantDecimal, not "+this.getvt());
|
"getDecimal() only legal on Variants of type VariantDecimal, not "
|
||||||
|
+ this.getvt());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return the BigDecimal value held in this variant (fails on other types)
|
* return the BigDecimal value held in this variant (fails on other types)
|
||||||
|
*
|
||||||
* @return BigDecimal
|
* @return BigDecimal
|
||||||
* @throws IllegalStateException if variant is not of the requested type
|
* @throws IllegalStateException
|
||||||
|
* if variant is not of the requested type
|
||||||
*/
|
*/
|
||||||
public BigDecimal getDecimalRef() {
|
public BigDecimal getDecimalRef() {
|
||||||
if ((this.getvt() & VariantDecimal) == VariantDecimal &&
|
if ((this.getvt() & VariantDecimal) == VariantDecimal
|
||||||
(this.getvt() & VariantByref) == VariantByref) {
|
&& (this.getvt() & VariantByref) == VariantByref) {
|
||||||
return (BigDecimal) (getVariantDecRef());
|
return (BigDecimal) (getVariantDecRef());
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalStateException(
|
throw new IllegalStateException(
|
||||||
"getDecimalRef() only legal on byRef Variants of type VariantDecimal, not "+this.getvt());
|
"getDecimalRef() only legal on byRef Variants of type VariantDecimal, not "
|
||||||
|
+ this.getvt());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -833,7 +839,7 @@ public class Variant extends JacobObject {
|
|||||||
* @param mid middle 32 bits
|
* @param mid middle 32 bits
|
||||||
* @param hi high 32 bits
|
* @param hi high 32 bits
|
||||||
*/
|
*/
|
||||||
private native void putVariantDec(int signum, int scale, int lo, int mid, int hi);
|
private native void putVariantDec(int signum, byte scale, int lo, int mid, int hi);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the value of this variant and set the type.
|
* Set the value of this variant and set the type.
|
||||||
@@ -845,21 +851,23 @@ public class Variant extends JacobObject {
|
|||||||
public void putDecimal(BigDecimal in) {
|
public void putDecimal(BigDecimal in) {
|
||||||
// verify we aren't released yet
|
// verify we aren't released yet
|
||||||
getvt();
|
getvt();
|
||||||
int scale = in.scale();
|
if (in.scale() > 28) {
|
||||||
if (scale > 28) {
|
|
||||||
// should this really cast to a string and call putStringRef()?
|
// should this really cast to a string and call putStringRef()?
|
||||||
throw new IllegalArgumentException("VT_DECIMAL only supports a scale of 28 and the passed"+
|
throw new IllegalArgumentException(
|
||||||
" in value has a scale of "+scale);
|
"VT_DECIMAL only supports a scale of 28 and the passed"
|
||||||
}
|
+ " in value has a scale of " + in.scale());
|
||||||
else {
|
} else {
|
||||||
|
byte scale = (byte) in.scale();
|
||||||
BigInteger unscaled = in.unscaledValue();
|
BigInteger unscaled = in.unscaledValue();
|
||||||
BigInteger shifted = unscaled.shiftRight(32);
|
BigInteger shifted = unscaled.shiftRight(32);
|
||||||
putVariantDec(in.signum(), in.scale(), unscaled.intValue(), shifted.intValue(), shifted.shiftRight(32).intValue());
|
putVariantDec( in.signum(), scale, unscaled.intValue(), shifted
|
||||||
|
.intValue(), shifted.shiftRight(32).intValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set the value of this variant
|
* set the value of this variant
|
||||||
|
*
|
||||||
* @param in
|
* @param in
|
||||||
*/
|
*/
|
||||||
private native void putVariantDate(double in);
|
private native void putVariantDate(double in);
|
||||||
|
|||||||
Reference in New Issue
Block a user