ReactOS  0.4.14-dev-593-g1793dcc
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, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
HRESULT JSGlobal_eval (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT JSGlobal_isNaN (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT JSGlobal_isFinite (script_ctx_t *ctx, vdisp_t *jsthis, 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, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT JSGlobal_parseFloat (script_ctx_t *ctx, vdisp_t *jsthis, 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, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT JSGlobal_GetObject (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT JSGlobal_ScriptEngine (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT JSGlobal_ScriptEngineMajorVersion (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT JSGlobal_ScriptEngineMinorVersion (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT JSGlobal_ScriptEngineBuildVersion (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT JSGlobal_CollectGarbage (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT JSGlobal_encodeURI (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT JSGlobal_decodeURI (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT JSGlobal_encodeURIComponent (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT JSGlobal_decodeURIComponent (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT init_constructors (script_ctx_t *ctx, jsdisp_t *object_prototype)
 
HRESULT init_global (script_ctx_t *ctx)
 

Variables

static const WCHAR NaNW [] = {'N','a','N',0}
 
static const WCHAR InfinityW [] = {'I','n','f','i','n','i','t','y',0}
 
static const WCHAR ArrayW [] = {'A','r','r','a','y',0}
 
static const WCHAR BooleanW [] = {'B','o','o','l','e','a','n',0}
 
static const WCHAR DateW [] = {'D','a','t','e',0}
 
static const WCHAR ErrorW [] = {'E','r','r','o','r',0}
 
static const WCHAR EvalErrorW [] = {'E','v','a','l','E','r','r','o','r',0}
 
static const WCHAR RangeErrorW [] = {'R','a','n','g','e','E','r','r','o','r',0}
 
static const WCHAR ReferenceErrorW [] = {'R','e','f','e','r','e','n','c','e','E','r','r','o','r',0}
 
static const WCHAR SyntaxErrorW [] = {'S','y','n','t','a','x','E','r','r','o','r',0}
 
static const WCHAR TypeErrorW [] = {'T','y','p','e','E','r','r','o','r',0}
 
static const WCHAR URIErrorW [] = {'U','R','I','E','r','r','o','r',0}
 
static const WCHAR FunctionW [] = {'F','u','n','c','t','i','o','n',0}
 
static const WCHAR NumberW [] = {'N','u','m','b','e','r',0}
 
static const WCHAR ObjectW [] = {'O','b','j','e','c','t',0}
 
static const WCHAR StringW [] = {'S','t','r','i','n','g',0}
 
static const WCHAR RegExpW [] = {'R','e','g','E','x','p',0}
 
static const WCHAR RegExpErrorW [] = {'R','e','g','E','x','p','E','r','r','o','r',0}
 
static const WCHAR ActiveXObjectW [] = {'A','c','t','i','v','e','X','O','b','j','e','c','t',0}
 
static const WCHAR VBArrayW [] = {'V','B','A','r','r','a','y',0}
 
static const WCHAR EnumeratorW [] = {'E','n','u','m','e','r','a','t','o','r',0}
 
static const WCHAR escapeW [] = {'e','s','c','a','p','e',0}
 
static const WCHAR evalW [] = {'e','v','a','l',0}
 
static const WCHAR isNaNW [] = {'i','s','N','a','N',0}
 
static const WCHAR isFiniteW [] = {'i','s','F','i','n','i','t','e',0}
 
static const WCHAR parseIntW [] = {'p','a','r','s','e','I','n','t',0}
 
static const WCHAR parseFloatW [] = {'p','a','r','s','e','F','l','o','a','t',0}
 
static const WCHAR unescapeW [] = {'u','n','e','s','c','a','p','e',0}
 
static const WCHAR _GetObjectW [] = {'G','e','t','O','b','j','e','c','t',0}
 
static const WCHAR ScriptEngineW [] = {'S','c','r','i','p','t','E','n','g','i','n','e',0}
 
static const WCHAR ScriptEngineMajorVersionW []
 
static const WCHAR ScriptEngineMinorVersionW []
 
static const WCHAR ScriptEngineBuildVersionW []
 
static const WCHAR CollectGarbageW [] = {'C','o','l','l','e','c','t','G','a','r','b','a','g','e',0}
 
static const WCHAR MathW [] = {'M','a','t','h',0}
 
static const WCHAR JSONW [] = {'J','S','O','N',0}
 
static const WCHAR encodeURIW [] = {'e','n','c','o','d','e','U','R','I',0}
 
static const WCHAR decodeURIW [] = {'d','e','c','o','d','e','U','R','I',0}
 
static const WCHAR encodeURIComponentW [] = {'e','n','c','o','d','e','U','R','I','C','o','m','p','o','n','e','n','t',0}
 
static const WCHAR decodeURIComponentW [] = {'d','e','c','o','d','e','U','R','I','C','o','m','p','o','n','e','n','t',0}
 
static const WCHAR undefinedW [] = {'u','n','d','e','f','i','n','e','d',0}
 
static int uri_char_table []
 
static const builtin_prop_t JSGlobal_props []
 
static const builtin_info_t JSGlobal_info
 

Function Documentation

◆ char_to_int()

static INT char_to_int ( WCHAR  c)
static

Definition at line 273 of file global.c.

274 {
275  if('0' <= c && c <= '9')
276  return c - '0';
277  if('a' <= c && c <= 'z')
278  return c - 'a' + 10;
279  if('A' <= c && c <= 'Z')
280  return c - 'A' + 10;
281  return 100;
282 }
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 466 of file global.c.

466  {
467  if(towupper(wch)>='A' && towupper(wch)<='F') return towupper(wch)-'A'+10;
468  if(iswdigit(wch)) return wch-'0';
469  return -1;
470 }
#define iswdigit(_c)
Definition: ctype.h:667
#define towupper(c)
Definition: wctype.h:99

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

◆ init_constructors()

static HRESULT init_constructors ( script_ctx_t ctx,
jsdisp_t object_prototype 
)
static

Definition at line 964 of file global.c.

965 {
966  HRESULT hres;
967 
968  hres = init_function_constr(ctx, object_prototype);
969  if(FAILED(hres))
970  return hres;
971 
973  jsval_obj(ctx->function_constr));
974  if(FAILED(hres))
975  return hres;
976 
977  hres = create_object_constr(ctx, object_prototype, &ctx->object_constr);
978  if(FAILED(hres))
979  return hres;
980 
982  jsval_obj(ctx->object_constr));
983  if(FAILED(hres))
984  return hres;
985 
986  hres = create_array_constr(ctx, object_prototype, &ctx->array_constr);
987  if(FAILED(hres))
988  return hres;
989 
991  jsval_obj(ctx->array_constr));
992  if(FAILED(hres))
993  return hres;
994 
995  hres = create_bool_constr(ctx, object_prototype, &ctx->bool_constr);
996  if(FAILED(hres))
997  return hres;
998 
1000  jsval_obj(ctx->bool_constr));
1001  if(FAILED(hres))
1002  return hres;
1003 
1004  hres = create_date_constr(ctx, object_prototype, &ctx->date_constr);
1005  if(FAILED(hres))
1006  return hres;
1007 
1009  jsval_obj(ctx->date_constr));
1010  if(FAILED(hres))
1011  return hres;
1012 
1013  hres = create_enumerator_constr(ctx, object_prototype, &ctx->enumerator_constr);
1014  if(FAILED(hres))
1015  return hres;
1016 
1019  if(FAILED(hres))
1020  return hres;
1021 
1022  hres = init_error_constr(ctx, object_prototype);
1023  if(FAILED(hres))
1024  return hres;
1025 
1027  jsval_obj(ctx->error_constr));
1028  if(FAILED(hres))
1029  return hres;
1030 
1033  if(FAILED(hres))
1034  return hres;
1035 
1038  if(FAILED(hres))
1039  return hres;
1040 
1043  if(FAILED(hres))
1044  return hres;
1045 
1048  if(FAILED(hres))
1049  return hres;
1050 
1053  if(FAILED(hres))
1054  return hres;
1055 
1058  if(FAILED(hres))
1059  return hres;
1060 
1062  jsval_obj(ctx->uri_error_constr));
1063  if(FAILED(hres))
1064  return hres;
1065 
1066  hres = create_number_constr(ctx, object_prototype, &ctx->number_constr);
1067  if(FAILED(hres))
1068  return hres;
1069 
1071  jsval_obj(ctx->number_constr));
1072  if(FAILED(hres))
1073  return hres;
1074 
1075  hres = create_regexp_constr(ctx, object_prototype, &ctx->regexp_constr);
1076  if(FAILED(hres))
1077  return hres;
1078 
1080  jsval_obj(ctx->regexp_constr));
1081  if(FAILED(hres))
1082  return hres;
1083 
1084  hres = create_string_constr(ctx, object_prototype, &ctx->string_constr);
1085  if(FAILED(hres))
1086  return hres;
1087 
1089  jsval_obj(ctx->string_constr));
1090  if(FAILED(hres))
1091  return hres;
1092 
1093  hres = create_vbarray_constr(ctx, object_prototype, &ctx->vbarray_constr);
1094  if(FAILED(hres))
1095  return hres;
1096 
1098  jsval_obj(ctx->vbarray_constr));
1099  if(FAILED(hres))
1100  return hres;
1101 
1102  return S_OK;
1103 }
#define PROPF_WRITABLE
Definition: jscript.h:101
jsdisp_t * bool_constr
Definition: jscript.h:444
static const WCHAR DateW[]
Definition: global.c:38
static const WCHAR NumberW[]
Definition: global.c:47
static const WCHAR RangeErrorW[]
Definition: global.c:41
jsdisp_t * vbarray_constr
Definition: jscript.h:459
HRESULT create_object_constr(script_ctx_t *, jsdisp_t *, jsdisp_t **) DECLSPEC_HIDDEN
Definition: object.c:718
jsdisp_t * reference_error_constr
Definition: jscript.h:450
static const WCHAR EvalErrorW[]
Definition: global.c:40
jsdisp_t * enumerator_constr
Definition: jscript.h:446
jsdisp_t * array_constr
Definition: jscript.h:443
jsdisp_t * type_error_constr
Definition: jscript.h:453
jsdisp_t * range_error_constr
Definition: jscript.h:449
static const WCHAR ObjectW[]
Definition: global.c:48
HRESULT jsdisp_define_data_property(jsdisp_t *obj, const WCHAR *name, unsigned flags, jsval_t value)
Definition: dispex.c:1801
HRESULT create_number_constr(script_ctx_t *, jsdisp_t *, jsdisp_t **) DECLSPEC_HIDDEN
Definition: number.c:613
jsdisp_t * string_constr
Definition: jscript.h:458
static const WCHAR BooleanW[]
Definition: global.c:37
HRESULT create_bool_constr(script_ctx_t *ctx, jsdisp_t *object_prototype, jsdisp_t **ret)
Definition: bool.c:198
jsdisp_t * syntax_error_constr
Definition: jscript.h:452
jsdisp_t * error_constr
Definition: jscript.h:447
jsdisp_t * regexp_error_constr
Definition: jscript.h:451
static const WCHAR EnumeratorW[]
Definition: global.c:54
jsdisp_t * number_constr
Definition: jscript.h:455
HRESULT create_vbarray_constr(script_ctx_t *, jsdisp_t *, jsdisp_t **) DECLSPEC_HIDDEN
Definition: vbarray.c:330
HRESULT create_enumerator_constr(script_ctx_t *ctx, jsdisp_t *object_prototype, jsdisp_t **ret)
Definition: enumerator.c:332
static const WCHAR ErrorW[]
Definition: global.c:39
jsdisp_t * regexp_constr
Definition: jscript.h:457
HRESULT init_error_constr(script_ctx_t *ctx, jsdisp_t *object_prototype)
Definition: error.c:328
static const WCHAR TypeErrorW[]
Definition: global.c:44
HRESULT hres
Definition: protocol.c:465
static const WCHAR SyntaxErrorW[]
Definition: global.c:43
LONG HRESULT
Definition: typedefs.h:77
static const WCHAR ArrayW[]
Definition: global.c:36
static const WCHAR URIErrorW[]
Definition: global.c:45
jsdisp_t * object_constr
Definition: jscript.h:456
static const WCHAR ReferenceErrorW[]
Definition: global.c:42
static const WCHAR VBArrayW[]
Definition: global.c:53
static const WCHAR StringW[]
Definition: global.c:49
HRESULT create_regexp_constr(script_ctx_t *, jsdisp_t *, jsdisp_t **) DECLSPEC_HIDDEN
Definition: jsregexp.c:1004
HRESULT init_function_constr(script_ctx_t *ctx, jsdisp_t *object_prototype)
Definition: function.c:1010
#define S_OK
Definition: intsafe.h:59
jsdisp_t * function_constr
Definition: jscript.h:442
HRESULT create_date_constr(script_ctx_t *ctx, jsdisp_t *object_prototype, jsdisp_t **ret)
Definition: date.c:2534
static const WCHAR FunctionW[]
Definition: global.c:46
HRESULT create_string_constr(script_ctx_t *, jsdisp_t *, jsdisp_t **) DECLSPEC_HIDDEN
Definition: string.c:1769
jsdisp_t * date_constr
Definition: jscript.h:445
jsdisp_t * global
Definition: jscript.h:441
static jsval_t jsval_obj(jsdisp_t *obj)
Definition: jsval.h:125
HRESULT create_array_constr(script_ctx_t *ctx, jsdisp_t *object_prototype, jsdisp_t **ret)
Definition: array.c:1364
jsdisp_t * eval_error_constr
Definition: jscript.h:448
static const WCHAR RegExpW[]
Definition: global.c:50
jsdisp_t * uri_error_constr
Definition: jscript.h:454
static const WCHAR RegExpErrorW[]
Definition: global.c:51

Referenced by init_global().

◆ init_global()

HRESULT init_global ( script_ctx_t ctx)

Definition at line 1105 of file global.c.

1106 {
1107  unsigned const_flags = ctx->version >= SCRIPTLANGUAGEVERSION_ES5 ? 0 : PROPF_WRITABLE;
1108  jsdisp_t *math, *object_prototype, *constr;
1109  HRESULT hres;
1110 
1111  if(ctx->global)
1112  return S_OK;
1113 
1114  hres = create_dispex(ctx, &JSGlobal_info, NULL, &ctx->global);
1115  if(FAILED(hres))
1116  return hres;
1117 
1118  hres = create_object_prototype(ctx, &object_prototype);
1119  if(FAILED(hres))
1120  return hres;
1121 
1122  hres = init_constructors(ctx, object_prototype);
1123  jsdisp_release(object_prototype);
1124  if(FAILED(hres))
1125  return hres;
1126 
1127  hres = create_math(ctx, &math);
1128  if(FAILED(hres))
1129  return hres;
1130 
1132  jsdisp_release(math);
1133  if(FAILED(hres))
1134  return hres;
1135 
1136  if(ctx->version >= 2) {
1137  jsdisp_t *json;
1138 
1139  hres = create_json(ctx, &json);
1140  if(FAILED(hres))
1141  return hres;
1142 
1144  jsdisp_release(json);
1145  if(FAILED(hres))
1146  return hres;
1147  }
1148 
1149  hres = create_activex_constr(ctx, &constr);
1150  if(FAILED(hres))
1151  return hres;
1152 
1154  jsval_obj(constr));
1155  jsdisp_release(constr);
1156  if(FAILED(hres))
1157  return hres;
1158 
1160  if(FAILED(hres))
1161  return hres;
1162 
1163  hres = jsdisp_define_data_property(ctx->global, NaNW, const_flags, jsval_number(NAN));
1164  if(FAILED(hres))
1165  return hres;
1166 
1168  return hres;
1169 }
#define PROPF_WRITABLE
Definition: jscript.h:101
HRESULT jsdisp_define_data_property(jsdisp_t *obj, const WCHAR *name, unsigned flags, jsval_t value)
Definition: dispex.c:1801
static const WCHAR undefinedW[]
Definition: global.c:78
HRESULT create_math(script_ctx_t *, jsdisp_t **) DECLSPEC_HIDDEN
Definition: math.c:533
HRESULT create_json(script_ctx_t *, jsdisp_t **) DECLSPEC_HIDDEN
Definition: json.c:837
smooth NULL
Definition: ftsmooth.c:416
DWORD version
Definition: jscript.h:420
HRESULT create_object_prototype(script_ctx_t *, jsdisp_t **) DECLSPEC_HIDDEN
Definition: object.c:726
static const WCHAR NaNW[]
Definition: global.c:34
static const builtin_info_t JSGlobal_info
Definition: global.c:955
HRESULT hres
Definition: protocol.c:465
static HRESULT init_constructors(script_ctx_t *ctx, jsdisp_t *object_prototype)
Definition: global.c:964
static const WCHAR ActiveXObjectW[]
Definition: global.c:52
LONG HRESULT
Definition: typedefs.h:77
#define NAN
Definition: misc.c:46
#define SCRIPTLANGUAGEVERSION_ES5
Definition: jscript.h:52
static jsval_t jsval_undefined(void)
Definition: jsval.h:137
#define S_OK
Definition: intsafe.h:59
static const WCHAR JSONW[]
Definition: global.c:72
HRESULT create_dispex(script_ctx_t *ctx, const builtin_info_t *builtin_info, jsdisp_t *prototype, jsdisp_t **dispex)
Definition: dispex.c:957
static const WCHAR MathW[]
Definition: global.c:71
static void jsdisp_release(jsdisp_t *jsdisp)
Definition: jscript.h:268
static const WCHAR InfinityW[]
Definition: global.c:35
jsdisp_t * global
Definition: jscript.h:441
static jsval_t jsval_obj(jsdisp_t *obj)
Definition: jsval.h:125
HRESULT create_activex_constr(script_ctx_t *ctx, jsdisp_t **ret)
Definition: activex.c:188
#define INFINITY
Definition: misc.c:36
static jsval_t jsval_number(double n)
Definition: jsval.h:144

Referenced by set_ctx_site(), and VBScriptFactory_CreateInstance().

◆ int_to_char()

static WCHAR int_to_char ( int  i)
static

Definition at line 111 of file global.c.

112 {
113  if(i < 10)
114  return '0'+i;
115  return 'A'+i-10;
116 }
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 105 of file global.c.

106 {
107  return ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') ||
108  c == '@' || c == '*' || c == '_' || c == '+' || c == '-' || c == '.' || c == '/');
109 }
const GLubyte * c
Definition: glext.h:8905

Referenced by JSGlobal_escape().

◆ is_uri_reserved()

static BOOL is_uri_reserved ( WCHAR  c)
inlinestatic

Definition at line 94 of file global.c.

95 {
96  return c < 128 && uri_char_table[c] == 1;
97 }
const GLubyte * c
Definition: glext.h:8905
#define c
Definition: ke_i.h:80
static int uri_char_table[]
Definition: global.c:80

Referenced by JSGlobal_encodeURI().

◆ is_uri_unescaped()

static BOOL is_uri_unescaped ( WCHAR  c)
inlinestatic

Definition at line 99 of file global.c.

100 {
101  return c < 128 && uri_char_table[c] == 2;
102 }
const GLubyte * c
Definition: glext.h:8905
#define c
Definition: ke_i.h:80
static int uri_char_table[]
Definition: global.c:80

Referenced by JSGlobal_encodeURI(), and JSGlobal_encodeURIComponent().

◆ JSGlobal_CollectGarbage()

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

Definition at line 599 of file global.c.

601 {
602  static int once = 0;
603  if (!once++)
604  FIXME(": stub\n");
605  return S_OK;
606 }
#define FIXME(fmt,...)
Definition: debug.h:110
#define S_OK
Definition: intsafe.h:59

◆ JSGlobal_decodeURI()

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

Definition at line 673 of file global.c.

675 {
676  const WCHAR *ptr, *uri;
677  jsstr_t *str, *ret_str;
678  unsigned len = 0;
679  int i, val, res;
680  WCHAR *ret;
681  char buf[4];
682  WCHAR out;
683  HRESULT hres;
684 
685  TRACE("\n");
686 
687  if(!argc) {
688  if(r)
690  return S_OK;
691  }
692 
693  hres = to_flat_string(ctx, argv[0], &str, &uri);
694  if(FAILED(hres))
695  return hres;
696 
697  for(ptr = uri; *ptr; ptr++) {
698  if(*ptr != '%') {
699  len++;
700  }else {
701  res = 0;
702  for(i=0; i<4; i++) {
703  if(ptr[i*3]!='%' || hex_to_int(ptr[i*3+1])==-1 || (val=hex_to_int(ptr[i*3+2]))==-1)
704  break;
705  val += hex_to_int(ptr[i*3+1])<<4;
706  buf[i] = val;
707 
708  res = MultiByteToWideChar(CP_UTF8, 0, buf, i+1, &out, 1);
709  if(res)
710  break;
711  }
712 
713  if(!res) {
716  }
717 
718  ptr += i*3+2;
719  len++;
720  }
721  }
722 
723  ret_str = jsstr_alloc_buf(len, &ret);
724  if(!ret_str) {
726  return E_OUTOFMEMORY;
727  }
728 
729  for(ptr = uri; *ptr; ptr++) {
730  if(*ptr != '%') {
731  *ret++ = *ptr;
732  }else {
733  for(i=0; i<4; i++) {
734  if(ptr[i*3]!='%' || hex_to_int(ptr[i*3+1])==-1 || (val=hex_to_int(ptr[i*3+2]))==-1)
735  break;
736  val += hex_to_int(ptr[i*3+1])<<4;
737  buf[i] = val;
738 
739  res = MultiByteToWideChar(CP_UTF8, 0, buf, i+1, ret, 1);
740  if(res)
741  break;
742  }
743 
744  ptr += i*3+2;
745  ret++;
746  }
747  }
748 
749  TRACE("%s -> %s\n", debugstr_jsstr(str), debugstr_jsstr(ret_str));
751 
752  if(r)
753  *r = jsval_string(ret_str);
754  else
755  jsstr_release(ret_str);
756  return S_OK;
757 }
static int argc
Definition: ServiceArgs.c:12
jsstr_t * jsstr_undefined(void)
Definition: jsstr.c:293
Definition: jsstr.h:39
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
const char * uri
Definition: sec_mgr.c:1594
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static void jsstr_release(jsstr_t *str)
Definition: jsstr.h:110
#define argv
Definition: mplay32.c:18
HRESULT throw_uri_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:445
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
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define CP_UTF8
Definition: nls.h:20
static PVOID ptr
Definition: dispmode.c:27
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
static jsval_t jsval_string(jsstr_t *str)
Definition: jsval.h:109
GLuint GLfloat * val
Definition: glext.h:7180
#define TRACE(s)
Definition: solgame.cpp:4
const char * debugstr_jsstr(jsstr_t *str)
Definition: jsstr.c:37
HRESULT hres
Definition: protocol.c:465
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
static FILE * out
Definition: regtests2xml.c:44
int ret
GLenum GLsizei len
Definition: glext.h:6722
#define S_OK
Definition: intsafe.h:59
#define JS_E_INVALID_URI_CODING
Definition: jscript.h:564
#define MultiByteToWideChar
Definition: compat.h:100
jsstr_t * jsstr_alloc_buf(unsigned len, WCHAR **buf)
Definition: jsstr.c:69
GLuint res
Definition: glext.h:9613
static int hex_to_int(const WCHAR wch)
Definition: global.c:466
HRESULT to_flat_string(script_ctx_t *, jsval_t, jsstr_t **, const WCHAR **) DECLSPEC_HIDDEN
Definition: jsutils.c:798

◆ JSGlobal_decodeURIComponent()

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

Definition at line 823 of file global.c.

825 {
826  const WCHAR *ptr, *uri;
827  jsstr_t *str, *ret;
828  WCHAR *out_ptr;
829  DWORD len = 0;
830  HRESULT hres;
831 
832  TRACE("\n");
833 
834  if(!argc) {
835  if(r)
837  return S_OK;
838  }
839 
840  hres = to_flat_string(ctx, argv[0], &str, &uri);
841  if(FAILED(hres))
842  return hres;
843 
844  ptr = uri;
845  while(*ptr) {
846  if(*ptr == '%') {
847  char octets[4];
848  unsigned char mask = 0x80;
849  int i, size, num_bytes = 0;
850  if(hex_to_int(*(ptr+1)) < 0 || hex_to_int(*(ptr+2)) < 0) {
851  FIXME("Throw URIError: Invalid hex sequence\n");
853  return E_FAIL;
854  }
855  octets[0] = (hex_to_int(*(ptr+1)) << 4) + hex_to_int(*(ptr+2));
856  ptr += 3;
857  while(octets[0] & mask) {
858  mask = mask >> 1;
859  ++num_bytes;
860  }
861  if(num_bytes == 1 || num_bytes > 4) {
862  FIXME("Throw URIError: Invalid initial UTF character\n");
864  return E_FAIL;
865  }
866  for(i = 1; i < num_bytes; ++i) {
867  if(*ptr != '%'){
868  FIXME("Throw URIError: Incomplete UTF sequence\n");
870  return E_FAIL;
871  }
872  if(hex_to_int(*(ptr+1)) < 0 || hex_to_int(*(ptr+2)) < 0) {
873  FIXME("Throw URIError: Invalid hex sequence\n");
875  return E_FAIL;
876  }
877  octets[i] = (hex_to_int(*(ptr+1)) << 4) + hex_to_int(*(ptr+2));
878  ptr += 3;
879  }
881  num_bytes ? num_bytes : 1, NULL, 0);
882  if(size == 0) {
883  FIXME("Throw URIError: Invalid UTF sequence\n");
885  return E_FAIL;
886  }
887  len += size;
888  }else {
889  ++ptr;
890  ++len;
891  }
892  }
893 
894  ret = jsstr_alloc_buf(len, &out_ptr);
895  if(!ret) {
897  return E_OUTOFMEMORY;
898  }
899 
900  ptr = uri;
901  while(*ptr) {
902  if(*ptr == '%') {
903  char octets[4];
904  unsigned char mask = 0x80;
905  int i, size, num_bytes = 0;
906  octets[0] = (hex_to_int(*(ptr+1)) << 4) + hex_to_int(*(ptr+2));
907  ptr += 3;
908  while(octets[0] & mask) {
909  mask = mask >> 1;
910  ++num_bytes;
911  }
912  for(i = 1; i < num_bytes; ++i) {
913  octets[i] = (hex_to_int(*(ptr+1)) << 4) + hex_to_int(*(ptr+2));
914  ptr += 3;
915  }
917  num_bytes ? num_bytes : 1, out_ptr, len);
918  len -= size;
919  out_ptr += size;
920  }else {
921  *out_ptr++ = *ptr++;
922  --len;
923  }
924  }
925 
927 
928  if(r)
929  *r = jsval_string(ret);
930  else
932  return S_OK;
933 }
static int argc
Definition: ServiceArgs.c:12
#define MB_ERR_INVALID_CHARS
Definition: unicode.h:41
jsstr_t * jsstr_undefined(void)
Definition: jsstr.c:293
Definition: jsstr.h:39
const char * uri
Definition: sec_mgr.c:1594
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static void jsstr_release(jsstr_t *str)
Definition: jsstr.h:110
#define argv
Definition: mplay32.c:18
#define E_FAIL
Definition: ddrawi.h:102
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
GLenum GLint GLuint mask
Definition: glext.h:6028
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define CP_UTF8
Definition: nls.h:20
#define FIXME(fmt,...)
Definition: debug.h:110
static PVOID ptr
Definition: dispmode.c:27
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
static jsval_t jsval_string(jsstr_t *str)
Definition: jsval.h:109
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
HRESULT hres
Definition: protocol.c:465
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
ed2 num_bytes
Definition: write.c:2846
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
GLenum GLsizei len
Definition: glext.h:6722
#define S_OK
Definition: intsafe.h:59
#define MultiByteToWideChar
Definition: compat.h:100
jsstr_t * jsstr_alloc_buf(unsigned len, WCHAR **buf)
Definition: jsstr.c:69
static int hex_to_int(const WCHAR wch)
Definition: global.c:466
HRESULT to_flat_string(script_ctx_t *, jsval_t, jsstr_t **, const WCHAR **) DECLSPEC_HIDDEN
Definition: jsutils.c:798

