Author: akhaldi
Date: Wed Nov 23 10:06:56 2016
New Revision: 73354
URL:
http://svn.reactos.org/svn/reactos?rev=73354&view=rev
Log:
[JSCRIPT] Sync with Wine Staging 1.9.23. Dedicated to Ged. CORE-12409
7af3f65 jscript: Add more jsdisp_t to Instance helpers.
55f6e3c jscript: Use the existing helpers to get from a jsdisp_t to an Instance.
0f21353 jscript: Use wine_rb_tree to store local variables in compiler_ctx_t.
fc1ae4f jscript: Use CONTAINING_RECORD() to get from a field to a struct.
57291c4 jscript: Simplify create_utc_string and add basic tests.
20d5bba jscript: Simplify date_to_string and add basic tests.
4d67ffd jscript: Allocate string of correct size in Date toLocaleDateString method.
79f18d0 jscript: Properly handle \0 characters in Array join method.
fd07a15 jscript: Allocate string of correct size in Date toTimeString method.
1c3e0dd jscript: Properly handle \0 characters in String indexOf method.
54e6736 jscript: Properly handle \0 characters in String to{Lower,Upper}Case methods.
1842082 jscript: Do not include terminating \0 in result returned by
Date_toLocale{Date,Time}String.
69437af jscript: Change prototype of jsstr_alloc_buf and fix some error handling issues.
d36ae56 jscript: Fix definition of JSSTR_MAX_LENGTH.
7369836 jscript: Simplify jsstr_release implementation.
Modified:
trunk/reactos/dll/win32/jscript/array.c
trunk/reactos/dll/win32/jscript/bool.c
trunk/reactos/dll/win32/jscript/compile.c
trunk/reactos/dll/win32/jscript/date.c
trunk/reactos/dll/win32/jscript/error.c
trunk/reactos/dll/win32/jscript/function.c
trunk/reactos/dll/win32/jscript/global.c
trunk/reactos/dll/win32/jscript/jsregexp.c
trunk/reactos/dll/win32/jscript/jsstr.c
trunk/reactos/dll/win32/jscript/jsstr.h
trunk/reactos/dll/win32/jscript/number.c
trunk/reactos/dll/win32/jscript/object.c
trunk/reactos/dll/win32/jscript/string.c
trunk/reactos/dll/win32/jscript/vbarray.c
trunk/reactos/media/doc/README.WINE
Modified: trunk/reactos/dll/win32/jscript/array.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/jscript/array.c?…
==============================================================================
--- trunk/reactos/dll/win32/jscript/array.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/jscript/array.c [iso-8859-1] Wed Nov 23 10:06:56 2016
@@ -93,7 +93,7 @@
static HRESULT set_length(jsdisp_t *obj, DWORD length)
{
if(is_class(obj, JSCLASS_ARRAY)) {
- ((ArrayInstance*)obj)->length = length;
+ array_from_jsdisp(obj)->length = length;
return S_OK;
}
@@ -181,7 +181,7 @@
jsobj = iface_to_jsdisp(obj);
if(jsobj) {
if(is_class(jsobj, JSCLASS_ARRAY)) {
- hres = concat_array(array, (ArrayInstance*)jsobj, len);
+ hres = concat_array(array, array_from_jsdisp(jsobj), len);
jsdisp_release(jsobj);
return hres;
}
@@ -228,9 +228,10 @@
return S_OK;
}
-static HRESULT array_join(script_ctx_t *ctx, jsdisp_t *array, DWORD length, const WCHAR
*sep, jsval_t *r)
-{
- jsstr_t **str_tab, *ret;
+static HRESULT array_join(script_ctx_t *ctx, jsdisp_t *array, DWORD length, const WCHAR
*sep,
+ unsigned seplen, jsval_t *r)
+{
+ jsstr_t **str_tab, *ret = NULL;
jsval_t val;
DWORD i;
HRESULT hres = E_FAIL;
@@ -262,9 +263,7 @@
}
if(SUCCEEDED(hres)) {
- DWORD seplen = 0, len = 0;
-
- seplen = strlenW(sep);
+ DWORD len = 0;
if(str_tab[0])
len = jsstr_length(str_tab[0]);
@@ -281,8 +280,8 @@
if(SUCCEEDED(hres)) {
WCHAR *ptr = NULL;
- ptr = jsstr_alloc_buf(len, &ret);
- if(ptr) {
+ ret = jsstr_alloc_buf(len, &ptr);
+ if(ret) {
if(str_tab[0])
ptr += jsstr_flush(str_tab[0], ptr);
@@ -340,11 +339,11 @@
if(FAILED(hres))
return hres;
- hres = array_join(ctx, jsthis, length, sep, r);
+ hres = array_join(ctx, jsthis, length, sep, jsstr_length(sep_str), r);
jsstr_release(sep_str);
}else {
- hres = array_join(ctx, jsthis, length, default_separatorW, r);
+ hres = array_join(ctx, jsthis, length, default_separatorW,
strlenW(default_separatorW), r);
}
return hres;
@@ -928,7 +927,8 @@
if(!array)
return throw_type_error(ctx, JS_E_ARRAY_EXPECTED, NULL);
- return array_join(ctx, &array->dispex, array->length, default_separatorW,
r);
+ return array_join(ctx, &array->dispex, array->length, default_separatorW,
+ strlenW(default_separatorW), r);
}
static HRESULT Array_toLocaleString(script_ctx_t *ctx, vdisp_t *vthis, WORD flags,
unsigned argc, jsval_t *argv,
@@ -1004,7 +1004,8 @@
TRACE("\n");
- return array_join(ctx, &array->dispex, array->length, default_separatorW,
r);
+ return array_join(ctx, &array->dispex, array->length, default_separatorW,
+ strlenW(default_separatorW), r);
}
static void Array_destructor(jsdisp_t *dispex)
@@ -1014,7 +1015,7 @@
static void Array_on_put(jsdisp_t *dispex, const WCHAR *name)
{
- ArrayInstance *array = (ArrayInstance*)dispex;
+ ArrayInstance *array = array_from_jsdisp(dispex);
const WCHAR *ptr = name;
DWORD id = 0;
Modified: trunk/reactos/dll/win32/jscript/bool.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/jscript/bool.c?r…
==============================================================================
--- trunk/reactos/dll/win32/jscript/bool.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/jscript/bool.c [iso-8859-1] Wed Nov 23 10:06:56 2016
@@ -28,15 +28,25 @@
static const WCHAR toStringW[] =
{'t','o','S','t','r','i','n','g',0};
static const WCHAR valueOfW[] =
{'v','a','l','u','e','O','f',0};
+static inline BoolInstance *bool_from_jsdisp(jsdisp_t *jsdisp)
+{
+ return CONTAINING_RECORD(jsdisp, BoolInstance, dispex);
+}
+
+static inline BoolInstance *bool_from_vdisp(vdisp_t *vdisp)
+{
+ return bool_from_jsdisp(vdisp->u.jsdisp);
+}
+
static inline BoolInstance *bool_this(vdisp_t *jsthis)
{
- return is_vclass(jsthis, JSCLASS_BOOLEAN) ? (BoolInstance*)jsthis->u.jsdisp :
NULL;
+ return is_vclass(jsthis, JSCLASS_BOOLEAN) ? bool_from_vdisp(jsthis) : NULL;
}
BOOL bool_obj_value(jsdisp_t *obj)
{
assert(is_class(obj, JSCLASS_BOOLEAN));
- return ((BoolInstance*)obj)->val;
+ return bool_from_jsdisp(obj)->val;
}
/* ECMA-262 3rd Edition 15.6.4.2 */
Modified: trunk/reactos/dll/win32/jscript/compile.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/jscript/compile.…
==============================================================================
--- trunk/reactos/dll/win32/jscript/compile.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/jscript/compile.c [iso-8859-1] Wed Nov 23 10:06:56 2016
@@ -18,6 +18,8 @@
#include "jscript.h"
+#include <wine/rbtree.h>
+
WINE_DECLARE_DEBUG_CHANNEL(jscript_disas);
typedef struct _statement_ctx_t {
@@ -34,6 +36,12 @@
} statement_ctx_t;
typedef struct {
+ struct wine_rb_entry entry;
+ BSTR name;
+ int ref;
+} function_local_t;
+
+typedef struct {
parser_ctx_t *parser;
bytecode_t *code;
@@ -46,8 +54,7 @@
unsigned labels_size;
unsigned labels_cnt;
- local_ref_t *locals_buf;
- unsigned locals_buf_size;
+ struct wine_rb_tree locals;
unsigned locals_cnt;
statement_ctx_t *stat_ctx;
@@ -55,6 +62,8 @@
function_expression_t *func_head;
function_expression_t *func_tail;
+
+ heap_pool_t heap;
} compiler_ctx_t;
static const struct {
@@ -1804,42 +1813,29 @@
return hres;
}
-static int local_cmp(const void *key, const void *ref)
-{
- return strcmpW((const WCHAR*)key, ((const local_ref_t*)ref)->name);
-}
-
-static inline local_ref_t *find_local(compiler_ctx_t *ctx, const WCHAR *name)
-{
- return bsearch(name, ctx->locals_buf, ctx->locals_cnt,
sizeof(*ctx->locals_buf), local_cmp);
+static int function_local_cmp(const void *key, const struct wine_rb_entry *entry)
+{
+ function_local_t *local = WINE_RB_ENTRY_VALUE(entry, function_local_t, entry);
+ return strcmpW(key, local->name);
+}
+
+static inline function_local_t *find_local(compiler_ctx_t *ctx, const WCHAR *name)
+{
+ struct wine_rb_entry *entry = wine_rb_get(&ctx->locals, name);
+ return entry ? WINE_RB_ENTRY_VALUE(entry, function_local_t, entry) : NULL;
}
static BOOL alloc_local(compiler_ctx_t *ctx, BSTR name, int ref)
{
- unsigned i;
-
- if(!ctx->locals_buf_size) {
- ctx->locals_buf = heap_alloc(4 * sizeof(*ctx->locals_buf));
- if(!ctx->locals_buf)
- return FALSE;
- ctx->locals_buf_size = 4;
- }else if(ctx->locals_buf_size == ctx->locals_cnt) {
- local_ref_t *new_buf = heap_realloc(ctx->locals_buf, ctx->locals_buf_size *
2 * sizeof(*ctx->locals_buf));
- if(!new_buf)
- return FALSE;
- ctx->locals_buf = new_buf;
- ctx->locals_buf_size *= 2;
- }
-
- for(i = 0; i < ctx->locals_cnt; i++) {
- if(strcmpW(ctx->locals_buf[i].name, name) > 0) {
- memmove(ctx->locals_buf + i+1, ctx->locals_buf + i, (ctx->locals_cnt
- i) * sizeof(*ctx->locals_buf));
- break;
- }
- }
-
- ctx->locals_buf[i].name = name;
- ctx->locals_buf[i].ref = ref;
+ function_local_t *local;
+
+ local = heap_pool_alloc(&ctx->heap, sizeof(*local));
+ if(!local)
+ return FALSE;
+
+ local->name = name;
+ local->ref = ref;
+ wine_rb_put(&ctx->locals, name, &local->entry);
ctx->locals_cnt++;
return TRUE;
}
@@ -2256,7 +2252,8 @@
BOOL from_eval, function_code_t *func)
{
function_expression_t *iter;
- unsigned off, i, j;
+ function_local_t *local;
+ unsigned off, i;
HRESULT hres;
TRACE("\n");
@@ -2265,6 +2262,7 @@
ctx->from_eval = from_eval;
ctx->func = func;
ctx->locals_cnt = 0;
+ wine_rb_init(&ctx->locals, function_local_cmp);
if(func_expr) {
parameter_t *param_iter;
@@ -2311,21 +2309,22 @@
if(!func->locals)
return E_OUTOFMEMORY;
func->locals_cnt = ctx->locals_cnt;
- memcpy(func->locals, ctx->locals_buf, func->locals_cnt *
sizeof(*func->locals));
func->variables = compiler_alloc(ctx->code, func->var_cnt *
sizeof(*func->variables));
if(!func->variables)
return E_OUTOFMEMORY;
- for(i = 0, j = 0; i < func->locals_cnt; i++) {
- if(func->locals[i].ref < 0)
- continue; /* skip arguments */
- func->variables[func->locals[i].ref].name = func->locals[i].name;
- func->variables[func->locals[i].ref].func_id = -1;
- j++;
- }
-
- assert(j == func->var_cnt);
+ i = 0;
+ WINE_RB_FOR_EACH_ENTRY(local, &ctx->locals, function_local_t, entry) {
+ func->locals[i].name = local->name;
+ func->locals[i].ref = local->ref;
+ if(local->ref >= 0) {
+ func->variables[local->ref].name = local->name;
+ func->variables[local->ref].func_id = -1;
+ }
+ i++;
+ }
+ assert(i == ctx->locals_cnt);
func->funcs = compiler_alloc(ctx->code, func->func_cnt *
sizeof(*func->funcs));
if(!func->funcs)
@@ -2468,9 +2467,10 @@
return hres;
}
+ heap_pool_init(&compiler.heap);
hres = compile_function(&compiler, compiler.parser->source, NULL, from_eval,
&compiler.code->global_code);
+ heap_pool_free(&compiler.heap);
parser_release(compiler.parser);
- heap_free(compiler.locals_buf);
if(FAILED(hres)) {
release_bytecode(compiler.code);
return hres;
Modified: trunk/reactos/dll/win32/jscript/date.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/jscript/date.c?r…
==============================================================================
--- trunk/reactos/dll/win32/jscript/date.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/jscript/date.c [iso-8859-1] Wed Nov 23 10:06:56 2016
@@ -483,8 +483,9 @@
BOOL formatAD = TRUE;
WCHAR week[64], month[64];
+ WCHAR buf[192];
jsstr_t *date_jsstr;
- int len, size, year, day;
+ int year, day;
DWORD lcid_en;
WCHAR sign = '-';
@@ -495,65 +496,44 @@
}
if(r) {
- WCHAR *date_str;
-
- len = 21;
-
lcid_en = MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT);
- size = GetLocaleInfoW(lcid_en, week_ids[(int)week_day(time)], week,
sizeof(week)/sizeof(*week));
- assert(size);
- len += size-1;
-
- size = GetLocaleInfoW(lcid_en, month_ids[(int)month_from_time(time)], month,
sizeof(month)/sizeof(*month));
- len += size-1;
-
- year = year_from_time(time);
- if(year<0)
- year = -year+1;
- do {
- year /= 10;
- len++;
- } while(year);
+ week[0] = 0;
+ GetLocaleInfoW(lcid_en, week_ids[(int)week_day(time)], week,
sizeof(week)/sizeof(*week));
+
+ month[0] = 0;
+ GetLocaleInfoW(lcid_en, month_ids[(int)month_from_time(time)], month,
sizeof(month)/sizeof(*month));
year = year_from_time(time);
if(year<0) {
formatAD = FALSE;
year = -year+1;
- len += 5;
}
day = date_from_time(time);
- do {
- day /= 10;
- len++;
- } while(day);
- day = date_from_time(time);
-
- if(!show_offset) len -= 9;
- else if(offset == 0) len -= 5;
- else if(offset < 0) {
+
+ if(offset < 0) {
sign = '+';
offset = -offset;
}
- date_str = jsstr_alloc_buf(len, &date_jsstr);
- if(!date_str)
- return E_OUTOFMEMORY;
-
if(!show_offset)
- sprintfW(date_str, formatNoOffsetW, week, month, day,
+ sprintfW(buf, formatNoOffsetW, week, month, day,
(int)hour_from_time(time), (int)min_from_time(time),
(int)sec_from_time(time), year, formatAD?ADW:BCW);
else if(offset)
- sprintfW(date_str, formatW, week, month, day,
+ sprintfW(buf, formatW, week, month, day,
(int)hour_from_time(time), (int)min_from_time(time),
(int)sec_from_time(time), sign, offset/60, offset%60,
year, formatAD?ADW:BCW);
else
- sprintfW(date_str, formatUTCW, week, month, day,
+ sprintfW(buf, formatUTCW, week, month, day,
(int)hour_from_time(time), (int)min_from_time(time),
(int)sec_from_time(time), year, formatAD?ADW:BCW);
+
+ date_jsstr = jsstr_alloc(buf);
+ if(!date_jsstr)
+ return E_OUTOFMEMORY;
*r = jsval_string(date_jsstr);
}
@@ -616,7 +596,7 @@
date_len = GetDateFormatW(ctx->lcid, DATE_LONGDATE, &st, NULL, NULL, 0);
time_len = GetTimeFormatW(ctx->lcid, 0, &st, NULL, NULL, 0);
- ptr = jsstr_alloc_buf(date_len+time_len-1, &date_str);
+ date_str = jsstr_alloc_buf(date_len+time_len-1, &ptr);
if(!date_str)
return E_OUTOFMEMORY;
@@ -663,9 +643,10 @@
BOOL formatAD = TRUE;
WCHAR week[64], month[64];
+ WCHAR buf[192];
DateInstance *date;
jsstr_t *date_str;
- int len, size, year, day;
+ int year, day;
DWORD lcid_en;
if(!(date = date_this(jsthis)))
@@ -678,47 +659,29 @@
}
if(r) {
- WCHAR *ptr;
-
- len = 17;
-
lcid_en = MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT);
- size = GetLocaleInfoW(lcid_en, week_ids[(int)week_day(date->time)], week,
sizeof(week)/sizeof(*week));
- len += size-1;
-
- size = GetLocaleInfoW(lcid_en, month_ids[(int)month_from_time(date->time)],
month, sizeof(month)/sizeof(*month));
- len += size-1;
-
- year = year_from_time(date->time);
- if(year<0)
- year = -year+1;
- do {
- year /= 10;
- len++;
- } while(year);
+ week[0] = 0;
+ GetLocaleInfoW(lcid_en, week_ids[(int)week_day(date->time)], week,
sizeof(week)/sizeof(*week));
+
+ month[0] = 0;
+ GetLocaleInfoW(lcid_en, month_ids[(int)month_from_time(date->time)], month,
sizeof(month)/sizeof(*month));
year = year_from_time(date->time);
if(year<0) {
formatAD = FALSE;
year = -year+1;
- len += 5;
}
day = date_from_time(date->time);
- do {
- day /= 10;
- len++;
- } while(day);
- day = date_from_time(date->time);
-
- ptr = jsstr_alloc_buf(len, &date_str);
+
+ sprintfW(buf, formatAD ? formatADW : formatBCW, week, day, month, year,
+ (int)hour_from_time(date->time), (int)min_from_time(date->time),
+ (int)sec_from_time(date->time));
+
+ date_str = jsstr_alloc(buf);
if(!date_str)
return E_OUTOFMEMORY;
-
- sprintfW(ptr, formatAD?formatADW:formatBCW, week, day, month, year,
- (int)hour_from_time(date->time), (int)min_from_time(date->time),
- (int)sec_from_time(date->time));
*r = jsval_string(date_str);
}
@@ -758,9 +721,10 @@
BOOL formatAD = TRUE;
WCHAR week[64], month[64];
+ WCHAR buf[192];
jsstr_t *date_str;
DOUBLE time;
- int len, size, year, day;
+ int year, day;
DWORD lcid_en;
if(isnan(date->time)) {
@@ -772,46 +736,27 @@
time = local_time(date->time, date);
if(r) {
- WCHAR *ptr;
-
- len = 5;
-
lcid_en = MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT);
- size = GetLocaleInfoW(lcid_en, week_ids[(int)week_day(time)], week,
sizeof(week)/sizeof(*week));
- assert(size);
- len += size-1;
-
- size = GetLocaleInfoW(lcid_en, month_ids[(int)month_from_time(time)], month,
sizeof(month)/sizeof(*month));
- assert(size);
- len += size-1;
-
- year = year_from_time(time);
- if(year<0)
- year = -year+1;
- do {
- year /= 10;
- len++;
- } while(year);
+ week[0] = 0;
+ GetLocaleInfoW(lcid_en, week_ids[(int)week_day(time)], week,
sizeof(week)/sizeof(*week));
+
+ month[0] = 0;
+ GetLocaleInfoW(lcid_en, month_ids[(int)month_from_time(time)], month,
sizeof(month)/sizeof(*month));
year = year_from_time(time);
if(year<0) {
formatAD = FALSE;
year = -year+1;
- len += 5;
}
day = date_from_time(time);
- do {
- day /= 10;
- len++;
- } while(day);
- day = date_from_time(time);
-
- ptr = jsstr_alloc_buf(len, &date_str);
- if(!ptr)
+
+ sprintfW(buf, formatAD ? formatADW : formatBCW, week, month, day, year);
+
+ date_str = jsstr_alloc(buf);
+ if(!date_str)
return E_OUTOFMEMORY;
- sprintfW(ptr, formatAD?formatADW:formatBCW, week, month, day, year);
*r = jsval_string(date_str);
}
@@ -839,6 +784,7 @@
':','%','0','2','d','
','U','T','C',0 };
DateInstance *date;
jsstr_t *date_str;
+ WCHAR buf[32];
DOUBLE time;
WCHAR sign;
int offset;
@@ -857,12 +803,6 @@
time = local_time(date->time, date);
if(r) {
- WCHAR *ptr;
-
- ptr = jsstr_alloc_buf(17, &date_str);
- if(!date_str)
- return E_OUTOFMEMORY;
-
offset = date->bias +
daylight_saving_ta(time, date);
@@ -873,12 +813,16 @@
else sign = '-';
if(offset)
- sprintfW(ptr, formatW, (int)hour_from_time(time),
+ sprintfW(buf, formatW, (int)hour_from_time(time),
(int)min_from_time(time), (int)sec_from_time(time),
sign, offset/60, offset%60);
else
- sprintfW(ptr, formatUTCW, (int)hour_from_time(time),
+ sprintfW(buf, formatUTCW, (int)hour_from_time(time),
(int)min_from_time(time), (int)sec_from_time(time));
+
+ date_str = jsstr_alloc(buf);
+ if(!date_str)
+ return E_OUTOFMEMORY;
*r = jsval_string(date_str);
}
@@ -914,8 +858,8 @@
WCHAR *ptr;
len = GetDateFormatW(ctx->lcid, DATE_LONGDATE, &st, NULL, NULL, 0);
- ptr = jsstr_alloc_buf(len, &date_str);
- if(!ptr)
+ date_str = jsstr_alloc_buf(len-1, &ptr);
+ if(!date_str)
return E_OUTOFMEMORY;
GetDateFormatW(ctx->lcid, DATE_LONGDATE, &st, NULL, ptr, len);
@@ -953,8 +897,8 @@
WCHAR *ptr;
len = GetTimeFormatW(ctx->lcid, 0, &st, NULL, NULL, 0);
- ptr = jsstr_alloc_buf(len, &date_str);
- if(!ptr)
+ date_str = jsstr_alloc_buf(len-1, &ptr);
+ if(!date_str)
return E_OUTOFMEMORY;
GetTimeFormatW(ctx->lcid, 0, &st, NULL, ptr, len);
@@ -2469,7 +2413,7 @@
if(FAILED(hres))
return hres;
- di = (DateInstance*)date;
+ di = date_from_jsdisp(date);
di->time = utc(di->time, di);
}
}
Modified: trunk/reactos/dll/win32/jscript/error.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/jscript/error.c?…
==============================================================================
--- trunk/reactos/dll/win32/jscript/error.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/jscript/error.c [iso-8859-1] Wed Nov 23 10:06:56 2016
@@ -76,8 +76,8 @@
if(name_len && msg_len) {
WCHAR *ptr;
- ptr = jsstr_alloc_buf(name_len + msg_len + 2, &ret);
- if(ptr) {
+ ret = jsstr_alloc_buf(name_len + msg_len + 2, &ptr);
+ if(ret) {
jsstr_flush(name, ptr);
ptr[name_len] = ':';
ptr[name_len+1] = ' ';
Modified: trunk/reactos/dll/win32/jscript/function.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/jscript/function…
==============================================================================
--- trunk/reactos/dll/win32/jscript/function.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/jscript/function.c [iso-8859-1] Wed Nov 23 10:06:56 2016
@@ -74,7 +74,7 @@
static void Arguments_destructor(jsdisp_t *jsdisp)
{
- ArgumentsInstance *arguments = (ArgumentsInstance*)jsdisp;
+ ArgumentsInstance *arguments = arguments_from_jsdisp(jsdisp);
TRACE("(%p)\n", arguments);
@@ -91,7 +91,7 @@
static unsigned Arguments_idx_length(jsdisp_t *jsdisp)
{
- ArgumentsInstance *arguments = (ArgumentsInstance*)jsdisp;
+ ArgumentsInstance *arguments = arguments_from_jsdisp(jsdisp);
return arguments->argc;
}
@@ -106,7 +106,7 @@
static HRESULT Arguments_idx_get(jsdisp_t *jsdisp, unsigned idx, jsval_t *r)
{
- ArgumentsInstance *arguments = (ArgumentsInstance*)jsdisp;
+ ArgumentsInstance *arguments = arguments_from_jsdisp(jsdisp);
jsval_t *ref;
TRACE("%p[%u]\n", arguments, idx);
@@ -120,7 +120,7 @@
static HRESULT Arguments_idx_put(jsdisp_t *jsdisp, unsigned idx, jsval_t val)
{
- ArgumentsInstance *arguments = (ArgumentsInstance*)jsdisp;
+ ArgumentsInstance *arguments = arguments_from_jsdisp(jsdisp);
jsval_t *ref;
HRESULT hres;
@@ -295,8 +295,8 @@
WCHAR *ptr;
name_len = strlenW(function->name);
- ptr =
jsstr_alloc_buf((sizeof(native_prefixW)+sizeof(native_suffixW))/sizeof(WCHAR) + name_len,
&str);
- if(!ptr)
+ str =
jsstr_alloc_buf((sizeof(native_prefixW)+sizeof(native_suffixW))/sizeof(WCHAR) + name_len,
&ptr);
+ if(!str)
return E_OUTOFMEMORY;
memcpy(ptr, native_prefixW, sizeof(native_prefixW));
@@ -320,7 +320,7 @@
TRACE("func %p this %p\n", func_this, jsthis);
assert(is_class(func_this, JSCLASS_FUNCTION));
- function = (FunctionInstance*)func_this;
+ function = function_from_jsdisp(func_this);
flags &= ~DISPATCH_JSCRIPT_INTERNAL_MASK;
if(function->value_proc)
@@ -523,7 +523,7 @@
return E_FAIL;
}
- function = (FunctionInstance*)jsthis->u.jsdisp;
+ function = function_from_jsdisp(jsthis->u.jsdisp);
assert(function->value_proc != NULL);
return invoke_value_proc(ctx, function, NULL, flags, argc, argv, r);
@@ -570,7 +570,7 @@
static void Function_destructor(jsdisp_t *dispex)
{
- FunctionInstance *This = (FunctionInstance*)dispex;
+ FunctionInstance *This = function_from_jsdisp(dispex);
if(This->code)
release_bytecode(This->code);
Modified: trunk/reactos/dll/win32/jscript/global.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/jscript/global.c…
==============================================================================
--- trunk/reactos/dll/win32/jscript/global.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/jscript/global.c [iso-8859-1] Wed Nov 23 10:06:56 2016
@@ -140,8 +140,8 @@
len += 3;
}
- ret = jsstr_alloc_buf(len, &ret_str);
- if(!ret) {
+ ret_str = jsstr_alloc_buf(len, &ret);
+ if(!ret_str) {
jsstr_release(str);
return E_OUTOFMEMORY;
}
@@ -500,8 +500,8 @@
len++;
}
- ret = jsstr_alloc_buf(len, &ret_str);
- if(!ret) {
+ ret_str = jsstr_alloc_buf(len, &ret);
+ if(!ret_str) {
jsstr_release(str);
return E_OUTOFMEMORY;
}
@@ -639,8 +639,8 @@
}
}
- rptr = jsstr_alloc_buf(len, &ret);
- if(!rptr) {
+ ret = jsstr_alloc_buf(len, &rptr);
+ if(!ret) {
jsstr_release(str);
return E_OUTOFMEMORY;
}
@@ -718,8 +718,8 @@
}
}
- ret = jsstr_alloc_buf(len, &ret_str);
- if(!ret) {
+ ret_str = jsstr_alloc_buf(len, &ret);
+ if(!ret_str) {
jsstr_release(str);
return E_OUTOFMEMORY;
}
@@ -789,8 +789,8 @@
}
}
- ret = jsstr_alloc_buf(len, &ret_str);
- if(!ret) {
+ ret_str = jsstr_alloc_buf(len, &ret);
+ if(!ret_str) {
jsstr_release(str);
return E_OUTOFMEMORY;
}
@@ -889,7 +889,7 @@
}
}
- out_ptr = jsstr_alloc_buf(len, &ret);
+ ret = jsstr_alloc_buf(len, &out_ptr);
if(!ret) {
jsstr_release(str);
return E_OUTOFMEMORY;
Modified: trunk/reactos/dll/win32/jscript/jsregexp.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/jscript/jsregexp…
==============================================================================
--- trunk/reactos/dll/win32/jscript/jsregexp.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/jscript/jsregexp.c [iso-8859-1] Wed Nov 23 10:06:56 2016
@@ -118,7 +118,7 @@
HRESULT regexp_match_next(script_ctx_t *ctx, jsdisp_t *dispex,
DWORD rem_flags, jsstr_t *jsstr, match_state_t **ret)
{
- RegExpInstance *regexp = (RegExpInstance*)dispex;
+ RegExpInstance *regexp = regexp_from_jsdisp(dispex);
match_state_t *match;
heap_pool_t *mark;
const WCHAR *str;
@@ -175,7 +175,7 @@
static HRESULT regexp_match(script_ctx_t *ctx, jsdisp_t *dispex, jsstr_t *jsstr, BOOL
gflag,
match_result_t **match_result, DWORD *result_cnt)
{
- RegExpInstance *This = (RegExpInstance*)dispex;
+ RegExpInstance *This = regexp_from_jsdisp(dispex);
match_result_t *ret = NULL;
match_state_t *result;
DWORD i=0, ret_size = 0;
@@ -367,8 +367,8 @@
if(f & REG_MULTILINE)
len++;
- ptr = jsstr_alloc_buf(len, &ret);
- if(!ptr)
+ ret = jsstr_alloc_buf(len, &ptr);
+ if(!ret)
return E_OUTOFMEMORY;
*ptr++ = '/';
@@ -589,7 +589,7 @@
static void RegExp_destructor(jsdisp_t *dispex)
{
- RegExpInstance *This = (RegExpInstance*)dispex;
+ RegExpInstance *This = regexp_from_jsdisp(dispex);
if(This->jsregexp)
regexp_destroy(This->jsregexp);
@@ -701,7 +701,7 @@
obj = iface_to_jsdisp(get_object(src_arg));
if(obj) {
if(is_class(obj, JSCLASS_REGEXP)) {
- RegExpInstance *regexp = (RegExpInstance*)obj;
+ RegExpInstance *regexp = regexp_from_jsdisp(obj);
hres = create_regexp(ctx, regexp->str, regexp->jsregexp->flags,
ret);
jsdisp_release(obj);
@@ -747,7 +747,7 @@
static const WCHAR inputW[] =
{'i','n','p','u','t',0};
static const WCHAR lastIndexW[] =
{'l','a','s','t','I','n','d','e','x',0};
- RegExpInstance *regexp = (RegExpInstance*)re;
+ RegExpInstance *regexp = regexp_from_jsdisp(re);
match_result_t *match_result;
unsigned match_cnt, i;
const WCHAR *str;
Modified: trunk/reactos/dll/win32/jscript/jsstr.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/jscript/jsstr.c?…
==============================================================================
--- trunk/reactos/dll/win32/jscript/jsstr.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/jscript/jsstr.c [iso-8859-1] Wed Nov 23 10:06:56 2016
@@ -62,7 +62,7 @@
str->ref = 1;
}
-WCHAR *jsstr_alloc_buf(unsigned len, jsstr_t **r)
+jsstr_t *jsstr_alloc_buf(unsigned len, WCHAR **buf)
{
jsstr_inline_t *ret;
@@ -75,8 +75,8 @@
jsstr_init(&ret->str, len, JSSTR_INLINE);
ret->buf[len] = 0;
- *r = &ret->str;
- return ret->buf;
+ *buf = ret->buf;
+ return &ret->str;
}
jsstr_t *jsstr_alloc_len(const WCHAR *buf, unsigned len)
@@ -84,8 +84,8 @@
jsstr_t *ret;
WCHAR *ptr;
- ptr = jsstr_alloc_buf(len, &ret);
- if(ptr)
+ ret = jsstr_alloc_buf(len, &ptr);
+ if(ret)
memcpy(ptr, buf, len*sizeof(WCHAR));
return ret;
@@ -243,7 +243,7 @@
}
}
- ptr = jsstr_alloc_buf(len1+len2, &ret);
+ ret = jsstr_alloc_buf(len1+len2, &ptr);
if(!ret)
return NULL;
@@ -305,14 +305,15 @@
{
static const WCHAR NaNW[] = { 'N','a','N',0 };
static const WCHAR undefinedW[] =
{'u','n','d','e','f','i','n','e','d',0};
-
- if(!jsstr_alloc_buf(0, &empty_str))
+ WCHAR *ptr;
+
+ if(!(empty_str = jsstr_alloc_buf(0, &ptr)))
return FALSE;
if(!(nan_str = jsstr_alloc(NaNW)))
return FALSE;
if(!(undefined_str = jsstr_alloc(undefinedW)))
return FALSE;
- if(!jsstr_alloc_buf(0, &null_bstr_str))
+ if(!(null_bstr_str = jsstr_alloc_buf(0, &ptr)))
return FALSE;
return TRUE;
}
Modified: trunk/reactos/dll/win32/jscript/jsstr.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/jscript/jsstr.h?…
==============================================================================
--- trunk/reactos/dll/win32/jscript/jsstr.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/jscript/jsstr.h [iso-8859-1] Wed Nov 23 10:06:56 2016
@@ -42,7 +42,7 @@
};
#define JSSTR_LENGTH_SHIFT 4
-#define JSSTR_MAX_LENGTH (1 << (32-JSSTR_LENGTH_SHIFT))
+#define JSSTR_MAX_LENGTH ((1 << (32-JSSTR_LENGTH_SHIFT))-1)
#define JSSTR_FLAGS_MASK ((1 << JSSTR_LENGTH_SHIFT)-1)
#define JSSTR_FLAG_LBIT 1
@@ -98,7 +98,7 @@
} jsstr_rope_t;
jsstr_t *jsstr_alloc_len(const WCHAR*,unsigned) DECLSPEC_HIDDEN;
-WCHAR *jsstr_alloc_buf(unsigned,jsstr_t**) DECLSPEC_HIDDEN;
+jsstr_t *jsstr_alloc_buf(unsigned,WCHAR**) DECLSPEC_HIDDEN;
static inline jsstr_t *jsstr_alloc(const WCHAR *str)
{
@@ -109,12 +109,8 @@
static inline void jsstr_release(jsstr_t *str)
{
- if(!--str->ref) {
- if(jsstr_is_inline(str))
- heap_free(str);
- else
- jsstr_free(str);
- }
+ if(!--str->ref)
+ jsstr_free(str);
}
static inline jsstr_t *jsstr_addref(jsstr_t *str)
@@ -169,8 +165,8 @@
jsstr_t *ret;
WCHAR *ptr;
- ptr = jsstr_alloc_buf(len, &ret);
- if(ptr)
+ ret = jsstr_alloc_buf(len, &ptr);
+ if(ret)
jsstr_extract(str, off, len, ptr);
return ret;
}
Modified: trunk/reactos/dll/win32/jscript/number.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/jscript/number.c…
==============================================================================
--- trunk/reactos/dll/win32/jscript/number.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/jscript/number.c [iso-8859-1] Wed Nov 23 10:06:56 2016
@@ -120,7 +120,7 @@
if(prec)
size += prec+1;
- str = jsstr_alloc_buf(size, &ret);
+ ret = jsstr_alloc_buf(size, &str);
if(!ret)
return NULL;
@@ -187,7 +187,7 @@
if(neg)
size++;
- str = jsstr_alloc_buf(size, &ret);
+ ret = jsstr_alloc_buf(size, &str);
if(!ret)
return NULL;
Modified: trunk/reactos/dll/win32/jscript/object.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/jscript/object.c…
==============================================================================
--- trunk/reactos/dll/win32/jscript/object.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/jscript/object.c [iso-8859-1] Wed Nov 23 10:06:56 2016
@@ -67,8 +67,8 @@
jsstr_t *ret;
WCHAR *ptr;
- ptr = jsstr_alloc_buf(9+strlenW(str), &ret);
- if(!ptr)
+ ret = jsstr_alloc_buf(9+strlenW(str), &ptr);
+ if(!ret)
return E_OUTOFMEMORY;
sprintfW(ptr, formatW, str);
Modified: trunk/reactos/dll/win32/jscript/string.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/jscript/string.c…
==============================================================================
--- trunk/reactos/dll/win32/jscript/string.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/jscript/string.c [iso-8859-1] Wed Nov 23 10:06:56 2016
@@ -103,7 +103,7 @@
static HRESULT String_get_length(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
{
- StringInstance *string = (StringInstance*)jsthis;
+ StringInstance *string = string_from_jsdisp(jsthis);
TRACE("%p\n", jsthis);
@@ -167,7 +167,7 @@
tagname_len = strlenW(tagname);
- ptr = jsstr_alloc_buf(jsstr_length(str) + 2*tagname_len + 5, &ret);
+ ret = jsstr_alloc_buf(jsstr_length(str) + 2*tagname_len + 5, &ptr);
if(!ret) {
jsstr_release(str);
return E_OUTOFMEMORY;
@@ -217,8 +217,8 @@
jsstr_t *ret;
WCHAR *ptr;
- ptr = jsstr_alloc_buf(2*tagname_len + attrname_len + jsstr_length(attr_value) +
jsstr_length(str) + 9, &ret);
- if(ptr) {
+ ret = jsstr_alloc_buf(2*tagname_len + attrname_len + jsstr_length(attr_value) +
jsstr_length(str) + 9, &ptr);
+ if(ret) {
*ptr++ = '<';
memcpy(ptr, tagname, tagname_len*sizeof(WCHAR));
ptr += tagname_len;
@@ -368,7 +368,7 @@
static HRESULT String_concat(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned
argc, jsval_t *argv,
jsval_t *r)
{
- jsstr_t *ret, *str;
+ jsstr_t *ret = NULL, *str;
HRESULT hres;
TRACE("\n");
@@ -425,8 +425,8 @@
}
if(SUCCEEDED(hres)) {
- ptr = jsstr_alloc_buf(len, &ret);
- if(ptr) {
+ ret = jsstr_alloc_buf(len, &ptr);
+ if(ret) {
for(i=0; i < str_cnt; i++)
ptr += jsstr_flush(strs[i], ptr);
}else {
@@ -478,9 +478,9 @@
static HRESULT String_indexOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned
argc, jsval_t *argv,
jsval_t *r)
{
+ unsigned pos = 0, search_len, length;
jsstr_t *search_jsstr, *jsstr;
const WCHAR *search_str, *str;
- int length, pos = 0;
INT ret = -1;
HRESULT hres;
@@ -490,7 +490,6 @@
if(FAILED(hres))
return hres;
- length = jsstr_length(jsstr);
if(!argc) {
if(r)
*r = jsval_number(-1);
@@ -504,6 +503,9 @@
return hres;
}
+ search_len = jsstr_length(search_jsstr);
+ length = jsstr_length(jsstr);
+
if(argc >= 2) {
double d;
@@ -512,14 +514,16 @@
pos = is_int32(d) ? min(length, d) : length;
}
- if(SUCCEEDED(hres)) {
+ if(SUCCEEDED(hres) && length >= search_len) {
+ const WCHAR *end = str+length-search_len;
const WCHAR *ptr;
- ptr = strstrW(str+pos, search_str);
- if(ptr)
- ret = ptr - str;
- else
- ret = -1;
+ for(ptr = str+pos; ptr <= end; ptr++) {
+ if(!memcmp(ptr, search_str, search_len*sizeof(WCHAR))) {
+ ret = ptr-str;
+ break;
+ }
+ }
}
jsstr_release(search_jsstr);
@@ -1394,17 +1398,19 @@
return hres;
if(r) {
+ unsigned len = jsstr_length(str);
jsstr_t *ret;
WCHAR *buf;
- buf = jsstr_alloc_buf(jsstr_length(str), &ret);
- if(!buf) {
+ ret = jsstr_alloc_buf(len, &buf);
+ if(!ret) {
jsstr_release(str);
return E_OUTOFMEMORY;
}
jsstr_flush(str, buf);
- strlwrW(buf);
+ for (; len--; buf++) *buf = tolowerW(*buf);
+
*r = jsval_string(ret);
}
jsstr_release(str);
@@ -1424,17 +1430,19 @@
return hres;
if(r) {
+ unsigned len = jsstr_length(str);
jsstr_t *ret;
WCHAR *buf;
- buf = jsstr_alloc_buf(jsstr_length(str), &ret);
- if(!buf) {
+ ret = jsstr_alloc_buf(len, &buf);
+ if(!ret) {
jsstr_release(str);
return E_OUTOFMEMORY;
}
jsstr_flush(str, buf);
- struprW(buf);
+ for (; len--; buf++) *buf = toupperW(*buf);
+
*r = jsval_string(ret);
}
jsstr_release(str);
@@ -1464,7 +1472,7 @@
static HRESULT String_get_value(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
{
- StringInstance *This = (StringInstance*)jsthis;
+ StringInstance *This = string_from_jsdisp(jsthis);
TRACE("\n");
@@ -1474,7 +1482,7 @@
static void String_destructor(jsdisp_t *dispex)
{
- StringInstance *This = (StringInstance*)dispex;
+ StringInstance *This = string_from_jsdisp(dispex);
jsstr_release(This->str);
heap_free(This);
@@ -1482,7 +1490,7 @@
static unsigned String_idx_length(jsdisp_t *jsdisp)
{
- StringInstance *string = (StringInstance*)jsdisp;
+ StringInstance *string = string_from_jsdisp(jsdisp);
/*
* NOTE: For invoke version < 2, indexed array is not implemented at all.
@@ -1496,7 +1504,7 @@
static HRESULT String_idx_get(jsdisp_t *jsdisp, unsigned idx, jsval_t *r)
{
- StringInstance *string = (StringInstance*)jsdisp;
+ StringInstance *string = string_from_jsdisp(jsdisp);
jsstr_t *ret;
ret = jsstr_substr(string->str, idx, 1);
@@ -1580,8 +1588,8 @@
TRACE("\n");
- ret_str = jsstr_alloc_buf(argc, &ret);
- if(!ret_str)
+ ret = jsstr_alloc_buf(argc, &ret_str);
+ if(!ret)
return E_OUTOFMEMORY;
for(i=0; i<argc; i++) {
Modified: trunk/reactos/dll/win32/jscript/vbarray.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/jscript/vbarray.…
==============================================================================
--- trunk/reactos/dll/win32/jscript/vbarray.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/jscript/vbarray.c [iso-8859-1] Wed Nov 23 10:06:56 2016
@@ -30,9 +30,14 @@
static const WCHAR toArrayW[] =
{'t','o','A','r','r','a','y',0};
static const WCHAR uboundW[] =
{'u','b','o','u','n','d',0};
+static inline VBArrayInstance *vbarray_from_jsdisp(jsdisp_t *jsdisp)
+{
+ return CONTAINING_RECORD(jsdisp, VBArrayInstance, dispex);
+}
+
static inline VBArrayInstance *vbarray_from_vdisp(vdisp_t *vdisp)
{
- return (VBArrayInstance*)vdisp->u.jsdisp;
+ return vbarray_from_jsdisp(vdisp->u.jsdisp);
}
static inline VBArrayInstance *vbarray_this(vdisp_t *jsthis)
@@ -232,7 +237,7 @@
static void VBArray_destructor(jsdisp_t *dispex)
{
- VBArrayInstance *vbarray = (VBArrayInstance*)dispex;
+ VBArrayInstance *vbarray = vbarray_from_jsdisp(dispex);
SafeArrayDestroy(vbarray->safearray);
heap_free(vbarray);
Modified: trunk/reactos/media/doc/README.WINE
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/media/doc/README.WINE?rev=…
==============================================================================
--- trunk/reactos/media/doc/README.WINE [iso-8859-1] (original)
+++ trunk/reactos/media/doc/README.WINE [iso-8859-1] Wed Nov 23 10:06:56 2016
@@ -85,7 +85,7 @@
reactos/dll/win32/iphlpapi # Out of sync
reactos/dll/win32/itircl # Synced to WineStaging-1.9.11
reactos/dll/win32/itss # Synced to WineStaging-1.9.11
-reactos/dll/win32/jscript # Synced to WineStaging-1.9.16
+reactos/dll/win32/jscript # Synced to WineStaging-1.9.23
reactos/dll/win32/jsproxy # Synced to WineStaging-1.9.11
reactos/dll/win32/loadperf # Synced to WineStaging-1.9.11
reactos/dll/win32/lz32 # Synced to WineStaging-1.9.11