ReactOS  0.4.13-dev-563-g0561610
global.c File Reference
#include "config.h"
#include "wine/port.h"
#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_Enumerator (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
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 283 of file global.c.

284 {
285  if('0' <= c && c <= '9')
286  return c - '0';
287  if('a' <= c && c <= 'z')
288  return c - 'a' + 10;
289  if('A' <= c && c <= 'Z')
290  return c - 'A' + 10;
291  return 100;
292 }
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 474 of file global.c.

474  {
475  if(toupperW(wch)>='A' && toupperW(wch)<='F') return toupperW(wch)-'A'+10;
476  if(isdigitW(wch)) return wch-'0';
477  return -1;
478 }
WINE_UNICODE_INLINE WCHAR toupperW(WCHAR ch)
Definition: unicode.h:141
WINE_UNICODE_INLINE int isdigitW(WCHAR wc)
Definition: unicode.h:170

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 973 of file global.c.

974 {
975  HRESULT hres;
976 
977  hres = init_function_constr(ctx, object_prototype);
978  if(FAILED(hres))
979  return hres;
980 
982  jsval_obj(ctx->function_constr));
983  if(FAILED(hres))
984  return hres;
985 
986  hres = create_object_constr(ctx, object_prototype, &ctx->object_constr);
987  if(FAILED(hres))
988  return hres;
989 
991  jsval_obj(ctx->object_constr));
992  if(FAILED(hres))
993  return hres;
994 
995  hres = create_array_constr(ctx, object_prototype, &ctx->array_constr);
996  if(FAILED(hres))
997  return hres;
998 
1000  jsval_obj(ctx->array_constr));
1001  if(FAILED(hres))
1002  return hres;
1003 
1004  hres = create_bool_constr(ctx, object_prototype, &ctx->bool_constr);
1005  if(FAILED(hres))
1006  return hres;
1007 
1009  jsval_obj(ctx->bool_constr));
1010  if(FAILED(hres))
1011  return hres;
1012 
1013  hres = create_date_constr(ctx, object_prototype, &ctx->date_constr);
1014  if(FAILED(hres))
1015  return hres;
1016 
1018  jsval_obj(ctx->date_constr));
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:98
jsdisp_t * bool_constr
Definition: jscript.h:439
static const WCHAR DateW[]
Definition: global.c:36
static const WCHAR NumberW[]
Definition: global.c:45
static const WCHAR RangeErrorW[]
Definition: global.c:39
jsdisp_t * vbarray_constr
Definition: jscript.h:453
HRESULT create_object_constr(script_ctx_t *, jsdisp_t *, jsdisp_t **) DECLSPEC_HIDDEN
Definition: object.c:584
jsdisp_t * reference_error_constr
Definition: jscript.h:444
static const WCHAR EvalErrorW[]
Definition: global.c:38
jsdisp_t * array_constr
Definition: jscript.h:438
jsdisp_t * type_error_constr
Definition: jscript.h:447
jsdisp_t * range_error_constr
Definition: jscript.h:443
static const WCHAR ObjectW[]
Definition: global.c:46
HRESULT jsdisp_define_data_property(jsdisp_t *obj, const WCHAR *name, unsigned flags, jsval_t value)
Definition: dispex.c:1794
HRESULT create_number_constr(script_ctx_t *, jsdisp_t *, jsdisp_t **) DECLSPEC_HIDDEN
Definition: number.c:613
jsdisp_t * string_constr
Definition: jscript.h:452
static const WCHAR BooleanW[]
Definition: global.c:35
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:446
jsdisp_t * error_constr
Definition: jscript.h:441
jsdisp_t * regexp_error_constr
Definition: jscript.h:445
jsdisp_t * number_constr
Definition: jscript.h:449
HRESULT create_vbarray_constr(script_ctx_t *, jsdisp_t *, jsdisp_t **) DECLSPEC_HIDDEN
Definition: vbarray.c:330
static const WCHAR ErrorW[]
Definition: global.c:37
jsdisp_t * regexp_constr
Definition: jscript.h:451
HRESULT init_error_constr(script_ctx_t *ctx, jsdisp_t *object_prototype)
Definition: error.c:326
static const WCHAR TypeErrorW[]
Definition: global.c:42
HRESULT hres
Definition: protocol.c:465
static const WCHAR SyntaxErrorW[]
Definition: global.c:41
LONG HRESULT
Definition: typedefs.h:77
static const WCHAR ArrayW[]
Definition: global.c:34
static const WCHAR URIErrorW[]
Definition: global.c:43
jsdisp_t * object_constr
Definition: jscript.h:450
static const WCHAR ReferenceErrorW[]
Definition: global.c:40
static const WCHAR VBArrayW[]
Definition: global.c:51
static const WCHAR StringW[]
Definition: global.c:47
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:853
#define S_OK
Definition: intsafe.h:59
jsdisp_t * function_constr
Definition: jscript.h:437
HRESULT create_date_constr(script_ctx_t *ctx, jsdisp_t *object_prototype, jsdisp_t **ret)
Definition: date.c:2531
static const WCHAR FunctionW[]
Definition: global.c:44
HRESULT create_string_constr(script_ctx_t *, jsdisp_t *, jsdisp_t **) DECLSPEC_HIDDEN
Definition: string.c:1750
jsdisp_t * date_constr
Definition: jscript.h:440
jsdisp_t * global
Definition: jscript.h:436
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:1293
jsdisp_t * eval_error_constr
Definition: jscript.h:442
static const WCHAR RegExpW[]
Definition: global.c:48
jsdisp_t * uri_error_constr
Definition: jscript.h:448
static const WCHAR RegExpErrorW[]
Definition: global.c:49

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:98
HRESULT jsdisp_define_data_property(jsdisp_t *obj, const WCHAR *name, unsigned flags, jsval_t value)
Definition: dispex.c:1794
static const WCHAR undefinedW[]
Definition: global.c:76
HRESULT create_math(script_ctx_t *, jsdisp_t **) DECLSPEC_HIDDEN
Definition: math.c:531
HRESULT create_json(script_ctx_t *, jsdisp_t **) DECLSPEC_HIDDEN
Definition: json.c:845
smooth NULL
Definition: ftsmooth.c:416
DWORD version
Definition: jscript.h:415
HRESULT create_object_prototype(script_ctx_t *, jsdisp_t **) DECLSPEC_HIDDEN
Definition: object.c:592
static const WCHAR NaNW[]
Definition: global.c:32
static const builtin_info_t JSGlobal_info
Definition: global.c:964
HRESULT hres
Definition: protocol.c:465
static HRESULT init_constructors(script_ctx_t *ctx, jsdisp_t *object_prototype)
Definition: global.c:973
static const WCHAR ActiveXObjectW[]
Definition: global.c:50
LONG HRESULT
Definition: typedefs.h:77
#define NAN
Definition: misc.c:46
#define SCRIPTLANGUAGEVERSION_ES5
Definition: jscript.h:49
static jsval_t jsval_undefined(void)
Definition: jsval.h:137
#define S_OK
Definition: intsafe.h:59
static const WCHAR JSONW[]
Definition: global.c:70
HRESULT create_dispex(script_ctx_t *ctx, const builtin_info_t *builtin_info, jsdisp_t *prototype, jsdisp_t **dispex)
Definition: dispex.c:978
static const WCHAR MathW[]
Definition: global.c:69
static void jsdisp_release(jsdisp_t *jsdisp)
Definition: jscript.h:264
static const WCHAR InfinityW[]
Definition: global.c:33
jsdisp_t * global
Definition: jscript.h:436
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:190
#define INFINITY
Definition: misc.c:36
static jsval_t jsval_number(double n)
Definition: jsval.h:144

