Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
d7f24b09
Commit
d7f24b09
authored
Mar 08, 2013
by
Jacek Caban
Committed by
Alexandre Julliard
Mar 08, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jscript: Reuse static instance of 'undefined' string.
parent
c7c71b87
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
33 additions
and
80 deletions
+33
-80
engine.c
dlls/jscript/engine.c
+2
-4
global.c
dlls/jscript/global.c
+12
-47
jsregexp.c
dlls/jscript/jsregexp.c
+2
-9
jsstr.c
dlls/jscript/jsstr.c
+10
-1
jsstr.h
dlls/jscript/jsstr.h
+1
-0
jsutils.c
dlls/jscript/jsutils.c
+2
-3
lex.c
dlls/jscript/lex.c
+0
-1
string.c
dlls/jscript/string.c
+4
-15
No files found.
dlls/jscript/engine.c
View file @
d7f24b09
...
@@ -1698,13 +1698,11 @@ static HRESULT interp_typeofid(exec_ctx_t *ctx)
...
@@ -1698,13 +1698,11 @@ static HRESULT interp_typeofid(exec_ctx_t *ctx)
DISPID
id
;
DISPID
id
;
HRESULT
hres
;
HRESULT
hres
;
static
const
WCHAR
undefinedW
[]
=
{
'u'
,
'n'
,
'd'
,
'e'
,
'f'
,
'i'
,
'n'
,
'e'
,
'd'
,
0
};
TRACE
(
"
\n
"
);
TRACE
(
"
\n
"
);
obj
=
stack_pop_objid
(
ctx
,
&
id
);
obj
=
stack_pop_objid
(
ctx
,
&
id
);
if
(
!
obj
)
if
(
!
obj
)
return
stack_push
_string
(
ctx
,
undefinedW
);
return
stack_push
(
ctx
,
jsval_string
(
jsstr_undefined
())
);
hres
=
disp_propget
(
ctx
->
script
,
obj
,
id
,
&
v
);
hres
=
disp_propget
(
ctx
->
script
,
obj
,
id
,
&
v
);
IDispatch_Release
(
obj
);
IDispatch_Release
(
obj
);
...
@@ -1735,7 +1733,7 @@ static HRESULT interp_typeofident(exec_ctx_t *ctx)
...
@@ -1735,7 +1733,7 @@ static HRESULT interp_typeofident(exec_ctx_t *ctx)
return
hres
;
return
hres
;
if
(
exprval
.
type
==
EXPRVAL_INVALID
)
{
if
(
exprval
.
type
==
EXPRVAL_INVALID
)
{
hres
=
stack_push
_string
(
ctx
,
undefinedW
);
hres
=
stack_push
(
ctx
,
jsval_string
(
jsstr_undefined
())
);
exprval_release
(
&
exprval
);
exprval_release
(
&
exprval
);
return
hres
;
return
hres
;
}
}
...
...
dlls/jscript/global.c
View file @
d7f24b09
...
@@ -286,14 +286,8 @@ static HRESULT JSGlobal_escape(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, u
...
@@ -286,14 +286,8 @@ static HRESULT JSGlobal_escape(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, u
TRACE
(
"
\n
"
);
TRACE
(
"
\n
"
);
if
(
!
argc
)
{
if
(
!
argc
)
{
if
(
r
)
{
if
(
r
)
ret_str
=
jsstr_alloc
(
undefinedW
);
*
r
=
jsval_string
(
jsstr_undefined
());
if
(
!
ret_str
)
return
E_OUTOFMEMORY
;
*
r
=
jsval_string
(
ret_str
);
}
return
S_OK
;
return
S_OK
;
}
}
...
@@ -640,13 +634,8 @@ static HRESULT JSGlobal_unescape(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
...
@@ -640,13 +634,8 @@ static HRESULT JSGlobal_unescape(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
TRACE
(
"
\n
"
);
TRACE
(
"
\n
"
);
if
(
!
argc
)
{
if
(
!
argc
)
{
if
(
r
)
{
if
(
r
)
ret_str
=
jsstr_alloc
(
undefinedW
);
*
r
=
jsval_string
(
jsstr_undefined
());
if
(
!
ret_str
)
return
E_OUTOFMEMORY
;
*
r
=
jsval_string
(
ret_str
);
}
return
S_OK
;
return
S_OK
;
}
}
...
@@ -781,14 +770,8 @@ static HRESULT JSGlobal_encodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
...
@@ -781,14 +770,8 @@ static HRESULT JSGlobal_encodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
TRACE
(
"
\n
"
);
TRACE
(
"
\n
"
);
if
(
!
argc
)
{
if
(
!
argc
)
{
if
(
r
)
{
if
(
r
)
ret
=
jsstr_alloc
(
undefinedW
);
*
r
=
jsval_string
(
jsstr_undefined
());
if
(
!
ret
)
return
E_OUTOFMEMORY
;
*
r
=
jsval_string
(
ret
);
}
return
S_OK
;
return
S_OK
;
}
}
...
@@ -853,14 +836,8 @@ static HRESULT JSGlobal_decodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
...
@@ -853,14 +836,8 @@ static HRESULT JSGlobal_decodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
TRACE
(
"
\n
"
);
TRACE
(
"
\n
"
);
if
(
!
argc
)
{
if
(
!
argc
)
{
if
(
r
)
{
if
(
r
)
ret
=
jsstr_alloc
(
undefinedW
);
*
r
=
jsval_string
(
jsstr_undefined
());
if
(
!
ret
)
return
E_OUTOFMEMORY
;
*
r
=
jsval_string
(
ret
);
}
return
S_OK
;
return
S_OK
;
}
}
...
@@ -944,14 +921,8 @@ static HRESULT JSGlobal_encodeURIComponent(script_ctx_t *ctx, vdisp_t *jsthis, W
...
@@ -944,14 +921,8 @@ static HRESULT JSGlobal_encodeURIComponent(script_ctx_t *ctx, vdisp_t *jsthis, W
TRACE
(
"
\n
"
);
TRACE
(
"
\n
"
);
if
(
!
argc
)
{
if
(
!
argc
)
{
if
(
r
)
{
if
(
r
)
ret
=
jsstr_alloc
(
undefinedW
);
*
r
=
jsval_string
(
jsstr_undefined
());
if
(
!
ret
)
return
E_OUTOFMEMORY
;
*
r
=
jsval_string
(
ret
);
}
return
S_OK
;
return
S_OK
;
}
}
...
@@ -1014,14 +985,8 @@ static HRESULT JSGlobal_decodeURIComponent(script_ctx_t *ctx, vdisp_t *jsthis, W
...
@@ -1014,14 +985,8 @@ static HRESULT JSGlobal_decodeURIComponent(script_ctx_t *ctx, vdisp_t *jsthis, W
TRACE
(
"
\n
"
);
TRACE
(
"
\n
"
);
if
(
!
argc
)
{
if
(
!
argc
)
{
if
(
r
)
{
if
(
r
)
ret
=
jsstr_alloc
(
undefinedW
);
*
r
=
jsval_string
(
jsstr_undefined
());
if
(
!
ret
)
return
E_OUTOFMEMORY
;
*
r
=
jsval_string
(
ret
);
}
return
S_OK
;
return
S_OK
;
}
}
...
...
dlls/jscript/jsregexp.c
View file @
d7f24b09
...
@@ -58,7 +58,6 @@ static const WCHAR idx7W[] = {'$','7',0};
...
@@ -58,7 +58,6 @@ static const WCHAR idx7W[] = {'$','7',0};
static
const
WCHAR
idx8W
[]
=
{
'$'
,
'8'
,
0
};
static
const
WCHAR
idx8W
[]
=
{
'$'
,
'8'
,
0
};
static
const
WCHAR
idx9W
[]
=
{
'$'
,
'9'
,
0
};
static
const
WCHAR
idx9W
[]
=
{
'$'
,
'9'
,
0
};
static
const
WCHAR
undefinedW
[]
=
{
'u'
,
'n'
,
'd'
,
'e'
,
'f'
,
'i'
,
'n'
,
'e'
,
'd'
,
0
};
static
const
WCHAR
emptyW
[]
=
{
0
};
static
const
WCHAR
emptyW
[]
=
{
0
};
static
inline
RegExpInstance
*
regexp_from_vdisp
(
vdisp_t
*
vdisp
)
static
inline
RegExpInstance
*
regexp_from_vdisp
(
vdisp_t
*
vdisp
)
...
@@ -487,21 +486,15 @@ static HRESULT RegExp_test(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsig
...
@@ -487,21 +486,15 @@ static HRESULT RegExp_test(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsig
jsval_t
*
r
)
jsval_t
*
r
)
{
{
match_state_t
*
match
;
match_state_t
*
match
;
heap_pool_t
*
mark
;
jsstr_t
*
undef_str
;
jsstr_t
*
undef_str
;
heap_pool_t
*
mark
;
BOOL
b
;
BOOL
b
;
HRESULT
hres
;
HRESULT
hres
;
TRACE
(
"
\n
"
);
TRACE
(
"
\n
"
);
if
(
!
argc
)
{
undef_str
=
jsstr_alloc
(
undefinedW
);
if
(
!
undef_str
)
return
E_OUTOFMEMORY
;
}
mark
=
heap_pool_mark
(
&
ctx
->
tmp_heap
);
mark
=
heap_pool_mark
(
&
ctx
->
tmp_heap
);
hres
=
run_exec
(
ctx
,
jsthis
,
argc
?
argv
[
0
]
:
jsval_string
(
undef_str
),
NULL
,
&
match
,
&
b
);
hres
=
run_exec
(
ctx
,
jsthis
,
argc
?
argv
[
0
]
:
jsval_string
(
undef_str
=
jsstr_undefined
()
),
NULL
,
&
match
,
&
b
);
heap_pool_clear
(
mark
);
heap_pool_clear
(
mark
);
if
(
!
argc
)
if
(
!
argc
)
jsstr_release
(
undef_str
);
jsstr_release
(
undef_str
);
...
...
dlls/jscript/jsstr.c
View file @
d7f24b09
...
@@ -88,7 +88,7 @@ jsstr_t *jsstr_concat(jsstr_t *str1, jsstr_t *str2)
...
@@ -88,7 +88,7 @@ jsstr_t *jsstr_concat(jsstr_t *str1, jsstr_t *str2)
return
ret
;
return
ret
;
}
}
static
jsstr_t
*
empty_str
,
*
nan_str
;
static
jsstr_t
*
empty_str
,
*
nan_str
,
*
undefined_str
;
jsstr_t
*
jsstr_nan
(
void
)
jsstr_t
*
jsstr_nan
(
void
)
{
{
...
@@ -100,14 +100,22 @@ jsstr_t *jsstr_empty(void)
...
@@ -100,14 +100,22 @@ jsstr_t *jsstr_empty(void)
return
jsstr_addref
(
empty_str
);
return
jsstr_addref
(
empty_str
);
}
}
jsstr_t
*
jsstr_undefined
(
void
)
{
return
jsstr_addref
(
undefined_str
);
}
BOOL
init_strings
(
void
)
BOOL
init_strings
(
void
)
{
{
static
const
WCHAR
NaNW
[]
=
{
'N'
,
'a'
,
'N'
,
0
};
static
const
WCHAR
NaNW
[]
=
{
'N'
,
'a'
,
'N'
,
0
};
static
const
WCHAR
undefinedW
[]
=
{
'u'
,
'n'
,
'd'
,
'e'
,
'f'
,
'i'
,
'n'
,
'e'
,
'd'
,
0
};
if
(
!
(
empty_str
=
jsstr_alloc_buf
(
0
)))
if
(
!
(
empty_str
=
jsstr_alloc_buf
(
0
)))
return
FALSE
;
return
FALSE
;
if
(
!
(
nan_str
=
jsstr_alloc
(
NaNW
)))
if
(
!
(
nan_str
=
jsstr_alloc
(
NaNW
)))
return
FALSE
;
return
FALSE
;
if
(
!
(
undefined_str
=
jsstr_alloc
(
undefinedW
)))
return
FALSE
;
return
TRUE
;
return
TRUE
;
}
}
...
@@ -115,4 +123,5 @@ void free_strings(void)
...
@@ -115,4 +123,5 @@ void free_strings(void)
{
{
jsstr_release
(
empty_str
);
jsstr_release
(
empty_str
);
jsstr_release
(
nan_str
);
jsstr_release
(
nan_str
);
jsstr_release
(
undefined_str
);
}
}
dlls/jscript/jsstr.h
View file @
d7f24b09
...
@@ -76,6 +76,7 @@ jsstr_t *jsstr_concat(jsstr_t*,jsstr_t*) DECLSPEC_HIDDEN;
...
@@ -76,6 +76,7 @@ jsstr_t *jsstr_concat(jsstr_t*,jsstr_t*) DECLSPEC_HIDDEN;
jsstr_t
*
jsstr_nan
(
void
)
DECLSPEC_HIDDEN
;
jsstr_t
*
jsstr_nan
(
void
)
DECLSPEC_HIDDEN
;
jsstr_t
*
jsstr_empty
(
void
)
DECLSPEC_HIDDEN
;
jsstr_t
*
jsstr_empty
(
void
)
DECLSPEC_HIDDEN
;
jsstr_t
*
jsstr_undefined
(
void
)
DECLSPEC_HIDDEN
;
BOOL
init_strings
(
void
)
DECLSPEC_HIDDEN
;
BOOL
init_strings
(
void
)
DECLSPEC_HIDDEN
;
void
free_strings
(
void
)
DECLSPEC_HIDDEN
;
void
free_strings
(
void
)
DECLSPEC_HIDDEN
;
...
...
dlls/jscript/jsutils.c
View file @
d7f24b09
...
@@ -738,15 +738,14 @@ HRESULT double_to_string(double n, jsstr_t **str)
...
@@ -738,15 +738,14 @@ HRESULT double_to_string(double n, jsstr_t **str)
/* ECMA-262 3rd Edition 9.8 */
/* ECMA-262 3rd Edition 9.8 */
HRESULT
to_string
(
script_ctx_t
*
ctx
,
jsval_t
val
,
jsstr_t
**
str
)
HRESULT
to_string
(
script_ctx_t
*
ctx
,
jsval_t
val
,
jsstr_t
**
str
)
{
{
const
WCHAR
undefinedW
[]
=
{
'u'
,
'n'
,
'd'
,
'e'
,
'f'
,
'i'
,
'n'
,
'e'
,
'd'
,
0
};
const
WCHAR
nullW
[]
=
{
'n'
,
'u'
,
'l'
,
'l'
,
0
};
const
WCHAR
nullW
[]
=
{
'n'
,
'u'
,
'l'
,
'l'
,
0
};
const
WCHAR
trueW
[]
=
{
't'
,
'r'
,
'u'
,
'e'
,
0
};
const
WCHAR
trueW
[]
=
{
't'
,
'r'
,
'u'
,
'e'
,
0
};
const
WCHAR
falseW
[]
=
{
'f'
,
'a'
,
'l'
,
's'
,
'e'
,
0
};
const
WCHAR
falseW
[]
=
{
'f'
,
'a'
,
'l'
,
's'
,
'e'
,
0
};
switch
(
jsval_type
(
val
))
{
switch
(
jsval_type
(
val
))
{
case
JSV_UNDEFINED
:
case
JSV_UNDEFINED
:
*
str
=
jsstr_
alloc
(
undefinedW
);
*
str
=
jsstr_
undefined
(
);
break
;
return
S_OK
;
case
JSV_NULL
:
case
JSV_NULL
:
*
str
=
jsstr_alloc
(
nullW
);
*
str
=
jsstr_alloc
(
nullW
);
break
;
break
;
...
...
dlls/jscript/lex.c
View file @
d7f24b09
...
@@ -59,7 +59,6 @@ static const WCHAR throwW[] = {'t','h','r','o','w',0};
...
@@ -59,7 +59,6 @@ static const WCHAR throwW[] = {'t','h','r','o','w',0};
static
const
WCHAR
trueW
[]
=
{
't'
,
'r'
,
'u'
,
'e'
,
0
};
static
const
WCHAR
trueW
[]
=
{
't'
,
'r'
,
'u'
,
'e'
,
0
};
static
const
WCHAR
tryW
[]
=
{
't'
,
'r'
,
'y'
,
0
};
static
const
WCHAR
tryW
[]
=
{
't'
,
'r'
,
'y'
,
0
};
static
const
WCHAR
typeofW
[]
=
{
't'
,
'y'
,
'p'
,
'e'
,
'o'
,
'f'
,
0
};
static
const
WCHAR
typeofW
[]
=
{
't'
,
'y'
,
'p'
,
'e'
,
'o'
,
'f'
,
0
};
static
const
WCHAR
undefinedW
[]
=
{
'u'
,
'n'
,
'd'
,
'e'
,
'f'
,
'i'
,
'n'
,
'e'
,
'd'
,
0
};
static
const
WCHAR
varW
[]
=
{
'v'
,
'a'
,
'r'
,
0
};
static
const
WCHAR
varW
[]
=
{
'v'
,
'a'
,
'r'
,
0
};
static
const
WCHAR
voidW
[]
=
{
'v'
,
'o'
,
'i'
,
'd'
,
0
};
static
const
WCHAR
voidW
[]
=
{
'v'
,
'o'
,
'i'
,
'd'
,
0
};
static
const
WCHAR
whileW
[]
=
{
'w'
,
'h'
,
'i'
,
'l'
,
'e'
,
0
};
static
const
WCHAR
whileW
[]
=
{
'w'
,
'h'
,
'i'
,
'l'
,
'e'
,
0
};
...
...
dlls/jscript/string.c
View file @
d7f24b09
...
@@ -188,10 +188,7 @@ static HRESULT do_attributeless_tag_format(script_ctx_t *ctx, vdisp_t *jsthis, j
...
@@ -188,10 +188,7 @@ static HRESULT do_attributeless_tag_format(script_ctx_t *ctx, vdisp_t *jsthis, j
static
HRESULT
do_attribute_tag_format
(
script_ctx_t
*
ctx
,
vdisp_t
*
jsthis
,
unsigned
argc
,
jsval_t
*
argv
,
jsval_t
*
r
,
static
HRESULT
do_attribute_tag_format
(
script_ctx_t
*
ctx
,
vdisp_t
*
jsthis
,
unsigned
argc
,
jsval_t
*
argv
,
jsval_t
*
r
,
const
WCHAR
*
tagname
,
const
WCHAR
*
attrname
)
const
WCHAR
*
tagname
,
const
WCHAR
*
attrname
)
{
{
static
const
WCHAR
undefinedW
[]
=
{
'u'
,
'n'
,
'd'
,
'e'
,
'f'
,
'i'
,
'n'
,
'e'
,
'd'
,
0
};
jsstr_t
*
str
,
*
attr_value
=
NULL
;
jsstr_t
*
str
,
*
attr_value
=
NULL
;
unsigned
attr_len
;
HRESULT
hres
;
HRESULT
hres
;
hres
=
get_string_val
(
ctx
,
jsthis
,
&
str
);
hres
=
get_string_val
(
ctx
,
jsthis
,
&
str
);
...
@@ -204,9 +201,8 @@ static HRESULT do_attribute_tag_format(script_ctx_t *ctx, vdisp_t *jsthis, unsig
...
@@ -204,9 +201,8 @@ static HRESULT do_attribute_tag_format(script_ctx_t *ctx, vdisp_t *jsthis, unsig
jsstr_release
(
str
);
jsstr_release
(
str
);
return
hres
;
return
hres
;
}
}
attr_len
=
jsstr_length
(
attr_value
);
}
else
{
}
else
{
attr_
len
=
sizeof
(
undefinedW
)
/
sizeof
(
WCHAR
)
-
1
;
attr_
value
=
jsstr_undefined
()
;
}
}
if
(
r
)
{
if
(
r
)
{
...
@@ -214,7 +210,7 @@ static HRESULT do_attribute_tag_format(script_ctx_t *ctx, vdisp_t *jsthis, unsig
...
@@ -214,7 +210,7 @@ static HRESULT do_attribute_tag_format(script_ctx_t *ctx, vdisp_t *jsthis, unsig
unsigned
tagname_len
=
strlenW
(
tagname
);
unsigned
tagname_len
=
strlenW
(
tagname
);
jsstr_t
*
ret
;
jsstr_t
*
ret
;
ret
=
jsstr_alloc_buf
(
2
*
tagname_len
+
attrname_len
+
attr_len
+
jsstr_length
(
str
)
+
9
);
ret
=
jsstr_alloc_buf
(
2
*
tagname_len
+
attrname_len
+
jsstr_length
(
attr_value
)
+
jsstr_length
(
str
)
+
9
);
if
(
ret
)
{
if
(
ret
)
{
WCHAR
*
ptr
=
ret
->
str
;
WCHAR
*
ptr
=
ret
->
str
;
...
@@ -226,13 +222,7 @@ static HRESULT do_attribute_tag_format(script_ctx_t *ctx, vdisp_t *jsthis, unsig
...
@@ -226,13 +222,7 @@ static HRESULT do_attribute_tag_format(script_ctx_t *ctx, vdisp_t *jsthis, unsig
ptr
+=
attrname_len
;
ptr
+=
attrname_len
;
*
ptr
++
=
'='
;
*
ptr
++
=
'='
;
*
ptr
++
=
'"'
;
*
ptr
++
=
'"'
;
ptr
+=
jsstr_flush
(
attr_value
,
ptr
);
if
(
attr_value
)
jsstr_flush
(
attr_value
,
ptr
);
else
memcpy
(
ptr
,
undefinedW
,
attr_len
*
sizeof
(
WCHAR
));
ptr
+=
attr_len
;
*
ptr
++
=
'"'
;
*
ptr
++
=
'"'
;
*
ptr
++
=
'>'
;
*
ptr
++
=
'>'
;
ptr
+=
jsstr_flush
(
str
,
ptr
);
ptr
+=
jsstr_flush
(
str
,
ptr
);
...
@@ -249,8 +239,7 @@ static HRESULT do_attribute_tag_format(script_ctx_t *ctx, vdisp_t *jsthis, unsig
...
@@ -249,8 +239,7 @@ static HRESULT do_attribute_tag_format(script_ctx_t *ctx, vdisp_t *jsthis, unsig
}
}
}
}
if
(
attr_value
)
jsstr_release
(
attr_value
);
jsstr_release
(
attr_value
);
jsstr_release
(
str
);
jsstr_release
(
str
);
return
hres
;
return
hres
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment