mstask: Implement GetTargetComputer.
[wine] / dlls / jscript / jscript.h
1 /*
2  * Copyright 2008-2009 Jacek Caban for CodeWeavers
3  *
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.
8  *
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.
13  *
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
17  */
18
19 #include <stdarg.h>
20 #include <stdio.h>
21
22 #define COBJMACROS
23
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winuser.h"
27 #include "ole2.h"
28 #include "dispex.h"
29 #include "activscp.h"
30
31 #include "resource.h"
32
33 #include "wine/unicode.h"
34 #include "wine/list.h"
35
36 typedef struct _jsval_t jsval_t;
37 typedef struct _jsstr_t jsstr_t;
38 typedef struct _script_ctx_t script_ctx_t;
39 typedef struct _exec_ctx_t exec_ctx_t;
40 typedef struct _dispex_prop_t dispex_prop_t;
41
42 typedef struct {
43     void **blocks;
44     DWORD block_cnt;
45     DWORD last_block;
46     DWORD offset;
47     BOOL mark;
48     struct list custom_blocks;
49 } jsheap_t;
50
51 void jsheap_init(jsheap_t*) DECLSPEC_HIDDEN;
52 void *jsheap_alloc(jsheap_t*,DWORD) __WINE_ALLOC_SIZE(2) DECLSPEC_HIDDEN;
53 void *jsheap_grow(jsheap_t*,void*,DWORD,DWORD) DECLSPEC_HIDDEN;
54 void jsheap_clear(jsheap_t*) DECLSPEC_HIDDEN;
55 void jsheap_free(jsheap_t*) DECLSPEC_HIDDEN;
56 jsheap_t *jsheap_mark(jsheap_t*) DECLSPEC_HIDDEN;
57
58 static inline void *heap_alloc(size_t len)
59 {
60     return HeapAlloc(GetProcessHeap(), 0, len);
61 }
62
63 static inline void *heap_alloc_zero(size_t len)
64 {
65     return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
66 }
67
68 static inline void *heap_realloc(void *mem, size_t len)
69 {
70     return HeapReAlloc(GetProcessHeap(), 0, mem, len);
71 }
72
73 static inline BOOL heap_free(void *mem)
74 {
75     return HeapFree(GetProcessHeap(), 0, mem);
76 }
77
78 static inline LPWSTR heap_strdupW(LPCWSTR str)
79 {
80     LPWSTR ret = NULL;
81
82     if(str) {
83         DWORD size;
84
85         size = (strlenW(str)+1)*sizeof(WCHAR);
86         ret = heap_alloc(size);
87         memcpy(ret, str, size);
88     }
89
90     return ret;
91 }
92
93 typedef struct jsdisp_t jsdisp_t;
94
95 extern HINSTANCE jscript_hinstance DECLSPEC_HIDDEN;
96
97 #define PROPF_ARGMASK 0x00ff
98 #define PROPF_METHOD  0x0100
99 #define PROPF_ENUM    0x0200
100 #define PROPF_CONSTR  0x0400
101 #define PROPF_CONST   0x0800
102
103 /* NOTE: Keep in sync with names in Object.toString implementation */
104 typedef enum {
105     JSCLASS_NONE,
106     JSCLASS_ARRAY,
107     JSCLASS_BOOLEAN,
108     JSCLASS_DATE,
109     JSCLASS_ERROR,
110     JSCLASS_FUNCTION,
111     JSCLASS_GLOBAL,
112     JSCLASS_MATH,
113     JSCLASS_NUMBER,
114     JSCLASS_OBJECT,
115     JSCLASS_REGEXP,
116     JSCLASS_STRING,
117     JSCLASS_ARGUMENTS,
118     JSCLASS_VBARRAY
119 } jsclass_t;
120
121 jsdisp_t *iface_to_jsdisp(IUnknown*) DECLSPEC_HIDDEN;
122
123 typedef struct {
124     union {
125         IDispatch *disp;
126         IDispatchEx *dispex;
127         jsdisp_t *jsdisp;
128     } u;
129     DWORD flags;
130 } vdisp_t;
131
132 #define VDISP_DISPEX  0x0001
133 #define VDISP_JSDISP  0x0002
134
135 static inline void vdisp_release(vdisp_t *vdisp)
136 {
137     IDispatch_Release(vdisp->u.disp);
138 }
139
140 static inline BOOL is_jsdisp(vdisp_t *vdisp)
141 {
142     return (vdisp->flags & VDISP_JSDISP) != 0;
143 }
144
145 static inline BOOL is_dispex(vdisp_t *vdisp)
146 {
147     return (vdisp->flags & VDISP_DISPEX) != 0;
148 }
149
150 static inline void set_jsdisp(vdisp_t *vdisp, jsdisp_t *jsdisp)
151 {
152     vdisp->u.jsdisp = jsdisp;
153     vdisp->flags = VDISP_JSDISP | VDISP_DISPEX;
154     IDispatch_AddRef(vdisp->u.disp);
155 }
156
157 static inline void set_disp(vdisp_t *vdisp, IDispatch *disp)
158 {
159     IDispatchEx *dispex;
160     jsdisp_t *jsdisp;
161     HRESULT hres;
162
163     jsdisp = iface_to_jsdisp((IUnknown*)disp);
164     if(jsdisp) {
165         vdisp->u.jsdisp = jsdisp;
166         vdisp->flags = VDISP_JSDISP | VDISP_DISPEX;
167         return;
168     }
169
170     hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
171     if(SUCCEEDED(hres)) {
172         vdisp->u.dispex = dispex;
173         vdisp->flags = VDISP_DISPEX;
174         return;
175     }
176
177     IDispatch_AddRef(disp);
178     vdisp->u.disp = disp;
179     vdisp->flags = 0;
180 }
181
182 static inline jsdisp_t *get_jsdisp(vdisp_t *vdisp)
183 {
184     return is_jsdisp(vdisp) ? vdisp->u.jsdisp : NULL;
185 }
186
187 typedef HRESULT (*builtin_invoke_t)(script_ctx_t*,vdisp_t*,WORD,unsigned,jsval_t*,jsval_t*);
188
189 typedef struct {
190     const WCHAR *name;
191     builtin_invoke_t invoke;
192     DWORD flags;
193 } builtin_prop_t;
194
195 typedef struct {
196     jsclass_t class;
197     builtin_prop_t value_prop;
198     DWORD props_cnt;
199     const builtin_prop_t *props;
200     void (*destructor)(jsdisp_t*);
201     void (*on_put)(jsdisp_t*,const WCHAR*);
202 } builtin_info_t;
203
204 struct jsdisp_t {
205     IDispatchEx IDispatchEx_iface;
206
207     LONG ref;
208
209     DWORD buf_size;
210     DWORD prop_cnt;
211     dispex_prop_t *props;
212     script_ctx_t *ctx;
213
214     jsdisp_t *prototype;
215
216     const builtin_info_t *builtin_info;
217 };
218
219 static inline IDispatch *to_disp(jsdisp_t *jsdisp)
220 {
221     return (IDispatch*)&jsdisp->IDispatchEx_iface;
222 }
223
224 jsdisp_t *as_jsdisp(IDispatch*) DECLSPEC_HIDDEN;
225 jsdisp_t *to_jsdisp(IDispatch*) DECLSPEC_HIDDEN;
226 void jsdisp_free(jsdisp_t*) DECLSPEC_HIDDEN;
227
228 #ifndef TRACE_REFCNT
229
230 /*
231  * We do a lot of refcount calls during script execution, so having an inline
232  * version is a nice perf win. Define TRACE_REFCNT macro when debugging
233  * refcount bugs to have traces. Also, since jsdisp_t is not thread safe anyways,
234  * there is no point in using atomic operations.
235  */
236 static inline jsdisp_t *jsdisp_addref(jsdisp_t *jsdisp)
237 {
238     jsdisp->ref++;
239     return jsdisp;
240 }
241
242 static inline void jsdisp_release(jsdisp_t *jsdisp)
243 {
244     if(!--jsdisp->ref)
245         jsdisp_free(jsdisp);
246 }
247
248 #else
249
250 jsdisp_t *jsdisp_addref(jsdisp_t*) DECLSPEC_HIDDEN;
251 void jsdisp_release(jsdisp_t*) DECLSPEC_HIDDEN;
252
253 #endif
254
255 HRESULT create_dispex(script_ctx_t*,const builtin_info_t*,jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN;
256 HRESULT init_dispex(jsdisp_t*,script_ctx_t*,const builtin_info_t*,jsdisp_t*) DECLSPEC_HIDDEN;
257 HRESULT init_dispex_from_constr(jsdisp_t*,script_ctx_t*,const builtin_info_t*,jsdisp_t*) DECLSPEC_HIDDEN;
258
259 HRESULT disp_call(script_ctx_t*,IDispatch*,DISPID,WORD,unsigned,jsval_t*,jsval_t*) DECLSPEC_HIDDEN;
260 HRESULT disp_call_value(script_ctx_t*,IDispatch*,IDispatch*,WORD,unsigned,jsval_t*,jsval_t*) DECLSPEC_HIDDEN;
261 HRESULT jsdisp_call_value(jsdisp_t*,IDispatch*,WORD,unsigned,jsval_t*,jsval_t*) DECLSPEC_HIDDEN;
262 HRESULT jsdisp_call(jsdisp_t*,DISPID,WORD,unsigned,jsval_t*,jsval_t*) DECLSPEC_HIDDEN;
263 HRESULT jsdisp_call_name(jsdisp_t*,const WCHAR*,WORD,unsigned,jsval_t*,jsval_t*) DECLSPEC_HIDDEN;
264 HRESULT disp_propget(script_ctx_t*,IDispatch*,DISPID,jsval_t*) DECLSPEC_HIDDEN;
265 HRESULT disp_propput(script_ctx_t*,IDispatch*,DISPID,jsval_t) DECLSPEC_HIDDEN;
266 HRESULT jsdisp_propget(jsdisp_t*,DISPID,jsval_t*) DECLSPEC_HIDDEN;
267 HRESULT jsdisp_propput_name(jsdisp_t*,const WCHAR*,jsval_t) DECLSPEC_HIDDEN;
268 HRESULT jsdisp_propput_const(jsdisp_t*,const WCHAR*,jsval_t) DECLSPEC_HIDDEN;
269 HRESULT jsdisp_propput_dontenum(jsdisp_t*,const WCHAR*,jsval_t) DECLSPEC_HIDDEN;
270 HRESULT jsdisp_propput_idx(jsdisp_t*,DWORD,jsval_t) DECLSPEC_HIDDEN;
271 HRESULT jsdisp_propget_name(jsdisp_t*,LPCWSTR,jsval_t*) DECLSPEC_HIDDEN;
272 HRESULT jsdisp_get_idx(jsdisp_t*,DWORD,jsval_t*) DECLSPEC_HIDDEN;
273 HRESULT jsdisp_get_id(jsdisp_t*,const WCHAR*,DWORD,DISPID*) DECLSPEC_HIDDEN;
274 HRESULT jsdisp_delete_idx(jsdisp_t*,DWORD) DECLSPEC_HIDDEN;
275 HRESULT jsdisp_is_own_prop(jsdisp_t*,const WCHAR*,BOOL*) DECLSPEC_HIDDEN;
276 HRESULT jsdisp_is_enumerable(jsdisp_t*,const WCHAR*,BOOL*) DECLSPEC_HIDDEN;
277
278 HRESULT create_builtin_function(script_ctx_t*,builtin_invoke_t,const WCHAR*,const builtin_info_t*,DWORD,
279         jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN;
280 HRESULT create_builtin_constructor(script_ctx_t*,builtin_invoke_t,const WCHAR*,const builtin_info_t*,DWORD,
281         jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN;
282 HRESULT Function_value(script_ctx_t*,vdisp_t*,WORD,unsigned,jsval_t*,jsval_t*) DECLSPEC_HIDDEN;
283 HRESULT Function_invoke(jsdisp_t*,IDispatch*,WORD,unsigned,jsval_t*,jsval_t*) DECLSPEC_HIDDEN;
284
285 HRESULT throw_eval_error(script_ctx_t*,HRESULT,const WCHAR*) DECLSPEC_HIDDEN;
286 HRESULT throw_generic_error(script_ctx_t*,HRESULT,const WCHAR*) DECLSPEC_HIDDEN;
287 HRESULT throw_range_error(script_ctx_t*,HRESULT,const WCHAR*) DECLSPEC_HIDDEN;
288 HRESULT throw_reference_error(script_ctx_t*,HRESULT,const WCHAR*) DECLSPEC_HIDDEN;
289 HRESULT throw_regexp_error(script_ctx_t*,HRESULT,const WCHAR*) DECLSPEC_HIDDEN;
290 HRESULT throw_syntax_error(script_ctx_t*,HRESULT,const WCHAR*) DECLSPEC_HIDDEN;
291 HRESULT throw_type_error(script_ctx_t*,HRESULT,const WCHAR*) DECLSPEC_HIDDEN;
292 HRESULT throw_uri_error(script_ctx_t*,HRESULT,const WCHAR*) DECLSPEC_HIDDEN;
293
294 HRESULT create_object(script_ctx_t*,jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN;
295 HRESULT create_math(script_ctx_t*,jsdisp_t**) DECLSPEC_HIDDEN;
296 HRESULT create_array(script_ctx_t*,DWORD,jsdisp_t**) DECLSPEC_HIDDEN;
297 HRESULT create_regexp(script_ctx_t*,jsstr_t*,DWORD,jsdisp_t**) DECLSPEC_HIDDEN;
298 HRESULT create_regexp_var(script_ctx_t*,jsval_t,jsval_t*,jsdisp_t**) DECLSPEC_HIDDEN;
299 HRESULT create_string(script_ctx_t*,jsstr_t*,jsdisp_t**) DECLSPEC_HIDDEN;
300 HRESULT create_bool(script_ctx_t*,BOOL,jsdisp_t**) DECLSPEC_HIDDEN;
301 HRESULT create_number(script_ctx_t*,double,jsdisp_t**) DECLSPEC_HIDDEN;
302 HRESULT create_vbarray(script_ctx_t*,SAFEARRAY*,jsdisp_t**) DECLSPEC_HIDDEN;
303
304 typedef enum {
305     NO_HINT,
306     HINT_STRING,
307     HINT_NUMBER
308 } hint_t;
309
310 HRESULT to_primitive(script_ctx_t*,jsval_t,jsval_t*, hint_t) DECLSPEC_HIDDEN;
311 HRESULT to_boolean(jsval_t,BOOL*) DECLSPEC_HIDDEN;
312 HRESULT to_number(script_ctx_t*,jsval_t,double*) DECLSPEC_HIDDEN;
313 HRESULT to_integer(script_ctx_t*,jsval_t,double*) DECLSPEC_HIDDEN;
314 HRESULT to_int32(script_ctx_t*,jsval_t,INT*) DECLSPEC_HIDDEN;
315 HRESULT to_uint32(script_ctx_t*,jsval_t,DWORD*) DECLSPEC_HIDDEN;
316 HRESULT to_string(script_ctx_t*,jsval_t,jsstr_t**) DECLSPEC_HIDDEN;
317 HRESULT to_object(script_ctx_t*,jsval_t,IDispatch**) DECLSPEC_HIDDEN;
318
319 HRESULT variant_change_type(script_ctx_t*,VARIANT*,VARIANT*,VARTYPE) DECLSPEC_HIDDEN;
320
321 HRESULT decode_source(WCHAR*) DECLSPEC_HIDDEN;
322
323 HRESULT double_to_string(double,jsstr_t**) DECLSPEC_HIDDEN;
324
325 typedef struct named_item_t {
326     IDispatch *disp;
327     DWORD flags;
328     LPWSTR name;
329
330     struct named_item_t *next;
331 } named_item_t;
332
333 typedef struct _cc_var_t cc_var_t;
334
335 typedef struct {
336     cc_var_t *vars;
337 } cc_ctx_t;
338
339 void release_cc(cc_ctx_t*) DECLSPEC_HIDDEN;
340
341 typedef struct {
342     IServiceProvider IServiceProvider_iface;
343
344     LONG ref;
345
346     script_ctx_t *ctx;
347 } JSCaller;
348
349 #include "jsval.h"
350
351 typedef struct {
352     EXCEPINFO ei;
353     jsval_t val;
354 } jsexcept_t;
355
356 typedef struct {
357     const WCHAR *str;
358     DWORD len;
359 } match_result_t;
360
361 struct _script_ctx_t {
362     LONG ref;
363
364     SCRIPTSTATE state;
365     IActiveScript *active_script;
366
367     exec_ctx_t *exec_ctx;
368     named_item_t *named_items;
369     IActiveScriptSite *site;
370     IInternetHostSecurityManager *secmgr;
371     DWORD safeopt;
372     DWORD version;
373     LCID lcid;
374     cc_ctx_t *cc;
375     JSCaller *jscaller;
376     jsexcept_t ei;
377
378     jsheap_t tmp_heap;
379
380     IDispatch *host_global;
381
382     jsstr_t *last_match;
383     match_result_t match_parens[9];
384     DWORD last_match_index;
385     DWORD last_match_length;
386
387     jsdisp_t *global;
388     jsdisp_t *function_constr;
389     jsdisp_t *activex_constr;
390     jsdisp_t *array_constr;
391     jsdisp_t *bool_constr;
392     jsdisp_t *date_constr;
393     jsdisp_t *error_constr;
394     jsdisp_t *eval_error_constr;
395     jsdisp_t *range_error_constr;
396     jsdisp_t *reference_error_constr;
397     jsdisp_t *regexp_error_constr;
398     jsdisp_t *syntax_error_constr;
399     jsdisp_t *type_error_constr;
400     jsdisp_t *uri_error_constr;
401     jsdisp_t *number_constr;
402     jsdisp_t *object_constr;
403     jsdisp_t *regexp_constr;
404     jsdisp_t *string_constr;
405     jsdisp_t *vbarray_constr;
406 };
407
408 void script_release(script_ctx_t*) DECLSPEC_HIDDEN;
409 void clear_ei(script_ctx_t*) DECLSPEC_HIDDEN;
410
411 static inline void script_addref(script_ctx_t *ctx)
412 {
413     ctx->ref++;
414 }
415
416 HRESULT init_global(script_ctx_t*) DECLSPEC_HIDDEN;
417 HRESULT init_function_constr(script_ctx_t*,jsdisp_t*) DECLSPEC_HIDDEN;
418 HRESULT create_object_prototype(script_ctx_t*,jsdisp_t**) DECLSPEC_HIDDEN;
419
420 HRESULT create_activex_constr(script_ctx_t*,jsdisp_t**) DECLSPEC_HIDDEN;
421 HRESULT create_array_constr(script_ctx_t*,jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN;
422 HRESULT create_bool_constr(script_ctx_t*,jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN;
423 HRESULT create_date_constr(script_ctx_t*,jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN;
424 HRESULT init_error_constr(script_ctx_t*,jsdisp_t*) DECLSPEC_HIDDEN;
425 HRESULT create_number_constr(script_ctx_t*,jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN;
426 HRESULT create_object_constr(script_ctx_t*,jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN;
427 HRESULT create_regexp_constr(script_ctx_t*,jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN;
428 HRESULT create_string_constr(script_ctx_t*,jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN;
429 HRESULT create_vbarray_constr(script_ctx_t*,jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN;
430
431 IUnknown *create_ax_site(script_ctx_t*) DECLSPEC_HIDDEN;
432 HRESULT create_jscaller(script_ctx_t*) DECLSPEC_HIDDEN;
433
434 #define REM_CHECK_GLOBAL   0x0001
435 #define REM_RESET_INDEX    0x0002
436 #define REM_NO_CTX_UPDATE  0x0004
437 HRESULT regexp_match_next(script_ctx_t*,jsdisp_t*,DWORD,jsstr_t*,const WCHAR**,match_result_t**,
438         DWORD*,DWORD*,match_result_t*) DECLSPEC_HIDDEN;
439 HRESULT parse_regexp_flags(const WCHAR*,DWORD,DWORD*) DECLSPEC_HIDDEN;
440 HRESULT regexp_string_match(script_ctx_t*,jsdisp_t*,jsstr_t*,jsval_t*) DECLSPEC_HIDDEN;
441
442 static inline BOOL is_class(jsdisp_t *jsdisp, jsclass_t class)
443 {
444     return jsdisp->builtin_info->class == class;
445 }
446
447 static inline BOOL is_vclass(vdisp_t *vdisp, jsclass_t class)
448 {
449     return is_jsdisp(vdisp) && is_class(vdisp->u.jsdisp, class);
450 }
451
452 #ifndef INT32_MIN
453 #define INT32_MIN (-2147483647-1)
454 #endif
455
456 #ifndef INT32_MAX
457 #define INT32_MAX (2147483647)
458 #endif
459
460 static inline BOOL is_int32(double d)
461 {
462     return INT32_MIN <= d && d <= INT32_MAX && (double)(int)d == d;
463 }
464
465 static inline DWORD make_grfdex(script_ctx_t *ctx, DWORD flags)
466 {
467     return (ctx->version << 28) | flags;
468 }
469
470 #define FACILITY_JSCRIPT 10
471
472 #define MAKE_JSERROR(code) MAKE_HRESULT(SEVERITY_ERROR, FACILITY_JSCRIPT, code)
473
474 #define JS_E_TO_PRIMITIVE            MAKE_JSERROR(IDS_TO_PRIMITIVE)
475 #define JS_E_INVALIDARG              MAKE_JSERROR(IDS_INVALID_CALL_ARG)
476 #define JS_E_SUBSCRIPT_OUT_OF_RANGE  MAKE_JSERROR(IDS_SUBSCRIPT_OUT_OF_RANGE)
477 #define JS_E_OBJECT_REQUIRED         MAKE_JSERROR(IDS_OBJECT_REQUIRED)
478 #define JS_E_CANNOT_CREATE_OBJ       MAKE_JSERROR(IDS_CREATE_OBJ_ERROR)
479 #define JS_E_INVALID_PROPERTY        MAKE_JSERROR(IDS_NO_PROPERTY)
480 #define JS_E_INVALID_ACTION          MAKE_JSERROR(IDS_UNSUPPORTED_ACTION)
481 #define JS_E_MISSING_ARG             MAKE_JSERROR(IDS_ARG_NOT_OPT)
482 #define JS_E_SYNTAX                  MAKE_JSERROR(IDS_SYNTAX_ERROR)
483 #define JS_E_MISSING_SEMICOLON       MAKE_JSERROR(IDS_SEMICOLON)
484 #define JS_E_MISSING_LBRACKET        MAKE_JSERROR(IDS_LBRACKET)
485 #define JS_E_MISSING_RBRACKET        MAKE_JSERROR(IDS_RBRACKET)
486 #define JS_E_INVALID_CHAR            MAKE_JSERROR(IDS_INVALID_CHAR)
487 #define JS_E_UNTERMINATED_STRING     MAKE_JSERROR(IDS_UNTERMINATED_STR)
488 #define JS_E_INVALID_BREAK           MAKE_JSERROR(IDS_INVALID_BREAK)
489 #define JS_E_INVALID_CONTINUE        MAKE_JSERROR(IDS_INVALID_CONTINUE)
490 #define JS_E_LABEL_REDEFINED         MAKE_JSERROR(IDS_LABEL_REDEFINED)
491 #define JS_E_LABEL_NOT_FOUND         MAKE_JSERROR(IDS_LABEL_NOT_FOUND)
492 #define JS_E_DISABLED_CC             MAKE_JSERROR(IDS_DISABLED_CC)
493 #define JS_E_FUNCTION_EXPECTED       MAKE_JSERROR(IDS_NOT_FUNC)
494 #define JS_E_DATE_EXPECTED           MAKE_JSERROR(IDS_NOT_DATE)
495 #define JS_E_NUMBER_EXPECTED         MAKE_JSERROR(IDS_NOT_NUM)
496 #define JS_E_OBJECT_EXPECTED         MAKE_JSERROR(IDS_OBJECT_EXPECTED)
497 #define JS_E_ILLEGAL_ASSIGN          MAKE_JSERROR(IDS_ILLEGAL_ASSIGN)
498 #define JS_E_UNDEFINED_VARIABLE      MAKE_JSERROR(IDS_UNDEFINED)
499 #define JS_E_BOOLEAN_EXPECTED        MAKE_JSERROR(IDS_NOT_BOOL)
500 #define JS_E_VBARRAY_EXPECTED        MAKE_JSERROR(IDS_NOT_VBARRAY)
501 #define JS_E_INVALID_DELETE          MAKE_JSERROR(IDS_INVALID_DELETE)
502 #define JS_E_JSCRIPT_EXPECTED        MAKE_JSERROR(IDS_JSCRIPT_EXPECTED)
503 #define JS_E_REGEXP_SYNTAX           MAKE_JSERROR(IDS_REGEXP_SYNTAX_ERROR)
504 #define JS_E_INVALID_URI_CODING      MAKE_JSERROR(IDS_URI_INVALID_CODING)
505 #define JS_E_INVALID_URI_CHAR        MAKE_JSERROR(IDS_URI_INVALID_CHAR)
506 #define JS_E_FRACTION_DIGITS_OUT_OF_RANGE MAKE_JSERROR(IDS_FRACTION_DIGITS_OUT_OF_RANGE)
507 #define JS_E_PRECISION_OUT_OF_RANGE  MAKE_JSERROR(IDS_PRECISION_OUT_OF_RANGE)
508 #define JS_E_INVALID_LENGTH          MAKE_JSERROR(IDS_INVALID_LENGTH)
509 #define JS_E_ARRAY_EXPECTED          MAKE_JSERROR(IDS_ARRAY_EXPECTED)
510
511 static inline BOOL is_jscript_error(HRESULT hres)
512 {
513     return HRESULT_FACILITY(hres) == FACILITY_JSCRIPT;
514 }
515
516 const char *debugstr_variant(const VARIANT*) DECLSPEC_HIDDEN;
517 const char *debugstr_jsval(const jsval_t) DECLSPEC_HIDDEN;
518
519 HRESULT create_jscript_object(BOOL,REFIID,void**) DECLSPEC_HIDDEN;
520
521 extern LONG module_ref DECLSPEC_HIDDEN;
522
523 static inline void lock_module(void)
524 {
525     InterlockedIncrement(&module_ref);
526 }
527
528 static inline void unlock_module(void)
529 {
530     InterlockedDecrement(&module_ref);
531 }