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
2ac35ac4
Commit
2ac35ac4
authored
Apr 24, 2013
by
Jacek Caban
Committed by
Alexandre Julliard
Apr 24, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jscript: Use single string instance for strings representing NULL BSTR instead of a flag.
parent
cd55afec
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
8 deletions
+28
-8
jsstr.c
dlls/jscript/jsstr.c
+18
-1
jsstr.h
dlls/jscript/jsstr.h
+4
-3
jsutils.c
dlls/jscript/jsutils.c
+6
-4
No files found.
dlls/jscript/jsstr.c
View file @
2ac35ac4
...
@@ -277,7 +277,7 @@ const WCHAR *jsstr_rope_flatten(jsstr_rope_t *str)
...
@@ -277,7 +277,7 @@ const WCHAR *jsstr_rope_flatten(jsstr_rope_t *str)
return
jsstr_as_heap
(
&
str
->
str
)
->
buf
=
buf
;
return
jsstr_as_heap
(
&
str
->
str
)
->
buf
=
buf
;
}
}
static
jsstr_t
*
empty_str
,
*
nan_str
,
*
undefined_str
;
static
jsstr_t
*
empty_str
,
*
nan_str
,
*
undefined_str
,
*
null_bstr_str
;
jsstr_t
*
jsstr_nan
(
void
)
jsstr_t
*
jsstr_nan
(
void
)
{
{
...
@@ -294,6 +294,16 @@ jsstr_t *jsstr_undefined(void)
...
@@ -294,6 +294,16 @@ jsstr_t *jsstr_undefined(void)
return
jsstr_addref
(
undefined_str
);
return
jsstr_addref
(
undefined_str
);
}
}
jsstr_t
*
jsstr_null_bstr
(
void
)
{
return
jsstr_addref
(
null_bstr_str
);
}
BOOL
is_null_bstr
(
jsstr_t
*
str
)
{
return
str
==
null_bstr_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
};
...
@@ -305,12 +315,19 @@ BOOL init_strings(void)
...
@@ -305,12 +315,19 @@ BOOL init_strings(void)
return
FALSE
;
return
FALSE
;
if
(
!
(
undefined_str
=
jsstr_alloc
(
undefinedW
)))
if
(
!
(
undefined_str
=
jsstr_alloc
(
undefinedW
)))
return
FALSE
;
return
FALSE
;
if
(
!
jsstr_alloc_buf
(
0
,
&
null_bstr_str
))
return
FALSE
;
return
TRUE
;
return
TRUE
;
}
}
void
free_strings
(
void
)
void
free_strings
(
void
)
{
{
if
(
empty_str
)
jsstr_release
(
empty_str
);
jsstr_release
(
empty_str
);
if
(
nan_str
)
jsstr_release
(
nan_str
);
jsstr_release
(
nan_str
);
if
(
undefined_str
)
jsstr_release
(
undefined_str
);
jsstr_release
(
undefined_str
);
if
(
null_bstr_str
)
jsstr_release
(
null_bstr_str
);
}
}
dlls/jscript/jsstr.h
View file @
2ac35ac4
...
@@ -17,7 +17,7 @@
...
@@ -17,7 +17,7 @@
*/
*/
/*
/*
*
This
is a common header for all string representations. The exact layout of the string
*
jsstr_t
is a common header for all string representations. The exact layout of the string
* representation may be:
* representation may be:
*
*
* - inline string - string bytes directly follow string headers.
* - inline string - string bytes directly follow string headers.
...
@@ -42,8 +42,6 @@ struct _jsstr_t {
...
@@ -42,8 +42,6 @@ struct _jsstr_t {
#define JSSTR_MAX_LENGTH (1 << (32-JSSTR_LENGTH_SHIFT))
#define JSSTR_MAX_LENGTH (1 << (32-JSSTR_LENGTH_SHIFT))
#define JSSTR_FLAGS_MASK ((1 << JSSTR_LENGTH_SHIFT)-1)
#define JSSTR_FLAGS_MASK ((1 << JSSTR_LENGTH_SHIFT)-1)
#define JSSTR_FLAG_NULLBSTR 4
#define JSSTR_FLAG_LBIT 1
#define JSSTR_FLAG_LBIT 1
#define JSSTR_FLAG_FLAT 2
#define JSSTR_FLAG_FLAT 2
#define JSSTR_FLAG_TAG_MASK 3
#define JSSTR_FLAG_TAG_MASK 3
...
@@ -187,6 +185,9 @@ jsstr_t *jsstr_nan(void) DECLSPEC_HIDDEN;
...
@@ -187,6 +185,9 @@ 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
;
jsstr_t
*
jsstr_undefined
(
void
)
DECLSPEC_HIDDEN
;
jsstr_t
*
jsstr_null_bstr
(
void
)
DECLSPEC_HIDDEN
;
BOOL
is_null_bstr
(
jsstr_t
*
)
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 @
2ac35ac4
...
@@ -294,11 +294,13 @@ HRESULT variant_to_jsval(VARIANT *var, jsval_t *r)
...
@@ -294,11 +294,13 @@ HRESULT variant_to_jsval(VARIANT *var, jsval_t *r)
case
VT_BSTR
:
{
case
VT_BSTR
:
{
jsstr_t
*
str
;
jsstr_t
*
str
;
if
(
V_BSTR
(
var
))
{
str
=
jsstr_alloc_len
(
V_BSTR
(
var
),
SysStringLen
(
V_BSTR
(
var
)));
str
=
jsstr_alloc_len
(
V_BSTR
(
var
),
SysStringLen
(
V_BSTR
(
var
)));
if
(
!
str
)
if
(
!
str
)
return
E_OUTOFMEMORY
;
return
E_OUTOFMEMORY
;
if
(
!
V_BSTR
(
var
))
}
else
{
str
->
length_flags
|=
JSSTR_FLAG_NULLBSTR
;
str
=
jsstr_null_bstr
();
}
*
r
=
jsval_string
(
str
);
*
r
=
jsval_string
(
str
);
return
S_OK
;
return
S_OK
;
...
@@ -351,7 +353,7 @@ HRESULT jsval_to_variant(jsval_t val, VARIANT *retv)
...
@@ -351,7 +353,7 @@ HRESULT jsval_to_variant(jsval_t val, VARIANT *retv)
jsstr_t
*
str
=
get_string
(
val
);
jsstr_t
*
str
=
get_string
(
val
);
V_VT
(
retv
)
=
VT_BSTR
;
V_VT
(
retv
)
=
VT_BSTR
;
if
(
str
->
length_flags
&
JSSTR_FLAG_NULLBSTR
)
{
if
(
is_null_bstr
(
str
)
)
{
V_BSTR
(
retv
)
=
NULL
;
V_BSTR
(
retv
)
=
NULL
;
}
else
{
}
else
{
V_BSTR
(
retv
)
=
SysAllocStringLen
(
NULL
,
jsstr_length
(
str
));
V_BSTR
(
retv
)
=
SysAllocStringLen
(
NULL
,
jsstr_length
(
str
));
...
@@ -913,7 +915,7 @@ HRESULT variant_change_type(script_ctx_t *ctx, VARIANT *dst, VARIANT *src, VARTY
...
@@ -913,7 +915,7 @@ HRESULT variant_change_type(script_ctx_t *ctx, VARIANT *dst, VARIANT *src, VARTY
if
(
FAILED
(
hres
))
if
(
FAILED
(
hres
))
break
;
break
;
if
(
str
->
length_flags
&
JSSTR_FLAG_NULLBSTR
)
{
if
(
is_null_bstr
(
str
)
)
{
V_BSTR
(
dst
)
=
NULL
;
V_BSTR
(
dst
)
=
NULL
;
break
;
break
;
}
}
...
...
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