◆ JSGlobal_encodeURI()

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

Definition at line 608 of file global.c.

610 {
611  const WCHAR *ptr, *uri;
612  jsstr_t *str, *ret;
613  DWORD len = 0, i;
614  char buf[4];
615  WCHAR *rptr;
616  HRESULT hres;
617 
618  TRACE("\n");
619 
620  if(!argc) {
621  if(r)
623  return S_OK;
624  }
625 
626  hres = to_flat_string(ctx, argv[0], &str, &uri);
627  if(FAILED(hres))
628  return hres;
629 
630  for(ptr = uri; *ptr; ptr++) {
631  if(is_uri_unescaped(*ptr) || is_uri_reserved(*ptr) || *ptr == '#') {
632  len++;
633  }else {
634  i = WideCharToMultiByte(CP_UTF8, 0, ptr, 1, NULL, 0, NULL, NULL)*3;
635  if(!i) {
638  }
639 
640  len += i;
641  }
642  }
643 
644  ret = jsstr_alloc_buf(len, &rptr);
645  if(!ret) {
647  return E_OUTOFMEMORY;
648  }
649 
650  for(ptr = uri; *ptr; ptr++) {
651  if(is_uri_unescaped(*ptr) || is_uri_reserved(*ptr) || *ptr == '#') {
652  *rptr++ = *ptr;
653  }else {
654  len = WideCharToMultiByte(CP_UTF8, 0, ptr, 1, buf, sizeof(buf), NULL, NULL);
655  for(i=0; i<len; i++) {
656  *rptr++ = '%';
657  *rptr++ = int_to_char((BYTE)buf[i] >> 4);
658  *rptr++ = int_to_char(buf[i] & 0x0f);
659  }
660  }
661  }
662 
663  TRACE("%s -> %s\n", debugstr_jsstr(str), debugstr_jsstr(ret));
665 
666  if(r)
667  *r = jsval_string(ret);
668  else
670  return S_OK;
671 }
static int argc
Definition: ServiceArgs.c:12
#define WideCharToMultiByte
Definition: compat.h:101
jsstr_t * jsstr_undefined(void)
Definition: jsstr.c:293
Definition: jsstr.h:39
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
const char * uri
Definition: sec_mgr.c:1594
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static BOOL is_uri_reserved(WCHAR c)
Definition: global.c:94
static void jsstr_release(jsstr_t *str)
Definition: jsstr.h:110
#define argv
Definition: mplay32.c:18
HRESULT throw_uri_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:445
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
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define CP_UTF8
Definition: nls.h:20
static PVOID ptr
Definition: dispmode.c:27
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
#define JS_E_INVALID_URI_CHAR
Definition: jscript.h:565
static jsval_t jsval_string(jsstr_t *str)
Definition: jsval.h:109
#define TRACE(s)
Definition: solgame.cpp:4
const char * debugstr_jsstr(jsstr_t *str)
Definition: jsstr.c:37
HRESULT hres
Definition: protocol.c:465
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
GLenum GLsizei len
Definition: glext.h:6722
unsigned char BYTE
Definition: mem.h:68
#define S_OK
Definition: intsafe.h:59
static WCHAR int_to_char(int i)
Definition: global.c:111
jsstr_t * jsstr_alloc_buf(unsigned len, WCHAR **buf)
Definition: jsstr.c:69
static BOOL is_uri_unescaped(WCHAR c)
Definition: global.c:99
HRESULT to_flat_string(script_ctx_t *, jsval_t, jsstr_t **, const WCHAR **) DECLSPEC_HIDDEN
Definition: jsutils.c:798

