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
558e8466
Commit
558e8466
authored
Sep 28, 2021
by
Nikolay Sivov
Committed by
Alexandre Julliard
Sep 28, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ole32/composite: Reimplement Inverse().
Signed-off-by:
Nikolay Sivov
<
nsivov@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
dec1e46d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
97 additions
and
56 deletions
+97
-56
compositemoniker.c
dlls/ole32/compositemoniker.c
+18
-43
moniker.c
dlls/ole32/tests/moniker.c
+79
-13
No files found.
dlls/ole32/compositemoniker.c
View file @
558e8466
...
...
@@ -740,57 +740,32 @@ static HRESULT WINAPI CompositeMonikerImpl_GetTimeOfLastChange(IMoniker *iface,
return
hr
;
}
/******************************************************************************
* CompositeMoniker_Inverse
******************************************************************************/
static
HRESULT
WINAPI
CompositeMonikerImpl_Inverse
(
IMoniker
*
iface
,
IMoniker
**
ppmk
)
static
HRESULT
WINAPI
CompositeMonikerImpl_Inverse
(
IMoniker
*
iface
,
IMoniker
**
inverse
)
{
HRESULT
res
;
IMoniker
*
tempMk
,
*
antiMk
,
*
rightMostMk
,
*
tempInvMk
,
*
rightMostInvMk
;
IEnumMoniker
*
enumMoniker
;
TRACE
(
"(%p,%p)
\n
"
,
iface
,
ppmk
);
if
(
ppmk
==
NULL
)
return
E_POINTER
;
/* This method returns a composite moniker that consists of the inverses of each of the components */
/* of the original composite, stored in reverse order */
*
ppmk
=
NULL
;
res
=
CreateAntiMoniker
(
&
antiMk
);
if
(
FAILED
(
res
))
return
res
;
res
=
IMoniker_ComposeWith
(
iface
,
antiMk
,
FALSE
,
&
tempMk
);
IMoniker_Release
(
antiMk
);
if
(
FAILED
(
res
))
return
res
;
if
(
tempMk
==
NULL
)
CompositeMonikerImpl
*
moniker
=
impl_from_IMoniker
(
iface
);
IMoniker
*
right_inverted
,
*
left_inverted
;
HRESULT
hr
;
return
IMoniker_Inverse
(
iface
,
ppmk
);
TRACE
(
"%p, %p.
\n
"
,
iface
,
inverse
);
else
{
if
(
!
inverse
)
return
E_INVALIDARG
;
IMoniker_Enum
(
iface
,
FALSE
,
&
enumMoniker
);
IEnumMoniker_Next
(
enumMoniker
,
1
,
&
rightMostMk
,
NULL
);
IEnumMoniker_Release
(
enumMoniker
);
*
inverse
=
NULL
;
IMoniker_Inverse
(
rightMostMk
,
&
rightMostInvMk
);
CompositeMonikerImpl_Inverse
(
tempMk
,
&
tempInvMk
);
if
(
FAILED
(
hr
=
IMoniker_Inverse
(
moniker
->
right
,
&
right_inverted
)))
return
hr
;
if
(
FAILED
(
hr
=
IMoniker_Inverse
(
moniker
->
left
,
&
left_inverted
)))
{
IMoniker_Release
(
right_inverted
);
return
hr
;
}
res
=
CreateGenericComposite
(
rightMostInvMk
,
tempInvMk
,
ppmk
);
hr
=
CreateGenericComposite
(
right_inverted
,
left_inverted
,
inverse
);
IMoniker_Release
(
tempMk
);
IMoniker_Release
(
rightMostMk
);
IMoniker_Release
(
tempInvMk
);
IMoniker_Release
(
rightMostInvMk
);
IMoniker_Release
(
left_inverted
);
IMoniker_Release
(
right_inverted
);
return
res
;
}
return
hr
;
}
static
HRESULT
WINAPI
CompositeMonikerImpl_CommonPrefixWith
(
IMoniker
*
iface
,
IMoniker
*
other
,
...
...
dlls/ole32/tests/moniker.c
View file @
558e8466
...
...
@@ -53,18 +53,21 @@ static void check_interface_(unsigned int line, void *iface_ptr, REFIID iid, BOO
#define ok_ole_success(hr, func) ok(hr == S_OK, #func " failed with error 0x%08x\n", hr)
#define CHECK_EXPECTED_METHOD(method_name) \
do { \
ok(*expected_method_list != NULL, "Extra method %s called\n", method_name); \
if (*expected_method_list) \
{ \
ok(!strcmp(*expected_method_list, method_name), "Expected %s to be called instead of %s\n", \
*expected_method_list, method_name); \
expected_method_list++; \
} \
} while(0)
static
char
const
*
const
*
expected_method_list
;
#define CHECK_EXPECTED_METHOD(method_name) check_expected_method_(__LINE__, method_name)
static
void
check_expected_method_
(
unsigned
int
line
,
const
char
*
method_name
)
{
if
(
!
expected_method_list
)
return
;
ok
(
*
expected_method_list
!=
NULL
,
"Extra method %s called
\n
"
,
method_name
);
if
(
*
expected_method_list
)
{
ok
(
!
strcmp
(
*
expected_method_list
,
method_name
),
"Expected %s to be called instead of %s
\n
"
,
*
expected_method_list
,
method_name
);
expected_method_list
++
;
}
}
static
const
WCHAR
wszFileName1
[]
=
{
'c'
,
':'
,
'\\'
,
'w'
,
'i'
,
'n'
,
'd'
,
'o'
,
'w'
,
's'
,
'\\'
,
't'
,
'e'
,
's'
,
't'
,
'1'
,
'.'
,
'd'
,
'o'
,
'c'
,
0
};
static
const
WCHAR
wszFileName2
[]
=
{
'c'
,
':'
,
'\\'
,
'w'
,
'i'
,
'n'
,
'd'
,
'o'
,
'w'
,
's'
,
'\\'
,
't'
,
'e'
,
's'
,
't'
,
'2'
,
'.'
,
'd'
,
'o'
,
'c'
,
0
};
...
...
@@ -384,6 +387,7 @@ struct test_moniker
IOleItemContainer
IOleItemContainer_iface
;
IParseDisplayName
IParseDisplayName_iface
;
LONG
refcount
;
const
char
*
inverse
;
BOOL
no_IROTData
;
};
...
...
@@ -665,7 +669,7 @@ Moniker_ComposeWith(IMoniker* iface, IMoniker* pmkRight,
BOOL
fOnlyIfNotGeneric
,
IMoniker
**
ppmkComposite
)
{
CHECK_EXPECTED_METHOD
(
"Moniker_ComposeWith"
);
return
E_NOTIMPL
;
return
MK_E_NEEDGENERIC
;
}
static
HRESULT
WINAPI
...
...
@@ -714,8 +718,9 @@ Moniker_GetTimeOfLastChange(IMoniker* iface, IBindCtx* pbc,
static
HRESULT
WINAPI
Moniker_Inverse
(
IMoniker
*
iface
,
IMoniker
**
ppmk
)
{
struct
test_moniker
*
moniker
=
impl_from_IMoniker
(
iface
);
CHECK_EXPECTED_METHOD
(
"Moniker_Inverse"
);
return
E_NOTIMPL
;
return
create_moniker_from_desc
(
moniker
->
inverse
,
ppmk
)
;
}
static
HRESULT
WINAPI
...
...
@@ -933,6 +938,7 @@ static void test_ROT(void)
hr
=
IRunningObjectTable_IsRunning
(
pROT
,
&
test_moniker
->
IMoniker_iface
);
ok_ole_success
(
hr
,
IRunningObjectTable_IsRunning
);
ok
(
!*
expected_method_list
,
"Method sequence starting from %s not called
\n
"
,
*
expected_method_list
);
expected_method_list
=
NULL
;
hr
=
IRunningObjectTable_Revoke
(
pROT
,
dwCookie
);
ok_ole_success
(
hr
,
IRunningObjectTable_Revoke
);
...
...
@@ -2545,6 +2551,7 @@ static void test_item_moniker(void)
expected_method_list
=
methods_isrunning
;
hr
=
IMoniker_IsRunning
(
moniker
,
bindctx
,
&
container_moniker
->
IMoniker_iface
,
moniker2
);
ok
(
hr
==
0x8beef000
,
"Unexpected hr %#x.
\n
"
,
hr
);
expected_method_list
=
NULL
;
IMoniker_Release
(
moniker2
);
...
...
@@ -3043,6 +3050,7 @@ static void test_generic_composite_moniker(void)
{
"CI1I3"
,
"CA1I2"
,
MKSYS_GENERICCOMPOSITE
,
L"!I1!I2"
},
};
IMoniker
*
moniker
,
*
inverse
,
*
moniker1
,
*
moniker2
,
*
moniker3
;
struct
test_moniker
*
m
,
*
m2
;
IEnumMoniker
*
enummoniker
;
IRunningObjectTable
*
rot
;
DWORD
hash
,
cookie
;
...
...
@@ -3377,6 +3385,64 @@ todo_wine
IMoniker_Release
(
moniker2
);
IMoniker_Release
(
moniker1
);
/* Inverse() */
hr
=
create_moniker_from_desc
(
"CI1I2"
,
&
moniker1
);
ok
(
hr
==
S_OK
,
"Unexpected hr %#x.
\n
"
,
hr
);
hr
=
IMoniker_Inverse
(
moniker1
,
NULL
);
ok
(
hr
==
E_INVALIDARG
,
"Unexpected hr %#x.
\n
"
,
hr
);
hr
=
IMoniker_Inverse
(
moniker1
,
&
inverse
);
ok
(
hr
==
S_OK
,
"Unexpected hr %#x.
\n
"
,
hr
);
TEST_MONIKER_TYPE
(
inverse
,
MKSYS_GENERICCOMPOSITE
);
TEST_DISPLAY_NAME
(
inverse
,
L"
\\
..
\\
.."
);
IMoniker_Release
(
inverse
);
IMoniker_Release
(
moniker1
);
hr
=
create_moniker_from_desc
(
"CA1A2"
,
&
moniker1
);
ok
(
hr
==
S_OK
,
"Unexpected hr %#x.
\n
"
,
hr
);
inverse
=
(
void
*
)
0xdeadbeef
;
hr
=
IMoniker_Inverse
(
moniker1
,
&
inverse
);
ok
(
hr
==
MK_E_NOINVERSE
,
"Unexpected hr %#x.
\n
"
,
hr
);
ok
(
!
inverse
,
"Unexpected pointer.
\n
"
);
IMoniker_Release
(
moniker1
);
hr
=
create_moniker_from_desc
(
"CI1A2"
,
&
moniker1
);
ok
(
hr
==
S_OK
,
"Unexpected hr %#x.
\n
"
,
hr
);
inverse
=
(
void
*
)
0xdeadbeef
;
hr
=
IMoniker_Inverse
(
moniker1
,
&
inverse
);
ok
(
hr
==
MK_E_NOINVERSE
,
"Unexpected hr %#x.
\n
"
,
hr
);
ok
(
!
inverse
,
"Unexpected pointer.
\n
"
);
IMoniker_Release
(
moniker1
);
/* Now with custom moniker to observe inverse order */
m
=
create_test_moniker
();
m
->
inverse
=
"I5"
;
hr
=
create_moniker_from_desc
(
"I1"
,
&
moniker1
);
ok
(
hr
==
S_OK
,
"Unexpected hr %#x.
\n
"
,
hr
);
hr
=
CreateGenericComposite
(
moniker1
,
&
m
->
IMoniker_iface
,
&
moniker2
);
ok
(
hr
==
S_OK
,
"Unexpected hr %#x.
\n
"
,
hr
);
TEST_MONIKER_TYPE
(
moniker2
,
MKSYS_GENERICCOMPOSITE
);
inverse
=
(
void
*
)
0xdeadbeef
;
hr
=
IMoniker_Inverse
(
moniker2
,
&
inverse
);
ok
(
hr
==
S_OK
,
"Unexpected hr %#x.
\n
"
,
hr
);
ok
(
!
inverse
,
"Unexpected pointer.
\n
"
);
IMoniker_Release
(
moniker1
);
/* Use custom monikers for both, so they don't invert to anti monikers. */
m2
=
create_test_moniker
();
m2
->
inverse
=
"I4"
;
hr
=
CreateGenericComposite
(
&
m2
->
IMoniker_iface
,
&
m
->
IMoniker_iface
,
&
moniker2
);
ok
(
hr
==
S_OK
,
"Unexpected hr %#x.
\n
"
,
hr
);
hr
=
IMoniker_Inverse
(
moniker2
,
&
inverse
);
ok
(
hr
==
S_OK
,
"Unexpected hr %#x.
\n
"
,
hr
);
TEST_MONIKER_TYPE
(
inverse
,
MKSYS_GENERICCOMPOSITE
);
TEST_DISPLAY_NAME
(
inverse
,
L"!I5!I4"
);
IMoniker_Release
(
inverse
);
IMoniker_Release
(
moniker2
);
IMoniker_Release
(
&
m
->
IMoniker_iface
);
IMoniker_Release
(
&
m2
->
IMoniker_iface
);
IBindCtx_Release
(
bindctx
);
}
...
...
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