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
37120e75
Commit
37120e75
authored
Feb 24, 2015
by
Nikolay Sivov
Committed by
Alexandre Julliard
Feb 25, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
scrrun: Implement HashVal property for VT_BSTR case.
parent
5be738b0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
131 additions
and
5 deletions
+131
-5
dictionary.c
dlls/scrrun/dictionary.c
+33
-4
Makefile.in
dlls/scrrun/tests/Makefile.in
+1
-1
dictionary.c
dlls/scrrun/tests/dictionary.c
+97
-0
No files found.
dlls/scrrun/dictionary.c
View file @
37120e75
...
...
@@ -28,6 +28,7 @@
#include "scrrun_private.h"
#include "wine/debug.h"
#include "wine/unicode.h"
WINE_DEFAULT_DEBUG_CHANNEL
(
scrrun
);
...
...
@@ -290,15 +291,43 @@ static HRESULT WINAPI dictionary__NewEnum(IDictionary *iface, IUnknown **ppunk)
return
E_NOTIMPL
;
}
static
HRESULT
WINAPI
dictionary_get_HashVal
(
IDictionary
*
iface
,
VARIANT
*
Key
,
VARIANT
*
HashVal
)
static
DWORD
get_str_hash
(
const
WCHAR
*
str
,
CompareMethod
method
)
{
dictionary
*
This
=
impl_from_IDictionary
(
iface
)
;
DWORD
hash
=
0
;
FIXME
(
"(%p)->(%p %p)
\n
"
,
This
,
Key
,
HashVal
);
if
(
str
)
{
while
(
*
str
)
{
WCHAR
ch
;
return
E_NOTIMPL
;
ch
=
(
method
==
TextCompare
||
method
==
DatabaseCompare
)
?
tolowerW
(
*
str
)
:
*
str
;
hash
+=
(
hash
<<
4
)
+
ch
;
str
++
;
}
}
return
hash
%
1201
;
}
static
HRESULT
WINAPI
dictionary_get_HashVal
(
IDictionary
*
iface
,
VARIANT
*
key
,
VARIANT
*
hash
)
{
dictionary
*
This
=
impl_from_IDictionary
(
iface
);
TRACE
(
"(%p)->(%s %p)
\n
"
,
This
,
debugstr_variant
(
key
),
hash
);
V_VT
(
hash
)
=
VT_I4
;
switch
(
V_VT
(
key
))
{
case
VT_BSTR
:
V_I4
(
hash
)
=
get_str_hash
(
V_BSTR
(
key
),
This
->
method
);
break
;
default:
FIXME
(
"not implemented for type %d
\n
"
,
V_VT
(
key
));
return
E_NOTIMPL
;
}
return
S_OK
;
}
static
const
struct
IDictionaryVtbl
dictionary_vtbl
=
{
...
...
dlls/scrrun/tests/Makefile.in
View file @
37120e75
TESTDLL
=
scrrun.dll
IMPORTS
=
ole32 shlwapi uuid oleaut32
IMPORTS
=
ole32 shlwapi uuid oleaut32
user32
C_SRCS
=
\
dictionary.c
\
...
...
dlls/scrrun/tests/dictionary.c
View file @
37120e75
...
...
@@ -124,6 +124,102 @@ if (0) /* crashes on native */
IDictionary_Release
(
dict
);
}
static
DWORD
get_str_hash
(
const
WCHAR
*
str
,
CompareMethod
method
)
{
DWORD
hash
=
0
;
while
(
*
str
)
{
WCHAR
ch
;
if
(
method
==
TextCompare
||
method
==
DatabaseCompare
)
ch
=
PtrToInt
(
CharLowerW
(
IntToPtr
(
*
str
)));
else
ch
=
*
str
;
hash
+=
(
hash
<<
4
)
+
ch
;
str
++
;
}
return
hash
%
1201
;
}
static
void
test_hash_value
(
void
)
{
/* string test data */
static
const
WCHAR
str_hash_tests
[][
10
]
=
{
{
'a'
,
'b'
,
'c'
,
'd'
,
0
},
{
'a'
,
'B'
,
'C'
,
'd'
,
'1'
,
0
},
{
'1'
,
'2'
,
'3'
,
0
},
{
'A'
,
0
},
{
'a'
,
0
},
{
0
}
};
IDictionary
*
dict
;
VARIANT
key
,
hash
;
HRESULT
hr
;
unsigned
i
;
hr
=
CoCreateInstance
(
&
CLSID_Dictionary
,
NULL
,
CLSCTX_INPROC_SERVER
|
CLSCTX_INPROC_HANDLER
,
&
IID_IDictionary
,
(
void
**
)
&
dict
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
V_VT
(
&
key
)
=
VT_BSTR
;
V_BSTR
(
&
key
)
=
NULL
;
VariantInit
(
&
hash
);
hr
=
IDictionary_get_HashVal
(
dict
,
&
key
,
&
hash
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
ok
(
V_VT
(
&
hash
)
==
VT_I4
,
"got %d
\n
"
,
V_VT
(
&
hash
));
ok
(
V_I4
(
&
hash
)
==
0
,
"got %d
\n
"
,
V_I4
(
&
hash
));
for
(
i
=
0
;
i
<
sizeof
(
str_hash_tests
)
/
sizeof
(
str_hash_tests
[
0
]);
i
++
)
{
DWORD
expected
=
get_str_hash
(
str_hash_tests
[
i
],
BinaryCompare
);
hr
=
IDictionary_put_CompareMode
(
dict
,
BinaryCompare
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
V_VT
(
&
key
)
=
VT_BSTR
;
V_BSTR
(
&
key
)
=
SysAllocString
(
str_hash_tests
[
i
]);
VariantInit
(
&
hash
);
hr
=
IDictionary_get_HashVal
(
dict
,
&
key
,
&
hash
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
ok
(
V_VT
(
&
hash
)
==
VT_I4
,
"got %d
\n
"
,
V_VT
(
&
hash
));
ok
(
V_I4
(
&
hash
)
==
expected
,
"%d: binary mode: got hash 0x%08x, expected 0x%08x
\n
"
,
i
,
V_I4
(
&
hash
),
expected
);
VariantClear
(
&
key
);
expected
=
get_str_hash
(
str_hash_tests
[
i
],
TextCompare
);
hr
=
IDictionary_put_CompareMode
(
dict
,
TextCompare
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
V_VT
(
&
key
)
=
VT_BSTR
;
V_BSTR
(
&
key
)
=
SysAllocString
(
str_hash_tests
[
i
]);
VariantInit
(
&
hash
);
hr
=
IDictionary_get_HashVal
(
dict
,
&
key
,
&
hash
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
ok
(
V_VT
(
&
hash
)
==
VT_I4
,
"got %d
\n
"
,
V_VT
(
&
hash
));
ok
(
V_I4
(
&
hash
)
==
expected
,
"%d: text mode: got hash 0x%08x, expected 0x%08x
\n
"
,
i
,
V_I4
(
&
hash
),
expected
);
VariantClear
(
&
key
);
expected
=
get_str_hash
(
str_hash_tests
[
i
],
DatabaseCompare
);
hr
=
IDictionary_put_CompareMode
(
dict
,
DatabaseCompare
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
V_VT
(
&
key
)
=
VT_BSTR
;
V_BSTR
(
&
key
)
=
SysAllocString
(
str_hash_tests
[
i
]);
VariantInit
(
&
hash
);
hr
=
IDictionary_get_HashVal
(
dict
,
&
key
,
&
hash
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
ok
(
V_VT
(
&
hash
)
==
VT_I4
,
"got %d
\n
"
,
V_VT
(
&
hash
));
ok
(
V_I4
(
&
hash
)
==
expected
,
"%d: db mode: got hash 0x%08x, expected 0x%08x
\n
"
,
i
,
V_I4
(
&
hash
),
expected
);
VariantClear
(
&
key
);
}
IDictionary_Release
(
dict
);
}
START_TEST
(
dictionary
)
{
IDispatch
*
disp
;
...
...
@@ -142,6 +238,7 @@ START_TEST(dictionary)
test_interfaces
();
test_comparemode
();
test_hash_value
();
CoUninitialize
();
}
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