◆ JSGlobal_encodeURIComponent()

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

Definition at line 759 of file global.c.

761 {
762  jsstr_t *str, *ret_str;
763  char buf[4];
764  const WCHAR *ptr, *uri;
765  DWORD len = 0, size, i;
766  WCHAR *ret;
767  HRESULT hres;
768 
769  TRACE("\n");
770 
771  if(!argc) {
772  if(r)
774  return S_OK;
775  }
776 
777  hres = to_flat_string(ctx, argv[0], &str, &uri);
778  if(FAILED(hres))
779  return hres;
780 
781  for(ptr = uri; *ptr; ptr++) {
782  if(is_uri_unescaped(*ptr))
783  len++;
784  else {
785  size = WideCharToMultiByte(CP_UTF8, 0, ptr, 1, NULL, 0, NULL, NULL);
786  if(!size) {
789  }
790  len += size*3;
791  }
792  }
793 
794  ret_str = jsstr_alloc_buf(len, &ret);
795  if(!ret_str) {
797  return E_OUTOFMEMORY;
798  }
799 
800  for(ptr = uri; *ptr; ptr++) {
801  if(is_uri_unescaped(*ptr)) {
802  *ret++ = *ptr;
803  }else {
804  size = WideCharToMultiByte(CP_UTF8, 0, ptr, 1, buf, sizeof(buf), NULL, NULL);
805  for(i=0; i<size; i++) {
806  *ret++ = '%';
807  *ret++ = int_to_char((BYTE)buf[i] >> 4);
808  *ret++ = int_to_char(buf[i] & 0x0f);
809  }
810  }
811  }
812 
814 
815  if(r)
816  *r = jsval_string(ret_str);
817  else
818  jsstr_release(ret_str);
819  return S_OK;
820 }
static int argc
Definition: ServiceArgs.c:12
#define WideCharToMultiByte
Definition: compat.h:101
jsstr_t * jsstr_undefined(void)
Definition: jsstr.c:293
Definition: jsstr.h:39
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
const char * uri
Definition: sec_mgr.c:1594
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static void jsstr_release(jsstr_t *str)
Definition: jsstr.h:110
#define argv
Definition: mplay32.c:18
HRESULT throw_uri_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:445
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
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define CP_UTF8
Definition: nls.h:20
static PVOID ptr
Definition: dispmode.c:27
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
#define JS_E_INVALID_URI_CHAR
Definition: jscript.h:565
static jsval_t jsval_string(jsstr_t *str)
Definition: jsval.h:109
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
HRESULT hres
Definition: protocol.c:465
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
GLenum GLsizei len
Definition: glext.h:6722
unsigned char BYTE
Definition: mem.h:68
#define S_OK
Definition: intsafe.h:59
static WCHAR int_to_char(int i)
Definition: global.c:111
jsstr_t * jsstr_alloc_buf(unsigned len, WCHAR **buf)
Definition: jsstr.c:69
static BOOL is_uri_unescaped(WCHAR c)
Definition: global.c:99
HRESULT to_flat_string(script_ctx_t *, jsval_t, jsstr_t **, const WCHAR **) DECLSPEC_HIDDEN
Definition: jsutils.c:798

