jscript: Added NAN definition (1/10)

Piotr Caban piotr.caban at gmail.com
Wed Jun 3 03:36:28 CDT 2009


Alexandre Julliard wrote:
> Piotr Caban <piotr.caban at gmail.com> writes:
> 
>> diff --git a/dlls/jscript/jscript_main.c b/dlls/jscript/jscript_main.c
>> index 37266e5..740bb06 100644
>> --- a/dlls/jscript/jscript_main.c
>> +++ b/dlls/jscript/jscript_main.c
>> @@ -38,6 +38,21 @@ static const CLSID CLSID_JScriptAuthor =
>>  static const CLSID CLSID_JScriptEncode =
>>      {0xf414c262,0x6ac0,0x11cf,{0xb6,0xd1,0x00,0xaa,0x00,0xbb,0xbb,0x58}};
>>  
>> +#ifndef NAN
>> +DOUBLE NAN;
>> +
>> +static inline void set_jsnan(void)
>> +{
>> +    VARIANT v;
>> +    V_UI8(&v) = (ULONGLONG)0x7ff80000<<32;
>> +    NAN = V_R8(&v);
>> +}
>> +#else
>> +static inline void set_jsnan(void)
>> +{
>> +}
>> +#endif
>> +
>>  DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
>>  
>>  static HINSTANCE jscript_hinstance;
>> @@ -110,6 +125,7 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
>>          return FALSE;  /* prefer native version */
>>      case DLL_PROCESS_ATTACH:
>>          DisableThreadLibraryCalls(hInstDLL);
>> +        set_jsnan();
>>          jscript_hinstance = hInstDLL;
>>          break;
> 
> The previous implementation was better, having to explicitly initialize
> the constant on startup is ugly.
> 

Some functions needs to return NAN. The other possibility of
implementing it is following:

static inline DOUBLE ret_nan(void)
{
    VARIANT v;
    num_set_nan(&v);
    return V_R8(&v);
}

or

#ifdef NAN
static inline DOUBLE ret_nan(void)
{
    return NAN;
}
#else
static inline DOUBLE ret_nan(void)
{
    VARIANT v;
    num_set_nan(&v);
    return V_R8(&v);
}
#endif

But both of these methods are probably even uglier. Do you have any
suggestions how should I implement it?

Piotr



More information about the wine-devel mailing list