From e859503601a3d56c8807564734496a58d1f593dd Mon Sep 17 00:00:00 2001 From: "mkaply%us.ibm.com" Date: Wed, 15 Mar 2000 14:31:55 +0000 Subject: [PATCH] # 25555 r= rogerl@netscape.com OS/2 changes for Mozilla - add #ifdef, change #ifdef --- js/src/jsapi.c | 4 +-- js/src/jscpucfg.h | 4 +-- js/src/jsosdep.h | 2 +- js/src/jspubtd.h | 2 +- js/src/liveconnect/jsj_convert.c | 53 +++++++++++++++++++++++++++++++- 5 files changed, 58 insertions(+), 7 deletions(-) diff --git a/js/src/jsapi.c b/js/src/jsapi.c index 9263e00e427..1b6dd4172af 100644 --- a/js/src/jsapi.c +++ b/js/src/jsapi.c @@ -3292,10 +3292,10 @@ JS_IsAssigning(JSContext *cx) /************************************************************************/ #ifdef XP_PC -#include -#if defined(XP_OS2_HACK) +#if defined(XP_OS2) /*DSR031297 - the OS/2 equiv is dll_InitTerm, but I don't see the need for it*/ #else +#include /* * Initialization routine for the JS DLL... */ diff --git a/js/src/jscpucfg.h b/js/src/jscpucfg.h index dcce6f26957..9735ee5fd7f 100644 --- a/js/src/jscpucfg.h +++ b/js/src/jscpucfg.h @@ -84,7 +84,7 @@ #elif defined(XP_PC) -#ifdef _WIN32 +#if defined( _WIN32) || defined(XP_OS2) #define IS_LITTLE_ENDIAN 1 #undef IS_BIG_ENDIAN @@ -128,7 +128,7 @@ #define JS_BYTES_PER_WORD_LOG2 2L #define JS_BYTES_PER_DWORD_LOG2 3L #define PR_WORDS_PER_DWORD_LOG2 1L -#endif /* _WIN32 */ +#endif /* _WIN32 || XP_OS2 */ #if defined(_WINDOWS) && !defined(_WIN32) /* WIN16 */ #define IS_LITTLE_ENDIAN 1 diff --git a/js/src/jsosdep.h b/js/src/jsosdep.h index d02fedcd5f0..b470bc666b2 100644 --- a/js/src/jsosdep.h +++ b/js/src/jsosdep.h @@ -44,7 +44,7 @@ #ifdef XP_PC -#ifdef _WIN32 +#if defined(_WIN32) || defined (XP_OS2) #define JS_HAVE_LONG_LONG #else #undef JS_HAVE_LONG_LONG diff --git a/js/src/jspubtd.h b/js/src/jspubtd.h index 20209dc591c..5dccd30bef7 100644 --- a/js/src/jspubtd.h +++ b/js/src/jspubtd.h @@ -116,7 +116,7 @@ typedef struct JSXDRState JSXDRState; typedef struct JSExceptionState JSExceptionState; #ifndef CRT_CALL -#ifdef XP_OS2 +#ifdef XP_OS2_VACPP #define CRT_CALL _Optlink #else #define CRT_CALL diff --git a/js/src/liveconnect/jsj_convert.c b/js/src/liveconnect/jsj_convert.c index a8c84eebb01..7e4e6f97b25 100644 --- a/js/src/liveconnect/jsj_convert.c +++ b/js/src/liveconnect/jsj_convert.c @@ -449,10 +449,61 @@ if (!JSVAL_IS_NUMBER(jsvalue)) { \ java_value->member_name = member_name; \ } +#else +#ifdef XP_OS2 + +/* OS2 utility macro for jsj_ConvertJSValueToJavaValue(), below */ +/* jlong is a structure, see jri_md.h, where the jlong_ macros are defined. */ +#define JSVAL_TO_JLONG_JVALUE(member_name, member_type, jsvalue, java_value) \ + if (!JSVAL_IS_NUMBER(jsvalue)) { \ + if (!JS_ConvertValue(cx, jsvalue, JSTYPE_NUMBER, &jsvalue)) \ + goto conversion_error; \ + (*cost)++; \ + } \ + { \ + member_type member_name; \ + \ + if (JSVAL_IS_INT(jsvalue)) { \ + jsint ival = JSVAL_TO_INT(jsvalue); \ + jlong_I2L(member_name,ival); \ + \ + } else { \ + jdouble dval = *JSVAL_TO_DOUBLE(jsvalue); \ + \ + /* NaN becomes zero when converted to integral value */ \ + if (JSDOUBLE_IS_NaN(dval)) \ + jlong_I2L(member_name,0); \ + \ + /* Unrepresentably large numbers, including infinities, */ \ + /* cause an error. */ \ + else if ((dval > member_type ## _MAX_VALUE) || \ + (dval < member_type ## _MIN_VALUE)) { \ + goto numeric_conversion_error; \ + } else \ + jlong_D2L(member_name,dval); \ + \ + /* Don't allow a non-integral number to be converted \ + to an integral type */ \ + /* Actually, we have to allow this for LC1 compatibility */ \ + /*if (jlong_to_jdouble(member_name) != dval) \ + (*cost)++;*/ \ + } \ + if (java_value) \ + java_value->member_name = member_name; \ + } + +static jdouble jlong_to_jdouble(jlong lvalue) +{ + jdouble d; + jlong_L2D(d,lvalue); + return d; +} + #else #define jlong_to_jdouble(lvalue) ((jdouble) lvalue) +#endif #endif /* @@ -517,7 +568,7 @@ jsj_ConvertJSValueToJavaValue(JSContext *cx, JNIEnv *jEnv, jsval v_arg, break; case JAVA_SIGNATURE_LONG: -#if XP_MAC +#if defined(XP_MAC) || (defined(XP_OS2) && !defined(HAVE_LONG_LONG)) JSVAL_TO_JLONG_JVALUE(j, jlong, v, java_value); #else JSVAL_TO_INTEGRAL_JVALUE(long, j, jlong, v, java_value);