◆ JSGlobal_escape()

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

Definition at line 118 of file global.c.

120 {
121  jsstr_t *ret_str, *str;
122  const WCHAR *ptr, *buf;
123  DWORD len = 0;
124  WCHAR *ret;
125  HRESULT hres;
126 
127  TRACE("\n");
128 
129  if(!argc) {
130  if(r)
132  return S_OK;
133  }
134 
135  hres = to_flat_string(ctx, argv[0], &str, &buf);
136  if(FAILED(hres))
137  return hres;
138 
139  for(ptr = buf; *ptr; ptr++) {
140  if(*ptr > 0xff)
141  len += 6;
142  else if(is_ecma_nonblank(*ptr))
143  len++;
144  else
145  len += 3;
146  }
147 
148  ret_str = jsstr_alloc_buf(len, &ret);
149  if(!ret_str) {
151  return E_OUTOFMEMORY;
152  }
153 
154  len = 0;
155  for(ptr = buf; *ptr; ptr++) {
156  if(*ptr > 0xff) {
157  ret[len++] = '%';
158  ret[len++] = 'u';
159  ret[len++] = int_to_char(*ptr >> 12);
160  ret[len++] = int_to_char((*ptr >> 8) & 0xf);
161  ret[len++] = int_to_char((*ptr >> 4) & 0xf);
162  ret[len++] = int_to_char(*ptr & 0xf);
163  }
164  else if(is_ecma_nonblank(*ptr))
165  ret[len++] = *ptr;
166  else {
167  ret[len++] = '%';
168  ret[len++] = int_to_char(*ptr >> 4);
169  ret[len++] = int_to_char(*ptr & 0xf);
170  }
171  }
172 
174 
175  if(r)
176  *r = jsval_string(ret_str);
177  else
178  jsstr_release(ret_str);
179  return S_OK;
180 }
static int argc
Definition: ServiceArgs.c:12
jsstr_t * jsstr_undefined(void)
Definition: jsstr.c:293
Definition: jsstr.h:39
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static void jsstr_release(jsstr_t *str)
Definition: jsstr.h:110
#define argv
Definition: mplay32.c:18
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
static PVOID ptr
Definition: dispmode.c:27
static BOOL is_ecma_nonblank(const WCHAR c)
Definition: global.c:105
const WCHAR * str
static jsval_t jsval_string(jsstr_t *str)
Definition: jsval.h:109
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
GLenum GLsizei len
Definition: glext.h:6722
#define S_OK
Definition: intsafe.h:59
static WCHAR int_to_char(int i)
Definition: global.c:111
jsstr_t * jsstr_alloc_buf(unsigned len, WCHAR **buf)
Definition: jsstr.c:69
HRESULT to_flat_string(script_ctx_t *, jsval_t, jsstr_t **, const WCHAR **) DECLSPEC_HIDDEN
Definition: jsutils.c:798

