d3d10_1: Validate parameters in D3D10CreateDevice1().
[wine.git] / dlls / jscript / jscript.h
blob87f2e945be9c12e91f2fdcf21b3c867d65c039cb
1 /*
2 * Copyright 2008-2009 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 <stdarg.h>
20 #include <stdio.h>
22 #define COBJMACROS
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winuser.h"
27 #include "ole2.h"
28 #include "dispex.h"
29 #include "activscp.h"
31 #include "resource.h"
33 #include "wine/unicode.h"
34 #include "wine/list.h"
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;
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 } heap_pool_t;
51 void heap_pool_init(heap_pool_t*) DECLSPEC_HIDDEN;
52 void *heap_pool_alloc(heap_pool_t*,DWORD) __WINE_ALLOC_SIZE(2) DECLSPEC_HIDDEN;
53 void *heap_pool_grow(heap_pool_t*,void*,DWORD,DWORD) DECLSPEC_HIDDEN;
54 void heap_pool_clear(heap_pool_t*) DECLSPEC_HIDDEN;
55 void heap_pool_free(heap_pool_t*) DECLSPEC_HIDDEN;
56 heap_pool_t *heap_pool_mark(heap_pool_t*) DECLSPEC_HIDDEN;
58 static inline void *heap_alloc(size_t len)
60 return HeapAlloc(GetProcessHeap(), 0, len);
63 static inline void *heap_alloc_zero(size_t len)
65 return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
68 static inline void *heap_realloc(void *mem, size_t len)
70 return HeapReAlloc(GetProcessHeap(), 0, mem, len);
73 static inline BOOL heap_free(void *mem)
75 return HeapFree(GetProcessHeap(), 0, mem);
78 static inline LPWSTR heap_strdupW(LPCWSTR str)
80 LPWSTR ret = NULL;
82 if(str) {
83 DWORD size;
85 size = (strlenW(str)+1)*sizeof(WCHAR);
86 ret = heap_alloc(size);
87 if(ret)
88 memcpy(ret, str, size);
91 return ret;
94 typedef struct jsdisp_t jsdisp_t;
96 extern HINSTANCE jscript_hinstance DECLSPEC_HIDDEN;
98 #define PROPF_ARGMASK 0x00ff
99 #define PROPF_METHOD 0x0100
100 #define PROPF_ENUM 0x0200
101 #define PROPF_CONSTR 0x0400
102 #define PROPF_CONST 0x0800
103 #define PROPF_DONTDELETE 0x1000
105 /* NOTE: Keep in sync with names in Object.toString implementation */
106 typedef enum {
107 JSCLASS_NONE,
108 JSCLASS_ARRAY,
109 JSCLASS_BOOLEAN,
110 JSCLASS_DATE,
111 JSCLASS_ERROR,
112 JSCLASS_FUNCTION,
113 JSCLASS_GLOBAL,
114 JSCLASS_MATH,
115 JSCLASS_NUMBER,
116 JSCLASS_OBJECT,
117 JSCLASS_REGEXP,
118 JSCLASS_STRING,
119 JSCLASS_ARGUMENTS,
120 JSCLASS_VBARRAY,
121 JSCLASS_JSON
122 } jsclass_t;
124 jsdisp_t *iface_to_jsdisp(IUnknown*) DECLSPEC_HIDDEN;
126 typedef struct {
127 union {
128 IDispatch *disp;
129 IDispatchEx *dispex;
130 jsdisp_t *jsdisp;
131 } u;
132 DWORD flags;
133 } vdisp_t;
135 #define VDISP_DISPEX 0x0001
136 #define VDISP_JSDISP 0x0002
138 static inline void vdisp_release(vdisp_t *vdisp)
140 IDispatch_Release(vdisp->u.disp);
143 static inline BOOL is_jsdisp(vdisp_t *vdisp)
145 return (vdisp->flags & VDISP_JSDISP) != 0;
148 static inline BOOL is_dispex(vdisp_t *vdisp)
150 return (vdisp->flags & VDISP_DISPEX) != 0;
153 static inline void set_jsdisp(vdisp_t *vdisp, jsdisp_t *jsdisp)
155 vdisp->u.jsdisp = jsdisp;
156 vdisp->flags = VDISP_JSDISP | VDISP_DISPEX;
157 IDispatch_AddRef(vdisp->u.disp);
160 static inline void set_disp(vdisp_t *vdisp, IDispatch *disp)
162 IDispatchEx *dispex;
163 jsdisp_t *jsdisp;
164 HRESULT hres;
166 jsdisp = iface_to_jsdisp((IUnknown*)disp);
167 if(jsdisp) {
168 vdisp->u.jsdisp = jsdisp;
169 vdisp->flags = VDISP_JSDISP | VDISP_DISPEX;
170 return;
173 hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
174 if(SUCCEEDED(hres)) {
175 vdisp->u.dispex = dispex;
176 vdisp->flags = VDISP_DISPEX;
177 return;
180 IDispatch_AddRef(disp);
181 vdisp->u.disp = disp;
182 vdisp->flags = 0;
185 static inline jsdisp_t *get_jsdisp(vdisp_t *vdisp)
187 return is_jsdisp(vdisp) ? vdisp->u.jsdisp : NULL;
190 typedef HRESULT (*builtin_invoke_t)(script_ctx_t*,vdisp_t*,WORD,unsigned,jsval_t*,jsval_t*);
191 typedef HRESULT (*builtin_getter_t)(script_ctx_t*,jsdisp_t*,jsval_t*);
192 typedef HRESULT (*builtin_setter_t)(script_ctx_t*,jsdisp_t*,jsval_t);
194 HRESULT builtin_set_const(script_ctx_t*,jsdisp_t*,jsval_t) DECLSPEC_HIDDEN;
196 typedef struct {
197 const WCHAR *name;
198 builtin_invoke_t invoke;
199 DWORD flags;
200 builtin_getter_t getter;
201 builtin_setter_t setter;
202 } builtin_prop_t;
204 typedef struct {
205 jsclass_t class;
206 builtin_prop_t value_prop;
207 DWORD props_cnt;
208 const builtin_prop_t *props;
209 void (*destructor)(jsdisp_t*);
210 void (*on_put)(jsdisp_t*,const WCHAR*);
211 unsigned (*idx_length)(jsdisp_t*);
212 HRESULT (*idx_get)(jsdisp_t*,unsigned,jsval_t*);
213 HRESULT (*idx_put)(jsdisp_t*,unsigned,jsval_t);
214 } builtin_info_t;
216 struct jsdisp_t {
217 IDispatchEx IDispatchEx_iface;
219 LONG ref;
221 DWORD buf_size;
222 DWORD prop_cnt;
223 dispex_prop_t *props;
224 script_ctx_t *ctx;
226 jsdisp_t *prototype;
228 const builtin_info_t *builtin_info;
231 static inline IDispatch *to_disp(jsdisp_t *jsdisp)
233 return (IDispatch*)&jsdisp->IDispatchEx_iface;
236 jsdisp_t *as_jsdisp(IDispatch*) DECLSPEC_HIDDEN;
237 jsdisp_t *to_jsdisp(IDispatch*) DECLSPEC_HIDDEN;
238 void jsdisp_free(jsdisp_t*) DECLSPEC_HIDDEN;
240 #ifndef TRACE_REFCNT
243 * We do a lot of refcount calls during script execution, so having an inline
244 * version is a nice perf win. Define TRACE_REFCNT macro when debugging
245 * refcount bugs to have traces. Also, since jsdisp_t is not thread safe anyways,
246 * there is no point in using atomic operations.
248 static inline jsdisp_t *jsdisp_addref(jsdisp_t *jsdisp)
250 jsdisp->ref++;
251 return jsdisp;
254 static inline void jsdisp_release(jsdisp_t *jsdisp)
256 if(!--jsdisp->ref)
257 jsdisp_free(jsdisp);
260 #else
262 jsdisp_t *jsdisp_addref(jsdisp_t*) DECLSPEC_HIDDEN;
263 void jsdisp_release(jsdisp_t*) DECLSPEC_HIDDEN;
265 #endif
267 HRESULT create_dispex(script_ctx_t*,const builtin_info_t*,jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN;
268 HRESULT init_dispex(jsdisp_t*,script_ctx_t*,const builtin_info_t*,jsdisp_t*) DECLSPEC_HIDDEN;
269 HRESULT init_dispex_from_constr(jsdisp_t*,script_ctx_t*,const builtin_info_t*,jsdisp_t*) DECLSPEC_HIDDEN;
271 HRESULT disp_call(script_ctx_t*,IDispatch*,DISPID,WORD,unsigned,jsval_t*,jsval_t*) DECLSPEC_HIDDEN;
272 HRESULT disp_call_value(script_ctx_t*,IDispatch*,IDispatch*,WORD,unsigned,jsval_t*,jsval_t*) DECLSPEC_HIDDEN;
273 HRESULT jsdisp_call_value(jsdisp_t*,IDispatch*,WORD,unsigned,jsval_t*,jsval_t*) DECLSPEC_HIDDEN;
274 HRESULT jsdisp_call(jsdisp_t*,DISPID,WORD,unsigned,jsval_t*,jsval_t*) DECLSPEC_HIDDEN;
275 HRESULT jsdisp_call_name(jsdisp_t*,const WCHAR*,WORD,unsigned,jsval_t*,jsval_t*) DECLSPEC_HIDDEN;
276 HRESULT disp_propget(script_ctx_t*,IDispatch*,DISPID,jsval_t*) DECLSPEC_HIDDEN;
277 HRESULT disp_propput(script_ctx_t*,IDispatch*,DISPID,jsval_t) DECLSPEC_HIDDEN;
278 HRESULT jsdisp_propget(jsdisp_t*,DISPID,jsval_t*) DECLSPEC_HIDDEN;
279 HRESULT jsdisp_propput(jsdisp_t*,const WCHAR*,DWORD,jsval_t) DECLSPEC_HIDDEN;
280 HRESULT jsdisp_propput_name(jsdisp_t*,const WCHAR*,jsval_t) DECLSPEC_HIDDEN;
281 HRESULT jsdisp_propput_const(jsdisp_t*,const WCHAR*,jsval_t) DECLSPEC_HIDDEN;
282 HRESULT jsdisp_propput_dontenum(jsdisp_t*,const WCHAR*,jsval_t) DECLSPEC_HIDDEN;
283 HRESULT jsdisp_propput_idx(jsdisp_t*,DWORD,jsval_t) DECLSPEC_HIDDEN;
284 HRESULT jsdisp_propget_name(jsdisp_t*,LPCWSTR,jsval_t*) DECLSPEC_HIDDEN;
285 HRESULT jsdisp_get_idx(jsdisp_t*,DWORD,jsval_t*) DECLSPEC_HIDDEN;
286 HRESULT jsdisp_get_id(jsdisp_t*,const WCHAR*,DWORD,DISPID*) DECLSPEC_HIDDEN;
287 HRESULT disp_delete(IDispatch*,DISPID,BOOL*) DECLSPEC_HIDDEN;
288 HRESULT disp_delete_name(script_ctx_t*,IDispatch*,jsstr_t*,BOOL*) DECLSPEC_HIDDEN;
289 HRESULT jsdisp_delete_idx(jsdisp_t*,DWORD) DECLSPEC_HIDDEN;
290 HRESULT jsdisp_is_own_prop(jsdisp_t*,const WCHAR*,BOOL*) DECLSPEC_HIDDEN;
291 HRESULT jsdisp_is_enumerable(jsdisp_t*,const WCHAR*,BOOL*) DECLSPEC_HIDDEN;
293 HRESULT create_builtin_function(script_ctx_t*,builtin_invoke_t,const WCHAR*,const builtin_info_t*,DWORD,
294 jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN;
295 HRESULT create_builtin_constructor(script_ctx_t*,builtin_invoke_t,const WCHAR*,const builtin_info_t*,DWORD,
296 jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN;
297 HRESULT Function_invoke(jsdisp_t*,IDispatch*,WORD,unsigned,jsval_t*,jsval_t*) DECLSPEC_HIDDEN;
299 HRESULT Function_value(script_ctx_t*,vdisp_t*,WORD,unsigned,jsval_t*,jsval_t*) DECLSPEC_HIDDEN;
300 HRESULT Function_get_value(script_ctx_t*,jsdisp_t*,jsval_t*) DECLSPEC_HIDDEN;
301 #define DEFAULT_FUNCTION_VALUE {NULL, Function_value,0, Function_get_value}
303 HRESULT throw_eval_error(script_ctx_t*,HRESULT,const WCHAR*) DECLSPEC_HIDDEN;
304 HRESULT throw_generic_error(script_ctx_t*,HRESULT,const WCHAR*) DECLSPEC_HIDDEN;
305 HRESULT throw_range_error(script_ctx_t*,HRESULT,const WCHAR*) DECLSPEC_HIDDEN;
306 HRESULT throw_reference_error(script_ctx_t*,HRESULT,const WCHAR*) DECLSPEC_HIDDEN;
307 HRESULT throw_regexp_error(script_ctx_t*,HRESULT,const WCHAR*) DECLSPEC_HIDDEN;
308 HRESULT throw_syntax_error(script_ctx_t*,HRESULT,const WCHAR*) DECLSPEC_HIDDEN;
309 HRESULT throw_type_error(script_ctx_t*,HRESULT,const WCHAR*) DECLSPEC_HIDDEN;
310 HRESULT throw_uri_error(script_ctx_t*,HRESULT,const WCHAR*) DECLSPEC_HIDDEN;
312 HRESULT create_object(script_ctx_t*,jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN;
313 HRESULT create_math(script_ctx_t*,jsdisp_t**) DECLSPEC_HIDDEN;
314 HRESULT create_array(script_ctx_t*,DWORD,jsdisp_t**) DECLSPEC_HIDDEN;
315 HRESULT create_regexp(script_ctx_t*,jsstr_t*,DWORD,jsdisp_t**) DECLSPEC_HIDDEN;
316 HRESULT create_regexp_var(script_ctx_t*,jsval_t,jsval_t*,jsdisp_t**) DECLSPEC_HIDDEN;
317 HRESULT create_string(script_ctx_t*,jsstr_t*,jsdisp_t**) DECLSPEC_HIDDEN;
318 HRESULT create_bool(script_ctx_t*,BOOL,jsdisp_t**) DECLSPEC_HIDDEN;
319 HRESULT create_number(script_ctx_t*,double,jsdisp_t**) DECLSPEC_HIDDEN;
320 HRESULT create_vbarray(script_ctx_t*,SAFEARRAY*,jsdisp_t**) DECLSPEC_HIDDEN;
321 HRESULT create_json(script_ctx_t*,jsdisp_t**) DECLSPEC_HIDDEN;
323 typedef enum {
324 NO_HINT,
325 HINT_STRING,
326 HINT_NUMBER
327 } hint_t;
329 HRESULT to_primitive(script_ctx_t*,jsval_t,jsval_t*, hint_t) DECLSPEC_HIDDEN;
330 HRESULT to_boolean(jsval_t,BOOL*) DECLSPEC_HIDDEN;
331 HRESULT to_number(script_ctx_t*,jsval_t,double*) DECLSPEC_HIDDEN;
332 HRESULT to_integer(script_ctx_t*,jsval_t,double*) DECLSPEC_HIDDEN;
333 HRESULT to_int32(script_ctx_t*,jsval_t,INT*) DECLSPEC_HIDDEN;
334 HRESULT to_uint32(script_ctx_t*,jsval_t,UINT32*) DECLSPEC_HIDDEN;
335 HRESULT to_string(script_ctx_t*,jsval_t,jsstr_t**) DECLSPEC_HIDDEN;
336 HRESULT to_flat_string(script_ctx_t*,jsval_t,jsstr_t**,const WCHAR**) DECLSPEC_HIDDEN;
337 HRESULT to_object(script_ctx_t*,jsval_t,IDispatch**) DECLSPEC_HIDDEN;
339 HRESULT variant_change_type(script_ctx_t*,VARIANT*,VARIANT*,VARTYPE) DECLSPEC_HIDDEN;
341 HRESULT decode_source(WCHAR*) DECLSPEC_HIDDEN;
343 HRESULT double_to_string(double,jsstr_t**) DECLSPEC_HIDDEN;
344 BOOL is_finite(double) DECLSPEC_HIDDEN;
346 typedef struct named_item_t {
347 IDispatch *disp;
348 DWORD flags;
349 LPWSTR name;
351 struct named_item_t *next;
352 } named_item_t;
354 typedef struct _cc_var_t cc_var_t;
356 typedef struct {
357 cc_var_t *vars;
358 } cc_ctx_t;
360 void release_cc(cc_ctx_t*) DECLSPEC_HIDDEN;
362 typedef struct {
363 IServiceProvider IServiceProvider_iface;
365 LONG ref;
367 script_ctx_t *ctx;
368 } JSCaller;
370 #include "jsval.h"
372 typedef struct {
373 EXCEPINFO ei;
374 jsval_t val;
375 } jsexcept_t;
377 typedef struct {
378 unsigned index;
379 unsigned length;
380 } match_result_t;
382 struct _script_ctx_t {
383 LONG ref;
385 SCRIPTSTATE state;
386 IActiveScript *active_script;
388 exec_ctx_t *exec_ctx;
389 named_item_t *named_items;
390 IActiveScriptSite *site;
391 IInternetHostSecurityManager *secmgr;
392 DWORD safeopt;
393 DWORD version;
394 LCID lcid;
395 cc_ctx_t *cc;
396 JSCaller *jscaller;
397 jsexcept_t ei;
399 heap_pool_t tmp_heap;
401 IDispatch *host_global;
403 jsstr_t *last_match;
404 match_result_t match_parens[9];
405 DWORD last_match_index;
406 DWORD last_match_length;
408 jsdisp_t *global;
409 jsdisp_t *function_constr;
410 jsdisp_t *array_constr;
411 jsdisp_t *bool_constr;
412 jsdisp_t *date_constr;
413 jsdisp_t *error_constr;
414 jsdisp_t *eval_error_constr;
415 jsdisp_t *range_error_constr;
416 jsdisp_t *reference_error_constr;
417 jsdisp_t *regexp_error_constr;
418 jsdisp_t *syntax_error_constr;
419 jsdisp_t *type_error_constr;
420 jsdisp_t *uri_error_constr;
421 jsdisp_t *number_constr;
422 jsdisp_t *object_constr;
423 jsdisp_t *regexp_constr;
424 jsdisp_t *string_constr;
425 jsdisp_t *vbarray_constr;
428 void script_release(script_ctx_t*) DECLSPEC_HIDDEN;
429 void clear_ei(script_ctx_t*) DECLSPEC_HIDDEN;
431 static inline void script_addref(script_ctx_t *ctx)
433 ctx->ref++;
436 HRESULT init_global(script_ctx_t*) DECLSPEC_HIDDEN;
437 HRESULT init_function_constr(script_ctx_t*,jsdisp_t*) DECLSPEC_HIDDEN;
438 HRESULT create_object_prototype(script_ctx_t*,jsdisp_t**) DECLSPEC_HIDDEN;
440 HRESULT create_activex_constr(script_ctx_t*,jsdisp_t**) DECLSPEC_HIDDEN;
441 HRESULT create_array_constr(script_ctx_t*,jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN;
442 HRESULT create_bool_constr(script_ctx_t*,jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN;
443 HRESULT create_date_constr(script_ctx_t*,jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN;
444 HRESULT init_error_constr(script_ctx_t*,jsdisp_t*) DECLSPEC_HIDDEN;
445 HRESULT create_number_constr(script_ctx_t*,jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN;
446 HRESULT create_object_constr(script_ctx_t*,jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN;
447 HRESULT create_regexp_constr(script_ctx_t*,jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN;
448 HRESULT create_string_constr(script_ctx_t*,jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN;
449 HRESULT create_vbarray_constr(script_ctx_t*,jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN;
451 IUnknown *create_ax_site(script_ctx_t*) DECLSPEC_HIDDEN;
452 HRESULT create_jscaller(script_ctx_t*) DECLSPEC_HIDDEN;
454 #define REM_CHECK_GLOBAL 0x0001
455 #define REM_RESET_INDEX 0x0002
456 #define REM_NO_CTX_UPDATE 0x0004
457 #define REM_ALLOC_RESULT 0x0008
458 #define REM_NO_PARENS 0x0010
459 struct match_state_t;
460 HRESULT regexp_match_next(script_ctx_t*,jsdisp_t*,DWORD,jsstr_t*,struct match_state_t**) DECLSPEC_HIDDEN;
461 HRESULT parse_regexp_flags(const WCHAR*,DWORD,DWORD*) DECLSPEC_HIDDEN;
462 HRESULT regexp_string_match(script_ctx_t*,jsdisp_t*,jsstr_t*,jsval_t*) DECLSPEC_HIDDEN;
464 BOOL bool_obj_value(jsdisp_t*) DECLSPEC_HIDDEN;
465 unsigned array_get_length(jsdisp_t*) DECLSPEC_HIDDEN;
467 static inline BOOL is_class(jsdisp_t *jsdisp, jsclass_t class)
469 return jsdisp->builtin_info->class == class;
472 static inline BOOL is_vclass(vdisp_t *vdisp, jsclass_t class)
474 return is_jsdisp(vdisp) && is_class(vdisp->u.jsdisp, class);
477 #ifndef INT32_MIN
478 #define INT32_MIN (-2147483647-1)
479 #endif
481 #ifndef INT32_MAX
482 #define INT32_MAX (2147483647)
483 #endif
485 static inline BOOL is_int32(double d)
487 return INT32_MIN <= d && d <= INT32_MAX && (double)(int)d == d;
490 static inline DWORD make_grfdex(script_ctx_t *ctx, DWORD flags)
492 return (ctx->version << 28) | flags;
495 #define FACILITY_JSCRIPT 10
497 #define MAKE_JSERROR(code) MAKE_HRESULT(SEVERITY_ERROR, FACILITY_JSCRIPT, code)
499 #define JS_E_TO_PRIMITIVE MAKE_JSERROR(IDS_TO_PRIMITIVE)
500 #define JS_E_INVALIDARG MAKE_JSERROR(IDS_INVALID_CALL_ARG)
501 #define JS_E_SUBSCRIPT_OUT_OF_RANGE MAKE_JSERROR(IDS_SUBSCRIPT_OUT_OF_RANGE)
502 #define JS_E_OBJECT_REQUIRED MAKE_JSERROR(IDS_OBJECT_REQUIRED)
503 #define JS_E_CANNOT_CREATE_OBJ MAKE_JSERROR(IDS_CREATE_OBJ_ERROR)
504 #define JS_E_INVALID_PROPERTY MAKE_JSERROR(IDS_NO_PROPERTY)
505 #define JS_E_INVALID_ACTION MAKE_JSERROR(IDS_UNSUPPORTED_ACTION)
506 #define JS_E_MISSING_ARG MAKE_JSERROR(IDS_ARG_NOT_OPT)
507 #define JS_E_SYNTAX MAKE_JSERROR(IDS_SYNTAX_ERROR)
508 #define JS_E_MISSING_SEMICOLON MAKE_JSERROR(IDS_SEMICOLON)
509 #define JS_E_MISSING_LBRACKET MAKE_JSERROR(IDS_LBRACKET)
510 #define JS_E_MISSING_RBRACKET MAKE_JSERROR(IDS_RBRACKET)
511 #define JS_E_EXPECTED_IDENTIFIER MAKE_JSERROR(IDS_EXPECTED_IDENTIFIER)
512 #define JS_E_EXPECTED_ASSIGN MAKE_JSERROR(IDS_EXPECTED_ASSIGN)
513 #define JS_E_INVALID_CHAR MAKE_JSERROR(IDS_INVALID_CHAR)
514 #define JS_E_UNTERMINATED_STRING MAKE_JSERROR(IDS_UNTERMINATED_STR)
515 #define JS_E_MISPLACED_RETURN MAKE_JSERROR(IDS_MISPLACED_RETURN)
516 #define JS_E_INVALID_BREAK MAKE_JSERROR(IDS_INVALID_BREAK)
517 #define JS_E_INVALID_CONTINUE MAKE_JSERROR(IDS_INVALID_CONTINUE)
518 #define JS_E_LABEL_REDEFINED MAKE_JSERROR(IDS_LABEL_REDEFINED)
519 #define JS_E_LABEL_NOT_FOUND MAKE_JSERROR(IDS_LABEL_NOT_FOUND)
520 #define JS_E_EXPECTED_CCEND MAKE_JSERROR(IDS_EXPECTED_CCEND)
521 #define JS_E_DISABLED_CC MAKE_JSERROR(IDS_DISABLED_CC)
522 #define JS_E_EXPECTED_AT MAKE_JSERROR(IDS_EXPECTED_AT)
523 #define JS_E_FUNCTION_EXPECTED MAKE_JSERROR(IDS_NOT_FUNC)
524 #define JS_E_DATE_EXPECTED MAKE_JSERROR(IDS_NOT_DATE)
525 #define JS_E_NUMBER_EXPECTED MAKE_JSERROR(IDS_NOT_NUM)
526 #define JS_E_OBJECT_EXPECTED MAKE_JSERROR(IDS_OBJECT_EXPECTED)
527 #define JS_E_ILLEGAL_ASSIGN MAKE_JSERROR(IDS_ILLEGAL_ASSIGN)
528 #define JS_E_UNDEFINED_VARIABLE MAKE_JSERROR(IDS_UNDEFINED)
529 #define JS_E_BOOLEAN_EXPECTED MAKE_JSERROR(IDS_NOT_BOOL)
530 #define JS_E_VBARRAY_EXPECTED MAKE_JSERROR(IDS_NOT_VBARRAY)
531 #define JS_E_INVALID_DELETE MAKE_JSERROR(IDS_INVALID_DELETE)
532 #define JS_E_JSCRIPT_EXPECTED MAKE_JSERROR(IDS_JSCRIPT_EXPECTED)
533 #define JS_E_REGEXP_SYNTAX MAKE_JSERROR(IDS_REGEXP_SYNTAX_ERROR)
534 #define JS_E_INVALID_URI_CODING MAKE_JSERROR(IDS_URI_INVALID_CODING)
535 #define JS_E_INVALID_URI_CHAR MAKE_JSERROR(IDS_URI_INVALID_CHAR)
536 #define JS_E_FRACTION_DIGITS_OUT_OF_RANGE MAKE_JSERROR(IDS_FRACTION_DIGITS_OUT_OF_RANGE)
537 #define JS_E_PRECISION_OUT_OF_RANGE MAKE_JSERROR(IDS_PRECISION_OUT_OF_RANGE)
538 #define JS_E_INVALID_LENGTH MAKE_JSERROR(IDS_INVALID_LENGTH)
539 #define JS_E_ARRAY_EXPECTED MAKE_JSERROR(IDS_ARRAY_EXPECTED)
541 static inline BOOL is_jscript_error(HRESULT hres)
543 return HRESULT_FACILITY(hres) == FACILITY_JSCRIPT;
546 const char *debugstr_jsval(const jsval_t) DECLSPEC_HIDDEN;
548 HRESULT create_jscript_object(BOOL,REFIID,void**) DECLSPEC_HIDDEN;
550 extern LONG module_ref DECLSPEC_HIDDEN;
552 static inline void lock_module(void)
554 InterlockedIncrement(&module_ref);
557 static inline void unlock_module(void)
559 InterlockedDecrement(&module_ref);