Referenced by set_ctx_site().

◆ int_to_char()

static WCHAR int_to_char ( int  i)
static

Definition at line 109 of file global.c.

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

104 {
105  return ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') ||
106  c == '@' || c == '*' || c == '_' || c == '+' || c == '-' || c == '.' || c == '/');
107 }
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 92 of file global.c.

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

Referenced by JSGlobal_encodeURI().

◆ is_uri_unescaped()

static BOOL is_uri_unescaped ( WCHAR  c)
inlinestatic

Definition at line 97 of file global.c.

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

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 607 of file global.c.

609 {
610  static int once = 0;
611  if (!once++)
612  FIXME(": stub\n");
613  return S_OK;
614 }
#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 681 of file global.c.

683 {
684  const WCHAR *ptr, *uri;
685  jsstr_t *str, *ret_str;
686  unsigned len = 0;
687  int i, val, res;
688  WCHAR *ret;
689  char buf[4];
690  WCHAR out;
691  HRESULT hres;
692 
693  TRACE("\n");
694 
695  if(!argc) {
696  if(r)
698  return S_OK;
699  }
700 
701  hres = to_flat_string(ctx, argv[0], &str, &uri);
702  if(FAILED(hres))
703  return hres;
704 
705  for(ptr = uri; *ptr; ptr++) {
706  if(*ptr != '%') {
707  len++;
708  }else {
709  res = 0;
710  for(i=0; i<4; i++) {
711  if(ptr[i*3]!='%' || hex_to_int(ptr[i*3+1])==-1 || (val=hex_to_int(ptr[i*3+2]))==-1)
712  break;
713  val += hex_to_int(ptr[i*3+1])<<4;
714  buf[i] = val;
715 
716  res = MultiByteToWideChar(CP_UTF8, 0, buf, i+1, &out, 1);
717  if(res)
718  break;
719  }
720 
721  if(!res) {
724  }
725 
726  ptr += i*3+2;
727  len++;
728  }
729  }
730 
731  ret_str = jsstr_alloc_buf(len, &ret);
732  if(!ret_str) {
734  return E_OUTOFMEMORY;
735  }
736 
737  for(ptr = uri; *ptr; ptr++) {
738  if(*ptr != '%') {
739  *ret++ = *ptr;
740  }else {
741  for(i=0; i<4; i++) {
742  if(ptr[i*3]!='%' || hex_to_int(ptr[i*3+1])==-1 || (val=hex_to_int(ptr[i*3+2]))==-1)
743  break;
744  val += hex_to_int(ptr[i*3+1])<<4;
745  buf[i] = val;
746 
747  res = MultiByteToWideChar(CP_UTF8, 0, buf, i+1, ret, 1);
748  if(res)
749  break;
750  }
751 
752  ptr += i*3+2;
753  ret++;
754  }
755  }
756 
757  TRACE("%s -> %s\n", debugstr_jsstr(str), debugstr_jsstr(ret_str));
759 
760  if(r)
761  *r = jsval_string(ret_str);
762  else
763  jsstr_release(ret_str);
764  return S_OK;
765 }
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:443
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:474
HRESULT to_flat_string(script_ctx_t *, jsval_t, jsstr_t **, const WCHAR **) DECLSPEC_HIDDEN
Definition: jsutils.c:790

