-
Notifications
You must be signed in to change notification settings - Fork 379
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create an import library for 'msctf.dll'
This is a preparation to remove the dependency on CoCreateInstance from mozc_tip{32,64}.dll to comply with GUID_TFCAT_TIPCAP_COMLESS (#837). The idea is the same as my previous commit for input.dll [1]. Note that this commit only creates an import library with unit tests, and the production code has not been updated to use it yet. Thus there must be no observable behavior change (yet). #codehealth [1]: f470414 PiperOrigin-RevId: 576415439
- Loading branch information
1 parent
13bb7cc
commit 006084c
Showing
5 changed files
with
195 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// Copyright 2010-2021, Google Inc. | ||
// All rights reserved. | ||
// | ||
// Redistribution and use in source and binary forms, with or without | ||
// modification, are permitted provided that the following conditions are | ||
// met: | ||
// | ||
// * Redistributions of source code must retain the above copyright | ||
// notice, this list of conditions and the following disclaimer. | ||
// * Redistributions in binary form must reproduce the above | ||
// copyright notice, this list of conditions and the following disclaimer | ||
// in the documentation and/or other materials provided with the | ||
// distribution. | ||
// * Neither the name of Google Inc. nor the names of its | ||
// contributors may be used to endorse or promote products derived from | ||
// this software without specific prior written permission. | ||
// | ||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
||
// This file will be used to create an import library. Functions in this | ||
// file must not be called directly. | ||
|
||
#include <windows.h> | ||
|
||
#include "base/logging.h" | ||
|
||
class ITfCategoryMgr; | ||
class ITfLangBarItemMgr; | ||
class ITfInputProcessorProfiles; | ||
|
||
extern "C" UINT WINAPI | ||
TF_CreateCategoryMgr(__out ITfCategoryMgr **profile_mgr) { | ||
CHECK(false) << "This is a stub function to create an import library. " | ||
<< "Shouldn't be called from anywhere."; | ||
return 0; | ||
} | ||
|
||
extern "C" UINT WINAPI | ||
TF_CreateInputProcessorProfiles(__out ITfInputProcessorProfiles **pplbim) { | ||
CHECK(false) << "This is a stub function to create an import library. " | ||
<< "Shouldn't be called from anywhere."; | ||
return 0; | ||
} | ||
|
||
extern "C" UINT WINAPI | ||
TF_CreateLangBarItemMgr(__out ITfLangBarItemMgr **pplbim) { | ||
CHECK(false) << "This is a stub function to create an import library. " | ||
<< "Shouldn't be called from anywhere."; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
LIBRARY msctf.dll | ||
|
||
EXPORTS | ||
TF_CreateCategoryMgr | ||
TF_CreateInputProcessorProfiles | ||
TF_CreateLangBarItemMgr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// Copyright 2010-2021, Google Inc. | ||
// All rights reserved. | ||
// | ||
// Redistribution and use in source and binary forms, with or without | ||
// modification, are permitted provided that the following conditions are | ||
// met: | ||
// | ||
// * Redistributions of source code must retain the above copyright | ||
// notice, this list of conditions and the following disclaimer. | ||
// * Redistributions in binary form must reproduce the above | ||
// copyright notice, this list of conditions and the following disclaimer | ||
// in the documentation and/or other materials provided with the | ||
// distribution. | ||
// * Neither the name of Google Inc. nor the names of its | ||
// contributors may be used to endorse or promote products derived from | ||
// this software without specific prior written permission. | ||
// | ||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
||
#include <combaseapi.h> | ||
#include <msctf.h> | ||
#include <wil/com.h> | ||
#include <windows.h> | ||
|
||
#include "testing/gunit.h" | ||
|
||
namespace { | ||
|
||
void AssertComIsNotInitialized() { | ||
APTTYPE type = APTTYPE_CURRENT; | ||
APTTYPEQUALIFIER filter = APTTYPEQUALIFIER_NONE; | ||
HRESULT result = ::CoGetApartmentType(&type, &filter); | ||
EXPECT_EQ(result, CO_E_NOTINITIALIZED); | ||
} | ||
|
||
TEST(MsctfDllTest, CreateITfCategoryMgr) { | ||
AssertComIsNotInitialized(); | ||
|
||
wil::com_ptr_nothrow<ITfCategoryMgr> obj; | ||
HRESULT result = TF_CreateCategoryMgr(&obj); | ||
EXPECT_EQ(result, S_OK); | ||
} | ||
|
||
TEST(MsctfDllTest, CreateInputProcessorProfiles) { | ||
AssertComIsNotInitialized(); | ||
|
||
wil::com_ptr_nothrow<ITfInputProcessorProfiles> obj; | ||
HRESULT result = TF_CreateInputProcessorProfiles(&obj); | ||
EXPECT_EQ(result, S_OK); | ||
} | ||
|
||
TEST(MsctfDllTest, CreateLangBarItemMgr) { | ||
AssertComIsNotInitialized(); | ||
|
||
wil::com_ptr_nothrow<ITfLangBarItemMgr> obj; | ||
HRESULT result = TF_CreateLangBarItemMgr(&obj); | ||
EXPECT_EQ(result, S_OK); | ||
} | ||
|
||
} // namespace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters