ReactOS 0.4.17-dev-357-ga8f14ff
global.c File Reference
#include <math.h>
#include <limits.h>
#include "jscript.h"
#include "engine.h"
#include "wine/debug.h"
Include dependency graph for global.c:

Go to the source code of this file.

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (jscript)
 
static BOOL is_uri_reserved (WCHAR c)
 
static BOOL is_uri_unescaped (WCHAR c)
 
static BOOL is_ecma_nonblank (const WCHAR c)
 
static WCHAR int_to_char (int i)
 
static HRESULT JSGlobal_escape (script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
HRESULT builtin_eval (script_ctx_t *ctx, call_frame_t *frame, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
HRESULT JSGlobal_eval (script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT JSGlobal_isNaN (script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT JSGlobal_isFinite (script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static INT char_to_int (WCHAR c)
 
static HRESULT JSGlobal_parseInt (script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT JSGlobal_parseFloat (script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static int hex_to_int (const WCHAR wch)
 
static HRESULT JSGlobal_unescape (script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT JSGlobal_GetObject (script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT JSGlobal_ScriptEngine (script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT JSGlobal_ScriptEngineMajorVersion (script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT JSGlobal_ScriptEngineMinorVersion (script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT JSGlobal_ScriptEngineBuildVersion (script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT JSGlobal_CollectGarbage (script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT JSGlobal_encodeURI (script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT JSGlobal_decodeURI (script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT JSGlobal_encodeURIComponent (script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT JSGlobal_decodeURIComponent (script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT init_object_prototype_accessors (script_ctx_t *ctx, jsdisp_t *object_prototype)
 
static HRESULT init_constructors (script_ctx_t *ctx, jsdisp_t *object_prototype)
 
HRESULT init_global (script_ctx_t *ctx)
 

Variables

static int uri_char_table []
 
static const builtin_prop_t JSGlobal_props []
 
static const builtin_info_t JSGlobal_info
 

Function Documentation

◆ builtin_eval()

HRESULT builtin_eval ( script_ctx_t ctx,
call_frame_t frame,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)

Definition at line 137 of file global.c.

139{
140 DWORD exec_flags = EXEC_EVAL;
142 const WCHAR *src;
144
145 TRACE("\n");
146
147 if(!argc) {
148 if(r)
149 *r = jsval_undefined();
150 return S_OK;
151 }
152
153 if(!is_string(argv[0])) {
154 if(r)
155 return jsval_copy(argv[0], r);
156 return S_OK;
157 }
158
160 if(!src)
161 return E_OUTOFMEMORY;
162
163 TRACE("parsing %s\n", debugstr_jsval(argv[0]));
164 hres = compile_script(ctx, src, 0, 0, NULL, NULL, TRUE, FALSE, frame ? frame->bytecode->named_item : NULL, &code);
165 if(FAILED(hres)) {
166 WARN("parse (%s) failed: %08lx\n", debugstr_jsval(argv[0]), hres);
167 return hres;
168 }
169
170 if(!frame || (frame->flags & EXEC_GLOBAL))
171 exec_flags |= EXEC_GLOBAL;
173 exec_flags |= EXEC_RETURN_TO_INTERP;
174 hres = exec_source(ctx, exec_flags, code, &code->global_code, frame ? frame->scope : NULL,
175 frame ? frame->this_obj : NULL, NULL, 0, NULL, r);
177 return hres;
178}
#define WARN(fmt,...)
Definition: precomp.h:61
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
MonoAssembly int argc
Definition: metahost.c:107
HRESULT exec_source(script_ctx_t *ctx, DWORD flags, bytecode_t *bytecode, function_code_t *function, scope_chain_t *scope, IDispatch *this_obj, jsdisp_t *function_instance, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: engine.c:3425
#define EXEC_GLOBAL
Definition: engine.h:305
#define EXEC_RETURN_TO_INTERP
Definition: engine.h:307
#define EXEC_EVAL
Definition: engine.h:308
unsigned long DWORD
Definition: ntddk_ex.h:95
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLenum src
Definition: glext.h:6340
GLbitfield flags
Definition: glext.h:7161
#define S_OK
Definition: intsafe.h:52
#define FAILED(hr)
Definition: intsafe.h:51
void release_bytecode(bytecode_t *code)
Definition: compile.c:2459
HRESULT compile_script(script_ctx_t *ctx, const WCHAR *code, UINT64 source_context, unsigned start_line, const WCHAR *args, const WCHAR *delimiter, BOOL from_eval, BOOL use_decode, named_item_t *named_item, bytecode_t **ret)
Definition: compile.c:2725
#define DISPATCH_JSCRIPT_CALLEREXECSSOURCE
Definition: jscript.h:98
const char * debugstr_jsval(const jsval_t)
Definition: jsutils.c:35
static const WCHAR * jsstr_flatten(jsstr_t *str)
Definition: jsstr.h:136
HRESULT jsval_copy(jsval_t v, jsval_t *r)
Definition: jsutils.c:225
static jsval_t jsval_undefined(void)
Definition: jsval.h:146
static jsstr_t * get_string(jsval_t v)
Definition: jsval.h:238
HRESULT hres
Definition: protocol.c:465
#define argv
Definition: mplay32.c:18
static BOOL is_string(parse_buffer *buf)
Definition: parsing.c:600
short WCHAR
Definition: pedump.c:58
#define TRACE(s)
Definition: solgame.cpp:4
named_item_t * named_item
Definition: engine.h:199
IDispatch * this_obj
Definition: engine.h:287
bytecode_t * bytecode
Definition: engine.h:299
DWORD flags
Definition: engine.h:291
scope_chain_t * scope
Definition: engine.h:282
Definition: inflate.c:139

Referenced by interp_call_eval(), and JSGlobal_eval().

◆ char_to_int()

static INT char_to_int ( WCHAR  c)
static

Definition at line 232 of file global.c.

233{
234 if('0' <= c && c <= '9')
235 return c - '0';
236 if('a' <= c && c <= 'z')
237 return c - 'a' + 10;
238 if('A' <= c && c <= 'Z')
239 return c - 'A' + 10;
240 return 100;
241}
const GLubyte * c
Definition: glext.h:8905

Referenced by JSGlobal_parseInt().

◆ hex_to_int()

static int hex_to_int ( const WCHAR  wch)
inlinestatic

Definition at line 434 of file global.c.

434 {
435#endif /* __REACTOS__ */
436 if(towupper(wch)>='A' && towupper(wch)<='F') return towupper(wch)-'A'+10;
437 if(is_digit(wch)) return wch-'0';
438 return -1;
439}
#define is_digit(c)
Definition: astoll.c:39
#define towupper(c)
Definition: wctype.h:99

Referenced by JSGlobal_decodeURI(), JSGlobal_decodeURIComponent(), JSGlobal_unescape(), and unescape_json_string().

◆ init_constructors()

static HRESULT init_constructors ( script_ctx_t ctx,
jsdisp_t object_prototype 
)
static

Definition at line 950 of file global.c.

951{
953
954 hres = init_function_constr(ctx, object_prototype);
955 if(FAILED(hres))
956 return hres;
957
959 jsval_obj(ctx->function_constr));
960 if(FAILED(hres))
961 return hres;
962
963 hres = create_object_constr(ctx, object_prototype, &ctx->object_constr);
964 if(FAILED(hres))
965 return hres;
966
968 jsval_obj(ctx->object_constr));
969 if(FAILED(hres))
970 return hres;
971
972 hres = create_array_constr(ctx, object_prototype, &ctx->array_constr);
973 if(FAILED(hres))
974 return hres;
975
977 jsval_obj(ctx->array_constr));
978 if(FAILED(hres))
979 return hres;
980
981 hres = create_bool_constr(ctx, object_prototype, &ctx->bool_constr);
982 if(FAILED(hres))
983 return hres;
984
986 jsval_obj(ctx->bool_constr));
987 if(FAILED(hres))
988 return hres;
989
990 hres = create_date_constr(ctx, object_prototype, &ctx->date_constr);
991 if(FAILED(hres))
992 return hres;
993
995 jsval_obj(ctx->date_constr));
996 if(FAILED(hres))
997 return hres;
998
999 hres = create_enumerator_constr(ctx, object_prototype, &ctx->enumerator_constr);
1000 if(FAILED(hres))
1001 return hres;
1002
1004 jsval_obj(ctx->enumerator_constr));
1005 if(FAILED(hres))
1006 return hres;
1007
1008 hres = init_error_constr(ctx, object_prototype);
1009 if(FAILED(hres))
1010 return hres;
1011
1013 jsval_obj(ctx->error_constr));
1014 if(FAILED(hres))
1015 return hres;
1016
1018 jsval_obj(ctx->eval_error_constr));
1019 if(FAILED(hres))
1020 return hres;
1021
1023 jsval_obj(ctx->range_error_constr));
1024 if(FAILED(hres))
1025 return hres;
1026
1028 jsval_obj(ctx->reference_error_constr));
1029 if(FAILED(hres))
1030 return hres;
1031
1033 jsval_obj(ctx->regexp_error_constr));
1034 if(FAILED(hres))
1035 return hres;
1036
1038 jsval_obj(ctx->syntax_error_constr));
1039 if(FAILED(hres))
1040 return hres;
1041
1043 jsval_obj(ctx->type_error_constr));
1044 if(FAILED(hres))
1045 return hres;
1046
1048 jsval_obj(ctx->uri_error_constr));
1049 if(FAILED(hres))
1050 return hres;
1051
1052 hres = create_number_constr(ctx, object_prototype, &ctx->number_constr);
1053 if(FAILED(hres))
1054 return hres;
1055
1057 jsval_obj(ctx->number_constr));
1058 if(FAILED(hres))
1059 return hres;
1060
1061 hres = create_regexp_constr(ctx, object_prototype, &ctx->regexp_constr);
1062 if(FAILED(hres))
1063 return hres;
1064
1066 jsval_obj(ctx->regexp_constr));
1067 if(FAILED(hres))
1068 return hres;
1069
1070 hres = create_string_constr(ctx, object_prototype, &ctx->string_constr);
1071 if(FAILED(hres))
1072 return hres;
1073
1075 jsval_obj(ctx->string_constr));
1076 if(FAILED(hres))
1077 return hres;
1078
1079 hres = create_vbarray_constr(ctx, object_prototype, &ctx->vbarray_constr);
1080 if(FAILED(hres))
1081 return hres;
1082
1084 jsval_obj(ctx->vbarray_constr));
1085 if(FAILED(hres))
1086 return hres;
1087
1088 return S_OK;
1089}
HRESULT create_array_constr(script_ctx_t *ctx, jsdisp_t *object_prototype, jsdisp_t **ret)
Definition: array.c:1765
HRESULT create_bool_constr(script_ctx_t *ctx, jsdisp_t *object_prototype, jsdisp_t **ret)
Definition: bool.c:196
HRESULT create_date_constr(script_ctx_t *ctx, jsdisp_t *object_prototype, jsdisp_t **ret)
Definition: date.c:2442
HRESULT init_error_constr(script_ctx_t *ctx, jsdisp_t *object_prototype)
Definition: error.c:321
HRESULT init_function_constr(script_ctx_t *ctx, jsdisp_t *object_prototype)
Definition: function.c:1476
#define L(x)
Definition: resources.c:13
HRESULT create_enumerator_constr(script_ctx_t *ctx, jsdisp_t *object_prototype, jsdisp_t **ret)
Definition: enumerator.c:320
HRESULT jsdisp_define_data_property(jsdisp_t *obj, const WCHAR *name, unsigned flags, jsval_t value)
Definition: dispex.c:3349
HRESULT create_string_constr(script_ctx_t *, jsdisp_t *, jsdisp_t **)
Definition: string.c:1720
HRESULT create_vbarray_constr(script_ctx_t *, jsdisp_t *, jsdisp_t **)
Definition: vbarray.c:321
HRESULT create_number_constr(script_ctx_t *, jsdisp_t *, jsdisp_t **)
Definition: number.c:682
HRESULT create_object_constr(script_ctx_t *, jsdisp_t *, jsdisp_t **)
Definition: object.c:1120
HRESULT create_regexp_constr(script_ctx_t *, jsdisp_t *, jsdisp_t **)
Definition: jsregexp.c:964
const unsigned int PROPF_WRITABLE
Definition: jsdisp.idl:37
const unsigned int PROPF_CONFIGURABLE
Definition: jsdisp.idl:38
static jsval_t jsval_obj(jsdisp_t *obj)
Definition: jsval.h:125

Referenced by init_global().

◆ init_global()

HRESULT init_global ( script_ctx_t ctx)

Definition at line 1091 of file global.c.

1092{
1093 unsigned const_flags = ctx->version >= SCRIPTLANGUAGEVERSION_ES5 ? 0 : PROPF_WRITABLE;
1094 jsdisp_t *math, *constr;
1095 HRESULT hres;
1096
1097 if(ctx->global)
1098 return S_OK;
1099
1100 hres = create_dispex(ctx, &JSGlobal_info, NULL, &ctx->global);
1101 if(FAILED(hres))
1102 return hres;
1103
1104 hres = create_object_prototype(ctx, &ctx->object_prototype);
1105 if(FAILED(hres))
1106 return hres;
1107
1108 hres = init_constructors(ctx, ctx->object_prototype);
1109 if(FAILED(hres))
1110 return hres;
1111
1112 hres = init_object_prototype_accessors(ctx, ctx->object_prototype);
1113 if(FAILED(hres))
1114 return hres;
1115
1116 hres = create_math(ctx, &math);
1117 if(FAILED(hres))
1118 return hres;
1119
1121 jsdisp_release(math);
1122 if(FAILED(hres))
1123 return hres;
1124
1125 if(ctx->version >= 2) {
1126 jsdisp_t *json;
1127
1128 hres = create_json(ctx, &json);
1129 if(FAILED(hres))
1130 return hres;
1131
1133 jsdisp_release(json);
1134 if(FAILED(hres))
1135 return hres;
1136 }
1137
1138 hres = create_activex_constr(ctx, &constr);
1139 if(FAILED(hres))
1140 return hres;
1141
1143 jsval_obj(constr));
1144 jsdisp_release(constr);
1145 if(FAILED(hres))
1146 return hres;
1147
1148 hres = jsdisp_define_data_property(ctx->global, L"undefined", const_flags, jsval_undefined());
1149 if(FAILED(hres))
1150 return hres;
1151
1152 hres = jsdisp_define_data_property(ctx->global, L"NaN", const_flags, jsval_number(NAN));
1153 if(FAILED(hres))
1154 return hres;
1155
1156 hres = jsdisp_define_data_property(ctx->global, L"Infinity", const_flags, jsval_number(INFINITY));
1157 if(FAILED(hres))
1158 return hres;
1159
1161 if(FAILED(hres))
1162 return hres;
1163
1164 return init_set_constructor(ctx);
1165}
HRESULT init_arraybuf_constructors(script_ctx_t *ctx)
Definition: arraybuf.c:692
HRESULT create_activex_constr(script_ctx_t *ctx, jsdisp_t **ret)
Definition: activex.c:189
#define NAN
Definition: math.h:273
#define INFINITY
Definition: math.h:272
ULONG jsdisp_release(jsdisp_t *obj)
Definition: dispex.c:1911
HRESULT create_dispex(script_ctx_t *ctx, const builtin_info_t *builtin_info, jsdisp_t *prototype, jsdisp_t **dispex)
Definition: dispex.c:2493
static const builtin_info_t JSGlobal_info
Definition: global.c:919
static HRESULT init_constructors(script_ctx_t *ctx, jsdisp_t *object_prototype)
Definition: global.c:950
static HRESULT init_object_prototype_accessors(script_ctx_t *ctx, jsdisp_t *object_prototype)
Definition: global.c:925
HRESULT create_math(script_ctx_t *, jsdisp_t **)
Definition: math.c:503
HRESULT create_object_prototype(script_ctx_t *, jsdisp_t **)
Definition: object.c:1126
#define SCRIPTLANGUAGEVERSION_ES5
Definition: jscript.h:53
HRESULT init_set_constructor(script_ctx_t *)
Definition: set.c:894
HRESULT create_json(script_ctx_t *, jsdisp_t **)
Definition: json.c:1032
static jsval_t jsval_number(double n)
Definition: jsval.h:153