◆ JSGlobal_eval()

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

Definition at line 183 of file global.c.

185 {
186  call_frame_t *frame = ctx->call_ctx;
187  DWORD exec_flags = EXEC_EVAL;
188  bytecode_t *code;
189  const WCHAR *src;
190  HRESULT hres;
191 
192  TRACE("\n");
193 
194  if(!argc) {
195  if(r)
196  *r = jsval_undefined();
197  return S_OK;
198  }
199 
200  if(!is_string(argv[0])) {
201  if(r)
202  return jsval_copy(argv[0], r);
203  return S_OK;
204  }
205 
207  if(!src)
208  return E_OUTOFMEMORY;
209 
210  TRACE("parsing %s\n", debugstr_jsval(argv[0]));
211  hres = compile_script(ctx, src, NULL, NULL, TRUE, FALSE, &code);
212  if(FAILED(hres)) {
213  WARN("parse (%s) failed: %08x\n", debugstr_jsval(argv[0]), hres);
214  return throw_syntax_error(ctx, hres, NULL);
215  }
216 
217  if(!frame || (frame->flags & EXEC_GLOBAL))
218  exec_flags |= EXEC_GLOBAL;
220  exec_flags |= EXEC_RETURN_TO_INTERP;
221  hres = exec_source(ctx, exec_flags, code, &code->global_code, frame ? frame->scope : NULL,
222  frame ? frame->this_obj : NULL, NULL, frame ? frame->variable_obj : ctx->global, 0, NULL, r);
224  return hres;
225 }
static const WCHAR * jsstr_flatten(jsstr_t *str)
Definition: jsstr.h:139
static int argc
Definition: ServiceArgs.c:12
#define TRUE
Definition: types.h:120
DWORD flags
Definition: engine.h:234
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
jsdisp_t * variable_obj
Definition: engine.h:232
#define WARN(fmt,...)
Definition: debug.h:111
struct _call_frame_t * call_ctx
Definition: jscript.h:415
static BOOL is_string(parse_buffer *buf)
Definition: parsing.c:600
#define argv
Definition: mplay32.c:18
#define EXEC_RETURN_TO_INTERP
Definition: engine.h:250
#define EXEC_EVAL
Definition: engine.h:251
scope_chain_t * scope
Definition: engine.h:225
static char * get_string(void)
Definition: ppl.yy.c:4402
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
HRESULT jsval_copy(jsval_t v, jsval_t *r)
Definition: jsutils.c:231
smooth NULL
Definition: ftsmooth.c:416
HRESULT throw_syntax_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:435
HRESULT compile_script(script_ctx_t *ctx, const WCHAR *code, const WCHAR *args, const WCHAR *delimiter, BOOL from_eval, BOOL use_decode, bytecode_t **ret)
Definition: compile.c:2461
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, jsdisp_t *variable_obj, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: engine.c:2958
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
GLbitfield flags
Definition: glext.h:7161
#define EXEC_GLOBAL
Definition: engine.h:248
GLenum src
Definition: glext.h:6340
int code
Definition: i386-dis.c:3591
static jsval_t jsval_undefined(void)
Definition: jsval.h:137
#define S_OK
Definition: intsafe.h:59
IDispatch * this_obj
Definition: engine.h:230
#define DISPATCH_JSCRIPT_CALLEREXECSSOURCE
Definition: jscript.h:115
jsdisp_t * global
Definition: jscript.h:441
void release_bytecode(bytecode_t *code)
Definition: compile.c:2226
const char * debugstr_jsval(const jsval_t) DECLSPEC_HIDDEN
Definition: jsutils.c:35

Referenced by invoke_prop_func().

◆ JSGlobal_GetObject()

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

Definition at line 542 of file global.c.

544 {
545  FIXME("\n");
546  return E_NOTIMPL;
547 }
#define FIXME(fmt,...)
Definition: debug.h:110
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ JSGlobal_isFinite()

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

Definition at line 250 of file global.c.

