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
71b58e56
Commit
71b58e56
authored
Sep 02, 2011
by
Piotr Caban
Committed by
Alexandre Julliard
Sep 02, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jscript: Added Object.hasOwnProperty implementation.
parent
a0f1b204
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
97 additions
and
2 deletions
+97
-2
dispex.c
dlls/jscript/dispex.c
+14
-0
jscript.h
dlls/jscript/jscript.h
+1
-0
object.c
dlls/jscript/object.c
+41
-2
api.js
dlls/jscript/tests/api.js
+11
-0
run.c
dlls/jscript/tests/run.c
+30
-0
No files found.
dlls/jscript/dispex.c
View file @
71b58e56
...
@@ -1132,3 +1132,17 @@ HRESULT jsdisp_delete_idx(jsdisp_t *obj, DWORD idx)
...
@@ -1132,3 +1132,17 @@ HRESULT jsdisp_delete_idx(jsdisp_t *obj, DWORD idx)
return
delete_prop
(
prop
);
return
delete_prop
(
prop
);
}
}
VARIANT_BOOL
jsdisp_is_own_prop
(
jsdisp_t
*
obj
,
BSTR
name
)
{
dispex_prop_t
*
prop
;
HRESULT
hres
;
hres
=
find_prop_name
(
obj
,
name
,
&
prop
);
if
(
FAILED
(
hres
))
return
VARIANT_FALSE
;
else
if
(
!
prop
)
return
VARIANT_FALSE
;
return
prop
->
type
==
PROP_VARIANT
?
VARIANT_TRUE
:
VARIANT_FALSE
;
}
dlls/jscript/jscript.h
View file @
71b58e56
...
@@ -217,6 +217,7 @@ HRESULT jsdisp_propget_name(jsdisp_t*,LPCWSTR,VARIANT*,jsexcept_t*,IServiceProvi
...
@@ -217,6 +217,7 @@ HRESULT jsdisp_propget_name(jsdisp_t*,LPCWSTR,VARIANT*,jsexcept_t*,IServiceProvi
HRESULT
jsdisp_get_idx
(
jsdisp_t
*
,
DWORD
,
VARIANT
*
,
jsexcept_t
*
,
IServiceProvider
*
)
DECLSPEC_HIDDEN
;
HRESULT
jsdisp_get_idx
(
jsdisp_t
*
,
DWORD
,
VARIANT
*
,
jsexcept_t
*
,
IServiceProvider
*
)
DECLSPEC_HIDDEN
;
HRESULT
jsdisp_get_id
(
jsdisp_t
*
,
const
WCHAR
*
,
DWORD
,
DISPID
*
)
DECLSPEC_HIDDEN
;
HRESULT
jsdisp_get_id
(
jsdisp_t
*
,
const
WCHAR
*
,
DWORD
,
DISPID
*
)
DECLSPEC_HIDDEN
;
HRESULT
jsdisp_delete_idx
(
jsdisp_t
*
,
DWORD
)
DECLSPEC_HIDDEN
;
HRESULT
jsdisp_delete_idx
(
jsdisp_t
*
,
DWORD
)
DECLSPEC_HIDDEN
;
VARIANT_BOOL
jsdisp_is_own_prop
(
jsdisp_t
*
obj
,
BSTR
name
)
DECLSPEC_HIDDEN
;
HRESULT
create_builtin_function
(
script_ctx_t
*
,
builtin_invoke_t
,
const
WCHAR
*
,
const
builtin_info_t
*
,
DWORD
,
HRESULT
create_builtin_function
(
script_ctx_t
*
,
builtin_invoke_t
,
const
WCHAR
*
,
const
builtin_info_t
*
,
DWORD
,
jsdisp_t
*
,
jsdisp_t
**
)
DECLSPEC_HIDDEN
;
jsdisp_t
*
,
jsdisp_t
**
)
DECLSPEC_HIDDEN
;
...
...
dlls/jscript/object.c
View file @
71b58e56
...
@@ -111,8 +111,47 @@ static HRESULT Object_valueOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DI
...
@@ -111,8 +111,47 @@ static HRESULT Object_valueOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DI
static
HRESULT
Object_hasOwnProperty
(
script_ctx_t
*
ctx
,
vdisp_t
*
jsthis
,
WORD
flags
,
DISPPARAMS
*
dp
,
static
HRESULT
Object_hasOwnProperty
(
script_ctx_t
*
ctx
,
vdisp_t
*
jsthis
,
WORD
flags
,
DISPPARAMS
*
dp
,
VARIANT
*
retv
,
jsexcept_t
*
ei
,
IServiceProvider
*
sp
)
VARIANT
*
retv
,
jsexcept_t
*
ei
,
IServiceProvider
*
sp
)
{
{
FIXME
(
"
\n
"
);
BSTR
name
;
return
E_NOTIMPL
;
BOOL
result
;
DISPID
id
;
HRESULT
hres
;
TRACE
(
"
\n
"
);
if
(
!
arg_cnt
(
dp
))
{
if
(
retv
)
{
V_VT
(
retv
)
=
VT_BOOL
;
V_BOOL
(
retv
)
=
VARIANT_FALSE
;
}
return
S_OK
;
}
hres
=
to_string
(
ctx
,
get_arg
(
dp
,
0
),
ei
,
&
name
);
if
(
FAILED
(
hres
))
return
hres
;
if
(
is_jsdisp
(
jsthis
))
{
result
=
jsdisp_is_own_prop
(
jsthis
->
u
.
jsdisp
,
name
);
if
(
retv
)
{
V_VT
(
retv
)
=
VT_BOOL
;
V_BOOL
(
retv
)
=
result
;
}
return
S_OK
;
}
else
if
(
is_dispex
(
jsthis
))
{
hres
=
IDispatchEx_GetDispID
(
jsthis
->
u
.
dispex
,
name
,
make_grfdex
(
ctx
,
fdexNameCaseSensitive
),
&
id
);
}
else
{
hres
=
IDispatch_GetIDsOfNames
(
jsthis
->
u
.
disp
,
&
IID_NULL
,
&
name
,
1
,
ctx
->
lcid
,
&
id
);
}
if
(
retv
)
{
V_VT
(
retv
)
=
VT_BOOL
;
V_BOOL
(
retv
)
=
SUCCEEDED
(
hres
)
?
VARIANT_TRUE
:
VARIANT_FALSE
;
}
return
S_OK
;
}
}
static
HRESULT
Object_propertyIsEnumerable
(
script_ctx_t
*
ctx
,
vdisp_t
*
jsthis
,
WORD
flags
,
DISPPARAMS
*
dp
,
static
HRESULT
Object_propertyIsEnumerable
(
script_ctx_t
*
ctx
,
vdisp_t
*
jsthis
,
WORD
flags
,
DISPPARAMS
*
dp
,
...
...
dlls/jscript/tests/api.js
View file @
71b58e56
...
@@ -1864,11 +1864,22 @@ ok(err.message === 4, "err.message = " + err.message);
...
@@ -1864,11 +1864,22 @@ ok(err.message === 4, "err.message = " + err.message);
ok
(
!
(
"number"
in
Error
),
"number is in Error"
);
ok
(
!
(
"number"
in
Error
),
"number is in Error"
);
tmp
=
new
Object
();
tmp
=
new
Object
();
ok
(
tmp
.
hasOwnProperty
(
"toString"
)
===
false
,
"toString property should be inherited"
);
tmp
.
toString
=
function
()
{
return
"test"
;
};
tmp
.
toString
=
function
()
{
return
"test"
;
};
ok
(
tmp
.
hasOwnProperty
(
"toString"
)
===
true
,
"toString own property should exist"
);
ok
(
tmp
.
hasOwnProperty
(
"nonExisting"
)
===
false
,
"nonExisting property should not exist"
);
tmp
=
Error
.
prototype
.
toString
.
call
(
tmp
);
tmp
=
Error
.
prototype
.
toString
.
call
(
tmp
);
ok
(
tmp
===
"[object Error]"
,
"Error.prototype.toString.call(tmp) = "
+
tmp
);
ok
(
tmp
===
"[object Error]"
,
"Error.prototype.toString.call(tmp) = "
+
tmp
);
tmp
=
function
()
{
return
0
;
};
tmp
[
0
]
=
true
;
ok
(
tmp
.
hasOwnProperty
(
"toString"
)
===
false
,
"toString property should be inherited"
);
ok
(
tmp
.
hasOwnProperty
(
"0"
)
===
true
,
"hasOwnProperty(0) returned false"
);
ok
(
tmp
.
hasOwnProperty
()
===
false
,
"hasOwnProperty() returned true"
);
ok
(
Object
.
prototype
.
hasOwnProperty
.
call
(
testObj
)
===
false
,
"hasOwnProperty without name returned true"
);
if
(
invokeVersion
>=
2
)
{
if
(
invokeVersion
>=
2
)
{
obj
=
new
Object
();
obj
=
new
Object
();
obj
.
name
=
"test"
;
obj
.
name
=
"test"
;
...
...
dlls/jscript/tests/run.c
View file @
71b58e56
...
@@ -64,6 +64,8 @@ DEFINE_EXPECT(global_propput_i);
...
@@ -64,6 +64,8 @@ DEFINE_EXPECT(global_propput_i);
DEFINE_EXPECT
(
global_success_d
);
DEFINE_EXPECT
(
global_success_d
);
DEFINE_EXPECT
(
global_success_i
);
DEFINE_EXPECT
(
global_success_i
);
DEFINE_EXPECT
(
global_notexists_d
);
DEFINE_EXPECT
(
global_notexists_d
);
DEFINE_EXPECT
(
puredisp_prop_d
);
DEFINE_EXPECT
(
puredisp_noprop_d
);
DEFINE_EXPECT
(
testobj_delete
);
DEFINE_EXPECT
(
testobj_delete
);
DEFINE_EXPECT
(
testobj_value
);
DEFINE_EXPECT
(
testobj_value
);
DEFINE_EXPECT
(
testobj_prop_d
);
DEFINE_EXPECT
(
testobj_prop_d
);
...
@@ -173,6 +175,18 @@ static HRESULT WINAPI DispatchEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
...
@@ -173,6 +175,18 @@ static HRESULT WINAPI DispatchEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
LPOLESTR
*
rgszNames
,
UINT
cNames
,
LPOLESTR
*
rgszNames
,
UINT
cNames
,
LCID
lcid
,
DISPID
*
rgDispId
)
LCID
lcid
,
DISPID
*
rgDispId
)
{
{
ok
(
IsEqualGUID
(
riid
,
&
IID_NULL
),
"Expected IID_NULL
\n
"
);
ok
(
cNames
==
1
,
"cNames = %d
\n
"
,
cNames
);
if
(
!
strcmp_wa
(
*
rgszNames
,
"prop"
))
{
CHECK_EXPECT
(
puredisp_prop_d
);
*
rgDispId
=
DISPID_TESTOBJ_PROP
;
return
S_OK
;
}
else
if
(
!
strcmp_wa
(
*
rgszNames
,
"noprop"
))
{
CHECK_EXPECT
(
puredisp_noprop_d
);
return
DISP_E_UNKNOWNNAME
;
}
ok
(
0
,
"unexpected call
\n
"
);
ok
(
0
,
"unexpected call
\n
"
);
return
E_NOTIMPL
;
return
E_NOTIMPL
;
}
}
...
@@ -1476,6 +1490,22 @@ static void run_tests(void)
...
@@ -1476,6 +1490,22 @@ static void run_tests(void)
parse_script_a
(
"ok(('noprop' in testObj) === false, 'noprop is in testObj');"
);
parse_script_a
(
"ok(('noprop' in testObj) === false, 'noprop is in testObj');"
);
CHECK_CALLED
(
testobj_noprop_d
);
CHECK_CALLED
(
testobj_noprop_d
);
SET_EXPECT
(
testobj_prop_d
);
parse_script_a
(
"ok(Object.prototype.hasOwnProperty.call(testObj, 'prop') === true, 'hasOwnProperty(
\\\"
prop
\\\"
) returned false');"
);
CHECK_CALLED
(
testobj_prop_d
);
SET_EXPECT
(
testobj_noprop_d
);
parse_script_a
(
"ok(Object.prototype.hasOwnProperty.call(testObj, 'noprop') === false, 'hasOwnProperty(
\\\"
noprop
\\\"
) returned true');"
);
CHECK_CALLED
(
testobj_noprop_d
);
SET_EXPECT
(
puredisp_prop_d
);
parse_script_a
(
"ok(Object.prototype.hasOwnProperty.call(pureDisp, 'prop') === true, 'hasOwnProperty(
\\\"
noprop
\\\"
) returned false');"
);
CHECK_CALLED
(
puredisp_prop_d
);
SET_EXPECT
(
puredisp_noprop_d
);
parse_script_a
(
"ok(Object.prototype.hasOwnProperty.call(pureDisp, 'noprop') === false, 'hasOwnProperty(
\\\"
noprop
\\\"
) returned true');"
);
CHECK_CALLED
(
puredisp_noprop_d
);
SET_EXPECT
(
testobj_value
);
SET_EXPECT
(
testobj_value
);
parse_script_a
(
"ok(String(testObj) === '1', 'wrong testObj value');"
);
parse_script_a
(
"ok(String(testObj) === '1', 'wrong testObj value');"
);
CHECK_CALLED
(
testobj_value
);
CHECK_CALLED
(
testobj_value
);
...
...
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