Referenced by JScript_SetScriptSite(), and VBScriptFactory_CreateInstance().

◆ init_object_prototype_accessors()

static HRESULT init_object_prototype_accessors ( script_ctx_t ctx,
jsdisp_t object_prototype 
)
static

Definition at line 925 of file global.c.

926{
928 HRESULT hres = S_OK;
929
930 /* __proto__ is an actual accessor on native, despite being a builtin */
931 if(ctx->version >= SCRIPTLANGUAGEVERSION_ES6) {
932 desc.flags = PROPF_CONFIGURABLE;
934 desc.explicit_getter = desc.explicit_setter = TRUE;
935 desc.explicit_value = FALSE;
936
938 if(SUCCEEDED(hres)) {
940 if(SUCCEEDED(hres)) {
941 hres = jsdisp_define_property(object_prototype, L"__proto__", &desc);
942 jsdisp_release(desc.setter);
943 }
944 jsdisp_release(desc.getter);
945 }
946 }
947 return hres;
948}
HRESULT create_builtin_function(script_ctx_t *ctx, builtin_invoke_t value_proc, const WCHAR *name, const builtin_info_t *builtin_info, DWORD flags, jsdisp_t *prototype, jsdisp_t **ret)
Definition: function.c:773
#define SUCCEEDED(hr)
Definition: intsafe.h:50
HRESULT jsdisp_define_property(jsdisp_t *obj, const WCHAR *name, property_desc_t *desc)
Definition: dispex.c:3216
HRESULT Object_get_proto_(script_ctx_t *, jsval_t, WORD, unsigned, jsval_t *, jsval_t *)
Definition: object.c:393
#define SCRIPTLANGUAGEVERSION_ES6
Definition: jscript.h:54
HRESULT Object_set_proto_(script_ctx_t *, jsval_t, WORD, unsigned, jsval_t *, jsval_t *)
Definition: object.c:422
const unsigned int PROPF_ENUMERABLE
Definition: jsdisp.idl:36
const unsigned int PROPF_METHOD
Definition: jsdisp.idl:33
D3D11_SHADER_VARIABLE_DESC desc
Definition: reflection.c:1204

