[WIN32DLLS]
[reactos.git] / reactos / dll / win32 / 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 #ifndef _WINE_JSCRIPT_H
20 #define _WINE_JSCRIPT_H
21
22 #include <wine/config.h>
23 #include <wine/port.h>
24
25 #include <assert.h>
26 #include <stdarg.h>
27
28 #define WIN32_NO_STATUS
29 #define _INC_WINDOWS
30 #define COM_NO_WINDOWS_H
31
32 #define COBJMACROS
33
34 #include <windef.h>
35 #include <winbase.h>
36 #include <objbase.h>
37 #include <oleauto.h>
38 #include <dispex.h>
39 #include <activscp.h>
40 #include <objsafe.h>
41
42 #include <wine/debug.h>
43 #include <wine/list.h>
44 #include <wine/unicode.h>
45
46 WINE_DEFAULT_DEBUG_CHANNEL(jscript);
47
48 #include "resource.h"
49
50 typedef struct _jsval_t jsval_t;
51 typedef struct _jsstr_t jsstr_t;
52 typedef struct _script_ctx_t script_ctx_t;
53 typedef struct _exec_ctx_t exec_ctx_t;
54 typedef struct _dispex_prop_t dispex_prop_t;
55
56 typedef struct {
57 void **blocks;
58 DWORD block_cnt;
59 DWORD last_block;
60 DWORD offset;
61 BOOL mark;
62 struct list custom_blocks;
63 } heap_pool_t;
64
65 void heap_pool_init(heap_pool_t*) DECLSPEC_HIDDEN;
66 void *heap_pool_alloc(heap_pool_t*,DWORD) __WINE_ALLOC_SIZE(2) DECLSPEC_HIDDEN;
67 void *heap_pool_grow(heap_pool_t*,void*,DWORD,DWORD) DECLSPEC_HIDDEN;
68 void heap_pool_clear(heap_pool_t*) DECLSPEC_HIDDEN;
69 void heap_pool_free(heap_pool_t*) DECLSPEC_HIDDEN;
70 heap_pool_t *heap_pool_mark(heap_pool_t*) DECLSPEC_HIDDEN;
71
72 static inline void *heap_alloc(size_t len)
73 {
74 return HeapAlloc(GetProcessHeap(), 0, len);
75 }
76
77 static inline void *heap_alloc_zero(size_t len)
78 {
79 return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
80 }
81
82 static inline void *heap_realloc(void *mem, size_t len)
83 {
84 return HeapReAlloc(GetProcessHeap(), 0, mem, len);
85 }
86
87 static inline BOOL heap_free(void *mem)
88 {
89 return HeapFree(GetProcessHeap(), 0, mem);
90 }
91
92 static inline LPWSTR heap_strdupW(LPCWSTR str)
93 {
94 LPWSTR ret = NULL;
95
96 if(str) {
97 DWORD size;
98
99 size = (strlenW(str)+1)*sizeof(WCHAR);
100 ret = heap_alloc(size);
101 if(ret)
102 memcpy(ret, str, size);
103 }
104
105 return ret;
106 }
107
108 typedef struct jsdisp_t jsdisp_t;
109
110 extern HINSTANCE jscript_hinstance DECLSPEC_HIDDEN;
111
112 #define PROPF_ARGMASK 0x00ff
113 #define PROPF_METHOD 0x0100
114 #define PROPF_ENUM 0x0200
115 #define PROPF_CONSTR 0x0400
116 #define PROPF_CONST 0x0800
117 #define PROPF_DONTDELETE 0x1000
118
119 /* NOTE: Keep in sync with names in Object.toString implementation */
120 typedef enum {
121 JSCLASS_NONE,
122 JSCLASS_ARRAY,
123 JSCLASS_BOOLEAN,
124 JSCLASS_DATE,
125 JSCLASS_ERROR,
126 JSCLASS_FUNCTION,
127 JSCLASS_GLOBAL,
128 JSCLASS_MATH,
129 JSCLASS_NUMBER,
130 JSCLASS_OBJECT,
131 JSCLASS_REGEXP,
132 JSCLASS_STRING,
133 JSCLASS_ARGUMENTS,
134 JSCLASS_VBARRAY
135 } jsclass_t;
136
137 jsdisp_t *iface_to_jsdisp(IUnknown*) DECLSPEC_HIDDEN;
138
139 typedef struct {
140 union {
141 IDispatch *disp;
142 IDispatchEx *dispex;
143 jsdisp_t *jsdisp;
144 } u;
145 DWORD flags;
146 } vdisp_t;
147
148 #define VDISP_DISPEX 0x0001
149 #define VDISP_JSDISP 0x0002
150
151 static inline void vdisp_release(vdisp_t *vdisp)
152 {
153 IDispatch_Release(vdisp->u.disp);
154 }
155
156 static inline BOOL is_jsdisp(vdisp_t *vdisp)
157 {
158 return (vdisp->flags & VDISP_JSDISP) != 0;
159 }
160
161 static inline BOOL is_dispex(vdisp_t *vdisp)
162 {
163 return (vdisp->flags & VDISP_DISPEX) != 0;
164 }
165
166 static inline void set_jsdisp(vdisp_t *vdisp, jsdisp_t *jsdisp)
167 {
168 vdisp->u.jsdisp = jsdisp;
169 vdisp->flags = VDISP_JSDISP | VDISP_DISPEX;
170 IDispatch_AddRef(vdisp->u.disp);
171 }
172
173 static inline void set_disp(vdisp_t *vdisp, IDispatch *disp)
174 {
175 IDispatchEx *dispex;
176 jsdisp_t *jsdisp;
177 HRESULT hres;
178
179 jsdisp = iface_to_jsdisp((IUnknown*)disp);
180 if(jsdisp) {
181 vdisp->u.jsdisp = jsdisp;
182 vdisp->flags = VDISP_JSDISP | VDISP_DISPEX;
183 return;
184 }
185
186 hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
187 if(SUCCEEDED(hres)) {
188 vdisp->u.dispex = dispex;
189 vdisp->flags = VDISP_DISPEX;
190 return;
191 }
192
193 IDispatch_AddRef(disp);
194 vdisp->u.disp = disp;
195 vdisp->flags = 0;
196 }
197
198 static inline jsdisp_t *get_jsdisp(vdisp_t *vdisp)
199 {
200 return is_jsdisp(vdisp) ? vdisp->u.jsdisp : NULL;
201 }
202
203 typedef HRESULT (*builtin_invoke_t)(script_ctx_t*,vdisp_t*,WORD,unsigned,jsval_t*,jsval_t*);
204
205 typedef struct {
206 const WCHAR *name;
207 builtin_invoke_t invoke;
208 DWORD flags;
209 } builtin_prop_t;
210
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;
222
223 struct jsdisp_t {
224 IDispatchEx IDispatchEx_iface;
225
226 LONG ref;
227
228 DWORD buf_size;
229 DWORD prop_cnt;
230 dispex_prop_t *props;
231 script_ctx_t *ctx;
232
233 jsdisp_t *prototype;
234
235 const builtin_info_t *builtin_info;
236 };
237
238 static inline IDispatch *to_disp(jsdisp_t *jsdisp)
239 {
240 return (IDispatch*)&jsdisp->IDispatchEx_iface;
241 }
242
243 jsdisp_t *as_jsdisp(IDispatch*) DECLSPEC_HIDDEN;
244 jsdisp_t *to_jsdisp(IDispatch*) DECLSPEC_HIDDEN;
245 void jsdisp_free(jsdisp_t*) DECLSPEC_HIDDEN;
246
247 #ifndef TRACE_REFCNT
248
249 /*
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.
254 */
255 static inline jsdisp_t *jsdisp_addref(jsdisp_t *jsdisp)
256 {
257 jsdisp->ref++;
258 return jsdisp;
259 }
260
261 static inline void jsdisp_release(jsdisp_t *jsdisp)
262 {
263 if(!--jsdisp->ref)
264 jsdisp_free(jsdisp);
265 }
266
267 #else
268
269 jsdisp_t *jsdisp_addref(jsdisp_t*) DECLSPEC_HIDDEN;
270 void jsdisp_release(jsdisp_t*) DECLSPEC_HIDDEN;
271
272 #endif
273
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;
277
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*);
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;
299
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_value(script_ctx_t*,vdisp_t*,WORD,unsigned,jsval_t*,jsval_t*) DECLSPEC_HIDDEN;
305 HRESULT Function_invoke(jsdisp_t*,IDispatch*,WORD,unsigned,jsval_t*,jsval_t*) DECLSPEC_HIDDEN;
306
307 HRESULT throw_eval_error(script_ctx_t*,HRESULT,const WCHAR*) DECLSPEC_HIDDEN;
308 HRESULT throw_generic_error(script_ctx_t*,HRESULT,const WCHAR*) DECLSPEC_HIDDEN;
309 HRESULT throw_range_error(script_ctx_t*,HRESULT,const WCHAR*) DECLSPEC_HIDDEN;
310 HRESULT throw_reference_error(script_ctx_t*,HRESULT,const WCHAR*) DECLSPEC_HIDDEN;
311 HRESULT throw_regexp_error(script_ctx_t*,HRESULT,const WCHAR*) DECLSPEC_HIDDEN;
312 HRESULT throw_syntax_error(script_ctx_t*,HRESULT,const WCHAR*) DECLSPEC_HIDDEN;
313 HRESULT throw_type_error(script_ctx_t*,HRESULT,const WCHAR*) DECLSPEC_HIDDEN;
314 HRESULT throw_uri_error(script_ctx_t*,HRESULT,const WCHAR*) DECLSPEC_HIDDEN;
315
316 HRESULT create_object(script_ctx_t*,jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN;
317 HRESULT create_math(script_ctx_t*,jsdisp_t**) DECLSPEC_HIDDEN;
318 HRESULT create_array(script_ctx_t*,DWORD,jsdisp_t**) DECLSPEC_HIDDEN;
319 HRESULT create_regexp(script_ctx_t*,jsstr_t*,DWORD,jsdisp_t**) DECLSPEC_HIDDEN;
320 HRESULT create_regexp_var(script_ctx_t*,jsval_t,jsval_t*,jsdisp_t**) DECLSPEC_HIDDEN;
321 HRESULT create_string(script_ctx_t*,jsstr_t*,jsdisp_t**) DECLSPEC_HIDDEN;
322 HRESULT create_bool(script_ctx_t*,BOOL,jsdisp_t**) DECLSPEC_HIDDEN;
323 HRESULT create_number(script_ctx_t*,double,jsdisp_t**) DECLSPEC_HIDDEN;
324 HRESULT create_vbarray(script_ctx_t*,SAFEARRAY*,jsdisp_t**) DECLSPEC_HIDDEN;
325
326 typedef enum {
327 NO_HINT,
328 HINT_STRING,
329 HINT_NUMBER
330 } hint_t;
331
332 HRESULT to_primitive(script_ctx_t*,jsval_t,jsval_t*, hint_t) DECLSPEC_HIDDEN;
333 HRESULT to_boolean(jsval_t,BOOL*) DECLSPEC_HIDDEN;
334 HRESULT to_number(script_ctx_t*,jsval_t,double*) DECLSPEC_HIDDEN;
335 HRESULT to_integer(script_ctx_t*,jsval_t,double*) DECLSPEC_HIDDEN;
336 HRESULT to_int32(script_ctx_t*,jsval_t,INT*) DECLSPEC_HIDDEN;
337 HRESULT to_uint32(script_ctx_t*,jsval_t,UINT32*) DECLSPEC_HIDDEN;
338 HRESULT to_string(script_ctx_t*,jsval_t,jsstr_t**) DECLSPEC_HIDDEN;
339 HRESULT to_flat_string(script_ctx_t*,jsval_t,jsstr_t**,const WCHAR**) DECLSPEC_HIDDEN;
340 HRESULT to_object(script_ctx_t*,jsval_t,IDispatch**) DECLSPEC_HIDDEN;
341
342 HRESULT variant_change_type(script_ctx_t*,VARIANT*,VARIANT*,VARTYPE) DECLSPEC_HIDDEN;
343
344 HRESULT decode_source(WCHAR*) DECLSPEC_HIDDEN;
345
346 HRESULT double_to_string(double,jsstr_t**) DECLSPEC_HIDDEN;
347
348 typedef struct named_item_t {
349 IDispatch *disp;
350 DWORD flags;
351 LPWSTR name;
352
353 struct named_item_t *next;
354 } named_item_t;
355
356 typedef struct _cc_var_t cc_var_t;
357
358 typedef struct {
359 cc_var_t *vars;
360 } cc_ctx_t;
361
362 void release_cc(cc_ctx_t*) DECLSPEC_HIDDEN;
363
364 typedef struct {
365 IServiceProvider IServiceProvider_iface;
366
367 LONG ref;
368
369 script_ctx_t *ctx;
370 } JSCaller;
371
372 #include "jsval.h"
373
374 typedef struct {
375 EXCEPINFO ei;
376 jsval_t val;
377 } jsexcept_t;
378
379 typedef struct {
380 unsigned index;
381 unsigned length;
382 } match_result_t;
383
384 struct _script_ctx_t {
385 LONG ref;
386
387 SCRIPTSTATE state;
388 IActiveScript *active_script;
389
390 exec_ctx_t *exec_ctx;
391 named_item_t *named_items;
392 IActiveScriptSite *site;
393 IInternetHostSecurityManager *secmgr;
394 DWORD safeopt;
395 DWORD version;
396 LCID lcid;
397 cc_ctx_t *cc;
398 JSCaller *jscaller;
399 jsexcept_t ei;
400
401 heap_pool_t tmp_heap;
402
403 IDispatch *host_global;
404
405 jsstr_t *last_match;
406 match_result_t match_parens[9];
407 DWORD last_match_index;
408 DWORD last_match_length;
409
410 jsdisp_t *global;
411 jsdisp_t *function_constr;
412 jsdisp_t *activex_constr;
413 jsdisp_t *array_constr;
414 jsdisp_t *bool_constr;
415 jsdisp_t *date_constr;
416 jsdisp_t *error_constr;
417 jsdisp_t *eval_error_constr;
418 jsdisp_t *range_error_constr;
419 jsdisp_t *reference_error_constr;
420 jsdisp_t *regexp_error_constr;
421 jsdisp_t *syntax_error_constr;
422 jsdisp_t *type_error_constr;
423 jsdisp_t *uri_error_constr;
424 jsdisp_t *number_constr;
425 jsdisp_t *object_constr;
426 jsdisp_t *regexp_constr;
427 jsdisp_t *string_constr;
428 jsdisp_t *vbarray_constr;
429 };
430
431 void script_release(script_ctx_t*) DECLSPEC_HIDDEN;
432 void clear_ei(script_ctx_t*) DECLSPEC_HIDDEN;
433
434 static inline void script_addref(script_ctx_t *ctx)
435 {
436 ctx->ref++;
437 }
438
439 HRESULT init_global(script_ctx_t*) DECLSPEC_HIDDEN;
440 HRESULT init_function_constr(script_ctx_t*,jsdisp_t*) DECLSPEC_HIDDEN;
441 HRESULT create_object_prototype(script_ctx_t*,jsdisp_t**) DECLSPEC_HIDDEN;
442
443 HRESULT create_activex_constr(script_ctx_t*,jsdisp_t**) DECLSPEC_HIDDEN;
444 HRESULT create_array_constr(script_ctx_t*,jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN;
445 HRESULT create_bool_constr(script_ctx_t*,jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN;
446 HRESULT create_date_constr(script_ctx_t*,jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN;
447 HRESULT init_error_constr(script_ctx_t*,jsdisp_t*) DECLSPEC_HIDDEN;
448 HRESULT create_number_constr(script_ctx_t*,jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN;
449 HRESULT create_object_constr(script_ctx_t*,jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN;
450 HRESULT create_regexp_constr(script_ctx_t*,jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN;
451 HRESULT create_string_constr(script_ctx_t*,jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN;
452 HRESULT create_vbarray_constr(script_ctx_t*,jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN;
453
454 IUnknown *create_ax_site(script_ctx_t*) DECLSPEC_HIDDEN;
455 HRESULT create_jscaller(script_ctx_t*) DECLSPEC_HIDDEN;
456
457 #define REM_CHECK_GLOBAL 0x0001
458 #define REM_RESET_INDEX 0x0002
459 #define REM_NO_CTX_UPDATE 0x0004
460 #define REM_ALLOC_RESULT 0x0008
461 #define REM_NO_PARENS 0x0010
462 struct match_state_t;
463 HRESULT regexp_match_next(script_ctx_t*,jsdisp_t*,DWORD,jsstr_t*,struct match_state_t**) DECLSPEC_HIDDEN;
464 HRESULT parse_regexp_flags(const WCHAR*,DWORD,DWORD*) DECLSPEC_HIDDEN;
465 HRESULT regexp_string_match(script_ctx_t*,jsdisp_t*,jsstr_t*,jsval_t*) DECLSPEC_HIDDEN;
466
467 static inline BOOL is_class(jsdisp_t *jsdisp, jsclass_t class)
468 {
469 return jsdisp->builtin_info->class == class;
470 }
471
472 static inline BOOL is_vclass(vdisp_t *vdisp, jsclass_t class)
473 {
474 return is_jsdisp(vdisp) && is_class(vdisp->u.jsdisp, class);
475 }
476
477 #ifndef INT32_MIN
478 #define INT32_MIN (-2147483647-1)
479 #endif
480
481 #ifndef INT32_MAX
482 #define INT32_MAX (2147483647)
483 #endif
484
485 static inline BOOL is_int32(double d)
486 {
487 return INT32_MIN <= d && d <= INT32_MAX && (double)(int)d == d;
488 }
489
490 static inline DWORD make_grfdex(script_ctx_t *ctx, DWORD flags)
491 {
492 return (ctx->version << 28) | flags;
493 }
494
495 #define FACILITY_JSCRIPT 10
496
497 #define MAKE_JSERROR(code) MAKE_HRESULT(SEVERITY_ERROR, FACILITY_JSCRIPT, code)
498
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_INVALID_CHAR MAKE_JSERROR(IDS_INVALID_CHAR)
512 #define JS_E_UNTERMINATED_STRING MAKE_JSERROR(IDS_UNTERMINATED_STR)
513 #define JS_E_MISPLACED_RETURN MAKE_JSERROR(IDS_MISPLACED_RETURN)
514 #define JS_E_INVALID_BREAK MAKE_JSERROR(IDS_INVALID_BREAK)
515 #define JS_E_INVALID_CONTINUE MAKE_JSERROR(IDS_INVALID_CONTINUE)
516 #define JS_E_LABEL_REDEFINED MAKE_JSERROR(IDS_LABEL_REDEFINED)
517 #define JS_E_LABEL_NOT_FOUND MAKE_JSERROR(IDS_LABEL_NOT_FOUND)
518 #define JS_E_DISABLED_CC MAKE_JSERROR(IDS_DISABLED_CC)
519 #define JS_E_FUNCTION_EXPECTED MAKE_JSERROR(IDS_NOT_FUNC)
520 #define JS_E_DATE_EXPECTED MAKE_JSERROR(IDS_NOT_DATE)
521 #define JS_E_NUMBER_EXPECTED MAKE_JSERROR(IDS_NOT_NUM)
522 #define JS_E_OBJECT_EXPECTED MAKE_JSERROR(IDS_OBJECT_EXPECTED)
523 #define JS_E_ILLEGAL_ASSIGN MAKE_JSERROR(IDS_ILLEGAL_ASSIGN)
524 #define JS_E_UNDEFINED_VARIABLE MAKE_JSERROR(IDS_UNDEFINED)
525 #define JS_E_BOOLEAN_EXPECTED MAKE_JSERROR(IDS_NOT_BOOL)
526 #define JS_E_VBARRAY_EXPECTED MAKE_JSERROR(IDS_NOT_VBARRAY)
527 #define JS_E_INVALID_DELETE MAKE_JSERROR(IDS_INVALID_DELETE)
528 #define JS_E_JSCRIPT_EXPECTED MAKE_JSERROR(IDS_JSCRIPT_EXPECTED)
529 #define JS_E_REGEXP_SYNTAX MAKE_JSERROR(IDS_REGEXP_SYNTAX_ERROR)
530 #define JS_E_INVALID_URI_CODING MAKE_JSERROR(IDS_URI_INVALID_CODING)
531 #define JS_E_INVALID_URI_CHAR MAKE_JSERROR(IDS_URI_INVALID_CHAR)
532 #define JS_E_FRACTION_DIGITS_OUT_OF_RANGE MAKE_JSERROR(IDS_FRACTION_DIGITS_OUT_OF_RANGE)
533 #define JS_E_PRECISION_OUT_OF_RANGE MAKE_JSERROR(IDS_PRECISION_OUT_OF_RANGE)
534 #define JS_E_INVALID_LENGTH MAKE_JSERROR(IDS_INVALID_LENGTH)
535 #define JS_E_ARRAY_EXPECTED MAKE_JSERROR(IDS_ARRAY_EXPECTED)
536
537 static inline BOOL is_jscript_error(HRESULT hres)
538 {
539 return HRESULT_FACILITY(hres) == FACILITY_JSCRIPT;
540 }
541
542 const char *debugstr_variant(const VARIANT*) DECLSPEC_HIDDEN;
543 const char *debugstr_jsval(const jsval_t) DECLSPEC_HIDDEN;
544
545 HRESULT create_jscript_object(BOOL,REFIID,void**) DECLSPEC_HIDDEN;
546
547 extern LONG module_ref DECLSPEC_HIDDEN;
548
549 static inline void lock_module(void)
550 {
551 InterlockedIncrement(&module_ref);
552 }
553
554 static inline void unlock_module(void)
555 {
556 InterlockedDecrement(&module_ref);
557 }
558
559 #include "engine.h"
560 #include "regexp.h"
561
562 #endif /* _WINE_JSCRIPT_H */