From a2d01d34fc05f05d4f55ce6622e1d39462d03c82 Mon Sep 17 00:00:00 2001 From: berryzplus Date: Sun, 30 Jan 2022 19:25:05 +0900 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E5=AD=97=E3=82=B3=E3=83=BC=E3=83=89?= =?UTF-8?q?=E8=87=AA=E5=8B=95=E5=88=A4=E5=88=A5=E3=81=ABWindows10=E3=81=AB?= =?UTF-8?q?=E7=B5=B1=E5=90=88=E3=81=95=E3=82=8C=E3=81=9FICU4C=E3=82=92?= =?UTF-8?q?=E4=BD=BF=E3=81=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sakura_core/Makefile | 2 +- sakura_core/extmodule/CIcu4cI18n.cpp | 20 +++++--------- sakura_core/extmodule/CIcu4cI18n.h | 40 +++++++++++++--------------- tests/unittests/Makefile | 2 +- 4 files changed, 26 insertions(+), 38 deletions(-) diff --git a/sakura_core/Makefile b/sakura_core/Makefile index faff1c34ce..fb02f428d6 100644 --- a/sakura_core/Makefile +++ b/sakura_core/Makefile @@ -153,7 +153,7 @@ githash.h: icu4MinGW/icu.h: -$(MKDIR) icu4MinGW > $(DEVNULL) 2>&1 - cp $(subst /, $(DIRSEP), "C:/Program Files (x86)/Windows Kits/10/Include/10.0.18362.0/um/icu.h") $(subst /, $(DIRSEP), ./) + cp "C:/Program Files (x86)/Windows Kits/10/Include/10.0.18362.0/um/icu.h" ./icu4MinGW/ StdAfx.h.gch: StdAfx.h githash.h Funccode_enum.h icu4MinGW/icu.h ifneq ($(SRCDIR),.) diff --git a/sakura_core/extmodule/CIcu4cI18n.cpp b/sakura_core/extmodule/CIcu4cI18n.cpp index 1527ca4891..7afa138f3f 100644 --- a/sakura_core/extmodule/CIcu4cI18n.cpp +++ b/sakura_core/extmodule/CIcu4cI18n.cpp @@ -25,20 +25,12 @@ #include "StdAfx.h" #include "CIcu4cI18n.h" -CIcu4cI18n::CIcu4cI18n() noexcept - : _ucsdet_open(nullptr) - , _ucsdet_setText(nullptr) - , _ucsdet_detect(nullptr) - , _ucsdet_close(nullptr) -{ -} - /*! * @brief DLLの名前を返す */ LPCWSTR CIcu4cI18n::GetDllNameImp( [[maybe_unused]] int index ) { - return L"icuin66.dll"; //バージョンは固定 + return L"icu.dll"; } /*! @@ -53,11 +45,11 @@ bool CIcu4cI18n::InitDllImp() { //DLL内関数名リスト const ImportTable table[] = { - { &_ucsdet_open, "ucsdet_open_66" }, //バージョンは固定 - { &_ucsdet_setText, "ucsdet_setText_66" }, //バージョンは固定 - { &_ucsdet_detect, "ucsdet_detect_66" }, //バージョンは固定 - { &_ucsdet_getName, "ucsdet_getName_66" }, //バージョンは固定 - { &_ucsdet_close, "ucsdet_close_66" }, //バージョンは固定 + { &_ucsdet_open, "ucsdet_open" }, + { &_ucsdet_setText, "ucsdet_setText" }, + { &_ucsdet_detect, "ucsdet_detect" }, + { &_ucsdet_getName, "ucsdet_getName" }, + { &_ucsdet_close, "ucsdet_close" }, { NULL, 0 } }; return RegisterEntries(table); diff --git a/sakura_core/extmodule/CIcu4cI18n.h b/sakura_core/extmodule/CIcu4cI18n.h index f9c09fbdba..e238d15581 100644 --- a/sakura_core/extmodule/CIcu4cI18n.h +++ b/sakura_core/extmodule/CIcu4cI18n.h @@ -1,6 +1,6 @@ /*! @file */ /* - Copyright (C) 2018-2021, Sakura Editor Organization + Copyright (C) 2018-2022, Sakura Editor Organization This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -26,37 +26,33 @@ #define SAKURA_CICU4CI18N_16EE9B14_2791_4C5D_AE1E_E78FBF5CB083_H_ #pragma once -#include "CDllHandler.h" - -//ICU4Cの型定義 -class UCharsetDetector; -class UCharsetMatch; - -typedef enum UErrorCode { - U_ZERO_ERROR = 0, /**< No error, no warning. */ -} UErrorCode; +#include /*! - * ICU4C の i18n ライブラリ(icuin.dll) をラップするクラス + * ICU4C のライブラリ(icu.dll) をラップするクラス + * + * Windows 10 1703でICU4CがWindowsに統合された。 + * この実装では最新1903以降で導入されたicu.dllを使うようにしている。 + * 1703~1809だと実装DLLが2つに分かれていてicu.dllが存在しない。 */ class CIcu4cI18n final : public CDllImp { // DLL関数型定義 - typedef UCharsetDetector* (__cdecl *ucsdet_open_t)(UErrorCode *status); - typedef void (__cdecl *ucsdet_setText_t)(UCharsetDetector *ucsd, const char *textIn, int32_t len, UErrorCode *status); - typedef const UCharsetMatch * (__cdecl *ucsdet_detect_t)(UCharsetDetector *ucsd, UErrorCode *status); - typedef const char* (__cdecl *ucsdet_getName_t)(const UCharsetMatch *ucsm, UErrorCode *status); - typedef void (__cdecl *ucsdet_close_t)(UCharsetDetector *ucsd); + using ucsdet_open_t = decltype(::ucsdet_open); + using ucsdet_setText_t = decltype(::ucsdet_setText); + using ucsdet_detect_t = decltype(::ucsdet_detect); + using ucsdet_getName_t = decltype(::ucsdet_getName); + using ucsdet_close_t = decltype(::ucsdet_close); // メンバ定義 - ucsdet_open_t _ucsdet_open; - ucsdet_setText_t _ucsdet_setText; - ucsdet_detect_t _ucsdet_detect; - ucsdet_getName_t _ucsdet_getName; - ucsdet_close_t _ucsdet_close; + ucsdet_open_t* _ucsdet_open = nullptr; + ucsdet_setText_t* _ucsdet_setText = nullptr; + ucsdet_detect_t* _ucsdet_detect = nullptr; + ucsdet_getName_t* _ucsdet_getName = nullptr; + ucsdet_close_t* _ucsdet_close = nullptr; public: - CIcu4cI18n() noexcept; + CIcu4cI18n() noexcept = default; protected: // CDllImpインタフェース diff --git a/tests/unittests/Makefile b/tests/unittests/Makefile index 0db017fbaa..0a2937203d 100644 --- a/tests/unittests/Makefile +++ b/tests/unittests/Makefile @@ -146,7 +146,7 @@ $(exe): $(OBJS) $(SAKURA_OBJS) icu4MinGW/icu.h: -$(MKDIR) icu4MinGW > $(DEVNULL) 2>&1 - cp $(subst /, $(DIRSEP), "C:/Program Files (x86)/Windows Kits/10/Include/10.0.18362.0/um/icu.h") $(subst /, $(DIRSEP), ./) + cp "C:/Program Files (x86)/Windows Kits/10/Include/10.0.18362.0/um/icu.h" ./icu4MinGW/ .cpp.o: icu4MinGW/icu.h $(CXX) $(CXXFLAGS) -o $@ -c $<