Referenced by init_global().

◆ int_to_char()

static WCHAR int_to_char ( int  i)
static

Definition at line 65 of file global.c.

66{
67 if(i < 10)
68 return '0'+i;
69 return 'A'+i-10;
70}
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248

Referenced by JSGlobal_encodeURI(), JSGlobal_encodeURIComponent(), and JSGlobal_escape().

◆ is_ecma_nonblank()

static BOOL is_ecma_nonblank ( const WCHAR  c)
inlinestatic

Definition at line 59 of file global.c.

60{
61 return ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') ||
62 c == '@' || c == '*' || c == '_' || c == '+' || c == '-' || c == '.' || c == '/');
63}

Referenced by JSGlobal_escape().

◆ is_uri_reserved()

static BOOL is_uri_reserved ( WCHAR  c)
inlinestatic

Definition at line 48 of file global.c.

49{
50 return c < 128 && uri_char_table[c] == 1;
51}
static int uri_char_table[]
Definition: global.c:34
#define c
Definition: ke_i.h:80

Referenced by JSGlobal_encodeURI().

◆ is_uri_unescaped()

static BOOL is_uri_unescaped ( WCHAR  c)
inlinestatic

Definition at line 53 of file global.c.

54{
55 return c < 128 && uri_char_table[c] == 2;
56}