◆ 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 831 of file global.c.

833 {
834  const WCHAR *ptr, *uri;
835  jsstr_t *str, *ret;
836  WCHAR *out_ptr;
837  DWORD len = 0;
838  HRESULT hres;
839 
840  TRACE("\n");
841 
842  if(!argc) {
843  if(r)
845  return S_OK;
846  }
847 
848  hres = to_flat_string(ctx, argv[0], &str, &uri);
849  if(FAILED(hres))
850  return hres;
851 
852  ptr = uri;
853  while(*ptr) {
854  if(*ptr == '%') {
855  char octets[4];
856  unsigned char mask = 0x80;
857  int i, size, num_bytes = 0;
858  if(hex_to_int(*(ptr+1)) < 0 || hex_to_int(*(ptr+2)) < 0) {
859  FIXME("Throw URIError: Invalid hex sequence\n");
861  return E_FAIL;
862  }
863  octets[0] = (hex_to_int(*(ptr+1)) << 4) + hex_to_int(*(ptr+2));
864  ptr += 3;
865  while(octets[0] & mask) {
866  mask = mask >> 1;
867  ++num_bytes;
868  }
869  if(num_bytes == 1 || num_bytes > 4) {
870  FIXME("Throw URIError: Invalid initial UTF character\n");
872  return E_FAIL;
873  }
874  for(i = 1; i < num_bytes; ++i) {
875  if(*ptr != '%'){
876  FIXME("Throw URIError: Incomplete UTF sequence\n");
878  return E_FAIL;
879  }
880  if(hex_to_int(*(ptr+1)) < 0 || hex_to_int(*(ptr+2)) < 0) {
881  FIXME("Throw URIError: Invalid hex sequence\n");
883  return E_FAIL;
884  }
885  octets[i] = (hex_to_int(*(ptr+1)) << 4) + hex_to_int(*(ptr+2));
886  ptr += 3;
887  }
889  num_bytes ? num_bytes : 1, NULL, 0);
890  if(size == 0) {
891  FIXME("Throw URIError: Invalid UTF sequence\n");
893  return E_FAIL;
894  }
895  len += size;
896  }else {
897  ++ptr;
898  ++len;
899  }
900  }
901 
902  ret = jsstr_alloc_buf(len, &out_ptr);
903  if(!ret) {
905  return E_OUTOFMEMORY;
906  }
907 
908  ptr = uri;
909  while(*ptr) {
910  if(*ptr == '%') {
911  char octets[4];
912  unsigned char mask = 0x80;
913  int i, size, num_bytes = 0;
914  octets[0] = (hex_to_int(*(ptr+1)) << 4) + hex_to_int(*(ptr+2));
915  ptr += 3;
916  while(octets[0] & mask) {
917  mask = mask >> 1;
918  ++num_bytes;
919  }
920  for(i = 1; i < num_bytes; ++i) {
921  octets[i] = (hex_to_int(*(ptr+1)) << 4) + hex_to_int(*(ptr+2));
922  ptr += 3;
923  }
925  num_bytes ? num_bytes : 1, out_ptr, len);
926  len -= size;
927  out_ptr += size;
928  }else {
929  *out_ptr++ = *ptr++;
930  --len;
931  }
932  }
933 
935 
936  if(r)
937  *r = jsval_string(ret);
938  else
940  return S_OK;
941 }
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:2854
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:474
HRESULT to_flat_string(script_ctx_t *, jsval_t, jsstr_t **, const WCHAR **) DECLSPEC_HIDDEN
Definition: jsutils.c:790