252 {
253  BOOL ret = FALSE;
254  HRESULT hres;
255 
256  TRACE("\n");
257 
258  if(argc) {
259  double n;
260 
261  hres = to_number(ctx, argv[0], &n);
262  if(FAILED(hres))
263  return hres;
264 
265  ret = is_finite(n);
266  }
267 
268  if(r)
269  *r = jsval_bool(ret);
270  return S_OK;
271 }
static int argc
Definition: ServiceArgs.c:12
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLdouble n
Definition: glext.h:7729
#define argv
Definition: mplay32.c:18
HRESULT to_number(script_ctx_t *, jsval_t, double *) DECLSPEC_HIDDEN
Definition: jsutils.c:609
unsigned int BOOL
Definition: ntddk_ex.h:94
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
int ret
BOOL is_finite(double) DECLSPEC_HIDDEN
Definition: jsutils.c:58
#define S_OK
Definition: intsafe.h:59
static jsval_t jsval_bool(BOOL b)
Definition: jsval.h:101

◆ JSGlobal_isNaN()

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

Definition at line 227 of file global.c.

229 {
230  BOOL ret = TRUE;
231  double n;
232  HRESULT hres;
233 
234  TRACE("\n");
235 
236  if(argc) {
237  hres = to_number(ctx, argv[0], &n);
238  if(FAILED(hres))
239  return hres;
240 
241  if(!isnan(n))
242  ret = FALSE;
243  }
244 
245  if(r)
246  *r = jsval_bool(ret);
247  return S_OK;
248 }
static int argc
Definition: ServiceArgs.c:12
#define TRUE
Definition: types.h:120
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLdouble n
Definition: glext.h:7729
#define argv
Definition: mplay32.c:18
HRESULT to_number(script_ctx_t *, jsval_t, double *) DECLSPEC_HIDDEN
Definition: jsutils.c:609
unsigned int BOOL
Definition: ntddk_ex.h:94
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
int ret
int isnan(double x)
#define S_OK
Definition: intsafe.h:59
static jsval_t jsval_bool(BOOL b)
Definition: jsval.h:101

◆ JSGlobal_parseFloat()

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

Definition at line 367 of file global.c.

369 {
370  LONGLONG d = 0, hlp;
371  jsstr_t *val_str;
372  int exp = 0;
373  const WCHAR *str;
374  BOOL ret_nan = TRUE, positive = TRUE;
375  HRESULT hres;
376 
377  if(!argc) {
378  if(r)
379  *r = jsval_number(NAN);
380  return S_OK;
381  }
382 
383  hres = to_flat_string(ctx, argv[0], &val_str, &str);
384  if(FAILED(hres))
385  return hres;
386 
387  while(iswspace(*str)) str++;
388 
389  if(*str == '+')
390  str++;
391  else if(*str == '-') {
392  positive = FALSE;
393  str++;
394  }
395 
396  if(iswdigit(*str))
397  ret_nan = FALSE;
398 
399  while(iswdigit(*str)) {
400  hlp = d*10 + *(str++) - '0';
401  if(d>MAXLONGLONG/10 || hlp<0) {
402  exp++;
403  break;
404  }
405  else
406  d = hlp;
407  }
408  while(iswdigit(*str)) {
409  exp++;
410  str++;
411  }
412 
413  if(*str == '.') str++;
414 
415  if(iswdigit(*str))
416  ret_nan = FALSE;
417 
418  while(iswdigit(*str)) {
419  hlp = d*10 + *(str++) - '0';
420  if(d>MAXLONGLONG/10 || hlp<0)
421  break;
422 
423  d = hlp;
424  exp--;
425  }
426  while(iswdigit(*str))
427  str++;
428 
429  if(*str && !ret_nan && (*str=='e' || *str=='E')) {
430  int sign = 1, e = 0;
431 
432  str++;
433  if(*str == '+')
434  str++;
435  else if(*str == '-') {
436  sign = -1;
437  str++;
438  }
439 
440  while(iswdigit(*str)) {
441  if(e>INT_MAX/10 || (e = e*10 + *str++ - '0')<0)
442  e = INT_MAX;
443  }
444  e *= sign;
445 
446  if(exp<0 && e<0 && exp+e>0) exp = INT_MIN;
447  else if(exp>0 && e>0 && exp+e<0) exp = INT_MAX;
448  else exp += e;
449  }
450 
451  jsstr_release(val_str);
452 
453  if(ret_nan) {
454  if(r)
455  *r = jsval_number(NAN);
456  return S_OK;
457  }
458 
459  if(!positive)
460  d = -d;
461  if(r)
462  *r = jsval_number(exp>0 ? d*pow(10, exp) : d/pow(10, -exp));
463  return S_OK;
464 }
static size_t double int int int * sign
Definition: printf.c:69
static int argc
Definition: ServiceArgs.c:12
#define TRUE
Definition: types.h:120
#define INT_MAX
Definition: limits.h:40
Definition: jsstr.h:39
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define iswdigit(_c)
Definition: ctype.h:667
#define MAXLONGLONG
static void jsstr_release(jsstr_t *str)
Definition: jsstr.h:110
#define argv
Definition: mplay32.c:18
unsigned int BOOL
Definition: ntddk_ex.h:94
float pow(float __x, int __y)
Definition: _cmath.h:458
#define e
Definition: ke_i.h:82
const WCHAR * str
int64_t LONGLONG
Definition: typedefs.h:66
HRESULT hres
Definition: protocol.c:465
#define d
Definition: ke_i.h:81
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
#define NAN
Definition: misc.c:46
#define iswspace(_c)
Definition: ctype.h:669
#define INT_MIN
Definition: limits.h:39
#define S_OK
Definition: intsafe.h:59
DWORD exp
Definition: msg.c:16038
HRESULT to_flat_string(script_ctx_t *, jsval_t, jsstr_t **, const WCHAR **) DECLSPEC_HIDDEN
Definition: jsutils.c:798
static jsval_t jsval_number(double n)
Definition: jsval.h:144
Definition: unary.h:15

◆ JSGlobal_parseInt()

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

Definition at line 284 of file global.c.

286 {
287  BOOL neg = FALSE, empty = TRUE;
288  const WCHAR *ptr;
289  DOUBLE ret = 0.0;
290  INT radix=0, i;
291  jsstr_t *str;
292  HRESULT hres;
293 
294  if(!argc) {
295  if(r)
296  *r = jsval_number(NAN);
297  return S_OK;
298  }
299 
300  if(argc >= 2) {
301  hres = to_int32(ctx, argv[1], &radix);
302  if(FAILED(hres))
303  return hres;
304 
305  if(radix && (radix < 2 || radix > 36)) {
306  WARN("radix %d out of range\n", radix);
307  if(r)
308  *r = jsval_number(NAN);
309  return S_OK;
310  }
311  }
312 
313  hres = to_flat_string(ctx, argv[0], &str, &ptr);
314  if(FAILED(hres))
315  return hres;
316 
317  while(iswspace(*ptr))
318  ptr++;
319 
320  switch(*ptr) {
321  case '+':
322  ptr++;
323  break;
324  case '-':
325  neg = TRUE;
326  ptr++;
327  break;
328  }
329 
330  if(!radix) {
331  if(*ptr == '0') {
332  if(ptr[1] == 'x' || ptr[1] == 'X') {
333  radix = 16;
334  ptr += 2;
335  }else {
336  radix = 8;
337  ptr++;
338  empty = FALSE;
339  }
340  }else {
341  radix = 10;
342  }
343  }else if(radix == 16 && *ptr == '0' && (ptr[1] == 'x' || ptr[1] == 'X')) {
344  ptr += 2;
345  }
346 
347  i = char_to_int(*ptr++);
348  if(i < radix) {
349  do {
350  ret = ret*radix + i;
351  i = char_to_int(*ptr++);
352  }while(i < radix);
353  }else if(empty) {
354  ret = NAN;
355  }
356 
358 
359  if(neg)
360  ret = -ret;
361 
362  if(r)
363  *r = jsval_number(ret);
364  return S_OK;
365 }
static int argc
Definition: ServiceArgs.c:12
#define TRUE
Definition: types.h:120
Definition: jsstr.h:39
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define WARN(fmt,...)
Definition: debug.h:111
static void jsstr_release(jsstr_t *str)
Definition: jsstr.h:110
#define argv
Definition: mplay32.c:18
int32_t INT
Definition: typedefs.h:56
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
unsigned int BOOL
Definition: ntddk_ex.h:94
static PVOID ptr
Definition: dispmode.c:27
const WCHAR * str
HRESULT to_int32(script_ctx_t *, jsval_t, INT *) DECLSPEC_HIDDEN
Definition: jsutils.c:665
HRESULT hres
Definition: protocol.c:465
static INT char_to_int(WCHAR c)
Definition: global.c:273
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
#define NAN
Definition: misc.c:46
#define iswspace(_c)
Definition: ctype.h:669
int ret
#define S_OK
Definition: intsafe.h:59
BOOL empty
Definition: button.c:170
double DOUBLE
Definition: typedefs.h:68
HRESULT to_flat_string(script_ctx_t *, jsval_t, jsstr_t **, const WCHAR **) DECLSPEC_HIDDEN
Definition: jsutils.c:798
static jsval_t jsval_number(double n)
Definition: jsval.h:144

