storage.dll16: Fix get_nth_next_small_blocknr.
[wine.git] / dlls / jscript / jscript.h
blob756d7cf9549d6afa9adb701670d83ed3ca94e9c2
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 _dispex_prop_t dispex_prop_t;
41 typedef struct {
42 void **blocks;
43 DWORD block_cnt;
44 DWORD last_block;
45 DWORD offset;
46 BOOL mark;
47 struct list custom_blocks;
48 } heap_pool_t;
50 void heap_pool_init(heap_pool_t*) DECLSPEC_HIDDEN;
51 void *heap_pool_alloc(heap_pool_t*,DWORD) __WINE_ALLOC_SIZE(2) DECLSPEC_HIDDEN;
52 void *heap_pool_grow(heap_pool_t*,void*,DWORD,DWORD) DECLSPEC_HIDDEN;
53 void heap_pool_clear(heap_pool_t*) DECLSPEC_HIDDEN;
54 void heap_pool_free(heap_pool_t*) DECLSPEC_HIDDEN;
55 heap_pool_t *heap_pool_mark(heap_pool_t*) DECLSPEC_HIDDEN;
57 static inline void* __WINE_ALLOC_SIZE(1) heap_alloc(size_t size)
59 return HeapAlloc(GetProcessHeap(), 0, size);
62 static inline void* __WINE_ALLOC_SIZE(1) heap_alloc_zero(size_t size)
64 return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
67 static inline void* __WINE_ALLOC_SIZE(2) heap_realloc(void *mem, size_t size)
69 return HeapReAlloc(GetProcessHeap(), 0, mem, size);
72 static inline BOOL heap_free(void *mem)
74 return HeapFree(GetProcessHeap(), 0, mem);
77 static inline LPWSTR heap_strdupW(LPCWSTR str)
79 LPWSTR ret = NULL;
81 if(str) {
82 DWORD size;
84 size = (strlenW(str)+1)*sizeof(WCHAR);
85 ret = heap_alloc(size);
86 if(ret)
87 memcpy(ret, str, size);
90 return ret;
93 typedef struct jsdisp_t jsdisp_t;
95 extern HINSTANCE jscript_hinstance DECLSPEC_HIDDEN;
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 #define PROPF_DONTDELETE 0x1000
105 * This is our internal dispatch flag informing calee that it's called directly from interpreter.
106 * If calee is executed as interpreted function, we may let already running interpreter to take
107 * of execution.
109 #define DISPATCH_JSCRIPT_CALLEREXECSSOURCE 0x8000
110 #define DISPATCH_JSCRIPT_INTERNAL_MASK DISPATCH_JSCRIPT_CALLEREXECSSOURCE
112 /* NOTE: Keep in sync with names in Object.toString implementation */
113 typedef enum {
114 JSCLASS_NONE,
115 JSCLASS_ARRAY,
116 JSCLASS_BOOLEAN,
117 JSCLASS_DATE,
118 JSCLASS_ERROR,
119 JSCLASS_FUNCTION,
120 JSCLASS_GLOBAL,
121 JSCLASS_MATH,
122 JSCLASS_NUMBER,
123 JSCLASS_OBJECT,
124 JSCLASS_REGEXP,
125 JSCLASS_STRING,
126 JSCLASS_ARGUMENTS,
127 JSCLASS_VBARRAY,
128 JSCLASS_JSON
129 } jsclass_t;
131 jsdisp_t *iface_to_jsdisp(IDispatch*) DECLSPEC_HIDDEN;
133 typedef struct {
134 union {
135 IDispatch *disp;
136 IDispatchEx *dispex;
137 jsdisp_t *jsdisp;
138 } u;
139 DWORD flags;
140 } vdisp_t;
142 #define VDISP_DISPEX 0x0001
143 #define VDISP_JSDISP 0x0002
145 static inline void vdisp_release(vdisp_t *vdisp)
147 IDispatch_Release(vdisp->u.disp);
150 static inline BOOL is_jsdisp(vdisp_t *vdisp)
152 return (vdisp->flags & VDISP_JSDISP) != 0;
155 static inline BOOL is_dispex(vdisp_t *vdisp)
157 return (vdisp->flags & VDISP_DISPEX) != 0;
160 static inline void set_jsdisp(vdisp_t *vdisp, jsdisp_t *jsdisp)
162 vdisp->u.jsdisp = jsdisp;
163 vdisp->flags = VDISP_JSDISP | VDISP_DISPEX;
164 IDispatch_AddRef(vdisp->u.disp);
167 static inline void set_disp(vdisp_t *vdisp, IDispatch *disp)
169 IDispatchEx *dispex;
170 jsdisp_t *jsdisp;
171 HRESULT hres;
173 jsdisp = iface_to_jsdisp(disp);
174 if(jsdisp) {
175 vdisp->u.jsdisp = jsdisp;
176 vdisp->flags = VDISP_JSDISP | VDISP_DISPEX;
177 return;
180 hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
181 if(SUCCEEDED(hres)) {
182 vdisp->u.dispex = dispex;
183 vdisp->flags = VDISP_DISPEX;
184 return;
187 IDispatch_AddRef(disp);
188 vdisp->u.disp = disp;
189 vdisp->flags = 0;
192 static inline jsdisp_t *get_jsdisp(vdisp_t *vdisp)
194 return is_jsdisp(vdisp) ? vdisp->u.jsdisp : NULL;
197 typedef HRESULT (*builtin_invoke_t)(script_ctx_t*,vdisp_t*,WORD,unsigned,jsval_t*,jsval_t*);
198 typedef HRESULT (*builtin_getter_t)(script_ctx_t*,jsdisp_t*,jsval_t*);
199 typedef HRESULT (*builtin_setter_t)(script_ctx_t*,jsdisp_t*,jsval_t);
201 HRESULT builtin_set_const(script_ctx_t*,jsdisp_t*,jsval_t) DECLSPEC_HIDDEN;
203 typedef struct {
204 const WCHAR *name;
205 builtin_invoke_t invoke;
206 DWORD flags;
207 builtin_getter_t getter;
208 builtin_setter_t setter;
209 } builtin_prop_t;
211 typedef struct {
212 jsclass_t class;
213 builtin_prop_t value_prop;
214 DWORD props_cnt;
215 const builtin_prop_t *props;
216 void (*destructor)(jsdisp_t*);
217 void (*on_put)(jsdisp_t*,const WCHAR*);
218 unsigned (*idx_length)(jsdisp_t*);
219 HRESULT (*idx_get)(jsdisp_t*,unsigned,jsval_t*);
220 HRESULT (*idx_put)(jsdisp_t*,unsigned,jsval_t);
221 } builtin_info_t;
223 struct jsdisp_t {
224 IDispatchEx IDispatchEx_iface;
226 LONG ref;
228 DWORD buf_size;
229 DWORD prop_cnt;
230 dispex_prop_t *props;
231 script_ctx_t *ctx;
233 jsdisp_t *prototype;
235 const builtin_info_t *builtin_info;
238 static inline IDispatch *to_disp(jsdisp_t *jsdisp)
240 return (IDispatch*)&jsdisp->IDispatchEx_iface;
243 jsdisp_t *as_jsdisp(IDispatch*) DECLSPEC_HIDDEN;
244 jsdisp_t *to_jsdisp(IDispatch*) DECLSPEC_HIDDEN;
245 void jsdisp_free(jsdisp_t*) DECLSPEC_HIDDEN;
247 #ifndef TRACE_REFCNT
250 * We do a lot of refcount calls during script execution, so having an inline
251 * version is a nice perf win. Define TRACE_REFCNT macro when debugging
252 * refcount bugs to have traces. Also, since jsdisp_t is not thread safe anyways,
253 * there is no point in using atomic operations.
255 static inline jsdisp_t *jsdisp_addref(jsdisp_t *jsdisp)
257 jsdisp->ref++;
258 return jsdisp;
261 static inline void jsdisp_release(jsdisp_t *jsdisp)
263 if(!--jsdisp->ref)
264 jsdisp_free(jsdisp);
267 #else
269 jsdisp_t *jsdisp_addref(jsdisp_t*) DECLSPEC_HIDDEN;
270 void jsdisp_release(jsdisp_t*) DECLSPEC_HIDDEN;
272 #endif
274 HRESULT create_dispex(script_ctx_t*,const builtin_info_t*,jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN;
275 HRESULT init_dispex(jsdisp_t*,script_ctx_t*,const builtin_info_t*,jsdisp_t*) DECLSPEC_HIDDEN;
276 HRESULT init_dispex_from_constr(jsdisp_t*,script_ctx_t*,const builtin_info_t*,jsdisp_t*) DECLSPEC_HIDDEN;
278 HRESULT disp_call(script_ctx_t*,IDispatch*,DISPID,WORD,unsigned,jsval_t*,jsval_t*) DECLSPEC_HIDDEN;
279 HRESULT disp_call_value(script_ctx_t*,IDispatch*,IDispatch*,WORD,unsigned,jsval_t*,jsval_t*) DECLSPEC_HIDDEN;
280 HRESULT jsdisp_call_value(jsdisp_t*,IDispatch*,WORD,unsigned,jsval_t*,jsval_t*) DECLSPEC_HIDDEN;
281 HRESULT jsdisp_call(jsdisp_t*,DISPID,WORD,unsigned,jsval_t*,jsval_t*) DECLSPEC_HIDDEN;
282 HRESULT jsdisp_call_name(jsdisp_t*,const WCHAR*,WORD,unsigned,jsval_t*,jsval_t*) DECLSPEC_HIDDEN;
283 HRESULT disp_propget(script_ctx_t*,IDispatch*,DISPID,jsval_t*) DECLSPEC_HIDDEN;
284 HRESULT disp_propput(script_ctx_t*,IDispatch*,DISPID,jsval_t) DECLSPEC_HIDDEN;
285 HRESULT jsdisp_propget(jsdisp_t*,DISPID,jsval_t*) DECLSPEC_HIDDEN;
286 HRESULT jsdisp_propput(jsdisp_t*,const WCHAR*,DWORD,jsval_t) DECLSPEC_HIDDEN;
287 HRESULT jsdisp_propput_name(jsdisp_t*,const WCHAR*,jsval_t) DECLSPEC_HIDDEN;
288 HRESULT jsdisp_propput_const(jsdisp_t*,const WCHAR*,jsval_t) DECLSPEC_HIDDEN;
289 HRESULT jsdisp_propput_dontenum(jsdisp_t*,const WCHAR*,jsval_t) DECLSPEC_HIDDEN;
290 HRESULT jsdisp_propput_idx(jsdisp_t*,DWORD,jsval_t) DECLSPEC_HIDDEN;
291 HRESULT jsdisp_propget_name(jsdisp_t*,LPCWSTR,jsval_t*) DECLSPEC_HIDDEN;
292 HRESULT jsdisp_get_idx(jsdisp_t*,DWORD,jsval_t*) DECLSPEC_HIDDEN;
293 HRESULT jsdisp_get_id(jsdisp_t*,const WCHAR*,DWORD,DISPID*) DECLSPEC_HIDDEN;
294 HRESULT disp_delete(IDispatch*,DISPID,BOOL*) DECLSPEC_HIDDEN;
295 HRESULT disp_delete_name(script_ctx_t*,IDispatch*,jsstr_t*,BOOL*) DECLSPEC_HIDDEN;
296 HRESULT jsdisp_delete_idx(jsdisp_t*,DWORD) DECLSPEC_HIDDEN;
297 HRESULT jsdisp_is_own_prop(jsdisp_t*,const WCHAR*,BOOL*) DECLSPEC_HIDDEN;
298 HRESULT jsdisp_is_enumerable(jsdisp_t*,const WCHAR*,BOOL*) DECLSPEC_HIDDEN;
300 HRESULT create_builtin_function(script_ctx_t*,builtin_invoke_t,const WCHAR*,const builtin_info_t*,DWORD,
301 jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN;
302 HRESULT create_builtin_constructor(script_ctx_t*,builtin_invoke_t,const WCHAR*,const builtin_info_t*,DWORD,
303 jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN;
304 HRESULT Function_invoke(jsdisp_t*,IDispatch*,WORD,unsigned,jsval_t*,jsval_t*) DECLSPEC_HIDDEN;
306 HRESULT Function_value(script_ctx_t*,vdisp_t*,WORD,unsigned,jsval_t*,jsval_t*) DECLSPEC_HIDDEN;
307 HRESULT Function_get_value(script_ctx_t*,jsdisp_t*,jsval_t*) DECLSPEC_HIDDEN;
308 #define DEFAULT_FUNCTION_VALUE {NULL, Function_value,0, Function_get_value}
310 HRESULT throw_eval_error(script_ctx_t*,HRESULT,const WCHAR*) DECLSPEC_HIDDEN;
311 HRESULT throw_generic_error(script_ctx_t*,HRESULT,const WCHAR*) DECLSPEC_HIDDEN;
312 HRESULT throw_range_error(script_ctx_t*,HRESULT,const WCHAR*) DECLSPEC_HIDDEN;
313 HRESULT throw_reference_error(script_ctx_t*,HRESULT,const WCHAR*) DECLSPEC_HIDDEN;
314 HRESULT throw_regexp_error(script_ctx_t*,HRESULT,const WCHAR*) DECLSPEC_HIDDEN;
315 HRESULT throw_syntax_error(script_ctx_t*,HRESULT,const WCHAR*) DECLSPEC_HIDDEN;
316 HRESULT throw_type_error(script_ctx_t*,HRESULT,const WCHAR*) DECLSPEC_HIDDEN;
317 HRESULT throw_uri_error(script_ctx_t*,HRESULT,const WCHAR*) DECLSPEC_HIDDEN;
319 HRESULT create_object(script_ctx_t*,jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN;
320 HRESULT create_math(script_ctx_t*,jsdisp_t**) DECLSPEC_HIDDEN;
321 HRESULT create_array(script_ctx_t*,DWORD,jsdisp_t**) DECLSPEC_HIDDEN;
322 HRESULT create_regexp(script_ctx_t*,jsstr_t*,DWORD,jsdisp_t**) DECLSPEC_HIDDEN;
323 HRESULT create_regexp_var(script_ctx_t*,jsval_t,jsval_t*,jsdisp_t**) DECLSPEC_HIDDEN;
324 HRESULT create_string(script_ctx_t*,jsstr_t*,jsdisp_t**) DECLSPEC_HIDDEN;
325 HRESULT create_bool(script_ctx_t*,BOOL,jsdisp_t**) DECLSPEC_HIDDEN;
326 HRESULT create_number(script_ctx_t*,double,jsdisp_t**) DECLSPEC_HIDDEN;
327 HRESULT create_vbarray(script_ctx_t*,SAFEARRAY*,jsdisp_t**) DECLSPEC_HIDDEN;
328 HRESULT create_json(script_ctx_t*,jsdisp_t**) DECLSPEC_HIDDEN;
330 typedef enum {
331 NO_HINT,
332 HINT_STRING,
333 HINT_NUMBER
334 } hint_t;
336 HRESULT to_primitive(script_ctx_t*,jsval_t,jsval_t*, hint_t) DECLSPEC_HIDDEN;
337 HRESULT to_boolean(jsval_t,BOOL*) DECLSPEC_HIDDEN;
338 HRESULT to_number(script_ctx_t*,jsval_t,double*) DECLSPEC_HIDDEN;
339 HRESULT to_integer(script_ctx_t*,jsval_t,double*) DECLSPEC_HIDDEN;
340 HRESULT to_int32(script_ctx_t*,jsval_t,INT*) DECLSPEC_HIDDEN;
341 HRESULT to_uint32(script_ctx_t*,jsval_t,UINT32*) DECLSPEC_HIDDEN;
342 HRESULT to_string(script_ctx_t*,jsval_t,jsstr_t**) DECLSPEC_HIDDEN;
343 HRESULT to_flat_string(script_ctx_t*,jsval_t,jsstr_t**,const WCHAR**) DECLSPEC_HIDDEN;
344 HRESULT to_object(script_ctx_t*,jsval_t,IDispatch**) DECLSPEC_HIDDEN;
346 HRESULT variant_change_type(script_ctx_t*,VARIANT*,VARIANT*,VARTYPE) DECLSPEC_HIDDEN;
348 HRESULT decode_source(WCHAR*) DECLSPEC_HIDDEN;
350 HRESULT double_to_string(double,jsstr_t**) DECLSPEC_HIDDEN;
351 BOOL is_finite(double) DECLSPEC_HIDDEN;
353 typedef struct named_item_t {
354 IDispatch *disp;
355 DWORD flags;
356 LPWSTR name;
358 struct named_item_t *next;
359 } named_item_t;
361 typedef struct _cc_var_t cc_var_t;
363 typedef struct {
364 cc_var_t *vars;
365 } cc_ctx_t;
367 void release_cc(cc_ctx_t*) DECLSPEC_HIDDEN;
369 typedef struct {
370 IServiceProvider IServiceProvider_iface;
372 LONG ref;
374 script_ctx_t *ctx;
375 } JSCaller;
377 #include "jsval.h"
379 typedef struct {
380 EXCEPINFO ei;
381 jsval_t val;
382 } jsexcept_t;
384 typedef struct {
385 unsigned index;
386 unsigned length;
387 } match_result_t;
389 struct _script_ctx_t {
390 LONG ref;
392 SCRIPTSTATE state;
393 IActiveScript *active_script;
395 struct _call_frame_t *call_ctx;
396 named_item_t *named_items;
397 IActiveScriptSite *site;
398 IInternetHostSecurityManager *secmgr;
399 DWORD safeopt;
400 DWORD version;
401 LCID lcid;
402 cc_ctx_t *cc;
403 JSCaller *jscaller;
404 jsexcept_t ei;
406 heap_pool_t tmp_heap;
408 IDispatch *host_global;
410 jsval_t *stack;
411 unsigned stack_size;
412 unsigned stack_top;
414 jsstr_t *last_match;
415 match_result_t match_parens[9];
416 DWORD last_match_index;
417 DWORD last_match_length;
419 jsdisp_t *global;
420 jsdisp_t *function_constr;
421 jsdisp_t *array_constr;
422 jsdisp_t *bool_constr;
423 jsdisp_t *date_constr;
424 jsdisp_t *error_constr;
425 jsdisp_t *eval_error_constr;
426 jsdisp_t *range_error_constr;
427 jsdisp_t *reference_error_constr;
428 jsdisp_t *regexp_error_constr;
429 jsdisp_t *syntax_error_constr;
430 jsdisp_t *type_error_constr;
431 jsdisp_t *uri_error_constr;
432 jsdisp_t *number_constr;
433 jsdisp_t *object_constr;
434 jsdisp_t *regexp_constr;
435 jsdisp_t *string_constr;
436 jsdisp_t *vbarray_constr;
439 void script_release(script_ctx_t*) DECLSPEC_HIDDEN;
440 void clear_ei(script_ctx_t*) DECLSPEC_HIDDEN;
442 static inline void script_addref(script_ctx_t *ctx)
444 ctx->ref++;
447 HRESULT init_global(script_ctx_t*) DECLSPEC_HIDDEN;
448 HRESULT init_function_constr(script_ctx_t*,jsdisp_t*) DECLSPEC_HIDDEN;
449 HRESULT create_object_prototype(script_ctx_t*,jsdisp_t**) DECLSPEC_HIDDEN;
451 HRESULT create_activex_constr(script_ctx_t*,jsdisp_t**) DECLSPEC_HIDDEN;
452 HRESULT create_array_constr(script_ctx_t*,jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN;
453 HRESULT create_bool_constr(script_ctx_t*,jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN;
454 HRESULT create_date_constr(script_ctx_t*,jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN;
455 HRESULT init_error_constr(script_ctx_t*,jsdisp_t*) DECLSPEC_HIDDEN;
456 HRESULT create_number_constr(script_ctx_t*,jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN;
457 HRESULT create_object_constr(script_ctx_t*,jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN;
458 HRESULT create_regexp_constr(script_ctx_t*,jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN;
459 HRESULT create_string_constr(script_ctx_t*,jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN;
460 HRESULT create_vbarray_constr(script_ctx_t*,jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN;
462 IUnknown *create_ax_site(script_ctx_t*) DECLSPEC_HIDDEN;
463 HRESULT create_jscaller(script_ctx_t*) DECLSPEC_HIDDEN;
465 #define REM_CHECK_GLOBAL 0x0001
466 #define REM_RESET_INDEX 0x0002
467 #define REM_NO_CTX_UPDATE 0x0004
468 #define REM_ALLOC_RESULT 0x0008
469 #define REM_NO_PARENS 0x0010
470 struct match_state_t;
471 HRESULT regexp_match_next(script_ctx_t*,jsdisp_t*,DWORD,jsstr_t*,struct match_state_t**) DECLSPEC_HIDDEN;
472 HRESULT parse_regexp_flags(const WCHAR*,DWORD,DWORD*) DECLSPEC_HIDDEN;
473 HRESULT regexp_string_match(script_ctx_t*,jsdisp_t*,jsstr_t*,jsval_t*) DECLSPEC_HIDDEN;
475 BOOL bool_obj_value(jsdisp_t*) DECLSPEC_HIDDEN;
476 unsigned array_get_length(jsdisp_t*) DECLSPEC_HIDDEN;
478 HRESULT JSGlobal_eval(script_ctx_t*,vdisp_t*,WORD,unsigned,jsval_t*,jsval_t*) DECLSPEC_HIDDEN;
480 static inline BOOL is_class(jsdisp_t *jsdisp, jsclass_t class)
482 return jsdisp->builtin_info->class == class;
485 static inline BOOL is_vclass(vdisp_t *vdisp, jsclass_t class)
487 return is_jsdisp(vdisp) && is_class(vdisp->u.jsdisp, class);
490 #ifndef INT32_MIN
491 #define INT32_MIN (-2147483647-1)
492 #endif
494 #ifndef INT32_MAX
495 #define INT32_MAX (2147483647)
496 #endif
498 static inline BOOL is_int32(double d)
500 return INT32_MIN <= d && d <= INT32_MAX && (double)(int)d == d;
503 static inline DWORD make_grfdex(script_ctx_t *ctx, DWORD flags)
505 return (ctx->version << 28) | flags;
508 #define FACILITY_JSCRIPT 10
510 #define MAKE_JSERROR(code) MAKE_HRESULT(SEVERITY_ERROR, FACILITY_JSCRIPT, code)
512 #define JS_E_TO_PRIMITIVE MAKE_JSERROR(IDS_TO_PRIMITIVE)
513 #define JS_E_INVALIDARG MAKE_JSERROR(IDS_INVALID_CALL_ARG)
514 #define JS_E_SUBSCRIPT_OUT_OF_RANGE MAKE_JSERROR(IDS_SUBSCRIPT_OUT_OF_RANGE)
515 #define JS_E_OBJECT_REQUIRED MAKE_JSERROR(IDS_OBJECT_REQUIRED)
516 #define JS_E_CANNOT_CREATE_OBJ MAKE_JSERROR(IDS_CREATE_OBJ_ERROR)
517 #define JS_E_INVALID_PROPERTY MAKE_JSERROR(IDS_NO_PROPERTY)
518 #define JS_E_INVALID_ACTION MAKE_JSERROR(IDS_UNSUPPORTED_ACTION)
519 #define JS_E_MISSING_ARG MAKE_JSERROR(IDS_ARG_NOT_OPT)
520 #define JS_E_SYNTAX MAKE_JSERROR(IDS_SYNTAX_ERROR)
521 #define JS_E_MISSING_SEMICOLON MAKE_JSERROR(IDS_SEMICOLON)
522 #define JS_E_MISSING_LBRACKET MAKE_JSERROR(IDS_LBRACKET)
523 #define JS_E_MISSING_RBRACKET MAKE_JSERROR(IDS_RBRACKET)
524 #define JS_E_EXPECTED_IDENTIFIER MAKE_JSERROR(IDS_EXPECTED_IDENTIFIER)
525 #define JS_E_EXPECTED_ASSIGN MAKE_JSERROR(IDS_EXPECTED_ASSIGN)
526 #define JS_E_INVALID_CHAR MAKE_JSERROR(IDS_INVALID_CHAR)
527 #define JS_E_UNTERMINATED_STRING MAKE_JSERROR(IDS_UNTERMINATED_STR)
528 #define JS_E_MISPLACED_RETURN MAKE_JSERROR(IDS_MISPLACED_RETURN)
529 #define JS_E_INVALID_BREAK MAKE_JSERROR(IDS_INVALID_BREAK)
530 #define JS_E_INVALID_CONTINUE MAKE_JSERROR(IDS_INVALID_CONTINUE)
531 #define JS_E_LABEL_REDEFINED MAKE_JSERROR(IDS_LABEL_REDEFINED)
532 #define JS_E_LABEL_NOT_FOUND MAKE_JSERROR(IDS_LABEL_NOT_FOUND)
533 #define JS_E_EXPECTED_CCEND MAKE_JSERROR(IDS_EXPECTED_CCEND)
534 #define JS_E_DISABLED_CC MAKE_JSERROR(IDS_DISABLED_CC)
535 #define JS_E_EXPECTED_AT MAKE_JSERROR(IDS_EXPECTED_AT)
536 #define JS_E_FUNCTION_EXPECTED MAKE_JSERROR(IDS_NOT_FUNC)
537 #define JS_E_DATE_EXPECTED MAKE_JSERROR(IDS_NOT_DATE)
538 #define JS_E_NUMBER_EXPECTED MAKE_JSERROR(IDS_NOT_NUM)
539 #define JS_E_OBJECT_EXPECTED MAKE_JSERROR(IDS_OBJECT_EXPECTED)
540 #define JS_E_ILLEGAL_ASSIGN MAKE_JSERROR(IDS_ILLEGAL_ASSIGN)
541 #define JS_E_UNDEFINED_VARIABLE MAKE_JSERROR(IDS_UNDEFINED)
542 #define JS_E_BOOLEAN_EXPECTED MAKE_JSERROR(IDS_NOT_BOOL)
543 #define JS_E_VBARRAY_EXPECTED MAKE_JSERROR(IDS_NOT_VBARRAY)
544 #define JS_E_INVALID_DELETE MAKE_JSERROR(IDS_INVALID_DELETE)
545 #define JS_E_JSCRIPT_EXPECTED MAKE_JSERROR(IDS_JSCRIPT_EXPECTED)
546 #define JS_E_REGEXP_SYNTAX MAKE_JSERROR(IDS_REGEXP_SYNTAX_ERROR)
547 #define JS_E_INVALID_URI_CODING MAKE_JSERROR(IDS_URI_INVALID_CODING)
548 #define JS_E_INVALID_URI_CHAR MAKE_JSERROR(IDS_URI_INVALID_CHAR)
549 #define JS_E_FRACTION_DIGITS_OUT_OF_RANGE MAKE_JSERROR(IDS_FRACTION_DIGITS_OUT_OF_RANGE)
550 #define JS_E_PRECISION_OUT_OF_RANGE MAKE_JSERROR(IDS_PRECISION_OUT_OF_RANGE)
551 #define JS_E_INVALID_LENGTH MAKE_JSERROR(IDS_INVALID_LENGTH)
552 #define JS_E_ARRAY_EXPECTED MAKE_JSERROR(IDS_ARRAY_EXPECTED)
554 static inline BOOL is_jscript_error(HRESULT hres)
556 return HRESULT_FACILITY(hres) == FACILITY_JSCRIPT;
559 const char *debugstr_jsval(const jsval_t) DECLSPEC_HIDDEN;
561 HRESULT create_jscript_object(BOOL,REFIID,void**) DECLSPEC_HIDDEN;
563 extern LONG module_ref DECLSPEC_HIDDEN;
565 static inline void lock_module(void)
567 InterlockedIncrement(&module_ref);
570 static inline void unlock_module(void)
572 InterlockedDecrement(&module_ref);