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
9a752be1
Commit
9a752be1
authored
Sep 15, 2008
by
Jacek Caban
Committed by
Alexandre Julliard
Sep 16, 2008
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jscript: Added string to object conversion implementation.
parent
5670ca52
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
5 deletions
+53
-5
jscript.h
dlls/jscript/jscript.h
+1
-0
jsutils.c
dlls/jscript/jsutils.c
+11
-0
string.c
dlls/jscript/string.c
+38
-5
lang.js
dlls/jscript/tests/lang.js
+3
-0
No files found.
dlls/jscript/jscript.h
View file @
9a752be1
...
...
@@ -133,6 +133,7 @@ HRESULT create_object(script_ctx_t*,DispatchEx*,DispatchEx**);
HRESULT
create_math
(
script_ctx_t
*
,
DispatchEx
**
);
HRESULT
create_array
(
script_ctx_t
*
,
DWORD
,
DispatchEx
**
);
HRESULT
create_regexp_str
(
script_ctx_t
*
,
const
WCHAR
*
,
DWORD
,
const
WCHAR
*
,
DWORD
,
DispatchEx
**
);
HRESULT
create_string
(
script_ctx_t
*
,
const
WCHAR
*
,
DWORD
,
DispatchEx
**
);
HRESULT
to_primitive
(
script_ctx_t
*
,
VARIANT
*
,
jsexcept_t
*
,
VARIANT
*
);
HRESULT
to_boolean
(
VARIANT
*
,
VARIANT_BOOL
*
);
...
...
dlls/jscript/jsutils.c
View file @
9a752be1
...
...
@@ -17,6 +17,7 @@
*/
#include "jscript.h"
#include "engine.h"
#include "wine/debug.h"
...
...
@@ -248,7 +249,17 @@ HRESULT to_string(script_ctx_t *ctx, VARIANT *v, jsexcept_t *ei, BSTR *str)
/* ECMA-262 3rd Edition 9.9 */
HRESULT
to_object
(
exec_ctx_t
*
ctx
,
VARIANT
*
v
,
IDispatch
**
disp
)
{
DispatchEx
*
dispex
;
HRESULT
hres
;
switch
(
V_VT
(
v
))
{
case
VT_BSTR
:
hres
=
create_string
(
ctx
->
parser
->
script
,
V_BSTR
(
v
),
SysStringLen
(
V_BSTR
(
v
)),
&
dispex
);
if
(
FAILED
(
hres
))
return
hres
;
*
disp
=
(
IDispatch
*
)
_IDispatchEx_
(
dispex
);
break
;
case
VT_DISPATCH
:
IDispatch_AddRef
(
V_DISPATCH
(
v
));
*
disp
=
V_DISPATCH
(
v
);
...
...
dlls/jscript/string.c
View file @
9a752be1
...
...
@@ -24,6 +24,9 @@ WINE_DEFAULT_DEBUG_CHANNEL(jscript);
typedef
struct
{
DispatchEx
dispex
;
WCHAR
*
str
;
DWORD
length
;
}
StringInstance
;
static
const
WCHAR
lengthW
[]
=
{
'l'
,
'e'
,
'n'
,
'g'
,
't'
,
'h'
,
0
};
...
...
@@ -64,11 +67,6 @@ static const WCHAR propertyIsEnumerableW[] =
{
'p'
,
'r'
,
'o'
,
'p'
,
'e'
,
'r'
,
't'
,
'y'
,
'I'
,
's'
,
'E'
,
'n'
,
'u'
,
'm'
,
'e'
,
'r'
,
'a'
,
'b'
,
'l'
,
'e'
,
0
};
static
const
WCHAR
isPrototypeOfW
[]
=
{
'i'
,
's'
,
'P'
,
'r'
,
'o'
,
't'
,
'o'
,
't'
,
'y'
,
'p'
,
'e'
,
'O'
,
'f'
,
0
};
static
void
String_destructor
(
DispatchEx
*
dispex
)
{
FIXME
(
"
\n
"
);
}
static
HRESULT
String_length
(
DispatchEx
*
dispex
,
LCID
lcid
,
WORD
flags
,
DISPPARAMS
*
dp
,
VARIANT
*
retv
,
jsexcept_t
*
ei
,
IServiceProvider
*
sp
)
{
...
...
@@ -328,6 +326,14 @@ static HRESULT String_value(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAM
return
E_NOTIMPL
;
}
static
void
String_destructor
(
DispatchEx
*
dispex
)
{
StringInstance
*
This
=
(
StringInstance
*
)
dispex
;
heap_free
(
This
->
str
);
heap_free
(
This
);
}
static
const
builtin_prop_t
String_props
[]
=
{
{
anchorW
,
String_anchor
,
PROPF_METHOD
},
{
bigW
,
String_big
,
PROPF_METHOD
},
...
...
@@ -419,3 +425,30 @@ HRESULT create_string_constr(script_ctx_t *ctx, DispatchEx **ret)
jsdisp_release
(
&
string
->
dispex
);
return
hres
;
}
HRESULT
create_string
(
script_ctx_t
*
ctx
,
const
WCHAR
*
str
,
DWORD
len
,
DispatchEx
**
ret
)
{
StringInstance
*
string
;
HRESULT
hres
;
hres
=
string_alloc
(
ctx
,
TRUE
,
&
string
);
if
(
FAILED
(
hres
))
return
hres
;
if
(
len
==
-
1
)
len
=
strlenW
(
str
);
string
->
length
=
len
;
string
->
str
=
heap_alloc
((
len
+
1
)
*
sizeof
(
WCHAR
));
if
(
!
string
->
str
)
{
jsdisp_release
(
&
string
->
dispex
);
return
E_OUTOFMEMORY
;
}
memcpy
(
string
->
str
,
str
,
len
*
sizeof
(
WCHAR
));
string
->
str
[
len
]
=
0
;
*
ret
=
&
string
->
dispex
;
return
S_OK
;
}
dlls/jscript/tests/lang.js
View file @
9a752be1
...
...
@@ -233,4 +233,7 @@ ok(tmp === 2, "incremented tmp(1) is not 2");
ok
(
tmp
--
===
2
,
"tmp-- (2) is not 2"
);
ok
(
tmp
===
1
,
"decremented tmp is not 1"
);
String
.
prototype
.
test
=
true
;
ok
(
""
.
test
===
true
,
"
\"\"
,test is not true"
);
reportSuccess
();
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