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
4731f174
Commit
4731f174
authored
Sep 19, 2008
by
Jacek Caban
Committed by
Alexandre Julliard
Sep 19, 2008
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jscript: Added String.charAt implementation.
parent
53657393
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
95 additions
and
13 deletions
+95
-13
engine.c
dlls/jscript/engine.c
+0
-11
jscript.h
dlls/jscript/jscript.h
+12
-0
jsutils.c
dlls/jscript/jsutils.c
+20
-0
string.c
dlls/jscript/string.c
+44
-2
api.js
dlls/jscript/tests/api.js
+19
-0
No files found.
dlls/jscript/engine.c
View file @
4731f174
...
...
@@ -288,17 +288,6 @@ static inline DOUBLE num_val(const VARIANT *v)
return
V_VT
(
v
)
==
VT_I4
?
V_I4
(
v
)
:
V_R8
(
v
);
}
static
inline
void
num_set_val
(
VARIANT
*
v
,
DOUBLE
d
)
{
if
(
d
==
(
DOUBLE
)(
INT
)
d
)
{
V_VT
(
v
)
=
VT_I4
;
V_I4
(
v
)
=
d
;
}
else
{
V_VT
(
v
)
=
VT_R8
;
V_R8
(
v
)
=
d
;
}
}
/* ECMA-262 3rd Edition 11.9.6 */
HRESULT
equal2_values
(
VARIANT
*
lval
,
VARIANT
*
rval
,
BOOL
*
ret
)
{
...
...
dlls/jscript/jscript.h
View file @
4731f174
...
...
@@ -140,6 +140,7 @@ HRESULT create_number(script_ctx_t*,VARIANT*,DispatchEx**);
HRESULT
to_primitive
(
script_ctx_t
*
,
VARIANT
*
,
jsexcept_t
*
,
VARIANT
*
);
HRESULT
to_boolean
(
VARIANT
*
,
VARIANT_BOOL
*
);
HRESULT
to_number
(
script_ctx_t
*
,
VARIANT
*
,
jsexcept_t
*
,
VARIANT
*
);
HRESULT
to_integer
(
script_ctx_t
*
,
VARIANT
*
,
jsexcept_t
*
,
VARIANT
*
);
HRESULT
to_int32
(
script_ctx_t
*
,
VARIANT
*
,
jsexcept_t
*
,
INT
*
);
HRESULT
to_string
(
script_ctx_t
*
,
VARIANT
*
,
jsexcept_t
*
,
BSTR
*
);
HRESULT
to_object
(
exec_ctx_t
*
,
VARIANT
*
,
IDispatch
**
);
...
...
@@ -204,6 +205,17 @@ static inline DWORD arg_cnt(const DISPPARAMS *dp)
return
dp
->
cArgs
-
dp
->
cNamedArgs
;
}
static
inline
void
num_set_val
(
VARIANT
*
v
,
DOUBLE
d
)
{
if
(
d
==
(
DOUBLE
)(
INT
)
d
)
{
V_VT
(
v
)
=
VT_I4
;
V_I4
(
v
)
=
d
;
}
else
{
V_VT
(
v
)
=
VT_R8
;
V_R8
(
v
)
=
d
;
}
}
const
char
*
debugstr_variant
(
const
VARIANT
*
);
HRESULT
WINAPI
JScriptFactory_CreateInstance
(
IClassFactory
*
,
IUnknown
*
,
REFIID
,
void
**
);
...
...
dlls/jscript/jsutils.c
View file @
4731f174
...
...
@@ -16,6 +16,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <math.h>
#include "jscript.h"
#include "engine.h"
...
...
@@ -239,6 +241,24 @@ HRESULT to_number(script_ctx_t *ctx, VARIANT *v, jsexcept_t *ei, VARIANT *ret)
return
S_OK
;
}
/* ECMA-262 3rd Edition 9.4 */
HRESULT
to_integer
(
script_ctx_t
*
ctx
,
VARIANT
*
v
,
jsexcept_t
*
ei
,
VARIANT
*
ret
)
{
VARIANT
num
;
HRESULT
hres
;
hres
=
to_number
(
ctx
,
v
,
ei
,
&
num
);
if
(
FAILED
(
hres
))
return
hres
;
if
(
V_VT
(
&
num
)
==
VT_I4
)
*
ret
=
*
v
;
else
num_set_val
(
ret
,
V_R8
(
&
num
)
>=
0
.
0
?
floor
(
V_R8
(
&
num
))
:
-
floor
(
-
V_R8
(
&
num
)));
return
S_OK
;
}
/* ECMA-262 3rd Edition 9.5 */
HRESULT
to_int32
(
script_ctx_t
*
ctx
,
VARIANT
*
v
,
jsexcept_t
*
ei
,
INT
*
ret
)
{
...
...
dlls/jscript/string.c
View file @
4731f174
...
...
@@ -130,11 +130,52 @@ static HRESULT String_bold(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS
return
E_NOTIMPL
;
}
/* ECMA-262 3rd Edition 15.5.4.5 */
static
HRESULT
String_charAt
(
DispatchEx
*
dispex
,
LCID
lcid
,
WORD
flags
,
DISPPARAMS
*
dp
,
VARIANT
*
retv
,
jsexcept_t
*
ei
,
IServiceProvider
*
sp
)
{
FIXME
(
"
\n
"
);
return
E_NOTIMPL
;
StringInstance
*
strobj
;
BSTR
str
;
INT
pos
=
0
;
HRESULT
hres
;
TRACE
(
"
\n
"
);
if
(
dispex
->
builtin_info
->
class
!=
JSCLASS_STRING
)
{
FIXME
(
"not string this not supported
\n
"
);
return
E_NOTIMPL
;
}
strobj
=
(
StringInstance
*
)
dispex
;
if
(
arg_cnt
(
dp
))
{
VARIANT
num
;
hres
=
to_integer
(
dispex
->
ctx
,
get_arg
(
dp
,
0
),
ei
,
&
num
);
if
(
FAILED
(
hres
))
return
hres
;
if
(
V_VT
(
&
num
)
==
VT_I4
)
{
pos
=
V_I4
(
&
num
);
}
else
{
WARN
(
"pos = %lf
\n
"
,
V_R8
(
&
num
));
pos
=
-
1
;
}
}
if
(
!
retv
)
return
S_OK
;
if
(
0
<=
pos
&&
pos
<
strobj
->
length
)
str
=
SysAllocStringLen
(
strobj
->
str
+
pos
,
1
);
else
str
=
SysAllocStringLen
(
NULL
,
0
);
if
(
!
str
)
return
E_OUTOFMEMORY
;
V_VT
(
retv
)
=
VT_BSTR
;
V_BSTR
(
retv
)
=
str
;
return
S_OK
;
}
static
HRESULT
String_charCodeAt
(
DispatchEx
*
dispex
,
LCID
lcid
,
WORD
flags
,
DISPPARAMS
*
dp
,
...
...
@@ -200,6 +241,7 @@ static HRESULT String_link(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS
return
E_NOTIMPL
;
}
/* ECMA-262 3rd Edition 15.5.4.10 */
static
HRESULT
String_match
(
DispatchEx
*
dispex
,
LCID
lcid
,
WORD
flags
,
DISPPARAMS
*
dp
,
VARIANT
*
retv
,
jsexcept_t
*
ei
,
IServiceProvider
*
sp
)
{
...
...
dlls/jscript/tests/api.js
View file @
4731f174
...
...
@@ -16,11 +16,30 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
var
tmp
;
ok
(
""
.
length
===
0
,
"
\"\"
.length = "
+
""
.
length
);
ok
(
getVT
(
""
.
length
)
==
"VT_I4"
,
"
\"\"
.length = "
+
""
.
length
);
ok
(
"abc"
.
length
===
3
,
"
\"
abc
\"
.length = "
+
"abc"
.
length
);
ok
(
String
.
prototype
.
length
===
0
,
"String.prototype.length = "
+
String
.
prototype
.
length
);
tmp
=
"abc"
.
charAt
(
0
);
ok
(
tmp
===
"a"
,
"'abc',charAt(0) = "
+
tmp
);
tmp
=
"abc"
.
charAt
(
1
);
ok
(
tmp
===
"b"
,
"'abc',charAt(1) = "
+
tmp
);
tmp
=
"abc"
.
charAt
(
2
);
ok
(
tmp
===
"c"
,
"'abc',charAt(2) = "
+
tmp
);
tmp
=
"abc"
.
charAt
(
3
);
ok
(
tmp
===
""
,
"'abc',charAt(3) = "
+
tmp
);
tmp
=
"abc"
.
charAt
(
4
);
ok
(
tmp
===
""
,
"'abc',charAt(4) = "
+
tmp
);
tmp
=
"abc"
.
charAt
();
ok
(
tmp
===
"a"
,
"'abc',charAt() = "
+
tmp
);
tmp
=
"abc"
.
charAt
(
-
1
);
ok
(
tmp
===
""
,
"'abc',charAt(-1) = "
+
tmp
);
tmp
=
"abc"
.
charAt
(
0
,
2
);
ok
(
tmp
===
"a"
,
"'abc',charAt(0.2) = "
+
tmp
);
var
arr
=
new
Array
();
ok
(
typeof
(
arr
)
===
"object"
,
"arr () is not object"
);
ok
((
arr
.
length
===
0
),
"arr.length is not 0"
);
...
...
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