Referenced by JSGlobal_encodeURI(), and JSGlobal_encodeURIComponent().

◆ JSGlobal_CollectGarbage()

static HRESULT JSGlobal_CollectGarbage ( script_ctx_t ctx,
jsval_t  vthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 566 of file global.c.

568{
569 return gc_run(ctx);
570}
HRESULT gc_run(script_ctx_t *ctx)
Definition: dispex.c:928

◆ JSGlobal_decodeURI()

static HRESULT JSGlobal_decodeURI ( script_ctx_t ctx,
jsval_t  vthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 637 of file global.c.

639{
640 const WCHAR *ptr, *uri;
641 jsstr_t *str, *ret_str;
642 unsigned len = 0;
643 int i, val, res;
644 WCHAR *ret;
645 char buf[4];
646 WCHAR out;
648
649 TRACE("\n");
650
651 if(!argc) {
652 if(r)
654 return S_OK;
655 }
656
657 hres = to_flat_string(ctx, argv[0], &str, &uri);
658 if(FAILED(hres))
659 return hres;
660
661 for(ptr = uri; *ptr; ptr++) {
662 if(*ptr != '%') {
663 len++;
664 }else {
665 res = 0;
666 for(i=0; i<4; i++) {
667 if(ptr[i*3]!='%' || hex_to_int(ptr[i*3+1])==-1 || (val=hex_to_int(ptr[i*3+2]))==-1)
668 break;
669 val += hex_to_int(ptr[i*3+1])<<4;
670 buf[i] = val;
671
673 if(res)
674 break;
675 }
676
677 if(!res) {
680 }
681
682 ptr += i*3+2;
683 len++;
684 }
685 }
686
687 ret_str = jsstr_alloc_buf(len, &ret);
688 if(!ret_str) {
690 return E_OUTOFMEMORY;
691 }
692
693 for(ptr = uri; *ptr; ptr++) {
694 if(*ptr != '%') {
695 *ret++ = *ptr;
696 }else {
697 for(i=0; i<4; i++) {
698 if(ptr[i*3]!='%' || hex_to_int(ptr[i*3+1])==-1 || (val=hex_to_int(ptr[i*3+2]))==-1)
699 break;
700 val += hex_to_int(ptr[i*3+1])<<4;
701 buf[i] = val;
702
704 if(res)
705 break;
706 }
707
708 ptr += i*3+2;
709 ret++;
710 }
711 }
712
713 TRACE("%s -> %s\n", debugstr_jsstr(str), debugstr_jsstr(ret_str));
715
716 if(r)
717 *r = jsval_string(ret_str);
718 else
719 jsstr_release(ret_str);
720 return S_OK;
721}
#define MultiByteToWideChar
Definition: compat.h:110
return ret
Definition: mutex.c:146
GLuint res
Definition: glext.h:9613
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLuint GLfloat * val
Definition: glext.h:7180
GLenum GLsizei len
Definition: glext.h:6722
#define MB_ERR_INVALID_CHARS
Definition: unicode.h:41
static int hex_to_int(const WCHAR wch)
Definition: global.c:434
HRESULT to_flat_string(script_ctx_t *, jsval_t, jsstr_t **, const WCHAR **)
Definition: jsutils.c:846
#define JS_E_INVALID_URI_CODING
Definition: jscript.h:567
jsstr_t * jsstr_undefined(void)
Definition: jsstr.c:296
const char * debugstr_jsstr(jsstr_t *str)
Definition: jsstr.c:37
jsstr_t * jsstr_alloc_buf(unsigned len, WCHAR **buf)
Definition: jsstr.c:69
static void jsstr_release(jsstr_t *str)
Definition: jsstr.h:107
static jsval_t jsval_string(jsstr_t *str)
Definition: jsval.h:109
static PVOID ptr
Definition: dispmode.c:27
const char * uri
Definition: sec_mgr.c:1588
const WCHAR * str
#define CP_UTF8
Definition: nls.h:20
Definition: jsstr.h:36
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
Definition: wcsftime.cpp:383

◆ JSGlobal_decodeURIComponent()

static HRESULT JSGlobal_decodeURIComponent ( script_ctx_t ctx,
jsval_t  vthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 787 of file global.c.

789{
790 const WCHAR *ptr, *uri;
791 jsstr_t *str, *ret;
792 WCHAR *out_ptr;
793 DWORD len = 0;
795
796 TRACE("\n");
797
798 if(!argc) {
799 if(r)
801 return S_OK;
802 }
803
804 hres = to_flat_string(ctx, argv[0], &str, &uri);
805 if(FAILED(hres))
806 return hres;
807
808 ptr = uri;
809 while(*ptr) {
810 if(*ptr == '%') {
811 char octets[4];
812 unsigned char mask = 0x80;
813 int i, size, num_bytes = 0;
814 if(hex_to_int(*(ptr+1)) < 0 || hex_to_int(*(ptr+2)) < 0) {
815 FIXME("Throw URIError: Invalid hex sequence\n");
817 return E_FAIL;
818 }
819 octets[0] = (hex_to_int(*(ptr+1)) << 4) + hex_to_int(*(ptr+2));
820 ptr += 3;
821 while(octets[0] & mask) {
822 mask = mask >> 1;
823 ++num_bytes;
824 }
825 if(num_bytes == 1 || num_bytes > 4) {
826 FIXME("Throw URIError: Invalid initial UTF character\n");
828 return E_FAIL;
829 }
830 for(i = 1; i < num_bytes; ++i) {
831 if(*ptr != '%'){
832 FIXME("Throw URIError: Incomplete UTF sequence\n");
834 return E_FAIL;
835 }
836 if(hex_to_int(*(ptr+1)) < 0 || hex_to_int(*(ptr+2)) < 0) {
837 FIXME("Throw URIError: Invalid hex sequence\n");
839 return E_FAIL;
840 }
841 octets[i] = (hex_to_int(*(ptr+1)) << 4) + hex_to_int(*(ptr+2));
842 ptr += 3;
843 }
845 num_bytes ? num_bytes : 1, NULL, 0);
846 if(size == 0) {
847 FIXME("Throw URIError: Invalid UTF sequence\n");
849 return E_FAIL;
850 }
851 len += size;
852 }else {
853 ++ptr;
854 ++len;
855 }
856 }
857
858 ret = jsstr_alloc_buf(len, &out_ptr);
859 if(!ret) {
861 return E_OUTOFMEMORY;
862 }
863
864 ptr = uri;
865 while(*ptr) {
866 if(*ptr == '%') {
867 char octets[4];
868 unsigned char mask = 0x80;
869 int i, size, num_bytes = 0;
870 octets[0] = (hex_to_int(*(ptr+1)) << 4) + hex_to_int(*(ptr+2));
871 ptr += 3;
872 while(octets[0] & mask) {
873 mask = mask >> 1;
874 ++num_bytes;
875 }
876 for(i = 1; i < num_bytes; ++i) {
877 octets[i] = (hex_to_int(*(ptr+1)) << 4) + hex_to_int(*(ptr+2));
878 ptr += 3;
879 }
881 num_bytes ? num_bytes : 1, out_ptr, len);
882 len -= size;
883 out_ptr += size;
884 }else {
885 *out_ptr++ = *ptr++;
886 --len;
887 }
888 }
889
891
892 if(r)
893 *r = jsval_string(ret);
894 else
896 return S_OK;
897}
#define FIXME(fmt,...)
Definition: precomp.h:53
#define E_FAIL
Definition: ddrawi.h:102
GLsizeiptr size
Definition: glext.h:5919
GLenum GLint GLuint mask
Definition: glext.h:6028

◆ JSGlobal_encodeURI()

static HRESULT JSGlobal_encodeURI ( script_ctx_t ctx,
jsval_t  vthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 572 of file global.c.

574{
575 const WCHAR *ptr, *uri;
576 jsstr_t *str, *ret;
577 DWORD len = 0, i;
578 char buf[4];
579 WCHAR *rptr;
581
582 TRACE("\n");
583
584 if(!argc) {
585 if(r)
587 return S_OK;
588 }
589
590 hres = to_flat_string(ctx, argv[0], &str, &uri);
591 if(FAILED(hres))
592 return hres;
593
594 for(ptr = uri; *ptr; ptr++) {
595 if(is_uri_unescaped(*ptr) || is_uri_reserved(*ptr) || *ptr == '#') {
596 len++;
597 }else {
599 if(!i) {
602 }
603
604 len += i;
605 }
606 }
607
608 ret = jsstr_alloc_buf(len, &rptr);
609 if(!ret) {
611 return E_OUTOFMEMORY;
612 }
613
614 for(ptr = uri; *ptr; ptr++) {
615 if(is_uri_unescaped(*ptr) || is_uri_reserved(*ptr) || *ptr == '#') {
616 *rptr++ = *ptr;
617 }else {
619 for(i=0; i<len; i++) {
620 *rptr++ = '%';
621 *rptr++ = int_to_char((BYTE)buf[i] >> 4);
622 *rptr++ = int_to_char(buf[i] & 0x0f);
623 }
624 }
625 }
626
627 TRACE("%s -> %s\n", debugstr_jsstr(str), debugstr_jsstr(ret));
629
630 if(r)
631 *r = jsval_string(ret);
632 else
634 return S_OK;
635}
#define WideCharToMultiByte
Definition: compat.h:111
#define WC_ERR_INVALID_CHARS
Definition: unicode.h:47
static WCHAR int_to_char(int i)
Definition: global.c:65
static BOOL is_uri_reserved(WCHAR c)
Definition: global.c:48
static BOOL is_uri_unescaped(WCHAR c)
Definition: global.c:53
#define JS_E_INVALID_URI_CHAR
Definition: jscript.h:568
unsigned char BYTE
Definition: xxhash.c:193

◆ JSGlobal_encodeURIComponent()

static HRESULT JSGlobal_encodeURIComponent ( script_ctx_t ctx,
jsval_t  vthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 723 of file global.c.

725{
726 jsstr_t *str, *ret_str;
727 char buf[4];
728 const WCHAR *ptr, *uri;
729 DWORD len = 0, size, i;
730 WCHAR *ret;
732
733 TRACE("\n");
734
735 if(!argc) {
736 if(r)
738 return S_OK;
739 }
740
741 hres = to_flat_string(ctx, argv[0], &str, &uri);
742 if(FAILED(hres))
743 return hres;
744
745 for(ptr = uri; *ptr; ptr++) {
747 len++;
748 else {
750 if(!size) {
753 }
754 len += size*3;
755 }
756 }
757
758 ret_str = jsstr_alloc_buf(len, &ret);
759 if(!ret_str) {
761 return E_OUTOFMEMORY;
762 }
763
764 for(ptr = uri; *ptr; ptr++) {
765 if(is_uri_unescaped(*ptr)) {
766 *ret++ = *ptr;
767 }else {
769 for(i=0; i<size; i++) {
770 *ret++ = '%';
771 *ret++ = int_to_char((BYTE)buf[i] >> 4);
772 *ret++ = int_to_char(buf[i] & 0x0f);
773 }
774 }
775 }
776
778
779 if(r)
780 *r = jsval_string(ret_str);
781 else
782 jsstr_release(ret_str);
783 return S_OK;
784}

◆ JSGlobal_escape()

static HRESULT JSGlobal_escape ( script_ctx_t ctx,
jsval_t  vthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 72 of file global.c.

74{
75 jsstr_t *ret_str, *str;
76 const WCHAR *ptr, *buf;
77 DWORD len = 0;
78 WCHAR *ret;
80
81 TRACE("\n");
82
83 if(!argc) {
84 if(r)
86 return S_OK;
87 }
88
89 hres = to_flat_string(ctx, argv[0], &str, &buf);
90 if(FAILED(hres))
91 return hres;
92
93 for(ptr = buf; *ptr; ptr++) {
94 if(*ptr > 0xff)
95 len += 6;
96 else if(is_ecma_nonblank(*ptr))
97 len++;
98 else
99 len += 3;
100 }
101
102 ret_str = jsstr_alloc_buf(len, &ret);
103 if(!ret_str) {
105 return E_OUTOFMEMORY;
106 }
107
108 len = 0;
109 for(ptr = buf; *ptr; ptr++) {
110 if(*ptr > 0xff) {
111 ret[len++] = '%';
112 ret[len++] = 'u';
113 ret[len++] = int_to_char(*ptr >> 12);
114 ret[len++] = int_to_char((*ptr >> 8) & 0xf);
115 ret[len++] = int_to_char((*ptr >> 4) & 0xf);
116 ret[len++] = int_to_char(*ptr & 0xf);
117 }
118 else if(is_ecma_nonblank(*ptr))
119 ret[len++] = *ptr;
120 else {
121 ret[len++] = '%';
122 ret[len++] = int_to_char(*ptr >> 4);
123 ret[len++] = int_to_char(*ptr & 0xf);
124 }
125 }
126
128
129 if(r)
130 *r = jsval_string(ret_str);
131 else
132 jsstr_release(ret_str);
133 return S_OK;
134}
static BOOL is_ecma_nonblank(const WCHAR c)
Definition: global.c:59

◆ JSGlobal_eval()

HRESULT JSGlobal_eval ( script_ctx_t ctx,
jsval_t  vthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)

Definition at line 180 of file global.c.

182{
183 return builtin_eval(ctx, ctx->version < SCRIPTLANGUAGEVERSION_ES5 ? ctx->call_ctx : NULL, flags, argc, argv, r);
184}
HRESULT builtin_eval(script_ctx_t *ctx, call_frame_t *frame, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: global.c:137

Referenced by is_builtin_eval_func().

◆ JSGlobal_GetObject()

static HRESULT JSGlobal_GetObject ( script_ctx_t ctx,
jsval_t  vthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 511 of file global.c.

513{
514 FIXME("\n");
515 return E_NOTIMPL;
516}
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ JSGlobal_isFinite()

static HRESULT JSGlobal_isFinite ( script_ctx_t ctx,
jsval_t  vthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 209 of file global.c.

211{
212 BOOL ret = FALSE;
214
215 TRACE("\n");
216
217 if(argc) {
218 double n;
219
220 hres = to_number(ctx, argv[0], &n);
221 if(FAILED(hres))
222 return hres;
223
224 ret = isfinite(n);
225 }
226
227 if(r)
228 *r = jsval_bool(ret);
229 return S_OK;
230}
#define isfinite(x)
Definition: math.h:363
unsigned int BOOL
Definition: ntddk_ex.h:94
GLdouble n
Definition: glext.h:7729
HRESULT to_number(script_ctx_t *, jsval_t, double *)
Definition: jsutils.c:630
static jsval_t jsval_bool(BOOL b)
Definition: jsval.h:101

◆ JSGlobal_isNaN()

static HRESULT JSGlobal_isNaN ( script_ctx_t ctx,
jsval_t  vthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 186 of file global.c.

188{
189 BOOL ret = TRUE;
190 double n;
192
193 TRACE("\n");
194
195 if(argc) {
196 hres = to_number(ctx, argv[0], &n);
197 if(FAILED(hres))
198 return hres;
199
200 if(!isnan(n))
201 ret = FALSE;
202 }
203
204 if(r)
205 *r = jsval_bool(ret);
206 return S_OK;
207}
#define isnan(x)
Definition: math.h:360

◆ JSGlobal_parseFloat()

static HRESULT JSGlobal_parseFloat ( script_ctx_t ctx,
jsval_t  vthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 326 of file global.c.

328{
329 LONGLONG d = 0, hlp;
330 jsstr_t *val_str;
331 int exp = 0;
332 const WCHAR *str;
335
336 if(!argc) {
337 if(r)
338 *r = jsval_number(NAN);
339 return S_OK;
340 }
341
342 TRACE("%s\n", debugstr_jsval(argv[0]));
343
344 hres = to_flat_string(ctx, argv[0], &val_str, &str);
345 if(FAILED(hres))
346 return hres;
347
348 while(iswspace(*str)) str++;
349
350 if(*str == '+')
351 str++;
352 else if(*str == '-') {
353 positive = FALSE;
354 str++;
355 }
356
357 if(is_digit(*str))
358 ret_nan = FALSE;
359
360 while(is_digit(*str)) {
361 hlp = d*10 + *(str++) - '0';
362 if(d>MAXLONGLONG/10 || hlp<0) {
363 exp++;
364 break;
365 }
366 else
367 d = hlp;
368 }
369 while(is_digit(*str)) {
370 exp++;
371 str++;
372 }
373
374 if(*str == '.') str++;
375
376 if(is_digit(*str))
377 ret_nan = FALSE;
378
379 while(is_digit(*str)) {
380 hlp = d*10 + *(str++) - '0';
381 if(d>MAXLONGLONG/10 || hlp<0)
382 break;
383
384 d = hlp;
385 exp--;
386 }
387 while(is_digit(*str))
388 str++;
389
390 if(*str && !ret_nan && (*str=='e' || *str=='E')) {
391 int sign = 1, e = 0;
392
393 str++;
394 if(*str == '+')
395 str++;
396 else if(*str == '-') {
397 sign = -1;
398 str++;
399 }
400
401 while(is_digit(*str)) {
402 if(e>INT_MAX/10 || (e = e*10 + *str++ - '0')<0)
403 e = INT_MAX;
404 }
405 e *= sign;
406
407 if(exp<0 && e<0 && exp+e>0) exp = INT_MIN;
408 else if(exp>0 && e>0 && exp+e<0) exp = INT_MAX;
409 else exp += e;
410 }
411
412 jsstr_release(val_str);
413
414 if(ret_nan) {
415 if(r)
416 *r = jsval_number(NAN);
417 return S_OK;
418 }
419
420 if(!positive)
421 d = -d;
422 if(r)
423 *r = jsval_number(exp>0 ? d*pow(10, exp) : d/pow(10, -exp));
424 return S_OK;
425}
#define INT_MIN
Definition: limits.h:25
#define INT_MAX
Definition: limits.h:26
static double ret_nan(BOOL update_sw)
Definition: math.c:84
double pow(double x, double y)
Definition: freeldr.c:179
#define d
Definition: ke_i.h:81
#define e
Definition: ke_i.h:82
#define sign(x)
Definition: mapdesc.cc:613
DWORD exp
Definition: msg.c:18625
#define MAXLONGLONG
#define iswspace(_c)
Definition: ctype.h:669
Definition: unary.h:15
int64_t LONGLONG
Definition: typedefs.h:68

◆ JSGlobal_parseInt()

static HRESULT JSGlobal_parseInt ( script_ctx_t ctx,
jsval_t  vthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 243 of file global.c.

245{
246 BOOL neg = FALSE, empty = TRUE;
247 const WCHAR *ptr;
248 DOUBLE ret = 0.0;
249 INT radix=0, i;
250 jsstr_t *str;
252
253 if(!argc) {
254 if(r)
255 *r = jsval_number(NAN);
256 return S_OK;
257 }
258
259 if(argc >= 2) {
260 hres = to_int32(ctx, argv[1], &radix);
261 if(FAILED(hres))
262 return hres;
263
264 if(radix && (radix < 2 || radix > 36)) {
265 WARN("radix %d out of range\n", radix);
266 if(r)
267 *r = jsval_number(NAN);
268 return S_OK;
269 }
270 }
271
272 hres = to_flat_string(ctx, argv[0], &str, &ptr);
273 if(FAILED(hres))
274 return hres;
275
276 while(iswspace(*ptr))
277 ptr++;
278
279 switch(*ptr) {
280 case '+':
281 ptr++;
282 break;
283 case '-':
284 neg = TRUE;
285 ptr++;
286 break;
287 }
288
289 if(!radix) {
290 if(*ptr == '0') {
291 if(ptr[1] == 'x' || ptr[1] == 'X') {
292 radix = 16;
293 ptr += 2;
294 }else {
295 radix = 8;
296 ptr++;
297 empty = FALSE;
298 }
299 }else {
300 radix = 10;
301 }
302 }else if(radix == 16 && *ptr == '0' && (ptr[1] == 'x' || ptr[1] == 'X')) {
303 ptr += 2;
304 }
305
306 i = char_to_int(*ptr++);
307 if(i < radix) {
308 do {
309 ret = ret*radix + i;
310 i = char_to_int(*ptr++);
311 }while(i < radix);
312 }else if(empty) {
313 ret = NAN;
314 }
315
317
318 if(neg)
319 ret = -ret;
320
321 if(r)
322 *r = jsval_number(ret);
323 return S_OK;
324}
static const WCHAR empty[1]
Definition: string.c:47
static INT char_to_int(WCHAR c)
Definition: global.c:232
HRESULT to_int32(script_ctx_t *, jsval_t, INT *)
Definition: jsutils.c:735
int32_t INT
Definition: typedefs.h:58
double DOUBLE
Definition: typedefs.h:70
size_t const unsigned const radix
Definition: xtoa.cpp:37

◆ JSGlobal_ScriptEngine()

static HRESULT JSGlobal_ScriptEngine ( script_ctx_t ctx,
jsval_t  vthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 518 of file global.c.

520{
521 TRACE("\n");
522
523 if(r) {
524 jsstr_t *ret;
525
526 ret = jsstr_alloc(L"JScript");
527 if(!ret)
528 return E_OUTOFMEMORY;
529
530 *r = jsval_string(ret);
531 }
532
533 return S_OK;
534}
static jsstr_t * jsstr_alloc(const WCHAR *str)
Definition: jsstr.h:100

◆ JSGlobal_ScriptEngineBuildVersion()

static HRESULT JSGlobal_ScriptEngineBuildVersion ( script_ctx_t ctx,
jsval_t  vthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 556 of file global.c.

558{
559 TRACE("\n");
560
561 if(r)
563 return S_OK;
564}
#define JSCRIPT_BUILD_VERSION
Definition: resource.h:23

◆ JSGlobal_ScriptEngineMajorVersion()

static HRESULT JSGlobal_ScriptEngineMajorVersion ( script_ctx_t ctx,
jsval_t  vthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 536 of file global.c.

538{
539 TRACE("\n");
540
541 if(r)
543 return S_OK;
544}
#define JSCRIPT_MAJOR_VERSION
Definition: resource.h:21

◆ JSGlobal_ScriptEngineMinorVersion()

static HRESULT JSGlobal_ScriptEngineMinorVersion ( script_ctx_t ctx,
jsval_t  vthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 546 of file global.c.

548{
549 TRACE("\n");
550
551 if(r)
553 return S_OK;
554}
#define JSCRIPT_MINOR_VERSION
Definition: resource.h:22

◆ JSGlobal_unescape()

static HRESULT JSGlobal_unescape ( script_ctx_t ctx,
jsval_t  vthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 441 of file global.c.

443{
444 jsstr_t *ret_str, *str;
445 const WCHAR *ptr, *buf;
446 DWORD len = 0;
447 WCHAR *ret;
449
450 TRACE("\n");
451
452 if(!argc) {
453 if(r)
455 return S_OK;
456 }
457
458 hres = to_flat_string(ctx, argv[0], &str, &buf);
459 if(FAILED(hres))
460 return hres;
461
462 for(ptr = buf; *ptr; ptr++) {
463 if(*ptr == '%') {
464 if(hex_to_int(*(ptr+1))!=-1 && hex_to_int(*(ptr+2))!=-1)
465 ptr += 2;
466 else if(*(ptr+1)=='u' && hex_to_int(*(ptr+2))!=-1 && hex_to_int(*(ptr+3))!=-1
467 && hex_to_int(*(ptr+4))!=-1 && hex_to_int(*(ptr+5))!=-1)
468 ptr += 5;
469 }
470
471 len++;
472 }
473
474 ret_str = jsstr_alloc_buf(len, &ret);
475 if(!ret_str) {
477 return E_OUTOFMEMORY;
478 }
479
480 len = 0;
481 for(ptr = buf; *ptr; ptr++) {
482 if(*ptr == '%') {
483 if(hex_to_int(*(ptr+1))!=-1 && hex_to_int(*(ptr+2))!=-1) {
484 ret[len] = (hex_to_int(*(ptr+1))<<4) + hex_to_int(*(ptr+2));
485 ptr += 2;
486 }
487 else if(*(ptr+1)=='u' && hex_to_int(*(ptr+2))!=-1 && hex_to_int(*(ptr+3))!=-1
488 && hex_to_int(*(ptr+4))!=-1 && hex_to_int(*(ptr+5))!=-1) {
489 ret[len] = (hex_to_int(*(ptr+2))<<12) + (hex_to_int(*(ptr+3))<<8)
490 + (hex_to_int(*(ptr+4))<<4) + hex_to_int(*(ptr+5));
491 ptr += 5;
492 }
493 else
494 ret[len] = *ptr;
495 }
496 else
497 ret[len] = *ptr;
498
499 len++;
500 }
501
503
504 if(r)
505 *r = jsval_string(ret_str);
506 else
507 jsstr_release(ret_str);
508 return S_OK;
509}

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( jscript  )

Variable Documentation

◆ JSGlobal_info

const builtin_info_t JSGlobal_info
static
Initial value:
= {
.class = JSCLASS_GLOBAL,
.props_cnt = ARRAY_SIZE(JSGlobal_props),
.props = JSGlobal_props,
}
#define ARRAY_SIZE(A)
Definition: main.h:20
static const builtin_prop_t JSGlobal_props[]
Definition: global.c:899
@ JSCLASS_GLOBAL
Definition: jscript.h:110

Definition at line 919 of file global.c.

Referenced by init_global().

◆ JSGlobal_props

const builtin_prop_t JSGlobal_props[]
static
Initial value:
= {
{L"CollectGarbage", JSGlobal_CollectGarbage, PROPF_METHOD},
{L"GetObject", JSGlobal_GetObject, PROPF_METHOD|2},
{L"ScriptEngineBuildVersion", JSGlobal_ScriptEngineBuildVersion, PROPF_METHOD},
{L"ScriptEngineMajorVersion", JSGlobal_ScriptEngineMajorVersion, PROPF_METHOD},
{L"ScriptEngineMinorVersion", JSGlobal_ScriptEngineMinorVersion, PROPF_METHOD},
{L"decodeURI", JSGlobal_decodeURI, PROPF_METHOD|1},
{L"decodeURIComponent", JSGlobal_decodeURIComponent, PROPF_METHOD|1},
{L"encodeURI", JSGlobal_encodeURI, PROPF_METHOD|1},
{L"encodeURIComponent", JSGlobal_encodeURIComponent, PROPF_METHOD|1},
{L"isFinite", JSGlobal_isFinite, PROPF_METHOD|1},
{L"parseFloat", JSGlobal_parseFloat, PROPF_METHOD|1},
{L"parseInt", JSGlobal_parseInt, PROPF_METHOD|2},
}
static HRESULT JSGlobal_escape(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: global.c:72
HRESULT JSGlobal_eval(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: global.c:180
static HRESULT JSGlobal_decodeURI(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: global.c:637
static HRESULT JSGlobal_encodeURI(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: global.c:572
static HRESULT JSGlobal_encodeURIComponent(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: global.c:723
static HRESULT JSGlobal_unescape(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: global.c:441
static HRESULT JSGlobal_parseFloat(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: global.c:326
static HRESULT JSGlobal_GetObject(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: global.c:511
static HRESULT JSGlobal_ScriptEngineBuildVersion(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: global.c:556
static HRESULT JSGlobal_isNaN(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: global.c:186
static HRESULT JSGlobal_ScriptEngineMajorVersion(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: global.c:536
static HRESULT JSGlobal_CollectGarbage(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: global.c:566
static HRESULT JSGlobal_ScriptEngine(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: global.c:518
static HRESULT JSGlobal_ScriptEngineMinorVersion(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: global.c:546
static HRESULT JSGlobal_decodeURIComponent(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: global.c:787
static HRESULT JSGlobal_parseInt(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: global.c:243
static HRESULT JSGlobal_isFinite(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: global.c:209

Definition at line 899 of file global.c.

◆ uri_char_table

int uri_char_table[]
static
Initial value:
= {
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,2,0,0,1,0,1,2,2,2,2,1,1,2,2,1,
2,2,2,2,2,2,2,2,2,2,1,1,0,1,0,1,
1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
2,2,2,2,2,2,2,2,2,2,2,0,0,0,0,2,
0,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
2,2,2,2,2,2,2,2,2,2,2,0,0,0,2,0,
}

Definition at line 34 of file global.c.

Referenced by is_uri_reserved(), and is_uri_unescaped().