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
c44056d4
Commit
c44056d4
authored
Jul 14, 2009
by
Piotr Caban
Committed by
Alexandre Julliard
Jul 14, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jscript: Added String_fromCharCode implementation.
parent
2325e2cd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
1 deletion
+53
-1
string.c
dlls/jscript/string.c
+46
-1
api.js
dlls/jscript/tests/api.js
+7
-0
No files found.
dlls/jscript/string.c
View file @
c44056d4
...
...
@@ -66,6 +66,7 @@ static const WCHAR hasOwnPropertyW[] = {'h','a','s','O','w','n','P','r','o','p',
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
const
WCHAR
fromCharCodeW
[]
=
{
'f'
,
'r'
,
'o'
,
'm'
,
'C'
,
'h'
,
'a'
,
'r'
,
'C'
,
'o'
,
'd'
,
'e'
,
0
};
static
HRESULT
String_length
(
DispatchEx
*
dispex
,
LCID
lcid
,
WORD
flags
,
DISPPARAMS
*
dp
,
VARIANT
*
retv
,
jsexcept_t
*
ei
,
IServiceProvider
*
sp
)
...
...
@@ -1557,6 +1558,37 @@ static const builtin_info_t String_info = {
NULL
};
/* ECMA-262 3rd Edition 15.5.3.2 */
static
HRESULT
StringConstr_fromCharCode
(
DispatchEx
*
dispex
,
LCID
lcid
,
WORD
flags
,
DISPPARAMS
*
dp
,
VARIANT
*
retv
,
jsexcept_t
*
ei
,
IServiceProvider
*
sp
)
{
DWORD
i
,
code
;
BSTR
ret
;
HRESULT
hres
;
ret
=
SysAllocStringLen
(
NULL
,
arg_cnt
(
dp
));
if
(
!
ret
)
return
E_OUTOFMEMORY
;
for
(
i
=
0
;
i
<
arg_cnt
(
dp
);
i
++
)
{
hres
=
to_uint32
(
dispex
->
ctx
,
get_arg
(
dp
,
i
),
ei
,
&
code
);
if
(
FAILED
(
hres
))
{
SysFreeString
(
ret
);
return
hres
;
}
ret
[
i
]
=
code
;
}
if
(
retv
)
{
V_VT
(
retv
)
=
VT_BSTR
;
V_BSTR
(
retv
)
=
ret
;
}
else
SysFreeString
(
ret
);
return
S_OK
;
}
static
HRESULT
StringConstr_value
(
DispatchEx
*
dispex
,
LCID
lcid
,
WORD
flags
,
DISPPARAMS
*
dp
,
VARIANT
*
retv
,
jsexcept_t
*
ei
,
IServiceProvider
*
sp
)
{
...
...
@@ -1636,6 +1668,19 @@ static HRESULT string_alloc(script_ctx_t *ctx, BOOL use_constr, StringInstance *
return
S_OK
;
}
static
const
builtin_prop_t
StringConstr_props
[]
=
{
{
fromCharCodeW
,
StringConstr_fromCharCode
,
PROPF_METHOD
},
};
static
const
builtin_info_t
StringConstr_info
=
{
JSCLASS_FUNCTION
,
{
NULL
,
Function_value
,
0
},
sizeof
(
StringConstr_props
)
/
sizeof
(
*
StringConstr_props
),
StringConstr_props
,
NULL
,
NULL
};
HRESULT
create_string_constr
(
script_ctx_t
*
ctx
,
DispatchEx
**
ret
)
{
StringInstance
*
string
;
...
...
@@ -1645,7 +1690,7 @@ HRESULT create_string_constr(script_ctx_t *ctx, DispatchEx **ret)
if
(
FAILED
(
hres
))
return
hres
;
hres
=
create_builtin_function
(
ctx
,
StringConstr_value
,
NULL
,
PROPF_CONSTR
,
&
string
->
dispex
,
ret
);
hres
=
create_builtin_function
(
ctx
,
StringConstr_value
,
&
StringConstr_info
,
PROPF_CONSTR
,
&
string
->
dispex
,
ret
);
jsdisp_release
(
&
string
->
dispex
);
return
hres
;
...
...
dlls/jscript/tests/api.js
View file @
c44056d4
...
...
@@ -405,6 +405,13 @@ ok(tmp === "<SUP>test</SUP>", "'test'.sup() = " + tmp);
tmp
=
"test"
.
sup
(
3
);
ok
(
tmp
===
"<SUP>test</SUP>"
,
"'test'.sup(3) = "
+
tmp
);
ok
(
String
.
fromCharCode
()
===
""
,
"String.fromCharCode() = "
+
String
.
fromCharCode
());
ok
(
String
.
fromCharCode
(
65
,
"66"
,
67
)
===
"ABC"
,
"String.fromCharCode(65,'66',67) = "
+
String
.
fromCharCode
(
65
,
"66"
,
67
));
ok
(
String
.
fromCharCode
(
1024
*
64
+
65
,
-
1024
*
64
+
65
)
===
"AA"
,
"String.fromCharCode(1024*64+65, -1024*64+65) = "
+
String
.
fromCharCode
(
1024
*
64
+
65
,
-
1024
*
64
+
65
));
ok
(
String
.
fromCharCode
(
65
,
NaN
,
undefined
).
length
===
3
,
"String.fromCharCode(65, NaN, undefined).length = "
+
String
.
fromCharCode
(
65
,
NaN
,
undefined
).
length
);
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