◆ 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 616 of file global.c.

618 {
619  const WCHAR *ptr, *uri;
620  jsstr_t *str, *ret;
621  DWORD len = 0, i;
622  char buf[4];
623  WCHAR *rptr;
624  HRESULT hres;
625 
626  TRACE("\n");
627 
628  if(!argc) {
629  if(r)
631  return S_OK;
632  }
633 
634  hres = to_flat_string(ctx, argv[0], &str, &uri);
635  if(FAILED(hres))
636  return hres;
637 
638  for(ptr = uri; *ptr; ptr++) {
639  if(is_uri_unescaped(*ptr) || is_uri_reserved(*ptr) || *ptr == '#') {
640  len++;
641  }else {
642  i = WideCharToMultiByte(CP_UTF8, 0, ptr, 1, NULL, 0, NULL, NULL)*3;
643  if(!i) {
646  }
647 
648  len += i;
649  }
650  }
651 
652  ret = jsstr_alloc_buf(len, &rptr);
653  if(!ret) {
655  return E_OUTOFMEMORY;
656  }
657 
658  for(ptr = uri; *ptr; ptr++) {
659  if(is_uri_unescaped(*ptr) || is_uri_reserved(*ptr) || *ptr == '#') {
660  *rptr++ = *ptr;
661  }else {
662  len = WideCharToMultiByte(CP_UTF8, 0, ptr, 1, buf, sizeof(buf), NULL, NULL);
663  for(i=0; i<len; i++) {
664  *rptr++ = '%';
665  *rptr++ = int_to_char((BYTE)buf[i] >> 4);
666  *rptr++ = int_to_char(buf[i] & 0x0f);
667  }
668  }
669  }
670 
671  TRACE("%s -> %s\n", debugstr_jsstr(str), debugstr_jsstr(ret));
673 
674  if(r)
675  *r = jsval_string(ret);
676  else
678  return S_OK;
679 }
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:92
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:443
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:109
jsstr_t * jsstr_alloc_buf(unsigned len, WCHAR **buf)
Definition: jsstr.c:69
static BOOL is_uri_unescaped(WCHAR c)
Definition: global.c:97
HRESULT to_flat_string(script_ctx_t *, jsval_t, jsstr_t **, const WCHAR **) DECLSPEC_HIDDEN
Definition: jsutils.c:790

◆ 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 767 of file global.c.

769 {
770  jsstr_t *str, *ret_str;
771  char buf[4];
772  const WCHAR *ptr, *uri;
773  DWORD len = 0, size, i;
774  WCHAR *ret;
775  HRESULT hres;
776 
777  TRACE("\n");
778 
779  if(!argc) {
780  if(r)
782  return S_OK;
783  }
784 
785  hres = to_flat_string(ctx, argv[0], &str, &uri);
786  if(FAILED(hres))
787  return hres;
788 
789  for(ptr = uri; *ptr; ptr++) {
790  if(is_uri_unescaped(*ptr))
791  len++;
792  else {
793  size = WideCharToMultiByte(CP_UTF8, 0, ptr, 1, NULL, 0, NULL, NULL);
794  if(!size) {
797  }
798  len += size*3;
799  }
800  }
801 
802  ret_str = jsstr_alloc_buf(len, &ret);
803  if(!ret_str) {
805  return E_OUTOFMEMORY;
806  }
807 
808  for(ptr = uri; *ptr; ptr++) {
809  if(is_uri_unescaped(*ptr)) {
810  *ret++ = *ptr;
811  }else {
812  size = WideCharToMultiByte(CP_UTF8, 0, ptr, 1, buf, sizeof(buf), NULL, NULL);
813  for(i=0; i<size; i++) {
814  *ret++ = '%';
815  *ret++ = int_to_char((BYTE)buf[i] >> 4);
816  *ret++ = int_to_char(buf[i] & 0x0f);
817  }
818  }
819  }
820 
822 
823  if(r)
824  *r = jsval_string(ret_str);
825  else
826  jsstr_release(ret_str);
827  return S_OK;
828 }
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:443
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:109
jsstr_t * jsstr_alloc_buf(unsigned len, WCHAR **buf)
Definition: jsstr.c:69
static BOOL is_uri_unescaped(WCHAR c)
Definition: global.c:97
HRESULT to_flat_string(script_ctx_t *, jsval_t, jsstr_t **, const WCHAR **) DECLSPEC_HIDDEN
Definition: jsutils.c:790

◆ JSGlobal_Enumerator()

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

Definition at line 116 of file global.c.

118 {
119  FIXME("\n");
120  return E_NOTIMPL;
121 }
#define FIXME(fmt,...)
Definition: debug.h:110
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ 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 123 of file global.c.

125 {
126  jsstr_t *ret_str, *str;
127  const WCHAR *ptr, *buf;
128  DWORD len = 0;
129  WCHAR *ret;
130  HRESULT hres;
131 
132  TRACE("\n");
133 
134  if(!argc) {
135  if(r)
137  return S_OK;
138  }
139 
140  hres = to_flat_string(ctx, argv[0], &str, &buf);
141  if(FAILED(hres))
142  return hres;
143 
144  for(ptr = buf; *ptr; ptr++) {
145  if(*ptr > 0xff)
146  len += 6;
147  else if(is_ecma_nonblank(*ptr))
148  len++;
149  else
150  len += 3;
151  }
152 
153  ret_str = jsstr_alloc_buf(len, &ret);
154  if(!ret_str) {
156  return E_OUTOFMEMORY;
157  }
158 
159  len = 0;
160  for(ptr = buf; *ptr; ptr++) {
161  if(*ptr > 0xff) {
162  ret[len++] = '%';
163  ret[len++] = 'u';
164  ret[len++] = int_to_char(*ptr >> 12);
165  ret[len++] = int_to_char((*ptr >> 8) & 0xf);
166  ret[len++] = int_to_char((*ptr >> 4) & 0xf);
167  ret[len++] = int_to_char(*ptr & 0xf);
168  }
169  else if(is_ecma_nonblank(*ptr))
170  ret[len++] = *ptr;
171  else {
172  ret[len++] = '%';
173  ret[len++] = int_to_char(*ptr >> 4);
174  ret[len++] = int_to_char(*ptr & 0xf);
175  }
176  }
177 
179 
180  if(r)
181  *r = jsval_string(ret_str);
182  else
183  jsstr_release(ret_str);
184  return S_OK;
185 }
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:103
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:109
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:790

◆ 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 188 of file global.c.

190 {
191  call_frame_t *frame;
192  DWORD exec_flags = EXEC_EVAL;
193  bytecode_t *code;
194  const WCHAR *src;
195  HRESULT hres;
196 
197  TRACE("\n");
198 
199  if(!argc) {
200  if(r)
201  *r = jsval_undefined();
202  return S_OK;
203  }
204 
205  if(!is_string(argv[0])) {
206  if(r)
207  return jsval_copy(argv[0], r);
208  return S_OK;
209  }
210 
211  if(!(frame = ctx->call_ctx)) {
212  FIXME("No active exec_ctx\n");
213  return E_UNEXPECTED;
214  }
215 
217  if(!src)
218  return E_OUTOFMEMORY;
219 
220  TRACE("parsing %s\n", debugstr_jsval(argv[0]));
221  hres = compile_script(ctx, src, NULL, NULL, TRUE, FALSE, &code);
222  if(FAILED(hres)) {
223  WARN("parse (%s) failed: %08x\n", debugstr_jsval(argv[0]), hres);
224  return throw_syntax_error(ctx, hres, NULL);
225  }
226 
227  if(frame->flags & EXEC_GLOBAL)
228  exec_flags |= EXEC_GLOBAL;
230  exec_flags |= EXEC_RETURN_TO_INTERP;
231  hres = exec_source(ctx, exec_flags, code, &code->global_code, frame->scope,
232  frame->this_obj, NULL, frame->variable_obj, 0, NULL, r);
234  return hres;
235 }
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:410
static BOOL is_string(parse_buffer *buf)
Definition: parsing.c:601
#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
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
HRESULT jsval_copy(jsval_t v, jsval_t *r)
Definition: jsutils.c:229
static jsstr_t * get_string(jsval_t v)
Definition: jsval.h:229
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
HRESULT throw_syntax_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:433
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:2458
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:2952
#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:112
#define E_UNEXPECTED
Definition: winerror.h:2456
void release_bytecode(bytecode_t *code)
Definition: compile.c:2223
const char * debugstr_jsval(const jsval_t) DECLSPEC_HIDDEN
Definition: jsutils.c:33

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 550 of file global.c.

