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"/>
|
||||
<!-- raise the warning level from the default -->
|
||||
<!-- <arg value="/Wp64"/> -->
|
||||
<arg value="/W2" />
|
||||
<arg value="/W3" />
|
||||
<!-- sets the exception model -->
|
||||
<arg value="/EHsc" />
|
||||
<!-- /O2 and /RCT1 are incompatible -->
|
||||
@@ -312,7 +312,7 @@
|
||||
<arg value="/MD"/>
|
||||
<!-- raise the warning level from the default -->
|
||||
<!-- <arg value="/Wp64"/> -->
|
||||
<arg value="/W2" />
|
||||
<arg value="/W3" />
|
||||
<!-- sets the exception model -->
|
||||
<arg value="/EHsc" />
|
||||
<!-- /O2 and /RCT1 are incompatible -->
|
||||
|
||||
@@ -1069,7 +1069,7 @@ JNIEXPORT jint JNICALL Java_com_jacob_com_Variant_getVariantVariant
|
||||
* Added 1.13M4
|
||||
* */
|
||||
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);
|
||||
if (v) {
|
||||
@@ -1091,7 +1091,7 @@ JNIEXPORT jint JNICALL Java_com_jacob_com_Variant_getVariantVariant
|
||||
* Added 1.13M4
|
||||
* */
|
||||
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);
|
||||
DECIMAL *d;
|
||||
@@ -1151,18 +1151,18 @@ jobject extractDecimal
|
||||
}
|
||||
/* Unfortunately the byte ordering is completely wrong, so we remap it into buffer */
|
||||
buffer = (jbyte*)malloc(12);
|
||||
buffer[11] = d->Lo32 & 255;
|
||||
buffer[10] = (d->Lo32 >> 8) & 255;
|
||||
buffer[9] = (d->Lo32 >> 16) & 255;;
|
||||
buffer[8] = (d->Lo32 >> 24) & 255;;
|
||||
buffer[7] = (d->Mid32) & 255;;
|
||||
buffer[6] = (d->Mid32 >> 8) & 255;
|
||||
buffer[5] = (d->Mid32 >> 16) & 255;
|
||||
buffer[4] = (d->Mid32 >> 24) & 255;
|
||||
buffer[3] = (d->Hi32) & 255;
|
||||
buffer[2] = (d->Hi32 >> 8) & 255;
|
||||
buffer[1] = (d->Hi32 >> 16) & 255;
|
||||
buffer[0] = (d->Hi32 >> 24) & 255;
|
||||
buffer[11] = (byte)(d->Lo32 & 255);
|
||||
buffer[10] = (byte)((d->Lo32 >> 8) & 255);
|
||||
buffer[9] = (byte)((d->Lo32 >> 16) & 255);
|
||||
buffer[8] = (byte)((d->Lo32 >> 24) & 255);
|
||||
buffer[7] = (byte)((d->Mid32) & 255);
|
||||
buffer[6] = (byte)((d->Mid32 >> 8) & 255);
|
||||
buffer[5] = (byte)((d->Mid32 >> 16) & 255);
|
||||
buffer[4] = (byte)((d->Mid32 >> 24) & 255);
|
||||
buffer[3] = (byte)((d->Hi32) & 255);
|
||||
buffer[2] = (byte)((d->Hi32 >> 8) & 255);
|
||||
buffer[1] = (byte)((d->Hi32 >> 16) & 255);
|
||||
buffer[0] = (byte)((d->Hi32 >> 24) & 255);
|
||||
/* Load buffer into the actual array */
|
||||
env->SetByteArrayRegion(bArray, 0, 12, buffer);
|
||||
/* then clean up the C array */
|
||||
|
||||
@@ -519,7 +519,7 @@ JNIEXPORT jint JNICALL Java_com_jacob_com_Variant_getVariantVariant
|
||||
* Signature: (Ljava.math.BigDecimal;)V
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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,36 +308,38 @@ public class Variant extends JacobObject {
|
||||
* @param mid middle 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
|
||||
* most callers don't manage the scale of their BigDecimal objects.
|
||||
* @param in the BigDecimal that will be converted to VT_DECIMAL
|
||||
* @throws IllegalArgumentException if the scale is > 28, the maximum for VT_DECIMAL
|
||||
*/
|
||||
public void putDecimalRef(BigDecimal in){
|
||||
// verify we aren't released
|
||||
getvt();
|
||||
int scale = in.scale();
|
||||
if (scale > 28) {
|
||||
// should this really cast to a string and call putStringRef()?
|
||||
throw new IllegalArgumentException("VT_DECIMAL only supports a scale of 28 and the passed"+
|
||||
" in value has a scale of "+scale);
|
||||
}
|
||||
else {
|
||||
BigInteger unscaled = in.unscaledValue();
|
||||
BigInteger shifted = unscaled.shiftRight(32);
|
||||
putVariantDecRef(in.signum(), scale, unscaled.intValue(), shifted.intValue(), shifted.shiftRight(32).intValue());
|
||||
}
|
||||
}
|
||||
public void putDecimalRef(BigDecimal in) {
|
||||
// verify we aren't released
|
||||
getvt();
|
||||
if (in.scale() > 28) {
|
||||
// should this really cast to a string and call putStringRef()?
|
||||
throw new IllegalArgumentException(
|
||||
"VT_DECIMAL only supports a scale of 28 and the passed"
|
||||
+ " in value has a scale of " + in.scale());
|
||||
} else {
|
||||
byte scale = (byte) in.scale();
|
||||
BigInteger unscaled = in.unscaledValue();
|
||||
BigInteger shifted = unscaled.shiftRight(32);
|
||||
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)
|
||||
* @param in
|
||||
*/
|
||||
* set the content of this variant to a double (VT_R8|VT_BYREF)
|
||||
*
|
||||
* @param in
|
||||
*/
|
||||
private native void putVariantDoubleRef(double in);
|
||||
|
||||
/**
|
||||
@@ -801,27 +803,31 @@ public class Variant extends JacobObject {
|
||||
* @return BigDecimal
|
||||
* @throws IllegalStateException if variant is not of the requested type
|
||||
*/
|
||||
public BigDecimal getDecimal(){
|
||||
if (this.getvt() == VariantDecimal){
|
||||
return (BigDecimal)(getVariantDec());
|
||||
} else {
|
||||
throw new IllegalStateException(
|
||||
"getDecimal() only legal on Variants of type VariantDecimal, not "+this.getvt());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* return the BigDecimal value held in this variant (fails on other types)
|
||||
* @return BigDecimal
|
||||
* @throws IllegalStateException if variant is not of the requested type
|
||||
*/
|
||||
public BigDecimal getDecimalRef(){
|
||||
if ((this.getvt() & VariantDecimal) == VariantDecimal &&
|
||||
(this.getvt() & VariantByref) == VariantByref) {
|
||||
return (BigDecimal)(getVariantDecRef());
|
||||
public BigDecimal getDecimal() {
|
||||
if (this.getvt() == VariantDecimal) {
|
||||
return (BigDecimal) (getVariantDec());
|
||||
} else {
|
||||
throw new IllegalStateException(
|
||||
"getDecimalRef() only legal on byRef 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 BigDecimal
|
||||
* @throws IllegalStateException
|
||||
* if variant is not of the requested type
|
||||
*/
|
||||
public BigDecimal getDecimalRef() {
|
||||
if ((this.getvt() & VariantDecimal) == VariantDecimal
|
||||
&& (this.getvt() & VariantByref) == VariantByref) {
|
||||
return (BigDecimal) (getVariantDecRef());
|
||||
} else {
|
||||
throw new IllegalStateException(
|
||||
"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 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.
|
||||
@@ -842,26 +848,28 @@ public class Variant extends JacobObject {
|
||||
* @param in the big decimal that will convert to the VT_DECIMAL type
|
||||
* @throws IllegalArgumentException if the scale is > 28, the maximum for VT_DECIMAL
|
||||
*/
|
||||
public void putDecimal(BigDecimal in){
|
||||
// verify we aren't released yet
|
||||
getvt();
|
||||
int scale = in.scale();
|
||||
if (scale > 28) {
|
||||
// should this really cast to a string and call putStringRef()?
|
||||
throw new IllegalArgumentException("VT_DECIMAL only supports a scale of 28 and the passed"+
|
||||
" in value has a scale of "+scale);
|
||||
}
|
||||
else {
|
||||
BigInteger unscaled = in.unscaledValue();
|
||||
BigInteger shifted = unscaled.shiftRight(32);
|
||||
putVariantDec(in.signum(), in.scale(), unscaled.intValue(), shifted.intValue(), shifted.shiftRight(32).intValue());
|
||||
}
|
||||
}
|
||||
public void putDecimal(BigDecimal in) {
|
||||
// verify we aren't released yet
|
||||
getvt();
|
||||
if (in.scale() > 28) {
|
||||
// should this really cast to a string and call putStringRef()?
|
||||
throw new IllegalArgumentException(
|
||||
"VT_DECIMAL only supports a scale of 28 and the passed"
|
||||
+ " in value has a scale of " + in.scale());
|
||||
} else {
|
||||
byte scale = (byte) in.scale();
|
||||
BigInteger unscaled = in.unscaledValue();
|
||||
BigInteger shifted = unscaled.shiftRight(32);
|
||||
putVariantDec( in.signum(), scale, unscaled.intValue(), shifted
|
||||
.intValue(), shifted.shiftRight(32).intValue());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* set the value of this variant
|
||||
* @param in
|
||||
*/
|
||||
/**
|
||||
* set the value of this variant
|
||||
*
|
||||
* @param in
|
||||
*/
|
||||
private native void putVariantDate(double in);
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user