winapi: Fix the parse_c_declaration() prototype and remove unused variables.
[wine/hacks.git] / dlls / jscript / global.c
blob01d9eb245a2cf73738b5d3b0ff88de299ca5be8f
1 /*
2 * Copyright 2008 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include "config.h"
20 #include "wine/port.h"
22 #include <math.h>
24 #include "jscript.h"
25 #include "engine.h"
27 #include "wine/debug.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(jscript);
31 static const WCHAR NaNW[] = {'N','a','N',0};
32 static const WCHAR InfinityW[] = {'I','n','f','i','n','i','t','y',0};
33 static const WCHAR ArrayW[] = {'A','r','r','a','y',0};
34 static const WCHAR BooleanW[] = {'B','o','o','l','e','a','n',0};
35 static const WCHAR DateW[] = {'D','a','t','e',0};
36 static const WCHAR FunctionW[] = {'F','u','n','c','t','i','o','n',0};
37 static const WCHAR NumberW[] = {'N','u','m','b','e','r',0};
38 static const WCHAR ObjectW[] = {'O','b','j','e','c','t',0};
39 static const WCHAR StringW[] = {'S','t','r','i','n','g',0};
40 static const WCHAR RegExpW[] = {'R','e','g','E','x','p',0};
41 static const WCHAR ActiveXObjectW[] = {'A','c','t','i','v','e','X','O','b','j','e','c','t',0};
42 static const WCHAR VBArrayW[] = {'V','B','A','r','r','a','y',0};
43 static const WCHAR EnumeratorW[] = {'E','n','u','m','e','r','a','t','o','r',0};
44 static const WCHAR escapeW[] = {'e','s','c','a','p','e',0};
45 static const WCHAR evalW[] = {'e','v','a','l',0};
46 static const WCHAR isNaNW[] = {'i','s','N','a','N',0};
47 static const WCHAR isFiniteW[] = {'i','s','F','i','n','i','t','e',0};
48 static const WCHAR parseIntW[] = {'p','a','r','s','e','I','n','t',0};
49 static const WCHAR parseFloatW[] = {'p','a','r','s','e','F','l','o','a','t',0};
50 static const WCHAR unescapeW[] = {'u','n','e','s','c','a','p','e',0};
51 static const WCHAR _GetObjectW[] = {'G','e','t','O','b','j','e','c','t',0};
52 static const WCHAR ScriptEngineW[] = {'S','c','r','i','p','t','E','n','g','i','n','e',0};
53 static const WCHAR ScriptEngineMajorVersionW[] =
54 {'S','c','r','i','p','t','E','n','g','i','n','e','M','a','j','o','r','V','e','r','s','i','o','n',0};
55 static const WCHAR ScriptEngineMinorVersionW[] =
56 {'S','c','r','i','p','t','E','n','g','i','n','e','M','i','n','o','r','V','e','r','s','i','o','n',0};
57 static const WCHAR ScriptEngineBuildVersionW[] =
58 {'S','c','r','i','p','t','E','n','g','i','n','e','B','u','i','l','d','V','e','r','s','i','o','n',0};
59 static const WCHAR CollectGarbageW[] = {'C','o','l','l','e','c','t','G','a','r','b','a','g','e',0};
60 static const WCHAR MathW[] = {'M','a','t','h',0};
61 static const WCHAR encodeURIW[] = {'e','n','c','o','d','e','U','R','I',0};
63 static const WCHAR undefinedW[] = {'u','n','d','e','f','i','n','e','d',0};
65 static int uri_char_table[] = {
66 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 00-0f */
67 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 10-1f */
68 0,2,0,0,1,0,1,2,2,2,2,1,1,2,2,1, /* 20-2f */
69 2,2,2,2,2,2,2,2,2,2,1,1,0,1,0,1, /* 30-3f */
70 1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, /* 40-4f */
71 2,2,2,2,2,2,2,2,2,2,2,0,0,0,0,2, /* 50-5f */
72 0,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, /* 60-6f */
73 2,2,2,2,2,2,2,2,2,2,2,0,0,0,2,0, /* 70-7f */
76 /* 1 - reserved */
77 /* 2 - unescaped */
79 static inline BOOL is_uri_reserved(WCHAR c)
81 return c < 128 && uri_char_table[c] == 1;
84 static inline BOOL is_uri_unescaped(WCHAR c)
86 return c < 128 && uri_char_table[c] == 2;
89 static WCHAR int_to_char(int i)
91 if(i < 10)
92 return '0'+i;
93 return 'A'+i-10;
96 static HRESULT constructor_call(DispatchEx *constr, LCID lcid, WORD flags, DISPPARAMS *dp,
97 VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
99 if(flags != DISPATCH_PROPERTYGET)
100 return jsdisp_call_value(constr, lcid, flags, dp, retv, ei, sp);
102 V_VT(retv) = VT_DISPATCH;
103 V_DISPATCH(retv) = (IDispatch*)_IDispatchEx_(constr);
104 IDispatchEx_AddRef(_IDispatchEx_(constr));
105 return S_OK;
108 static HRESULT JSGlobal_NaN(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
109 VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
111 TRACE("\n");
113 switch(flags) {
114 case DISPATCH_PROPERTYGET:
115 num_set_nan(retv);
116 break;
118 default:
119 FIXME("unimplemented flags %x\n", flags);
120 return E_NOTIMPL;
123 return S_OK;
126 static HRESULT JSGlobal_Infinity(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
127 VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
129 TRACE("\n");
131 switch(flags) {
132 case DISPATCH_PROPERTYGET:
133 num_set_inf(retv, TRUE);
134 break;
136 default:
137 FIXME("unimplemented flags %x\n", flags);
138 return E_NOTIMPL;
141 return S_OK;
144 static HRESULT JSGlobal_Array(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
145 VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
147 TRACE("\n");
149 return constructor_call(dispex->ctx->array_constr, lcid, flags, dp, retv, ei, sp);
152 static HRESULT JSGlobal_Boolean(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
153 VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
155 TRACE("\n");
157 return constructor_call(dispex->ctx->bool_constr, lcid, flags, dp, retv, ei, sp);
160 static HRESULT JSGlobal_Date(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
161 VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
163 TRACE("\n");
165 return constructor_call(dispex->ctx->date_constr, lcid, flags, dp, retv, ei, sp);
168 static HRESULT JSGlobal_Function(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
169 VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
171 TRACE("\n");
173 return constructor_call(dispex->ctx->function_constr, lcid, flags, dp, retv, ei, sp);
176 static HRESULT JSGlobal_Number(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
177 VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
179 TRACE("\n");
181 return constructor_call(dispex->ctx->number_constr, lcid, flags, dp, retv, ei, sp);
184 static HRESULT JSGlobal_Object(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
185 VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
187 TRACE("\n");
189 return constructor_call(dispex->ctx->object_constr, lcid, flags, dp, retv, ei, sp);
192 static HRESULT JSGlobal_String(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
193 VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
195 TRACE("\n");
197 return constructor_call(dispex->ctx->string_constr, lcid, flags, dp, retv, ei, sp);
200 static HRESULT JSGlobal_RegExp(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
201 VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
203 TRACE("\n");
205 return constructor_call(dispex->ctx->regexp_constr, lcid, flags, dp, retv, ei, sp);
208 static HRESULT JSGlobal_ActiveXObject(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
209 VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
211 FIXME("\n");
212 return E_NOTIMPL;
215 static HRESULT JSGlobal_VBArray(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
216 VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
218 FIXME("\n");
219 return E_NOTIMPL;
222 static HRESULT JSGlobal_Enumerator(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
223 VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
225 FIXME("\n");
226 return E_NOTIMPL;
229 static HRESULT JSGlobal_escape(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
230 VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
232 FIXME("\n");
233 return E_NOTIMPL;
236 /* ECMA-262 3rd Edition 15.1.2.1 */
237 static HRESULT JSGlobal_eval(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
238 VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
240 parser_ctx_t *parser_ctx;
241 VARIANT *arg;
242 HRESULT hres;
244 TRACE("\n");
246 if(!arg_cnt(dp)) {
247 if(retv)
248 V_VT(retv) = VT_EMPTY;
249 return S_OK;
252 arg = get_arg(dp, 0);
253 if(V_VT(arg) != VT_BSTR) {
254 if(retv) {
255 V_VT(retv) = VT_EMPTY;
256 return VariantCopy(retv, arg);
258 return S_OK;
261 if(!dispex->ctx->exec_ctx) {
262 FIXME("No active exec_ctx\n");
263 return E_UNEXPECTED;
266 TRACE("parsing %s\n", debugstr_w(V_BSTR(arg)));
267 hres = script_parse(dispex->ctx, V_BSTR(arg), NULL, &parser_ctx);
268 if(FAILED(hres)) {
269 WARN("parse (%s) failed: %08x\n", debugstr_w(V_BSTR(arg)), hres);
270 return hres;
273 hres = exec_source(dispex->ctx->exec_ctx, parser_ctx, parser_ctx->source, ei, retv);
274 parser_release(parser_ctx);
276 return hres;
279 static HRESULT JSGlobal_isNaN(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
280 VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
282 VARIANT_BOOL ret = VARIANT_FALSE;
283 VARIANT num;
284 HRESULT hres;
286 TRACE("\n");
288 if(arg_cnt(dp)) {
289 hres = to_number(dispex->ctx, get_arg(dp,0), ei, &num);
290 if(FAILED(hres))
291 return hres;
293 if(V_VT(&num) == VT_R8 && isnan(V_R8(&num)))
294 ret = VARIANT_TRUE;
295 }else {
296 ret = VARIANT_TRUE;
299 if(retv) {
300 V_VT(retv) = VT_BOOL;
301 V_BOOL(retv) = ret;
303 return S_OK;
306 static HRESULT JSGlobal_isFinite(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
307 VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
309 VARIANT_BOOL ret = VARIANT_FALSE;
310 HRESULT hres;
312 TRACE("\n");
314 if(arg_cnt(dp)) {
315 VARIANT num;
317 hres = to_number(dispex->ctx, get_arg(dp,0), ei, &num);
318 if(FAILED(hres))
319 return hres;
321 if(V_VT(&num) != VT_R8 || (!isinf(V_R8(&num)) && !isnan(V_R8(&num))))
322 ret = VARIANT_TRUE;
325 if(retv) {
326 V_VT(retv) = VT_BOOL;
327 V_BOOL(retv) = ret;
329 return S_OK;
332 static INT char_to_int(WCHAR c)
334 if('0' <= c && c <= '9')
335 return c - '0';
336 if('a' <= c && c <= 'z')
337 return c - 'a' + 10;
338 if('A' <= c && c <= 'Z')
339 return c - 'A' + 10;
340 return 100;
343 static HRESULT JSGlobal_parseInt(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
344 VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
346 DOUBLE ret = 0.0;
347 INT radix=10, i;
348 WCHAR *ptr;
349 BOOL neg = FALSE;
350 BSTR str;
351 HRESULT hres;
353 if(!arg_cnt(dp)) {
354 FIXME("NAN\n");
355 return E_NOTIMPL;
358 if(arg_cnt(dp) >= 2) {
359 hres = to_int32(dispex->ctx, get_arg(dp, 1), ei, &radix);
360 if(FAILED(hres))
361 return hres;
363 if(!radix) {
364 radix = 10;
365 }else if(radix < 2 || radix > 36) {
366 WARN("radix %d out of range\n", radix);
367 return E_FAIL;
371 hres = to_string(dispex->ctx, get_arg(dp, 0), ei, &str);
372 if(FAILED(hres))
373 return hres;
375 for(ptr = str; isspaceW(*ptr); ptr++);
377 switch(*ptr) {
378 case '+':
379 ptr++;
380 break;
381 case '-':
382 neg = TRUE;
383 ptr++;
384 break;
385 case '0':
386 ptr++;
387 if(*ptr == 'x' || *ptr == 'X') {
388 radix = 16;
389 ptr++;
393 while(*ptr) {
394 i = char_to_int(*ptr++);
395 if(i > radix)
396 break;
398 ret = ret*radix + i;
401 SysFreeString(str);
403 if(neg)
404 ret = -ret;
406 if(retv)
407 num_set_val(retv, ret);
408 return S_OK;
411 static HRESULT JSGlobal_parseFloat(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
412 VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
414 FIXME("\n");
415 return E_NOTIMPL;
418 static HRESULT JSGlobal_unescape(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
419 VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
421 FIXME("\n");
422 return E_NOTIMPL;
425 static HRESULT JSGlobal_GetObject(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
426 VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
428 FIXME("\n");
429 return E_NOTIMPL;
432 static HRESULT JSGlobal_ScriptEngine(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
433 VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
435 FIXME("\n");
436 return E_NOTIMPL;
439 static HRESULT JSGlobal_ScriptEngineMajorVersion(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
440 VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
442 FIXME("\n");
443 return E_NOTIMPL;
446 static HRESULT JSGlobal_ScriptEngineMinorVersion(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
447 VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
449 FIXME("\n");
450 return E_NOTIMPL;
453 static HRESULT JSGlobal_ScriptEngineBuildVersion(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
454 VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
456 FIXME("\n");
457 return E_NOTIMPL;
460 static HRESULT JSGlobal_CollectGarbage(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
461 VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
463 FIXME("\n");
464 return E_NOTIMPL;
467 static HRESULT JSGlobal_encodeURI(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
468 VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
470 const WCHAR *ptr;
471 DWORD len = 0, i;
472 char buf[4];
473 BSTR str, ret;
474 WCHAR *rptr;
475 HRESULT hres;
477 TRACE("\n");
479 if(!arg_cnt(dp)) {
480 if(retv) {
481 ret = SysAllocString(undefinedW);
482 if(!ret)
483 return E_OUTOFMEMORY;
485 V_VT(retv) = VT_BSTR;
486 V_BSTR(retv) = ret;
489 return S_OK;
492 hres = to_string(dispex->ctx, get_arg(dp,0), ei, &str);
493 if(FAILED(hres))
494 return hres;
496 for(ptr = str; *ptr; ptr++) {
497 if(is_uri_unescaped(*ptr) || is_uri_reserved(*ptr) || *ptr == '#') {
498 len++;
499 }else {
500 i = WideCharToMultiByte(CP_UTF8, 0, ptr, 1, NULL, 0, NULL, NULL)*3;
501 if(!i) {
502 FIXME("throw URIError\n");
503 return E_FAIL;
506 len += i;
510 rptr = ret = SysAllocStringLen(NULL, len);
511 if(!ret)
512 return E_OUTOFMEMORY;
514 for(ptr = str; *ptr; ptr++) {
515 if(is_uri_unescaped(*ptr) || is_uri_reserved(*ptr) || *ptr == '#') {
516 *rptr++ = *ptr;
517 }else {
518 len = WideCharToMultiByte(CP_UTF8, 0, ptr, 1, buf, sizeof(buf), NULL, NULL);
519 for(i=0; i<len; i++) {
520 *rptr++ = '%';
521 *rptr++ = int_to_char((BYTE)buf[i] >> 4);
522 *rptr++ = int_to_char(buf[i] & 0x0f);
527 TRACE("%s -> %s\n", debugstr_w(str), debugstr_w(ret));
528 if(retv) {
529 V_VT(retv) = VT_BSTR;
530 V_BSTR(retv) = ret;
531 }else {
532 SysFreeString(ret);
534 return S_OK;
537 static const builtin_prop_t JSGlobal_props[] = {
538 {ActiveXObjectW, JSGlobal_ActiveXObject, PROPF_METHOD},
539 {ArrayW, JSGlobal_Array, PROPF_CONSTR},
540 {BooleanW, JSGlobal_Boolean, PROPF_CONSTR},
541 {CollectGarbageW, JSGlobal_CollectGarbage, PROPF_METHOD},
542 {DateW, JSGlobal_Date, PROPF_CONSTR},
543 {EnumeratorW, JSGlobal_Enumerator, PROPF_METHOD},
544 {FunctionW, JSGlobal_Function, PROPF_CONSTR},
545 {_GetObjectW, JSGlobal_GetObject, PROPF_METHOD},
546 {InfinityW, JSGlobal_Infinity, 0},
547 /* {MathW, JSGlobal_Math, 0}, */
548 {NaNW, JSGlobal_NaN, 0},
549 {NumberW, JSGlobal_Number, PROPF_CONSTR},
550 {ObjectW, JSGlobal_Object, PROPF_CONSTR},
551 {RegExpW, JSGlobal_RegExp, PROPF_CONSTR},
552 {ScriptEngineW, JSGlobal_ScriptEngine, PROPF_METHOD},
553 {ScriptEngineBuildVersionW, JSGlobal_ScriptEngineBuildVersion, PROPF_METHOD},
554 {ScriptEngineMajorVersionW, JSGlobal_ScriptEngineMajorVersion, PROPF_METHOD},
555 {ScriptEngineMinorVersionW, JSGlobal_ScriptEngineMinorVersion, PROPF_METHOD},
556 {StringW, JSGlobal_String, PROPF_CONSTR},
557 {VBArrayW, JSGlobal_VBArray, PROPF_METHOD},
558 {encodeURIW, JSGlobal_encodeURI, PROPF_METHOD},
559 {escapeW, JSGlobal_escape, PROPF_METHOD},
560 {evalW, JSGlobal_eval, PROPF_METHOD|1},
561 {isFiniteW, JSGlobal_isFinite, PROPF_METHOD},
562 {isNaNW, JSGlobal_isNaN, PROPF_METHOD},
563 {parseFloatW, JSGlobal_parseFloat, PROPF_METHOD},
564 {parseIntW, JSGlobal_parseInt, PROPF_METHOD|2},
565 {unescapeW, JSGlobal_unescape, PROPF_METHOD}
568 static const builtin_info_t JSGlobal_info = {
569 JSCLASS_GLOBAL,
570 {NULL, NULL, 0},
571 sizeof(JSGlobal_props)/sizeof(*JSGlobal_props),
572 JSGlobal_props,
573 NULL,
574 NULL
577 static HRESULT init_constructors(script_ctx_t *ctx)
579 HRESULT hres;
581 hres = init_function_constr(ctx);
582 if(FAILED(hres))
583 return hres;
585 hres = create_array_constr(ctx, &ctx->array_constr);
586 if(FAILED(hres))
587 return hres;
589 hres = create_bool_constr(ctx, &ctx->bool_constr);
590 if(FAILED(hres))
591 return hres;
593 hres = create_date_constr(ctx, &ctx->date_constr);
594 if(FAILED(hres))
595 return hres;
597 hres = create_number_constr(ctx, &ctx->number_constr);
598 if(FAILED(hres))
599 return hres;
601 hres = create_object_constr(ctx, &ctx->object_constr);
602 if(FAILED(hres))
603 return hres;
605 hres = create_regexp_constr(ctx, &ctx->regexp_constr);
606 if(FAILED(hres))
607 return hres;
609 hres = create_string_constr(ctx, &ctx->string_constr);
610 if(FAILED(hres))
611 return hres;
613 return S_OK;
616 HRESULT init_global(script_ctx_t *ctx)
618 DispatchEx *math;
619 VARIANT var;
620 HRESULT hres;
622 if(ctx->global)
623 return S_OK;
625 hres = init_constructors(ctx);
626 if(FAILED(hres))
627 return hres;
629 hres = create_dispex(ctx, &JSGlobal_info, NULL, &ctx->global);
630 if(FAILED(hres))
631 return hres;
633 hres = create_math(ctx, &math);
634 if(FAILED(hres))
635 return hres;
637 V_VT(&var) = VT_DISPATCH;
638 V_DISPATCH(&var) = (IDispatch*)_IDispatchEx_(math);
639 hres = jsdisp_propput_name(ctx->global, MathW, ctx->lcid, &var, NULL/*FIXME*/, NULL/*FIXME*/);
640 jsdisp_release(math);
642 return hres;