552 {
553  FIXME("\n");
554  return E_NOTIMPL;
555 }
#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 260 of file global.c.

262 {
263  BOOL ret = FALSE;
264  HRESULT hres;
265 
266  TRACE("\n");
267 
268  if(argc) {
269  double n;
270 
271  hres = to_number(ctx, argv[0], &n);
272  if(FAILED(hres))
273  return hres;
274 
275  ret = is_finite(n);
276  }
277 
278  if(r)
279  *r = jsval_bool(ret);
280  return S_OK;
281 }
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:601
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:56
#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 237 of file global.c.

239 {
240  BOOL ret = TRUE;
241  double n;
242  HRESULT hres;
243 
244  TRACE("\n");
245 
246  if(argc) {
247  hres = to_number(ctx, argv[0], &n);
248  if(FAILED(hres))
249  return hres;
250 
251  if(!isnan(n))
252  ret = FALSE;
253  }
254 
255  if(r)
256  *r = jsval_bool(ret);
257  return S_OK;
258 }
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:601
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 375 of file global.c.

377 {
378  LONGLONG d = 0, hlp;
379  jsstr_t *val_str;
380  int exp = 0;
381  const WCHAR *str;
382  BOOL ret_nan = TRUE, positive = TRUE;
383  HRESULT hres;
384 
385  if(!argc) {
386  if(r)
387  *r = jsval_number(NAN);
388  return S_OK;
389  }
390 
391  hres = to_flat_string(ctx, argv[0], &val_str, &str);
392  if(FAILED(hres))
393  return hres;
394 
395  while(isspaceW(*str)) str++;
396 
397  if(*str == '+')
398  str++;
399  else if(*str == '-') {
400  positive = FALSE;
401  str++;
402  }
403 
404  if(isdigitW(*str))
405  ret_nan = FALSE;
406 
407  while(isdigitW(*str)) {
408  hlp = d*10 + *(str++) - '0';
409  if(d>MAXLONGLONG/10 || hlp<0) {
410  exp++;
411  break;
412  }
413  else
414  d = hlp;
415  }
416  while(isdigitW(*str)) {
417  exp++;
418  str++;
419  }
420 
421  if(*str == '.') str++;
422 
423  if(isdigitW(*str))
424  ret_nan = FALSE;
425 
426  while(isdigitW(*str)) {
427  hlp = d*10 + *(str++) - '0';
428  if(d>MAXLONGLONG/10 || hlp<0)
429  break;
430 
431  d = hlp;
432  exp--;
433  }
434  while(isdigitW(*str))
435  str++;
436 
437  if(*str && !ret_nan && (*str=='e' || *str=='E')) {
438  int sign = 1, e = 0;
439 
440  str++;
441  if(*str == '+')
442  str++;
443  else if(*str == '-') {
444  sign = -1;
445  str++;
446  }
447 
448  while(isdigitW(*str)) {
449  if(e>INT_MAX/10 || (e = e*10 + *str++ - '0')<0)
450  e = INT_MAX;
451  }
452  e *= sign;
453 
454  if(exp<0 && e<0 && exp+e>0) exp = INT_MIN;
455  else if(exp>0 && e>0 && exp+e<0) exp = INT_MAX;
456  else exp += e;
457  }
458 
459  jsstr_release(val_str);
460 
461  if(ret_nan) {
462  if(r)
463  *r = jsval_number(NAN);
464  return S_OK;
465  }
466 
467  if(!positive)
468  d = -d;
469  if(r)
470  *r = jsval_number(exp>0 ? d*pow(10, exp) : d/pow(10, -exp));
471  return S_OK;
472 }
static size_t double int int int * sign
Definition: printf.c:64
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
WINE_UNICODE_INLINE int isspaceW(WCHAR wc)
Definition: unicode.h:165
#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 INT_MIN
Definition: limits.h:39
#define S_OK
Definition: intsafe.h:59
WINE_UNICODE_INLINE int isdigitW(WCHAR wc)
Definition: unicode.h:170
DWORD exp
Definition: msg.c:15681
HRESULT to_flat_string(script_ctx_t *, jsval_t, jsstr_t **, const WCHAR **) DECLSPEC_HIDDEN
Definition: jsutils.c:790
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 294 of file global.c.

