Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions build-gnu.bat
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,6 @@ if errorlevel 1 (
popd
exit /b 1
)
mingw32-make -f "%~dp0tests\unittests\resources\en-US\Makefile" -C "%~dp0tests\unittests\resources\en-US" OUTDIR="%TESTS1_BUILD_DIR%"
if errorlevel 1 (
echo error 2 errorlevel %errorlevel%
popd
exit /b 1
)
mingw32-make -f "%TESTS1_MAKEFILE%" MYDEFINES="%MYDEFINES%" SAKURA_CORE=../sakura_core OUTDIR=%OUTDIR% -j4
if errorlevel 1 (
echo error 2 errorlevel %errorlevel%
Expand Down
25 changes: 24 additions & 1 deletion sakura/sakura.natvis
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
<Type Name="CNativeW">
<Type Name="CNative&lt;wchar_t&gt;">
<DisplayString Condition="m_pRawData == 0">empty</DisplayString>
<DisplayString Condition="m_pRawData != 0">{m_pRawData,su}</DisplayString>
<Expand>
Expand All @@ -9,4 +9,27 @@
<Item Name="_Size">m_nDataBufSize / 2</Item>
</Expand>
</Type>
<Type Name="CNative&lt;char&gt;">
<DisplayString Condition="m_pRawData == 0">empty</DisplayString>
<DisplayString Condition="m_pRawData != 0">{m_pRawData,s}</DisplayString>
<Expand>
<Item Condition="m_pRawData != 0" Name="_Data">m_pRawData,s</Item>
<Item Name="_Length">m_nRawLen</Item>
<Item Name="_Size">m_nDataBufSize</Item>
</Expand>
</Type>
<Type Name="basis::SString&lt;*,wchar_t&gt;">
<DisplayString Condition="m_szData._Elems[0] == 0">empty</DisplayString>
<DisplayString Condition="m_szData._Elems[0] != 0">{m_szData._Elems,su}</DisplayString>
<Expand>
<Item Condition="m_szData._Elems[0] != 0" Name="_Data">m_szData._Elems,su</Item>
</Expand>
</Type>
<Type Name="basis::SString&lt;*,char&gt;">
<DisplayString Condition="m_szData._Elems[0] == 0">empty</DisplayString>
<DisplayString Condition="m_szData._Elems[0] != 0">{m_szData._Elems,s}</DisplayString>
<Expand>
<Item Condition="m_szData._Elems[0] != 0" Name="_Data">m_szData._Elems,s</Item>
</Expand>
</Type>
</AutoVisualizer>
28 changes: 0 additions & 28 deletions sakura_core/CDataProfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,6 @@
#include "StdAfx.h"
#include "CDataProfile.h"

#include <stdexcept>

/*!
コンストラクタ
*/
StringBufferW::StringBufferW(WCHAR* pData, size_t maxCount)
: pszData_(pData)
, cchDataSize_(maxCount)
{
if (pszData_ == nullptr) {
throw std::invalid_argument("data can't be nullptr");
}

if (cchDataSize_ == 0) {
throw std::invalid_argument("count can't be zero");
}
}

/*!
代入演算子
*/
StringBufferW& StringBufferW::operator = (std::wstring_view rhs)
{
::wcsncpy_s(pszData_, cchDataSize_, rhs.data(), _TRUNCATE);

return *this;
}

namespace profile_data {

//! 設定値を文字列に変換する
Expand Down
19 changes: 2 additions & 17 deletions sakura_core/CDataProfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,7 @@
*
* 読み書き可能なWCHARバッファとサイズを指定して構築する
*/
class StringBufferW {
WCHAR* pszData_;
size_t cchDataSize_;

public:
explicit StringBufferW(WCHAR* pData, size_t maxCount);

template <size_t N>
explicit StringBufferW(WCHAR (&buffer)[N])
: StringBufferW(buffer, N) {}

[[nodiscard]] const WCHAR* c_str() const noexcept { return pszData_; }
[[nodiscard]] size_t capacity() const noexcept { return cchDataSize_; }

StringBufferW& operator = (std::wstring_view rhs);
};
using StringBufferW = basis::TCharBuffer<WCHAR>;

/*!
* プロファイル用データ変換
Expand Down Expand Up @@ -220,7 +205,7 @@ namespace profile_data {
template<>
[[nodiscard]] inline bool TryParse<StringBufferW>(std::wstring_view profile, StringBufferW& value) noexcept
{
if (profile.length() < value.capacity()) {
if (profile.length() < std::size(value)) {
value = profile;
return true;
}
Expand Down
6 changes: 6 additions & 0 deletions sakura_core/StdAfx.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,5 +118,11 @@
// プリコンパイルの有無がビルドパフォーマンスに大きく影響するため。
#include "env/DLLSHAREDATA.h"

// 文字列リテラルのサッフィクス L""s を有効にします
using namespace std::literals::string_literals;

// 文字列参照リテラルのサッフィクス L""sv を有効にします
using namespace std::literals::string_view_literals;

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ は前行の直前に追加の宣言を挿入します。
9 changes: 5 additions & 4 deletions sakura_core/macro/CPPA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ char* CPPA::GetDeclarations( const MacroFuncInfo& cMacroFuncInfo, char* szBuffer
strcpy( szArguments[i], "u0: Unknown" );
}
}
std::filesystem::path funcName(cMacroFuncInfo.m_pszFuncName);
if ( i > 0 ){ // 引数があったとき
int j;
char szArgument[8*20];
Expand All @@ -256,18 +257,18 @@ char* CPPA::GetDeclarations( const MacroFuncInfo& cMacroFuncInfo, char* szBuffer
strcat( szArgument, "; " );
strcat( szArgument, szArguments[j] );
}
auto_sprintf( szBuffer, "%hs S_%ls(%hs)%hs; index %d;",
auto_sprintf( szBuffer, "%hs S_%hs(%hs)%hs; index %d;",
szType,
cMacroFuncInfo.m_pszFuncName,
funcName.string().c_str(),
szArgument,
szReturn,
cMacroFuncInfo.m_nFuncID
);
}
else {
auto_sprintf( szBuffer, "%hs S_%ls%hs; index %d;",
auto_sprintf( szBuffer, "%hs S_%hs%hs; index %d;",
szType,
cMacroFuncInfo.m_pszFuncName,
funcName.string().c_str(),
szReturn,
cMacroFuncInfo.m_nFuncID
);
Expand Down
35 changes: 26 additions & 9 deletions sakura_core/mem/CMemory.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,20 @@
#define CheckKanjiCode_MAXREADLENGTH 16384

/*!
メモリバッファクラス

ヒープメモリにバッファ領域を確保する
内部バッファのサイズは8の倍数に切り上げて確保される。
NUL文字(\0)を含むバイナリシーケンスを格納することができる。
* メモリバッファクラス
*
* ヒープメモリにバッファ領域を確保する
* 内部バッファのサイズは8の倍数に切り上げて確保される。
* NUL文字(\0)を含むバイナリシーケンスを格納することができる。
*
* * 元々は文字列バッファの変換機能を多く含むゴッドオブジェクトだった。
* * UNICODE対応で文字列変換機能の一部が分離された。
* * 残タスク _AppendSzメソッドの分離。
* * 残タスク SwapHLByteメソッドの分離。
*
* @author Norio Nakatani
* @date 1998/03/06 新規作成
* @date 2007/11/06 kobake Unicode対応
*/
class CMemory
{
Expand All @@ -39,6 +48,7 @@ class CMemory
CMemory( const void* pData, size_t nDataLen );
CMemory( const CMemory& rhs );
CMemory( CMemory&& other ) noexcept;

// デストラクタを仮想にすると仮想関数テーブルへのポインタを持つ為にインスタンスの容量が増えてしまうので仮想にしない
// 仮想デストラクタでは無いので派生クラスでメンバー変数を追加しない事
~CMemory() noexcept;
Expand All @@ -53,9 +63,16 @@ class CMemory
void AppendRawData( const void* pData, size_t nDataLen ); //!< バッファの最後にデータを追加する
void Reset( void ) noexcept; //!< バッファをリセットする

[[nodiscard]] const std::byte* GetRawPtr() const noexcept { return m_pRawData; } //!< データへのポインタを返す
std::byte* GetRawPtr() noexcept { return m_pRawData; } //!< データへのポインタを返す
[[nodiscard]] int GetRawLength() const noexcept { return static_cast<int>(m_nRawLen); } //!<データ長を返す。バイト単位。
template<typename T> auto get() noexcept { return (T*)m_pRawData; } //!< データへのポインタを返す
template<typename T> auto get() const noexcept { return (const T*)m_pRawData; } //!< データへのポインタを返す

auto GetRawPtr() noexcept { return m_pRawData; } //!< データへのポインタを返す
auto GetRawPtr() const noexcept { return m_pRawData; } //!< データへのポインタを返す

int GetRawLength() const noexcept { return Length<std::byte>(); } //!<データ長を返す。バイト単位。

template<typename T> auto length() const noexcept { return m_nRawLen / sizeof(T); }
template<typename T> int Length() const noexcept { return int(length<T>()); }

// 演算子
CMemory& operator = ( const CMemory& rhs );
Expand All @@ -72,7 +89,7 @@ class CMemory
void _SetRawLength( size_t nLength );
void swap( CMemory& left ) noexcept;
//! メモリ再確保を行わずに格納できる最大バイト数を求める
[[nodiscard]] int capacity() const noexcept { return 8 <= m_nDataBufSize ? m_nDataBufSize - 2: 0; }
int capacity() const noexcept { return 8 <= m_nDataBufSize ? m_nDataBufSize - 2: 0; }

private: // 2002/2/10 aroka アクセス権変更
/*
Expand Down
5 changes: 0 additions & 5 deletions sakura_core/mem/CNative.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,3 @@
#include "StdAfx.h"
#include "CNative.h"

//! 空っぽにする
void CNative::Clear()
{
this->_GetMemory()->_SetRawLength(0);
}
Loading