◆ JSGlobal_ScriptEngine()

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

Definition at line 549 of file global.c.

551 {
552  static const WCHAR JScriptW[] = {'J','S','c','r','i','p','t',0};
553 
554  TRACE("\n");
555 
556  if(r) {
557  jsstr_t *ret;
558 
559  ret = jsstr_alloc(JScriptW);
560  if(!ret)
561  return E_OUTOFMEMORY;
562 
563  *r = jsval_string(ret);
564  }
565 
566  return S_OK;
567 }
static jsstr_t * jsstr_alloc(const WCHAR *str)
Definition: jsstr.h:103
Definition: jsstr.h:39
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
static jsval_t jsval_string(jsstr_t *str)
Definition: jsval.h:109
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
int ret
#define S_OK
Definition: intsafe.h:59

◆ JSGlobal_ScriptEngineBuildVersion()

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

Definition at line 589 of file global.c.

591 {
592  TRACE("\n");
593 
594  if(r)
596  return S_OK;
597 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define JSCRIPT_BUILD_VERSION
Definition: resource.h:25
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59
static jsval_t jsval_number(double n)
Definition: jsval.h:144

◆ JSGlobal_ScriptEngineMajorVersion()

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

Definition at line 569 of file global.c.

571 {
572  TRACE("\n");
573 
574  if(r)
576  return S_OK;
577 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define JSCRIPT_MAJOR_VERSION
Definition: resource.h:23
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59
static jsval_t jsval_number(double n)
Definition: jsval.h:144

◆ JSGlobal_ScriptEngineMinorVersion()

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

Definition at line 579 of file global.c.

581 {
582  TRACE("\n");
583 
584  if(r)
586  return S_OK;
587 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59
#define JSCRIPT_MINOR_VERSION
Definition: resource.h:24
static jsval_t jsval_number(double n)
Definition: jsval.h:144

◆ JSGlobal_unescape()

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

Definition at line 472 of file global.c.

474 {
475  jsstr_t *ret_str, *str;
476  const WCHAR *ptr, *buf;
477  DWORD len = 0;
478  WCHAR *ret;
479  HRESULT hres;
480 
481  TRACE("\n");
482 
483  if(!argc) {
484  if(r)
486  return S_OK;
487  }
488 
489  hres = to_flat_string(ctx, argv[0], &str, &buf);
490  if(FAILED(hres))
491  return hres;
492 
493  for(ptr = buf; *ptr; ptr++) {
494  if(*ptr == '%') {
495  if(hex_to_int(*(ptr+1))!=-1 && hex_to_int(*(ptr+2))!=-1)
496  ptr += 2;
497  else if(*(ptr+1)=='u' && hex_to_int(*(ptr+2))!=-1 && hex_to_int(*(ptr+3))!=-1
498  && hex_to_int(*(ptr+4))!=-1 && hex_to_int(*(ptr+5))!=-1)
499  ptr += 5;
500  }
501 
502  len++;
503  }
504 
505  ret_str = jsstr_alloc_buf(len, &ret);
506  if(!ret_str) {
508  return E_OUTOFMEMORY;
509  }
510 
511  len = 0;
512  for(ptr = buf; *ptr; ptr++) {
513  if(*ptr == '%') {
514  if(hex_to_int(*(ptr+1))!=-1 && hex_to_int(*(ptr+2))!=-1) {
515  ret[len] = (hex_to_int(*(ptr+1))<<4) + hex_to_int(*(ptr+2));
516  ptr += 2;
517  }
518  else if(*(ptr+1)=='u' && hex_to_int(*(ptr+2))!=-1 && hex_to_int(*(ptr+3))!=-1
519  && hex_to_int(*(ptr+4))!=-1 && hex_to_int(*(ptr+5))!=-1) {
520  ret[len] = (hex_to_int(*(ptr+2))<<12) + (hex_to_int(*(ptr+3))<<8)
521  + (hex_to_int(*(ptr+4))<<4) + hex_to_int(*(ptr+5));
522  ptr += 5;
523  }
524  else
525  ret[len] = *ptr;
526  }
527  else
528  ret[len] = *ptr;
529 
530  len++;
531  }
532 
534 
535  if(r)
536  *r = jsval_string(ret_str);
537  else
538  jsstr_release(ret_str);
539  return S_OK;
540 }
static int argc
Definition: ServiceArgs.c:12
jsstr_t * jsstr_undefined(void)
Definition: jsstr.c:293
Definition: jsstr.h:39
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static void jsstr_release(jsstr_t *str)
Definition: jsstr.h:110
#define argv
Definition: mplay32.c:18
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
static PVOID ptr
Definition: dispmode.c:27
const WCHAR * str
static jsval_t jsval_string(jsstr_t *str)
Definition: jsval.h:109
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
GLenum GLsizei len
Definition: glext.h:6722
#define S_OK
Definition: intsafe.h:59
jsstr_t * jsstr_alloc_buf(unsigned len, WCHAR **buf)
Definition: jsstr.c:69
static int hex_to_int(const WCHAR wch)
Definition: global.c:466
HRESULT to_flat_string(script_ctx_t *, jsval_t, jsstr_t **, const WCHAR **) DECLSPEC_HIDDEN
Definition: jsutils.c:798

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( jscript  )

Variable Documentation

◆ _GetObjectW

const WCHAR _GetObjectW[] = {'G','e','t','O','b','j','e','c','t',0}
static

Definition at line 62 of file global.c.

◆ ActiveXObjectW

const WCHAR ActiveXObjectW[] = {'A','c','t','i','v','e','X','O','b','j','e','c','t',0}
static

Definition at line 52 of file global.c.

Referenced by create_activex_constr(), and init_global().

◆ ArrayW

const WCHAR ArrayW[] = {'A','r','r','a','y',0}
static

Definition at line 36 of file global.c.

Referenced by create_array_constr(), and init_constructors().

◆ BooleanW

const WCHAR BooleanW[] = {'B','o','o','l','e','a','n',0}
static

Definition at line 37 of file global.c.

Referenced by create_bool_constr(), Global_TypeName(), and init_constructors().

◆ CollectGarbageW

const WCHAR CollectGarbageW[] = {'C','o','l','l','e','c','t','G','a','r','b','a','g','e',0}
static

Definition at line 70 of file global.c.

◆ DateW

const WCHAR DateW[] = {'D','a','t','e',0}
static

Definition at line 38 of file global.c.

Referenced by create_date_constr(), Global_TypeName(), and init_constructors().

◆ decodeURIComponentW

const WCHAR decodeURIComponentW[] = {'d','e','c','o','d','e','U','R','I','C','o','m','p','o','n','e','n','t',0}
static

Definition at line 76 of file global.c.

◆ decodeURIW

const WCHAR decodeURIW[] = {'d','e','c','o','d','e','U','R','I',0}
static

Definition at line 74 of file global.c.

◆ encodeURIComponentW

const WCHAR encodeURIComponentW[] = {'e','n','c','o','d','e','U','R','I','C','o','m','p','o','n','e','n','t',0}
static

Definition at line 75 of file global.c.

◆ encodeURIW

const WCHAR encodeURIW[] = {'e','n','c','o','d','e','U','R','I',0}
static

Definition at line 73 of file global.c.

◆ EnumeratorW

const WCHAR EnumeratorW[] = {'E','n','u','m','e','r','a','t','o','r',0}
static

Definition at line 54 of file global.c.

Referenced by create_enumerator_constr(), and init_constructors().

◆ ErrorW

const WCHAR ErrorW[] = {'E','r','r','o','r',0}
static

Definition at line 39 of file global.c.

Referenced by init_constructors(), and init_error_constr().

◆ escapeW

const WCHAR escapeW[] = {'e','s','c','a','p','e',0}
static

Definition at line 55 of file global.c.

◆ EvalErrorW

const WCHAR EvalErrorW[] = {'E','v','a','l','E','r','r','o','r',0}
static

Definition at line 40 of file global.c.

Referenced by init_constructors(), and init_error_constr().

◆ evalW

const WCHAR evalW[] = {'e','v','a','l',0}
static

Definition at line 56 of file global.c.

◆ FunctionW

const WCHAR FunctionW[] = {'F','u','n','c','t','i','o','n',0}
static

Definition at line 46 of file global.c.

Referenced by init_constructors(), and init_function_constr().

◆ InfinityW

const WCHAR InfinityW[] = {'I','n','f','i','n','i','t','y',0}
static

Definition at line 35 of file global.c.

Referenced by double_to_string(), and init_global().

◆ isFiniteW

const WCHAR isFiniteW[] = {'i','s','F','i','n','i','t','e',0}
static

Definition at line 58 of file global.c.

◆ isNaNW

const WCHAR isNaNW[] = {'i','s','N','a','N',0}
static

Definition at line 57 of file global.c.

◆ JSGlobal_info

const builtin_info_t JSGlobal_info
static
Initial value:
= {
{NULL, NULL, 0},
}
smooth NULL
Definition: ftsmooth.c:416
static const builtin_prop_t JSGlobal_props[]
Definition: global.c:935
#define ARRAY_SIZE(a)
Definition: main.h:24

Definition at line 955 of file global.c.

Referenced by init_global().

◆ JSGlobal_props

const builtin_prop_t JSGlobal_props[]
static
Initial value:
= {
}
static const WCHAR decodeURIW[]
Definition: global.c:74
static const WCHAR _GetObjectW[]
Definition: global.c:62
static const WCHAR ScriptEngineW[]
Definition: global.c:63
static const WCHAR escapeW[]
Definition: global.c:55
static const WCHAR encodeURIW[]
Definition: global.c:73
static HRESULT JSGlobal_parseInt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: global.c:284
static const WCHAR ScriptEngineMinorVersionW[]
Definition: global.c:66
static const WCHAR isNaNW[]
Definition: global.c:57
HRESULT JSGlobal_eval(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: global.c:183
static const WCHAR unescapeW[]
Definition: global.c:61
static HRESULT JSGlobal_ScriptEngineBuildVersion(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: global.c:589
static HRESULT JSGlobal_encodeURIComponent(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: global.c:759
static HRESULT JSGlobal_ScriptEngineMinorVersion(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: global.c:579
static const WCHAR ScriptEngineBuildVersionW[]
Definition: global.c:68
static const WCHAR CollectGarbageW[]
Definition: global.c:70
static HRESULT JSGlobal_parseFloat(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: global.c:367
static const WCHAR ScriptEngineMajorVersionW[]
Definition: global.c:64
static HRESULT JSGlobal_unescape(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: global.c:472
static HRESULT JSGlobal_decodeURIComponent(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: global.c:823
static const WCHAR isFiniteW[]
Definition: global.c:58
static HRESULT JSGlobal_CollectGarbage(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: global.c:599
static HRESULT JSGlobal_ScriptEngineMajorVersion(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: global.c:569
static const WCHAR evalW[]
Definition: global.c:56
static HRESULT JSGlobal_escape(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: global.c:118
static HRESULT JSGlobal_isFinite(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: global.c:250
static const WCHAR parseFloatW[]
Definition: global.c:60
static HRESULT JSGlobal_encodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: global.c:608
static HRESULT JSGlobal_isNaN(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: global.c:227
#define PROPF_METHOD
Definition: jscript.h:97
static HRESULT JSGlobal_decodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: global.c:673
static HRESULT JSGlobal_GetObject(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: global.c:542
static const WCHAR encodeURIComponentW[]
Definition: global.c:75
static HRESULT JSGlobal_ScriptEngine(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: global.c:549
static const WCHAR decodeURIComponentW[]
Definition: global.c:76
static const WCHAR parseIntW[]
Definition: global.c:59

Definition at line 935 of file global.c.

◆ JSONW

const WCHAR JSONW[] = {'J','S','O','N',0}
static

Definition at line 72 of file global.c.

Referenced by init_global().

◆ MathW

const WCHAR MathW[] = {'M','a','t','h',0}
static

Definition at line 71 of file global.c.

Referenced by init_global().

◆ NaNW

const WCHAR NaNW[] = {'N','a','N',0}
static

Definition at line 34 of file global.c.

Referenced by init_global(), and init_strings().

◆ NumberW

const WCHAR NumberW[] = {'N','u','m','b','e','r',0}
static

Definition at line 47 of file global.c.

Referenced by create_number_constr(), and init_constructors().

◆ ObjectW

const WCHAR ObjectW[] = {'O','b','j','e','c','t',0}
static

Definition at line 48 of file global.c.

Referenced by create_object_constr(), and init_constructors().

◆ parseFloatW

const WCHAR parseFloatW[] = {'p','a','r','s','e','F','l','o','a','t',0}
static

Definition at line 60 of file global.c.

◆ parseIntW

const WCHAR parseIntW[] = {'p','a','r','s','e','I','n','t',0}
static

Definition at line 59 of file global.c.

◆ RangeErrorW

const WCHAR RangeErrorW[] = {'R','a','n','g','e','E','r','r','o','r',0}
static

Definition at line 41 of file global.c.

Referenced by init_constructors(), and init_error_constr().

◆ ReferenceErrorW

const WCHAR ReferenceErrorW[] = {'R','e','f','e','r','e','n','c','e','E','r','r','o','r',0}
static

Definition at line 42 of file global.c.

Referenced by init_constructors(), and init_error_constr().

◆ RegExpErrorW

const WCHAR RegExpErrorW[] = {'R','e','g','E','x','p','E','r','r','o','r',0}
static

Definition at line 51 of file global.c.

Referenced by init_constructors(), and init_error_constr().

◆ RegExpW

const WCHAR RegExpW[] = {'R','e','g','E','x','p',0}
static

Definition at line 50 of file global.c.

Referenced by create_regexp_constr(), and init_constructors().

◆ ScriptEngineBuildVersionW

const WCHAR ScriptEngineBuildVersionW[]
static
Initial value:
=
{'S','c','r','i','p','t','E','n','g','i','n','e','B','u','i','l','d','V','e','r','s','i','o','n',0}

Definition at line 68 of file global.c.

◆ ScriptEngineMajorVersionW

const WCHAR ScriptEngineMajorVersionW[]
static
Initial value:
=
{'S','c','r','i','p','t','E','n','g','i','n','e','M','a','j','o','r','V','e','r','s','i','o','n',0}

Definition at line 64 of file global.c.

◆ ScriptEngineMinorVersionW

const WCHAR ScriptEngineMinorVersionW[]
static
Initial value:
=
{'S','c','r','i','p','t','E','n','g','i','n','e','M','i','n','o','r','V','e','r','s','i','o','n',0}

Definition at line 66 of file global.c.

◆ ScriptEngineW

const WCHAR ScriptEngineW[] = {'S','c','r','i','p','t','E','n','g','i','n','e',0}
static

Definition at line 63 of file global.c.

◆ StringW

const WCHAR StringW[] = {'S','t','r','i','n','g',0}
static

◆ SyntaxErrorW

const WCHAR SyntaxErrorW[] = {'S','y','n','t','a','x','E','r','r','o','r',0}
static

Definition at line 43 of file global.c.

Referenced by init_constructors(), and init_error_constr().

◆ TypeErrorW

const WCHAR TypeErrorW[] = {'T','y','p','e','E','r','r','o','r',0}
static

Definition at line 44 of file global.c.

Referenced by init_constructors(), and init_error_constr().

◆ undefinedW

const WCHAR undefinedW[] = {'u','n','d','e','f','i','n','e','d',0}
static

Definition at line 78 of file global.c.

Referenced by init_global().

◆ unescapeW

const WCHAR unescapeW[] = {'u','n','e','s','c','a','p','e',0}
static

Definition at line 61 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 80 of file global.c.

Referenced by is_uri_reserved(), and is_uri_unescaped().

◆ URIErrorW

const WCHAR URIErrorW[] = {'U','R','I','E','r','r','o','r',0}
static

Definition at line 45 of file global.c.

Referenced by init_constructors(), and init_error_constr().

◆ VBArrayW

const WCHAR VBArrayW[] = {'V','B','A','r','r','a','y',0}
static

Definition at line 53 of file global.c.

Referenced by create_vbarray_constr(), and init_constructors().