296 {
297  BOOL neg = FALSE, empty = TRUE;
298  const WCHAR *ptr;
299  DOUBLE ret = 0.0;
300  INT radix=0, i;
301  jsstr_t *str;
302  HRESULT hres;
303 
304  if(!argc) {
305  if(r)
306  *r = jsval_number(NAN);
307  return S_OK;
308  }
309 
310  if(argc >= 2) {
311  hres = to_int32(ctx, argv[1], &radix);
312  if(FAILED(hres))
313  return hres;
314 
315  if(radix && (radix < 2 || radix > 36)) {
316  WARN("radix %d out of range\n", radix);
317  if(r)
318  *r = jsval_number(NAN);
319  return S_OK;
320  }
321  }
322 
323  hres = to_flat_string(ctx, argv[0], &str, &ptr);
324  if(FAILED(hres))
325  return hres;
326 
327  while(isspaceW(*ptr))
328  ptr++;
329 
330  switch(*ptr) {
331  case '+':
332  ptr++;
333  break;
334  case '-':
335  neg = TRUE;
336  ptr++;
337  break;
338  }
339 
340  if(!radix) {
341  if(*ptr == '0') {
342  if(ptr[1] == 'x' || ptr[1] == 'X') {
343  radix = 16;
344  ptr += 2;
345  }else {
346  radix = 8;
347  ptr++;
348  empty = FALSE;
349  }
350  }else {
351  radix = 10;
352  }
353  }
354 
355  i = char_to_int(*ptr++);
356  if(i < radix) {
357  do {
358  ret = ret*radix + i;
359  i = char_to_int(*ptr++);
360  }while(i < radix);
361  }else if(empty) {
362  ret = NAN;
363  }
364 
366 
367  if(neg)
368  ret = -ret;
369 
370  if(r)
371  *r = jsval_number(ret);
372  return S_OK;
373 }
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
static const WCHAR empty[]
Definition: main.c:49
WINE_UNICODE_INLINE int isspaceW(WCHAR wc)
Definition: unicode.h:165
#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:657
HRESULT hres
Definition: protocol.c:465
static INT char_to_int(WCHAR c)
Definition: global.c:283
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
#define NAN
Definition: misc.c:46
int ret
#define S_OK
Definition: intsafe.h:59
double DOUBLE
Definition: typedefs.h:68
HRESULT to_flat_string(script_ctx_t *, jsval_t, jsstr_t **, const WCHAR **) DECLSPEC_HIDDEN
Definition: jsutils.c:790
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 557 of file global.c.

559 {
560  static const WCHAR JScriptW[] = {'J','S','c','r','i','p','t',0};
561 
562  TRACE("\n");
563 
564  if(r) {
565  jsstr_t *ret;
566 
567  ret = jsstr_alloc(JScriptW);
568  if(!ret)
569  return E_OUTOFMEMORY;
570 
571  *r = jsval_string(ret);
572  }
573 
574  return S_OK;
575 }
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 597 of file global.c.

599 {
600  TRACE("\n");
601 
602  if(r)
604  return S_OK;
605 }
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 577 of file global.c.

579 {
580  TRACE("\n");
581 
582  if(r)
584  return S_OK;
585 }
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 587 of file global.c.

589 {
590  TRACE("\n");
591 
592  if(r)
594  return S_OK;
595 }
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 480 of file global.c.

482 {
483  jsstr_t *ret_str, *str;
484  const WCHAR *ptr, *buf;
485  DWORD len = 0;
486  WCHAR *ret;
487  HRESULT hres;
488 
489  TRACE("\n");
490 
491  if(!argc) {
492  if(r)
494  return S_OK;
495  }
496 
497  hres = to_flat_string(ctx, argv[0], &str, &buf);
498  if(FAILED(hres))
499  return hres;
500 
501  for(ptr = buf; *ptr; ptr++) {
502  if(*ptr == '%') {
503  if(hex_to_int(*(ptr+1))!=-1 && hex_to_int(*(ptr+2))!=-1)
504  ptr += 2;
505  else if(*(ptr+1)=='u' && hex_to_int(*(ptr+2))!=-1 && hex_to_int(*(ptr+3))!=-1
506  && hex_to_int(*(ptr+4))!=-1 && hex_to_int(*(ptr+5))!=-1)
507  ptr += 5;
508  }
509 
510  len++;
511  }
512 
513  ret_str = jsstr_alloc_buf(len, &ret);
514  if(!ret_str) {
516  return E_OUTOFMEMORY;
517  }
518 
519  len = 0;
520  for(ptr = buf; *ptr; ptr++) {
521  if(*ptr == '%') {
522  if(hex_to_int(*(ptr+1))!=-1 && hex_to_int(*(ptr+2))!=-1) {
523  ret[len] = (hex_to_int(*(ptr+1))<<4) + hex_to_int(*(ptr+2));
524  ptr += 2;
525  }
526  else if(*(ptr+1)=='u' && hex_to_int(*(ptr+2))!=-1 && hex_to_int(*(ptr+3))!=-1
527  && hex_to_int(*(ptr+4))!=-1 && hex_to_int(*(ptr+5))!=-1) {
528  ret[len] = (hex_to_int(*(ptr+2))<<12) + (hex_to_int(*(ptr+3))<<8)
529  + (hex_to_int(*(ptr+4))<<4) + hex_to_int(*(ptr+5));
530  ptr += 5;
531  }
532  else
533  ret[len] = *ptr;
534  }
535  else
536  ret[len] = *ptr;
537 
538  len++;
539  }
540 
542 
543  if(r)
544  *r = jsval_string(ret_str);
545  else
546  jsstr_release(ret_str);
547  return S_OK;
548 }
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:474
HRESULT to_flat_string(script_ctx_t *, jsval_t, jsstr_t **, const WCHAR **) DECLSPEC_HIDDEN
Definition: jsutils.c:790

