Skip to content

Commit

Permalink
Merge a2d01d3 into 8353cd2
Browse files Browse the repository at this point in the history
  • Loading branch information
berryzplus authored Jan 30, 2022
2 parents 8353cd2 + a2d01d3 commit 300a2d9
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 44 deletions.
2 changes: 1 addition & 1 deletion sakura/sakura.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
<ItemDefinitionGroup Label="sakura.common">
<ClCompile>
<AdditionalIncludeDirectories>..\sakura_core;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_WIN32_WINNT=_WIN32_WINNT_WIN7;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_WIN32_WINNT=_WIN32_WINNT_WIN10;NTDDI_VERSION=NTDDI_WIN10_RS3;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
Expand Down
11 changes: 9 additions & 2 deletions sakura_core/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,11 @@ RC= $(RCPREFIX)windres

DEFINES= \
-DWIN32 \
-D_WIN32_WINNT=_WIN32_WINNT_WIN7 \
-D_WIN32_WINNT=_WIN32_WINNT_WIN10 \
-DNTDDI_VERSION=NTDDI_WIN10_RS3 \
-D_UNICODE \
-DUNICODE \
-DNTDDI_VERSION=NTDDI_WIN10_RS3 \
$(MYDEFINES)

ifeq (,$(findstring -D_DEBUG,$(DEFINES)))
Expand All @@ -79,6 +81,7 @@ CFLAGS= \
-MMD \
-I. \
-I$(SRCDIR) \
-isystem icu4MinGW \
$(DEFINES) $(MYCFLAGS)
CXXFLAGS= $(CFLAGS) \
-std=c++17 \
Expand Down Expand Up @@ -148,7 +151,11 @@ Funccode_enum.h: Funccode_x.hsrc $(HEADERMAKE)
githash.h:
cmd /c $(subst /,\,$(SRCDIR))\..\sakura\githash.bat .

StdAfx.h.gch: StdAfx.h githash.h Funccode_enum.h
icu4MinGW/icu.h:
-$(MKDIR) icu4MinGW > $(DEVNULL) 2>&1
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),.)
-$(MKDIR) $(subst /,$(DIRSEP),$(DIRS)) > $(DEVNULL) 2>&1
endif
Expand Down
20 changes: 6 additions & 14 deletions sakura_core/extmodule/CIcu4cI18n.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}

/*!
Expand All @@ -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);
Expand Down
40 changes: 18 additions & 22 deletions sakura_core/extmodule/CIcu4cI18n.h
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 <icu.h>

/*!
* 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インタフェース
Expand Down
1 change: 0 additions & 1 deletion sakura_lang_en_US/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ RC= $(RCPREFIX)windres

DEFINES= \
-DWIN32 \
-D_WIN32_WINNT=_WIN32_WINNT_WIN7 \
-D_UNICODE \
-DUNICODE \
$(MYDEFINES)
Expand Down
2 changes: 1 addition & 1 deletion tests/compiletests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.12)
enable_language(CXX)

set( SAKURA_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../sakura_core)
set( SAKURA_DEFINITIONS -D_DEBUG -D_UNICODE -DUNICODE -D_WIN32_WINNT=_WIN32_WINNT_WIN7)
set( SAKURA_DEFINITIONS -D_DEBUG -D_UNICODE -DUNICODE)

# コンパイルテスト実行関数
function( compile_test TEST_TEMPLATE TEST_BODY TEST_DESCRIPTION TEST_NAME )
Expand Down
2 changes: 1 addition & 1 deletion tests/unittests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ if (BUILD_SHARED_LIBS)
endif (BUILD_SHARED_LIBS)

# Hacks to reuse compiled editor objects.
target_compile_definitions(${project_name} PRIVATE WIN32 _WIN32_WINNT=_WIN32_WINNT_WIN7)
target_compile_definitions(${project_name} PRIVATE WIN32 _WIN32_WINNT=_WIN32_WINNT_WIN10 NTDDI_VERSION=NTDDI_WIN10_RS3)
if (MSVC)
target_compile_options (${project_name} PRIVATE $<$<CONFIG:Release>:/GL> /MT$<$<CONFIG:Debug>:d> /GF /FD /EHsc /Zi /TP /source-charset:utf-8 /execution-charset:shift_jis)
target_link_libraries (${project_name} PRIVATE $<$<CONFIG:Release>:-LTCG> "${CMAKE_CURRENT_LIST_DIR}/../../sakura/${CMAKE_GENERATOR_PLATFORM}/$<CONFIG>/*.obj" "${CMAKE_CURRENT_LIST_DIR}/../../sakura/${CMAKE_GENERATOR_PLATFORM}/$<CONFIG>/*.res")
Expand Down
10 changes: 8 additions & 2 deletions tests/unittests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ RC= $(RCPREFIX)windres

DEFINES= \
-DWIN32 \
-D_WIN32_WINNT=_WIN32_WINNT_WIN7 \
-D_WIN32_WINNT=_WIN32_WINNT_WIN10 \
-DNTDDI_VERSION=NTDDI_WIN10_RS3 \
-D_UNICODE \
-DUNICODE \
$(MYDEFINES)
Expand All @@ -92,6 +93,7 @@ CFLAGS= \
-I$(SRCDIR)/../../sakura_core \
-I. \
-I$(SRCDIR) \
-isystem icu4MinGW \
$(DEFINES) $(MYCFLAGS)

CXXFLAGS= $(CFLAGS) \
Expand Down Expand Up @@ -142,7 +144,11 @@ all: $(exe)
$(exe): $(OBJS) $(SAKURA_OBJS)
$(CXX) -o $@ $(OBJS) $(SAKURA_OBJS) $(LIBS)

.cpp.o:
icu4MinGW/icu.h:
-$(MKDIR) icu4MinGW > $(DEVNULL) 2>&1
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 $<

$(OBJS):
Expand Down

0 comments on commit 300a2d9

Please sign in to comment.