◆ 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 60 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 50 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 34 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 35 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 68 of file global.c.

◆ DateW

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

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

◆ decodeURIW

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

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

◆ encodeURIW

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

Definition at line 71 of file global.c.

◆ EnumeratorW

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

Definition at line 52 of file global.c.

◆ ErrorW

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

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

◆ EvalErrorW

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

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

◆ FunctionW

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

Definition at line 44 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 33 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 56 of file global.c.

◆ isNaNW

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

Definition at line 55 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:943
#define ARRAY_SIZE(a)
Definition: main.h:24

Definition at line 964 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:72
static const WCHAR _GetObjectW[]
Definition: global.c:60
static const WCHAR ScriptEngineW[]
Definition: global.c:61
static const WCHAR escapeW[]
Definition: global.c:53
static HRESULT JSGlobal_Enumerator(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: global.c:116
static const WCHAR encodeURIW[]
Definition: global.c:71
static HRESULT JSGlobal_parseInt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: global.c:294
static const WCHAR ScriptEngineMinorVersionW[]
Definition: global.c:64
static const WCHAR isNaNW[]
Definition: global.c:55
HRESULT JSGlobal_eval(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: global.c:188
static const WCHAR unescapeW[]
Definition: global.c:59
static HRESULT JSGlobal_ScriptEngineBuildVersion(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: global.c:597
static HRESULT JSGlobal_encodeURIComponent(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: global.c:767
static HRESULT JSGlobal_ScriptEngineMinorVersion(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: global.c:587
static const WCHAR ScriptEngineBuildVersionW[]
Definition: global.c:66
static const WCHAR CollectGarbageW[]
Definition: global.c:68
static HRESULT JSGlobal_parseFloat(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: global.c:375
static const WCHAR ScriptEngineMajorVersionW[]
Definition: global.c:62
static HRESULT JSGlobal_unescape(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: global.c:480
static HRESULT JSGlobal_decodeURIComponent(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: global.c:831
static const WCHAR isFiniteW[]
Definition: global.c:56
static const WCHAR EnumeratorW[]
Definition: global.c:52
static HRESULT JSGlobal_CollectGarbage(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: global.c:607
static HRESULT JSGlobal_ScriptEngineMajorVersion(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: global.c:577
static const WCHAR evalW[]
Definition: global.c:54
static HRESULT JSGlobal_escape(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: global.c:123
static HRESULT JSGlobal_isFinite(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: global.c:260
static const WCHAR parseFloatW[]
Definition: global.c:58
static HRESULT JSGlobal_encodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: global.c:616
static HRESULT JSGlobal_isNaN(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: global.c:237
#define PROPF_METHOD
Definition: jscript.h:94
static HRESULT JSGlobal_decodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: global.c:681
static HRESULT JSGlobal_GetObject(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: global.c:550
static const WCHAR encodeURIComponentW[]
Definition: global.c:73
static HRESULT JSGlobal_ScriptEngine(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: global.c:557
static const WCHAR decodeURIComponentW[]
Definition: global.c:74
static const WCHAR parseIntW[]
Definition: global.c:57

Definition at line 943 of file global.c.

◆ JSONW

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

Definition at line 70 of file global.c.

Referenced by init_global().

◆ MathW

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

Definition at line 69 of file global.c.

Referenced by init_global().

◆ NaNW

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

Definition at line 32 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 45 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 46 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 58 of file global.c.

◆ parseIntW

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

Definition at line 57 of file global.c.

◆ RangeErrorW

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

Definition at line 39 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 40 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 49 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 48 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 66 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 62 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 64 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 61 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 41 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 42 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 76 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 59 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 78 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 43 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 51 of file global.c.

Referenced by create_vbarray_constr(), and init_constructors().