mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-16 23:34:10 +02:00
Merge branch 'master' into BookmarkPanel
This commit is contained in:
commit
6884b9fc21
267 changed files with 26197 additions and 17792 deletions
|
@ -93,6 +93,7 @@
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
|
@ -112,6 +113,7 @@
|
||||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
|
@ -128,6 +130,7 @@
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
|
@ -149,6 +152,7 @@
|
||||||
<AdditionalIncludeDirectories>../;../IDEHelper;../BeefySysLib/platform/win;../BeefySysLib/third_party;..\extern\llvm-project_13_0_1\llvm\include;..\extern\llvm_win64_13_0_1\include;..\extern\llvm-project_13_0_1\llvm\lib\Target;..\extern\llvm_win64_13_0_1\lib\Target\X86;..\extern\llvm\tools\clang\include</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>../;../IDEHelper;../BeefySysLib/platform/win;../BeefySysLib/third_party;..\extern\llvm-project_13_0_1\llvm\include;..\extern\llvm_win64_13_0_1\include;..\extern\llvm-project_13_0_1\llvm\lib\Target;..\extern\llvm_win64_13_0_1\lib\Target\X86;..\extern\llvm\tools\clang\include</AdditionalIncludeDirectories>
|
||||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
|
|
|
@ -27,9 +27,9 @@ if(NOT CMAKE_BUILD_TYPE)
|
||||||
endif(NOT CMAKE_BUILD_TYPE)
|
endif(NOT CMAKE_BUILD_TYPE)
|
||||||
|
|
||||||
# Definition of Macros
|
# Definition of Macros
|
||||||
add_definitions(
|
add_definitions(
|
||||||
-DIDEHELPER_EXPORTS
|
-DIDEHELPER_EXPORTS
|
||||||
-DBFSYSLIB_DYNAMIC
|
-DBFSYSLIB_DYNAMIC
|
||||||
-DUNICODE
|
-DUNICODE
|
||||||
-D_UNICODE
|
-D_UNICODE
|
||||||
-DBF_NO_FBX
|
-DBF_NO_FBX
|
||||||
|
@ -41,10 +41,10 @@ if (${APPLE})
|
||||||
include_directories(
|
include_directories(
|
||||||
.
|
.
|
||||||
../
|
../
|
||||||
../BeefySysLib/
|
../BeefySysLib/
|
||||||
../BeefySysLib/third_party
|
../BeefySysLib/third_party
|
||||||
../BeefySysLib/third_party/freetype/include
|
../BeefySysLib/third_party/freetype/include
|
||||||
../extern/llvm-project_13_0_1/llvm/include
|
../extern/llvm-project_13_0_1/llvm/include
|
||||||
../extern/llvm-project_13_0_1/llvm/lib/Target
|
../extern/llvm-project_13_0_1/llvm/lib/Target
|
||||||
../IDEHelper
|
../IDEHelper
|
||||||
|
|
||||||
|
@ -54,14 +54,14 @@ else()
|
||||||
include_directories(
|
include_directories(
|
||||||
.
|
.
|
||||||
../
|
../
|
||||||
../BeefySysLib/
|
../BeefySysLib/
|
||||||
../BeefySysLib/third_party
|
../BeefySysLib/third_party
|
||||||
../BeefySysLib/third_party/freetype/include
|
../BeefySysLib/third_party/freetype/include
|
||||||
../extern/llvm-project_13_0_1/llvm/include
|
../extern/llvm-project_13_0_1/llvm/include
|
||||||
../extern/llvm-project_13_0_1/llvm/lib/Target
|
../extern/llvm-project_13_0_1/llvm/lib/Target
|
||||||
../IDEHelper
|
../IDEHelper
|
||||||
|
|
||||||
../BeefySysLib/platform/linux
|
../BeefySysLib/platform/linux
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ endif()
|
||||||
# Defines outputs , depending Debug or Release. #
|
# Defines outputs , depending Debug or Release. #
|
||||||
#################################################
|
#################################################
|
||||||
|
|
||||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
add_definitions(
|
add_definitions(
|
||||||
-D_DEBUG
|
-D_DEBUG
|
||||||
)
|
)
|
||||||
|
@ -85,23 +85,23 @@ else()
|
||||||
../extern/llvm_linux_rel_13_0_1/lib/Target/X86
|
../extern/llvm_linux_rel_13_0_1/lib/Target/X86
|
||||||
)
|
)
|
||||||
set(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/${OUTPUT_RELEASE}")
|
set(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/${OUTPUT_RELEASE}")
|
||||||
set(LLVM_LIB "${CMAKE_CURRENT_SOURCE_DIR}/../extern/llvm_linux_rel_13_0_1/lib")
|
set(LLVM_LIB "${CMAKE_CURRENT_SOURCE_DIR}/../extern/llvm_linux_rel_13_0_1/lib")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
################### Dependencies ##################
|
################### Dependencies ##################
|
||||||
# Add Dependencies to project. #
|
# Add Dependencies to project. #
|
||||||
###################################################
|
###################################################
|
||||||
|
|
||||||
option(BUILD_DEPENDS
|
option(BUILD_DEPENDS
|
||||||
"Build other CMake project."
|
"Build other CMake project."
|
||||||
ON
|
ON
|
||||||
)
|
)
|
||||||
|
|
||||||
# Dependencies : disable BUILD_DEPENDS to link with lib already build.
|
# Dependencies : disable BUILD_DEPENDS to link with lib already build.
|
||||||
if(BUILD_DEPENDS)
|
if(BUILD_DEPENDS)
|
||||||
|
|
||||||
else()
|
else()
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
################# Flags ################
|
################# Flags ################
|
||||||
|
@ -113,7 +113,7 @@ if(MSVC)
|
||||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /W3 /GL /Od /Oi /Gy /EHsc")
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /W3 /GL /Od /Oi /Gy /EHsc")
|
||||||
endif(MSVC)
|
endif(MSVC)
|
||||||
if(NOT MSVC)
|
if(NOT MSVC)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -Wno-multichar -Wno-invalid-offsetof")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -Wno-multichar -Wno-invalid-offsetof")
|
||||||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||||
#set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
|
#set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
|
||||||
endif()
|
endif()
|
||||||
|
@ -137,8 +137,17 @@ execute_process(
|
||||||
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/../extern/llvm_linux_13_0_1/bin/llvm-config --system-libs --link-static
|
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/../extern/llvm_linux_13_0_1/bin/llvm-config --system-libs --link-static
|
||||||
OUTPUT_VARIABLE LLVM_SYSTEM_LIBS
|
OUTPUT_VARIABLE LLVM_SYSTEM_LIBS
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
|
RESULT_VARIABLE EXEC_RESULT
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (EXEC_RESULT AND NOT EXEC_RESULT EQUAL 0)
|
||||||
|
if (EXEC_RESULT MATCHES "^[0-9]+$")
|
||||||
|
message(FATAL_ERROR "llvm-config exited with code ${EXEC_RESULT}.")
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "llvm-config couldn't be executed: ${EXEC_RESULT}")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
if (${APPLE})
|
if (${APPLE})
|
||||||
set(TARGET_LIBS_OS "")
|
set(TARGET_LIBS_OS "")
|
||||||
else()
|
else()
|
||||||
|
@ -152,10 +161,10 @@ endif()
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
target_link_libraries(${PROJECT_NAME} BeefySysLib IDEHelper kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib)
|
target_link_libraries(${PROJECT_NAME} BeefySysLib IDEHelper kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib)
|
||||||
else()
|
else()
|
||||||
target_link_libraries(${PROJECT_NAME} BeefySysLib
|
target_link_libraries(${PROJECT_NAME} BeefySysLib
|
||||||
IDEHelper
|
IDEHelper
|
||||||
${TARGET_LIBS_OS}
|
${TARGET_LIBS_OS}
|
||||||
|
|
||||||
#${LLVM_LIB}/libLLVMSupport.a
|
#${LLVM_LIB}/libLLVMSupport.a
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -7,7 +7,7 @@ StartupObject = "BeefBuild.Program"
|
||||||
|
|
||||||
[Platform.Windows]
|
[Platform.Windows]
|
||||||
Description = "BeefBuild"
|
Description = "BeefBuild"
|
||||||
FileVersion = "0.43.3"
|
FileVersion = "0.43.4"
|
||||||
|
|
||||||
[Configs.Debug.Win32]
|
[Configs.Debug.Win32]
|
||||||
TargetName = ""
|
TargetName = ""
|
||||||
|
@ -19,7 +19,7 @@ TargetName = "$(ProjectName)_d"
|
||||||
OtherLinkFlags = "$(LinkFlags) Comdlg32.lib kernel32.lib user32.lib advapi32.lib shell32.lib IDEHelper64_d.lib Rpcrt4.lib Ole32.lib"
|
OtherLinkFlags = "$(LinkFlags) Comdlg32.lib kernel32.lib user32.lib advapi32.lib shell32.lib IDEHelper64_d.lib Rpcrt4.lib Ole32.lib"
|
||||||
CLibType = "Dynamic"
|
CLibType = "Dynamic"
|
||||||
BeefLibType = "DynamicDebug"
|
BeefLibType = "DynamicDebug"
|
||||||
DebugCommandArguments = "-proddir=c:\\Beef\\IDEHelper\\Tests -test"
|
DebugCommandArguments = "-proddir=c:\\Beef\\IDE -config=Debug2"
|
||||||
DebugWorkingDirectory = "c:\\beef\\ide"
|
DebugWorkingDirectory = "c:\\beef\\ide"
|
||||||
EnvironmentVars = ["_NO_DEBUG_HEAP=1"]
|
EnvironmentVars = ["_NO_DEBUG_HEAP=1"]
|
||||||
PreprocessorMacros = ["DEBUG", "CLI"]
|
PreprocessorMacros = ["DEBUG", "CLI"]
|
||||||
|
@ -75,9 +75,6 @@ DebugWorkingDirectory = "$(ProjectDir)\\dist"
|
||||||
EnvironmentVars = ["_NO_DEBUG_HEAP=1"]
|
EnvironmentVars = ["_NO_DEBUG_HEAP=1"]
|
||||||
PreprocessorMacros = ["RELEASE", "CLI"]
|
PreprocessorMacros = ["RELEASE", "CLI"]
|
||||||
|
|
||||||
[Configs.Release.Win64z]
|
|
||||||
BuildKind = "StaticLib"
|
|
||||||
|
|
||||||
[Configs.Debug2.Win32]
|
[Configs.Debug2.Win32]
|
||||||
TargetName = ""
|
TargetName = ""
|
||||||
OtherLinkFlags = ""
|
OtherLinkFlags = ""
|
||||||
|
|
87
BeefFuzz/BeefFuzz.cpp
Normal file
87
BeefFuzz/BeefFuzz.cpp
Normal file
|
@ -0,0 +1,87 @@
|
||||||
|
#pragma warning(disable:4996)
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include "BeefySysLib/Common.h"
|
||||||
|
#include "BeefySysLib/util/Array.h"
|
||||||
|
#include "BeefySysLib/util/SizedArray.h"
|
||||||
|
#include "BeefySysLib/util/Dictionary.h"
|
||||||
|
#include "BeefySysLib/util/CabUtil.h"
|
||||||
|
#include "BeefySysLib/util/BeefPerf.h"
|
||||||
|
#include "BeefySysLib/util/Deque.h"
|
||||||
|
#include "BeefySysLib/util/HashSet.h"
|
||||||
|
#include "BeefySysLib/util/MultiHashSet.h"
|
||||||
|
|
||||||
|
#define BF_DBG_64
|
||||||
|
#include "IDEHelper/StrHashMap.h"
|
||||||
|
|
||||||
|
using namespace Beefy;
|
||||||
|
|
||||||
|
#include "FuzzApp.h"
|
||||||
|
|
||||||
|
BF_IMPORT void BF_CALLTYPE IDEHelper_ProgramStart();
|
||||||
|
BF_IMPORT void BF_CALLTYPE IDEHelper_ProgramDone();
|
||||||
|
|
||||||
|
static void FuzzInit()
|
||||||
|
{
|
||||||
|
BfpSystem_SetCommandLine(0, NULL);
|
||||||
|
|
||||||
|
BfpThread_SetName(NULL, "MainThread", NULL);
|
||||||
|
|
||||||
|
BfpSystem_Init(BFP_VERSION, BfpSystemInitFlag_None);
|
||||||
|
|
||||||
|
IDEHelper_ProgramStart();
|
||||||
|
|
||||||
|
gApp = new FuzzApp();
|
||||||
|
gApp->SetTargetPath("fuzz_testd");
|
||||||
|
gApp->AddDefine("CLI");
|
||||||
|
gApp->AddDefine("DEBUG");
|
||||||
|
gApp->SetStartupObject("fuzz_test.Program");
|
||||||
|
gApp->SetLinkParams("./libBeefRT_d.a ./libBeefySysLib_d.so -ldl -lpthread -Wl,-rpath -Wl,$ORIGIN");
|
||||||
|
|
||||||
|
BF_ASSERT(gApp->Init());
|
||||||
|
}
|
||||||
|
|
||||||
|
void trimwhitespace(const uint8_t*& str, size_t& len)
|
||||||
|
{
|
||||||
|
while (len > 0 && isspace(*str))
|
||||||
|
{
|
||||||
|
str++;
|
||||||
|
len--;
|
||||||
|
}
|
||||||
|
|
||||||
|
const uint8_t* end = str + len - 1;
|
||||||
|
while (len > 0 && isspace(*end))
|
||||||
|
{
|
||||||
|
end--;
|
||||||
|
len--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool init = false;
|
||||||
|
|
||||||
|
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
|
||||||
|
{
|
||||||
|
if (!init)
|
||||||
|
{
|
||||||
|
init = true;
|
||||||
|
FuzzInit();
|
||||||
|
}
|
||||||
|
|
||||||
|
trimwhitespace(Data, Size);
|
||||||
|
if (Size == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
gApp->PrepareCompiler();
|
||||||
|
|
||||||
|
bool ready = gApp->QueueFile((char*)Data, Size);
|
||||||
|
|
||||||
|
//if (ready)
|
||||||
|
// ready = gApp->QueuePath("./corlib/src");
|
||||||
|
|
||||||
|
//if (ready)
|
||||||
|
// gApp->Compile();
|
||||||
|
|
||||||
|
gApp->ReleaseCompiler();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
180
BeefFuzz/BeefFuzz.h
Normal file
180
BeefFuzz/BeefFuzz.h
Normal file
|
@ -0,0 +1,180 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "BeefySysLib/Common.h"
|
||||||
|
#include "BeefySysLib/util/Array.h"
|
||||||
|
#include "BeefySysLib/util/String.h"
|
||||||
|
#include <set>
|
||||||
|
//#include <direct.h>
|
||||||
|
|
||||||
|
#pragma warning(disable:4996)
|
||||||
|
|
||||||
|
NS_BF_BEGIN
|
||||||
|
|
||||||
|
#define APPEND2(VAL1, VAL2) VAL1##VAL2
|
||||||
|
#define APPEND(VAL1, VAL2) APPEND2(VAL1, VAL2)
|
||||||
|
#define ENUM_VAL_GENERATE(ENUM_ENTRY) APPEND(ENUM_TYPE, _##ENUM_ENTRY),
|
||||||
|
#define ENUM_NAME_GENERATE(ENUM_ENTRY) #ENUM_ENTRY,
|
||||||
|
#define ENUM_CREATE_DO2(EnumName) \
|
||||||
|
static const char* EnumName##_Names[] = { ENUM_DECLARE(ENUM_NAME_GENERATE) }; \
|
||||||
|
enum EnumName { ENUM_DECLARE(ENUM_VAL_GENERATE) }; \
|
||||||
|
static bool EnumParse(const String& name, EnumName& result) \
|
||||||
|
{ \
|
||||||
|
for (int i = 0; i < sizeof(EnumName##_Names)/sizeof(const char*); i++) \
|
||||||
|
if (name == EnumName##_Names[i]) { result = (EnumName)i; return true; } \
|
||||||
|
return false; \
|
||||||
|
} \
|
||||||
|
static const char* EnumToString(EnumName enumVal) \
|
||||||
|
{ \
|
||||||
|
return EnumName##_Names[(int)enumVal]; \
|
||||||
|
}
|
||||||
|
#define ENUM_CREATE_DO(EnumType) ENUM_CREATE_DO2(EnumType)
|
||||||
|
#define ENUM_CREATE ENUM_CREATE_DO(ENUM_TYPE)
|
||||||
|
|
||||||
|
class IDEUtils
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static bool FixFilePath(String& filePath)
|
||||||
|
{
|
||||||
|
if (filePath.length() == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (filePath[0] == '<')
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if ((filePath.length() > 1) && (filePath[1] == ':'))
|
||||||
|
filePath[0] = tolower(filePath[0]);
|
||||||
|
|
||||||
|
bool prevWasSlash = false;
|
||||||
|
for (int i = 0; i < filePath.length(); i++)
|
||||||
|
{
|
||||||
|
//if ((filePath[i] == '/') && (filePath[i - 1])
|
||||||
|
|
||||||
|
if (filePath[i] == DIR_SEP_CHAR_ALT)
|
||||||
|
filePath[i] = DIR_SEP_CHAR;
|
||||||
|
|
||||||
|
if (filePath[i] == DIR_SEP_CHAR)
|
||||||
|
{
|
||||||
|
if ((prevWasSlash) && (i > 1))
|
||||||
|
{
|
||||||
|
filePath.Remove(i, 1);
|
||||||
|
i--;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
prevWasSlash = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
prevWasSlash = false;
|
||||||
|
|
||||||
|
if ((i >= 4) && (filePath[i - 3] == DIR_SEP_CHAR) && (filePath[i - 2] == '.') && (filePath[i - 1] == '.') && (filePath[i] == DIR_SEP_CHAR))
|
||||||
|
{
|
||||||
|
int prevSlash = (int)filePath.LastIndexOf(DIR_SEP_CHAR, i - 4);
|
||||||
|
if (prevSlash != -1)
|
||||||
|
{
|
||||||
|
filePath.Remove(prevSlash, i - prevSlash);
|
||||||
|
i = prevSlash;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void GetDirWithSlash(String& dirName)
|
||||||
|
{
|
||||||
|
if (dirName.length() == 0)
|
||||||
|
return;
|
||||||
|
char lastC = dirName[dirName.length() - 1];
|
||||||
|
if ((lastC != '\\') && (lastC != '/'))
|
||||||
|
dirName += DIR_SEP_CHAR;
|
||||||
|
}
|
||||||
|
|
||||||
|
static FILE* CreateFileWithDir(const String& fileName, const char* options)
|
||||||
|
{
|
||||||
|
FILE* fp = fopen(fileName.c_str(), options);
|
||||||
|
if (fp == NULL)
|
||||||
|
{
|
||||||
|
String fileDir = GetFileDir(fileName);
|
||||||
|
if (!fileDir.empty())
|
||||||
|
{
|
||||||
|
RecursiveCreateDirectory(fileDir);
|
||||||
|
fp = fopen(fileName.c_str(), "w");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return fp;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool WriteAllText(const String& fileName, const String& data)
|
||||||
|
{
|
||||||
|
FILE* fp = CreateFileWithDir(fileName, "w");
|
||||||
|
if (fp == NULL)
|
||||||
|
return false;
|
||||||
|
fwrite(data.c_str(), 1, data.length(), fp);
|
||||||
|
fclose(fp);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void GetFileNameWithoutExtension(const String& filePath, String& outFileName)
|
||||||
|
{
|
||||||
|
outFileName += GetFileName(filePath);
|
||||||
|
int dot = (int)outFileName.LastIndexOf('.');
|
||||||
|
if (dot != -1)
|
||||||
|
outFileName.RemoveToEnd(dot);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void GetExtension(const String& filePath, String& ext)
|
||||||
|
{
|
||||||
|
int idx = (int)filePath.LastIndexOf('.');
|
||||||
|
if (idx != -1)
|
||||||
|
ext = filePath.Substring(idx);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void AppendWithOptionalQuotes(String& targetStr, const String& srcFileName)
|
||||||
|
{
|
||||||
|
if ((int)srcFileName.IndexOf(' ') == -1)
|
||||||
|
targetStr += srcFileName;
|
||||||
|
else
|
||||||
|
targetStr += "\"" + srcFileName + "\"";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class ArgBuilder
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
String* mTarget;
|
||||||
|
bool mDoLongBreak;
|
||||||
|
int mLastBreak;
|
||||||
|
std::multiset<String> mLinkPaths;
|
||||||
|
|
||||||
|
public:
|
||||||
|
ArgBuilder(String& target, bool doLongBreak)
|
||||||
|
{
|
||||||
|
mTarget = ⌖
|
||||||
|
mDoLongBreak = doLongBreak;
|
||||||
|
if (mDoLongBreak)
|
||||||
|
mLastBreak = (int)mTarget->LastIndexOf('\n');
|
||||||
|
else
|
||||||
|
mLastBreak = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddSep()
|
||||||
|
{
|
||||||
|
if (mDoLongBreak)
|
||||||
|
{
|
||||||
|
if (mTarget->length() - mLastBreak > 0x1F000)
|
||||||
|
{
|
||||||
|
mLastBreak = (int)mTarget->length();
|
||||||
|
mTarget->Append('\n');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mTarget->Append(' ');
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddFileName(const String& filePath)
|
||||||
|
{
|
||||||
|
IDEUtils::AppendWithOptionalQuotes(*mTarget, filePath);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
NS_BF_END
|
||||||
|
|
182
BeefFuzz/BeefFuzz.vcxproj
Normal file
182
BeefFuzz/BeefFuzz.vcxproj
Normal file
|
@ -0,0 +1,182 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{F5FD6845-BBAE-47B6-AE4E-2C1D30F6E145}</ProjectGuid>
|
||||||
|
<Keyword>Win32Proj</Keyword>
|
||||||
|
<RootNamespace>BeefFuzz</RootNamespace>
|
||||||
|
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="Shared">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
<OutDir>$(SolutionDir)\ide\dist\</OutDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
<TargetName>$(ProjectName)_d</TargetName>
|
||||||
|
<OutDir>$(SolutionDir)\ide\dist\</OutDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
<OutDir>$(SolutionDir)\ide\dist\</OutDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
<OutDir>$(SolutionDir)\ide\dist\</OutDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<PrecompiledHeader>
|
||||||
|
</PrecompiledHeader>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<PrecompiledHeader>
|
||||||
|
</PrecompiledHeader>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<AdditionalIncludeDirectories>../;../IDEHelper;../BeefySysLib/platform/win;../BeefySysLib/third_party;..\extern\llvm-project_13_0_1\llvm\include;..\extern\llvm_win64_13_0_1\include;..\extern\llvm-project_13_0_1\llvm\lib\Target;..\extern\llvm_win64_13_0_1\lib\Target\X86;..\extern\llvm-project_13_0_1\llvm\tools\clang\include</AdditionalIncludeDirectories>
|
||||||
|
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
||||||
|
<SupportJustMyCode>false</SupportJustMyCode>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
|
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||||
|
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<GenerateDebugInformation>DebugFull</GenerateDebugInformation>
|
||||||
|
<OutputFile>$(SolutionDir)\ide\dist\$(TargetName).exe</OutputFile>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<PrecompiledHeader>
|
||||||
|
</PrecompiledHeader>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<PrecompiledHeader>
|
||||||
|
</PrecompiledHeader>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
||||||
|
<AdditionalIncludeDirectories>../;../IDEHelper;../BeefySysLib/platform/win;../BeefySysLib/third_party;..\extern\llvm-project_13_0_1\llvm\include;..\extern\llvm_win64_13_0_1\include;..\extern\llvm-project_13_0_1\llvm\lib\Target;..\extern\llvm_win64_13_0_1\lib\Target\X86;..\extern\llvm\tools\clang\include</AdditionalIncludeDirectories>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<GenerateDebugInformation>DebugFull</GenerateDebugInformation>
|
||||||
|
<OutputFile>$(SolutionDir)\ide\dist\$(TargetName).exe</OutputFile>
|
||||||
|
<LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="BeefFuzz.cpp" />
|
||||||
|
<ClCompile Include="FuzzApp.cpp" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\BeefySysLib\BeefySysLib_static.vcxproj">
|
||||||
|
<Project>{eceab68d-2f15-495f-a29c-5ea9548aa23d}</Project>
|
||||||
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\IDEHelper\IDEHelper.vcxproj">
|
||||||
|
<Project>{f8d29c38-d37c-4af2-8540-2f6e543264f1}</Project>
|
||||||
|
<Private>false</Private>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="BeefFuzz.h" />
|
||||||
|
<ClInclude Include="FuzzApp.h" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
33
BeefFuzz/BeefFuzz.vcxproj.filters
Normal file
33
BeefFuzz/BeefFuzz.vcxproj.filters
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup>
|
||||||
|
<Filter Include="Source Files">
|
||||||
|
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||||
|
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Header Files">
|
||||||
|
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||||
|
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Resource Files">
|
||||||
|
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||||
|
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||||
|
</Filter>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="BeefFuzz.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="FuzzApp.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="FuzzApp.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="BeefFuzz.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
169
BeefFuzz/CMakeLists.txt
Normal file
169
BeefFuzz/CMakeLists.txt
Normal file
|
@ -0,0 +1,169 @@
|
||||||
|
cmake_minimum_required(VERSION 3.0.0 FATAL_ERROR)
|
||||||
|
|
||||||
|
################### Variables. ####################
|
||||||
|
# Change if you want modify path or other values. #
|
||||||
|
###################################################
|
||||||
|
|
||||||
|
set(PROJECT_NAME BeefFuzz)
|
||||||
|
# Output Variables
|
||||||
|
set(OUTPUT_DEBUG Debug/bin)
|
||||||
|
set(OUTPUT_RELEASE Release/bin)
|
||||||
|
|
||||||
|
############## CMake Project ################
|
||||||
|
# The main options of project #
|
||||||
|
#############################################
|
||||||
|
|
||||||
|
project(${PROJECT_NAME} CXX C)
|
||||||
|
|
||||||
|
set (CMAKE_CXX_STANDARD 14)
|
||||||
|
add_definitions(-D_GLIBCXX_USE_CXX11_ABI=1)
|
||||||
|
|
||||||
|
#set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||||
|
|
||||||
|
# Define Release by default.
|
||||||
|
if(NOT CMAKE_BUILD_TYPE)
|
||||||
|
set(CMAKE_BUILD_TYPE "Debug")
|
||||||
|
message(STATUS "Build type not specified: Use Debug by default.")
|
||||||
|
endif(NOT CMAKE_BUILD_TYPE)
|
||||||
|
|
||||||
|
# Definition of Macros
|
||||||
|
add_definitions(
|
||||||
|
-DIDEHELPER_EXPORTS
|
||||||
|
-DBFSYSLIB_DYNAMIC
|
||||||
|
-DUNICODE
|
||||||
|
-D_UNICODE
|
||||||
|
-DBF_NO_FBX
|
||||||
|
-DFT2_BUILD_LIBRARY
|
||||||
|
-DBFSYSLIB_DYNAMIC
|
||||||
|
)
|
||||||
|
|
||||||
|
if (${APPLE})
|
||||||
|
include_directories(
|
||||||
|
.
|
||||||
|
../
|
||||||
|
../BeefySysLib/
|
||||||
|
../BeefySysLib/third_party
|
||||||
|
../BeefySysLib/third_party/freetype/include
|
||||||
|
../extern/llvm-project_13_0_1/llvm/include
|
||||||
|
../extern/llvm-project_13_0_1/llvm/lib/Target
|
||||||
|
../IDEHelper
|
||||||
|
|
||||||
|
../BeefySysLib/platform/osx
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
include_directories(
|
||||||
|
.
|
||||||
|
../
|
||||||
|
../BeefySysLib/
|
||||||
|
../BeefySysLib/third_party
|
||||||
|
../BeefySysLib/third_party/freetype/include
|
||||||
|
../extern/llvm-project_13_0_1/llvm/include
|
||||||
|
../extern/llvm-project_13_0_1/llvm/lib/Target
|
||||||
|
../IDEHelper
|
||||||
|
|
||||||
|
../BeefySysLib/platform/linux
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
############## Artefacts Output #################
|
||||||
|
# Defines outputs , depending Debug or Release. #
|
||||||
|
#################################################
|
||||||
|
|
||||||
|
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
|
add_definitions(
|
||||||
|
-D_DEBUG
|
||||||
|
)
|
||||||
|
include_directories(
|
||||||
|
../extern/llvm_linux_13_0_1/include
|
||||||
|
../extern/llvm_linux_13_0_1/lib/Target/X86
|
||||||
|
)
|
||||||
|
set(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/${OUTPUT_DEBUG}")
|
||||||
|
set(LLVM_LIB "${CMAKE_CURRENT_SOURCE_DIR}/../extern/llvm_linux_13_0_1/lib")
|
||||||
|
else()
|
||||||
|
include_directories(
|
||||||
|
../extern/llvm_linux_rel_13_0_1/include
|
||||||
|
../extern/llvm_linux_rel_13_0_1/lib/Target/X86
|
||||||
|
)
|
||||||
|
set(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/${OUTPUT_RELEASE}")
|
||||||
|
set(LLVM_LIB "${CMAKE_CURRENT_SOURCE_DIR}/../extern/llvm_linux_rel_13_0_1/lib")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
################### Dependencies ##################
|
||||||
|
# Add Dependencies to project. #
|
||||||
|
###################################################
|
||||||
|
|
||||||
|
option(BUILD_DEPENDS
|
||||||
|
"Build other CMake project."
|
||||||
|
ON
|
||||||
|
)
|
||||||
|
|
||||||
|
# Dependencies : disable BUILD_DEPENDS to link with lib already build.
|
||||||
|
if(BUILD_DEPENDS)
|
||||||
|
|
||||||
|
else()
|
||||||
|
|
||||||
|
endif()
|
||||||
|
|
||||||
|
################# Flags ################
|
||||||
|
# Defines Flags for Windows and Linux. #
|
||||||
|
########################################
|
||||||
|
|
||||||
|
if(MSVC)
|
||||||
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /W3 /MD /MDd /Od /EHsc")
|
||||||
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /W3 /GL /Od /Oi /Gy /EHsc")
|
||||||
|
else()
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -Wno-multichar -Wno-invalid-offsetof -fno-omit-frame-pointer -fsanitize=fuzzer")
|
||||||
|
if (BF_ENABLE_ASAN)
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
################ Files ################
|
||||||
|
# -- Add files to project. -- #
|
||||||
|
#######################################
|
||||||
|
|
||||||
|
file(GLOB SRC_FILES
|
||||||
|
BeefFuzz.cpp
|
||||||
|
FuzzApp.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
# Add executable to build.
|
||||||
|
add_executable(${PROJECT_NAME}
|
||||||
|
${SRC_FILES}
|
||||||
|
)
|
||||||
|
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/../extern/llvm_linux_13_0_1/bin/llvm-config --system-libs --link-static
|
||||||
|
OUTPUT_VARIABLE LLVM_SYSTEM_LIBS
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
|
RESULT_VARIABLE EXEC_RESULT
|
||||||
|
)
|
||||||
|
|
||||||
|
if (EXEC_RESULT AND NOT EXEC_RESULT EQUAL 0)
|
||||||
|
if (EXEC_RESULT MATCHES "^[0-9]+$")
|
||||||
|
message(FATAL_ERROR "llvm-config exited with code ${EXEC_RESULT}.")
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "llvm-config couldn't be executed: ${EXEC_RESULT}")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (${APPLE})
|
||||||
|
set(TARGET_LIBS_OS "")
|
||||||
|
else()
|
||||||
|
#set(TARGET_LIBS_OS "curses")
|
||||||
|
#set(TARGET_LIBS_OS "-Xlinker --no-demangle -v")
|
||||||
|
|
||||||
|
set(TARGET_LIBS_OS "${LLVM_SYSTEM_LIBS}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Link with other dependencies.
|
||||||
|
if(MSVC)
|
||||||
|
target_link_libraries(${PROJECT_NAME} BeefySysLib IDEHelper kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib)
|
||||||
|
else()
|
||||||
|
target_link_libraries(${PROJECT_NAME} BeefySysLib
|
||||||
|
IDEHelper
|
||||||
|
${TARGET_LIBS_OS}
|
||||||
|
|
||||||
|
#${LLVM_LIB}/libLLVMSupport.a
|
||||||
|
)
|
||||||
|
endif()
|
300
BeefFuzz/FuzzApp.cpp
Normal file
300
BeefFuzz/FuzzApp.cpp
Normal file
|
@ -0,0 +1,300 @@
|
||||||
|
#pragma warning(disable:4996)
|
||||||
|
|
||||||
|
#include "FuzzApp.h"
|
||||||
|
#include <iostream>
|
||||||
|
#include "BeefySysLib/util/String.h"
|
||||||
|
#include "BeefySysLib/util/FileEnumerator.h"
|
||||||
|
#include "BeefySysLib/util/WorkThread.h"
|
||||||
|
#include "BeefySysLib/platform/PlatformHelper.h"
|
||||||
|
#include "Compiler/BfSystem.h"
|
||||||
|
|
||||||
|
#ifdef BF_PLATFORM_WINDOWS
|
||||||
|
#include <direct.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
BF_IMPORT void BF_CALLTYPE Targets_Create();
|
||||||
|
BF_IMPORT void BF_CALLTYPE Targets_Delete();
|
||||||
|
|
||||||
|
BF_IMPORT void BF_CALLTYPE BfSystem_ReportMemory(void* bfSystem);
|
||||||
|
BF_EXPORT void BF_CALLTYPE BfCompiler_ProgramDone();
|
||||||
|
|
||||||
|
BF_IMPORT void BF_CALLTYPE Debugger_FullReportMemory();
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
BF_IMPORT void BF_CALLTYPE BfCompiler_Delete(void* bfCompiler);
|
||||||
|
BF_EXPORT void BF_CALLTYPE BfCompiler_SetOptions(void* bfCompiler, void* hotProject, int hotIdx,
|
||||||
|
const char* targetTriple, const char* targetCPU, int toolsetType, int simdSetting, int allocStackCount, int maxWorkerThreads,
|
||||||
|
Beefy::BfCompilerOptionFlags optionFlags, const char* mallocLinkName, const char* freeLinkName);
|
||||||
|
BF_IMPORT void BF_CALLTYPE BfCompiler_ClearBuildCache(void* bfCompiler);
|
||||||
|
BF_IMPORT bool BF_CALLTYPE BfCompiler_Compile(void* bfCompiler, void* bfPassInstance, const char* outputPath);
|
||||||
|
BF_IMPORT float BF_CALLTYPE BfCompiler_GetCompletionPercentage(void* bfCompiler);
|
||||||
|
BF_IMPORT const char* BF_CALLTYPE BfCompiler_GetUsedOutputFileNames(void* bfCompiler, void* bfProject, bool flushQueuedHotFiles, bool* hadOutputChanges);
|
||||||
|
|
||||||
|
BF_IMPORT void* BF_CALLTYPE BfSystem_CreateParser(void* bfSystem, void* bfProject);
|
||||||
|
BF_IMPORT void BF_CALLTYPE BfParser_SetSource(void* bfParser, const char* data, int length, const char* fileName);
|
||||||
|
BF_IMPORT void BF_CALLTYPE BfParser_SetCharIdData(void* bfParser, uint8* data, int length);
|
||||||
|
BF_IMPORT bool BF_CALLTYPE BfParser_Parse(void* bfParser, void* bfPassInstance, bool compatMode);
|
||||||
|
BF_IMPORT bool BF_CALLTYPE BfParser_Reduce(void* bfParser, void* bfPassInstance);
|
||||||
|
BF_IMPORT bool BF_CALLTYPE BfParser_BuildDefs(void* bfParser, void* bfPassInstance, void* resolvePassData, bool fullRefresh);
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
BF_IMPORT void* BF_CALLTYPE BfSystem_Create();
|
||||||
|
BF_EXPORT void BF_CALLTYPE BfSystem_Lock(void* bfSystem, int priority);
|
||||||
|
BF_EXPORT void BF_CALLTYPE BfSystem_Unlock(void* bfSystem);
|
||||||
|
BF_IMPORT void BF_CALLTYPE BfSystem_ReportMemory(void* bfSystem);
|
||||||
|
BF_IMPORT void BF_CALLTYPE BfSystem_Delete(void* bfSystem);
|
||||||
|
BF_IMPORT void* BF_CALLTYPE BfSystem_CreatePassInstance(void* bfSystem);
|
||||||
|
BF_IMPORT void* BF_CALLTYPE BfSystem_CreateCompiler(void* bfSystem, bool isResolveOnly);
|
||||||
|
BF_IMPORT void* BF_CALLTYPE BfSystem_CreateProject(void* bfSystem, const char* projectName, const char* projectDir);
|
||||||
|
BF_IMPORT void BF_CALLTYPE BfParser_Delete(void* bfParser);
|
||||||
|
BF_IMPORT void BF_CALLTYPE BfSystem_AddTypeOptions(void* bfSystem, const char* filter, int32 simdSetting, int32 optimizationLevel, int32 emitDebugInfo, int32 arrayBoundsCheck,
|
||||||
|
int32 initLocalVariables, int32 emitDynamicCastCheck, int32 emitObjectAccessCheck, int32 allocStackTraceDepth);
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
BF_IMPORT void BF_CALLTYPE BfProject_SetDisabled(void* bfProject, bool disabled);
|
||||||
|
BF_IMPORT void BF_CALLTYPE BfProject_SetOptions(void* bfProject, int targetType, const char* startupObject, const char* preprocessorMacros,
|
||||||
|
int optLevel, int ltoType, int relocType, int picLevel, int32 flags);
|
||||||
|
BF_IMPORT void BF_CALLTYPE BfProject_ClearDependencies(void* bfProject);
|
||||||
|
BF_IMPORT void BF_CALLTYPE BfProject_AddDependency(void* bfProject, void* depProject);
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
BF_IMPORT const char* BF_CALLTYPE BfPassInstance_PopOutString(void* bfPassInstance);
|
||||||
|
BF_IMPORT void BF_CALLTYPE BfPassInstance_Delete(void* bfPassInstance);
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
BF_IMPORT const char* BF_CALLTYPE VSSupport_Find();
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
USING_NS_BF;
|
||||||
|
|
||||||
|
FuzzApp* Beefy::gApp = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
FuzzApp::FuzzApp()
|
||||||
|
{
|
||||||
|
Targets_Create();
|
||||||
|
|
||||||
|
mTargetType = BfTargetType_BeefConsoleApplication;
|
||||||
|
|
||||||
|
mSystem = NULL;
|
||||||
|
mCompiler = NULL;
|
||||||
|
mProject = NULL;
|
||||||
|
mCELibProject = NULL;
|
||||||
|
mIsCERun = false;
|
||||||
|
mStartupObject = "Program";
|
||||||
|
|
||||||
|
#ifdef BF_PLATFORM_WINDOWS
|
||||||
|
mOptLevel = BfOptLevel_OgPlus;
|
||||||
|
mToolset = BfToolsetType_Microsoft;
|
||||||
|
#else
|
||||||
|
mOptLevel = BfOptLevel_O0;
|
||||||
|
mToolset = BfToolsetType_GNU;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef BF_PLATFORM_WINDOWS
|
||||||
|
mTargetTriple = "x86_64-pc-windows-msvc";
|
||||||
|
#elif defined BF_PLATFORM_MACOS
|
||||||
|
mTargetTriple = "x86_64-apple-macosx10.8.0";
|
||||||
|
#else
|
||||||
|
mTargetTriple = "x86_64-unknown-linux-gnu";
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
FuzzApp::~FuzzApp()
|
||||||
|
{
|
||||||
|
Targets_Delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FuzzApp::Init()
|
||||||
|
{
|
||||||
|
char* cwdPtr = getcwd(NULL, 0);
|
||||||
|
mWorkingDir = cwdPtr;
|
||||||
|
free(cwdPtr);
|
||||||
|
|
||||||
|
if (mTargetPath.IsEmpty())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FuzzApp::QueueFile(const char* data, size_t len)
|
||||||
|
{
|
||||||
|
bool worked = true;
|
||||||
|
void* bfParser = BfSystem_CreateParser(mSystem, (mCELibProject != NULL) ? mCELibProject : mProject);
|
||||||
|
BfParser_SetSource(bfParser, data, len, "Fuzz.bf");
|
||||||
|
//bfParser.SetCharIdData(charIdData);
|
||||||
|
worked &= BfParser_Parse(bfParser, mPassInstance, false);
|
||||||
|
worked &= BfParser_Reduce(bfParser, mPassInstance);
|
||||||
|
worked &= BfParser_BuildDefs(bfParser, mPassInstance, NULL, false);
|
||||||
|
return worked;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FuzzApp::QueuePath(const StringImpl& path)
|
||||||
|
{
|
||||||
|
if (DirectoryExists(path))
|
||||||
|
{
|
||||||
|
for (auto& fileEntry : FileEnumerator(path, FileEnumerator::Flags_Files))
|
||||||
|
{
|
||||||
|
String filePath = fileEntry.GetFilePath();
|
||||||
|
|
||||||
|
String fileName;
|
||||||
|
fileName = GetFileName(filePath);
|
||||||
|
|
||||||
|
String ext;
|
||||||
|
ext = GetFileExtension(filePath);
|
||||||
|
|
||||||
|
if ((ext.Equals(".bf", StringImpl::CompareKind_OrdinalIgnoreCase)) ||
|
||||||
|
(ext.Equals(".cs", StringImpl::CompareKind_OrdinalIgnoreCase)))
|
||||||
|
{
|
||||||
|
int len;
|
||||||
|
const char* data = LoadTextData(filePath, &len);
|
||||||
|
if (data != NULL)
|
||||||
|
{
|
||||||
|
bool success = QueueFile(data, len);
|
||||||
|
delete[] data;
|
||||||
|
|
||||||
|
if (!success)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto& fileEntry : FileEnumerator(path, FileEnumerator::Flags_Directories))
|
||||||
|
{
|
||||||
|
String childPath = fileEntry.GetFilePath();
|
||||||
|
String dirName;
|
||||||
|
dirName = GetFileName(childPath);
|
||||||
|
|
||||||
|
if (dirName == "build")
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (!QueuePath(childPath))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FuzzApp::CopyFile(const StringImpl& srcPath, const StringImpl& destPath)
|
||||||
|
{
|
||||||
|
BfpFileResult result = BfpFileResult_Ok;
|
||||||
|
for (int i = 0; i < 20; i++)
|
||||||
|
{
|
||||||
|
BfpFile_Copy(srcPath.c_str(), destPath.c_str(), BfpFileCopyKind_Always, &result);
|
||||||
|
if (result == BfpFileResult_Ok)
|
||||||
|
return true;
|
||||||
|
BfpThread_Sleep(100);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FuzzApp::PrepareCompiler()
|
||||||
|
{
|
||||||
|
mSystem = BfSystem_Create();
|
||||||
|
|
||||||
|
mCompiler = BfSystem_CreateCompiler(mSystem, false);
|
||||||
|
|
||||||
|
String projectName = GetFileName(mTargetPath);
|
||||||
|
int dotPos = (int)projectName.IndexOf('.');
|
||||||
|
if (dotPos != -1)
|
||||||
|
projectName.RemoveToEnd(dotPos);
|
||||||
|
if (projectName.IsEmpty())
|
||||||
|
projectName.Append("BeefProject");
|
||||||
|
|
||||||
|
mProject = BfSystem_CreateProject(mSystem, projectName.c_str(), GetFileDir(mTargetPath).c_str());
|
||||||
|
|
||||||
|
if (mIsCERun)
|
||||||
|
{
|
||||||
|
mCELibProject = BfSystem_CreateProject(mSystem, "BeefLib", GetFileDir(mTargetPath).c_str());
|
||||||
|
BfProject_SetOptions(mCELibProject, BfTargetType_BeefLib, "", mDefines.c_str(), mOptLevel, 0, 0, 0, BfProjectFlags_None);
|
||||||
|
}
|
||||||
|
|
||||||
|
String defines = mDefines;
|
||||||
|
if (!defines.IsEmpty())
|
||||||
|
defines.Append("\n");
|
||||||
|
defines.Append("BF_64_BIT");
|
||||||
|
defines.Append("\nBF_LITTLE_ENDIAN");
|
||||||
|
defines.Append("\n");
|
||||||
|
defines.Append(BF_PLATFORM_NAME);
|
||||||
|
|
||||||
|
int ltoType = 0;
|
||||||
|
BfProject_SetOptions(mProject, mTargetType, mStartupObject.c_str(), defines.c_str(), BfOptLevel_O0, ltoType, 0, 0, BfProjectFlags_None);
|
||||||
|
|
||||||
|
if (mCELibProject != NULL)
|
||||||
|
BfProject_AddDependency(mProject, mCELibProject);
|
||||||
|
|
||||||
|
mPassInstance = BfSystem_CreatePassInstance(mSystem);
|
||||||
|
|
||||||
|
Beefy::String exePath;
|
||||||
|
BfpGetStrHelper(exePath, [](char* outStr, int* inOutStrSize, BfpResult* result)
|
||||||
|
{
|
||||||
|
BfpSystem_GetExecutablePath(outStr, inOutStrSize, (BfpSystemResult*)result);
|
||||||
|
});
|
||||||
|
mBuildDir = GetFileDir(exePath) + "/build";
|
||||||
|
|
||||||
|
RecursiveCreateDirectory(mBuildDir + "/" + projectName);
|
||||||
|
if (mIsCERun)
|
||||||
|
RecursiveCreateDirectory(mBuildDir + "/BeefLib");
|
||||||
|
|
||||||
|
BfCompilerOptionFlags optionFlags = (BfCompilerOptionFlags)(BfCompilerOptionFlag_EmitDebugInfo | BfCompilerOptionFlag_EmitLineInfo | BfCompilerOptionFlag_GenerateOBJ | BfCompilerOptionFlag_OmitDebugHelpers);
|
||||||
|
|
||||||
|
//int maxWorkerThreads = BfpSystem_GetNumLogicalCPUs(NULL);
|
||||||
|
//if (maxWorkerThreads <= 1)
|
||||||
|
// maxWorkerThreads = 6;
|
||||||
|
|
||||||
|
BfCompiler_SetOptions(mCompiler, NULL, 0, mTargetTriple.c_str(), "", mToolset, BfSIMDSetting_SSE2, 1, 1, optionFlags, "malloc", "free");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool FuzzApp::Compile()
|
||||||
|
{
|
||||||
|
BfCompiler_ClearBuildCache(mCompiler);
|
||||||
|
|
||||||
|
if (!BfCompiler_Compile(mCompiler, mPassInstance, mBuildDir.c_str()))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!mCEDest.IsEmpty())
|
||||||
|
{
|
||||||
|
String ext;
|
||||||
|
String srcResult = mBuildDir + "/BeefProject/BeefProject";
|
||||||
|
srcResult += BF_OBJ_EXT;
|
||||||
|
|
||||||
|
if (!CopyFile(srcResult, mCEDest))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
const char* msg = BfPassInstance_PopOutString(mPassInstance);
|
||||||
|
if (msg == NULL)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if ((strncmp(msg, ":error ", 7) == 0) ||
|
||||||
|
(strncmp(msg, "ERROR(", 6) == 0) ||
|
||||||
|
(strncmp(msg, "ERROR:", 6) == 0))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FuzzApp::ReleaseCompiler()
|
||||||
|
{
|
||||||
|
BfPassInstance_Delete(mPassInstance);
|
||||||
|
BfCompiler_Delete(mCompiler);
|
||||||
|
|
||||||
|
BfSystem_Delete(mSystem);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
66
BeefFuzz/FuzzApp.h
Normal file
66
BeefFuzz/FuzzApp.h
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "BeefFuzz.h"
|
||||||
|
#include "BeefySysLib/FileStream.h"
|
||||||
|
#include "BeefySysLib/util/CritSect.h"
|
||||||
|
#include "BeefySysLib/util/String.h"
|
||||||
|
#include "BeefySysLib/util/Array.h"
|
||||||
|
#include "Compiler/BfSystem.h"
|
||||||
|
|
||||||
|
NS_BF_BEGIN
|
||||||
|
|
||||||
|
class FuzzApp
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
BfTargetType mTargetType;
|
||||||
|
String mTargetTriple;
|
||||||
|
BfOptLevel mOptLevel;
|
||||||
|
BfToolsetType mToolset;
|
||||||
|
String mBuildDir;
|
||||||
|
String mWorkingDir;
|
||||||
|
String mDefines;
|
||||||
|
String mStartupObject;
|
||||||
|
String mTargetPath;
|
||||||
|
String mLinkParams;
|
||||||
|
|
||||||
|
void* mSystem;
|
||||||
|
void* mCompiler;
|
||||||
|
void* mProject;
|
||||||
|
void* mPassInstance;
|
||||||
|
|
||||||
|
bool mIsCERun;
|
||||||
|
void* mCELibProject;
|
||||||
|
String mCEDest;
|
||||||
|
|
||||||
|
public:
|
||||||
|
bool CopyFile(const StringImpl& srcPath, const StringImpl& destPath);
|
||||||
|
|
||||||
|
bool QueueFile(const char* data, size_t len);
|
||||||
|
bool QueuePath(const StringImpl& path);
|
||||||
|
|
||||||
|
public:
|
||||||
|
FuzzApp();
|
||||||
|
~FuzzApp();
|
||||||
|
|
||||||
|
void SetTargetType(BfTargetType value) { mTargetType = value; }
|
||||||
|
void SetTargetTriple(const String& value) { mTargetTriple = value; }
|
||||||
|
void SetOptLevel(BfOptLevel value) { mOptLevel = value; }
|
||||||
|
void SetToolset(BfToolsetType value) { mToolset = value; }
|
||||||
|
void SetBuildDir(const String& value) { mBuildDir = value; }
|
||||||
|
void SetWorkingDir(const String& value) { mWorkingDir = value; }
|
||||||
|
void AddDefine(const String& value) { mDefines += mDefines.IsEmpty() ? value : "\n" + value; }
|
||||||
|
void SetStartupObject(const String& value) { mStartupObject = value; }
|
||||||
|
void SetTargetPath(const String& value) { mTargetPath = value; }
|
||||||
|
void SetLinkParams(const String& value) { mLinkParams = value; }
|
||||||
|
void SetCEDest(const String& value) { mCEDest = value; }
|
||||||
|
|
||||||
|
bool Init();
|
||||||
|
|
||||||
|
void PrepareCompiler();
|
||||||
|
bool Compile();
|
||||||
|
void ReleaseCompiler();
|
||||||
|
};
|
||||||
|
|
||||||
|
extern FuzzApp* gApp;
|
||||||
|
|
||||||
|
NS_BF_END
|
|
@ -792,9 +792,23 @@ namespace Beefy
|
||||||
BFApp_SetCursor((int32)cursor);
|
BFApp_SetCursor((int32)cursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void* GetClipboardData(String format, out int32 size)
|
public virtual void* GetClipboardData(String format, out int32 size, int waitTime = 500)
|
||||||
{
|
{
|
||||||
return BFApp_GetClipboardData(format, out size);
|
Stopwatch sw = null;
|
||||||
|
repeat
|
||||||
|
{
|
||||||
|
if (sw != null)
|
||||||
|
Thread.Sleep(1);
|
||||||
|
void* result = BFApp_GetClipboardData(format, out size);
|
||||||
|
if (size != -1)
|
||||||
|
return result;
|
||||||
|
if (waitTime == 0)
|
||||||
|
return null;
|
||||||
|
if (sw == null)
|
||||||
|
sw = scope:: .()..Start();
|
||||||
|
}
|
||||||
|
while (waitTime < sw.ElapsedMilliseconds);
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void ReleaseClipboardData(void* ptr)
|
public virtual void ReleaseClipboardData(void* ptr)
|
||||||
|
@ -802,9 +816,9 @@ namespace Beefy
|
||||||
BFApp_ReleaseClipboardData(ptr);
|
BFApp_ReleaseClipboardData(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual bool GetClipboardText(String outStr)
|
public virtual bool GetClipboardText(String outStr, int waitTime = 500)
|
||||||
{
|
{
|
||||||
return GetClipboardTextData("text", outStr);
|
return GetClipboardTextData("text", outStr, waitTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual bool GetClipboardText(String outStr, String extra)
|
public virtual bool GetClipboardText(String outStr, String extra)
|
||||||
|
@ -813,10 +827,10 @@ namespace Beefy
|
||||||
return GetClipboardTextData("text", outStr);
|
return GetClipboardTextData("text", outStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool GetClipboardTextData(String format, String outStr)
|
public bool GetClipboardTextData(String format, String outStr, int waitTime = 500)
|
||||||
{
|
{
|
||||||
int32 aSize;
|
int32 aSize;
|
||||||
void* clipboardData = GetClipboardData(format, out aSize);
|
void* clipboardData = GetClipboardData(format, out aSize, waitTime);
|
||||||
if (clipboardData == null)
|
if (clipboardData == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
|
@ -170,7 +170,7 @@ namespace Beefy
|
||||||
if (autoRetry)
|
if (autoRetry)
|
||||||
{
|
{
|
||||||
if (fileOpenErr == .SharingViolation)
|
if (fileOpenErr == .SharingViolation)
|
||||||
retry = true;
|
retry = i != 99;
|
||||||
}
|
}
|
||||||
if (!retry)
|
if (!retry)
|
||||||
return .Err(.OpenError(fileOpenErr));
|
return .Err(.OpenError(fileOpenErr));
|
||||||
|
|
|
@ -33,7 +33,7 @@ namespace Beefy.theme.dark
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void MouseDown(float x, float y, int btn, int btnCount)
|
public virtual void MouseDown(Rect rect, float x, float y, int btn, int btnCount)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -63,6 +63,7 @@ namespace Beefy.theme.dark
|
||||||
public bool mScrollToStartOnLostFocus;
|
public bool mScrollToStartOnLostFocus;
|
||||||
public bool mHiliteCurrentLine;
|
public bool mHiliteCurrentLine;
|
||||||
public Dictionary<int32, Embed> mEmbeds = new .() ~ DeleteDictionaryAndValues!(_);
|
public Dictionary<int32, Embed> mEmbeds = new .() ~ DeleteDictionaryAndValues!(_);
|
||||||
|
public Embed mEmbedSelected;
|
||||||
public Range? mLineRange;
|
public Range? mLineRange;
|
||||||
|
|
||||||
protected static uint32[] sDefaultColors = new uint32[] ( Color.White ) ~ delete _;
|
protected static uint32[] sDefaultColors = new uint32[] ( Color.White ) ~ delete _;
|
||||||
|
@ -457,6 +458,12 @@ namespace Beefy.theme.dark
|
||||||
LineStartsChanged();
|
LineStartsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void ClearText()
|
||||||
|
{
|
||||||
|
mLineRange = null;
|
||||||
|
base.ClearText();
|
||||||
|
}
|
||||||
|
|
||||||
public virtual float DrawText(Graphics g, String str, float x, float y, uint16 typeIdAndFlags)
|
public virtual float DrawText(Graphics g, String str, float x, float y, uint16 typeIdAndFlags)
|
||||||
{
|
{
|
||||||
using (g.PushColor(mTextColors[typeIdAndFlags & 0xFF]))
|
using (g.PushColor(mTextColors[typeIdAndFlags & 0xFF]))
|
||||||
|
|
|
@ -2781,6 +2781,11 @@ namespace MiniZ
|
||||||
array_ptr.m_element_size = element_size;
|
array_ptr.m_element_size = element_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static mixin ZIP_ARRAY_ELEMENT_PTR<T>(var array_ptr, int index)
|
||||||
|
{
|
||||||
|
&((T*)(array_ptr.m_p))[index]
|
||||||
|
}
|
||||||
|
|
||||||
static mixin ZIP_ARRAY_ELEMENT<T>(var array_ptr, int index)
|
static mixin ZIP_ARRAY_ELEMENT<T>(var array_ptr, int index)
|
||||||
{
|
{
|
||||||
((T*)(array_ptr.m_p))[index]
|
((T*)(array_ptr.m_p))[index]
|
||||||
|
@ -2929,9 +2934,9 @@ namespace MiniZ
|
||||||
|
|
||||||
static bool zip_reader_filename_less(ZipArray* pCentral_dir_array, ZipArray* pCentral_dir_offsets, uint32 l_index, uint32 r_index)
|
static bool zip_reader_filename_less(ZipArray* pCentral_dir_array, ZipArray* pCentral_dir_offsets, uint32 l_index, uint32 r_index)
|
||||||
{
|
{
|
||||||
uint8* pL = &ZIP_ARRAY_ELEMENT!<uint8>(pCentral_dir_array, ZIP_ARRAY_ELEMENT!<uint32>(pCentral_dir_offsets, l_index));
|
uint8* pL = ZIP_ARRAY_ELEMENT_PTR!<uint8>(pCentral_dir_array, ZIP_ARRAY_ELEMENT!<uint32>(pCentral_dir_offsets, l_index));
|
||||||
uint8* pE;
|
uint8* pE;
|
||||||
uint8* pR = &ZIP_ARRAY_ELEMENT!<uint8>(pCentral_dir_array, ZIP_ARRAY_ELEMENT!<uint32>(pCentral_dir_offsets, r_index));
|
uint8* pR = ZIP_ARRAY_ELEMENT_PTR!<uint8>(pCentral_dir_array, ZIP_ARRAY_ELEMENT!<uint32>(pCentral_dir_offsets, r_index));
|
||||||
uint32 l_len = ReadLE16!(pL + ZIP_CDH_FILENAME_LEN_OFS), r_len = ReadLE16!(pR + ZIP_CDH_FILENAME_LEN_OFS);
|
uint32 l_len = ReadLE16!(pL + ZIP_CDH_FILENAME_LEN_OFS), r_len = ReadLE16!(pR + ZIP_CDH_FILENAME_LEN_OFS);
|
||||||
char8 l = 0, r = 0;
|
char8 l = 0, r = 0;
|
||||||
pL += ZIP_CENTRAL_DIR_HEADER_SIZE; pR += ZIP_CENTRAL_DIR_HEADER_SIZE;
|
pL += ZIP_CENTRAL_DIR_HEADER_SIZE; pR += ZIP_CENTRAL_DIR_HEADER_SIZE;
|
||||||
|
@ -2951,7 +2956,7 @@ namespace MiniZ
|
||||||
ZipInternalState* pState = pZip.m_pState;
|
ZipInternalState* pState = pZip.m_pState;
|
||||||
ZipArray* pCentral_dir_offsets = &pState.m_central_dir_offsets;
|
ZipArray* pCentral_dir_offsets = &pState.m_central_dir_offsets;
|
||||||
ZipArray* pCentral_dir = &pState.m_central_dir;
|
ZipArray* pCentral_dir = &pState.m_central_dir;
|
||||||
uint32* pIndices = &ZIP_ARRAY_ELEMENT!<uint32>(&pState.m_sorted_central_dir_offsets, 0);
|
uint32* pIndices = ZIP_ARRAY_ELEMENT_PTR!<uint32>(&pState.m_sorted_central_dir_offsets, 0);
|
||||||
int size = (int)pZip.m_total_files;
|
int size = (int)pZip.m_total_files;
|
||||||
int start = (size - 2) >> 1, end;
|
int start = (size - 2) >> 1, end;
|
||||||
while (start >= 0)
|
while (start >= 0)
|
||||||
|
@ -3063,9 +3068,9 @@ namespace MiniZ
|
||||||
int32 total_header_size, comp_size, decomp_size, disk_index;
|
int32 total_header_size, comp_size, decomp_size, disk_index;
|
||||||
if ((n < ZIP_CENTRAL_DIR_HEADER_SIZE) || (ReadLE32!(p) != ZIP_CENTRAL_DIR_HEADER_SIG))
|
if ((n < ZIP_CENTRAL_DIR_HEADER_SIZE) || (ReadLE32!(p) != ZIP_CENTRAL_DIR_HEADER_SIG))
|
||||||
return false;
|
return false;
|
||||||
ZIP_ARRAY_ELEMENT!<uint32>(&pZip.m_pState.m_central_dir_offsets, i) = (uint32)(p - (uint8*)pZip.m_pState.m_central_dir.m_p);
|
*ZIP_ARRAY_ELEMENT_PTR!<uint32>(&pZip.m_pState.m_central_dir_offsets, i) = (uint32)(p - (uint8*)pZip.m_pState.m_central_dir.m_p);
|
||||||
if (sort_central_dir)
|
if (sort_central_dir)
|
||||||
ZIP_ARRAY_ELEMENT!<uint32>(&pZip.m_pState.m_sorted_central_dir_offsets, i) = (uint32)i;
|
*ZIP_ARRAY_ELEMENT_PTR!<uint32>(&pZip.m_pState.m_sorted_central_dir_offsets, i) = (uint32)i;
|
||||||
comp_size = (int32)ReadLE32!(p + ZIP_CDH_COMPRESSED_SIZE_OFS);
|
comp_size = (int32)ReadLE32!(p + ZIP_CDH_COMPRESSED_SIZE_OFS);
|
||||||
decomp_size = (int32)ReadLE32!(p + ZIP_CDH_DECOMPRESSED_SIZE_OFS);
|
decomp_size = (int32)ReadLE32!(p + ZIP_CDH_DECOMPRESSED_SIZE_OFS);
|
||||||
if (((ReadLE32!(p + ZIP_CDH_METHOD_OFS) == 0) && (decomp_size != comp_size)) || ((decomp_size != 0) && (comp_size == 0)) || (decomp_size == -1) || (comp_size == -1))
|
if (((ReadLE32!(p + ZIP_CDH_METHOD_OFS) == 0) && (decomp_size != comp_size)) || ((decomp_size != 0) && (comp_size == 0)) || (decomp_size == -1) || (comp_size == -1))
|
||||||
|
@ -3210,7 +3215,7 @@ namespace MiniZ
|
||||||
{
|
{
|
||||||
if ((pZip == null) || (pZip.m_pState == null) || (file_index >= pZip.m_total_files) || (pZip.m_zip_mode != .Reading))
|
if ((pZip == null) || (pZip.m_pState == null) || (file_index >= pZip.m_total_files) || (pZip.m_zip_mode != .Reading))
|
||||||
return null;
|
return null;
|
||||||
return &ZIP_ARRAY_ELEMENT!<uint8>(&pZip.m_pState.m_central_dir, ZIP_ARRAY_ELEMENT!<uint32>(&pZip.m_pState.m_central_dir_offsets, file_index));
|
return ZIP_ARRAY_ELEMENT_PTR!<uint8>(&pZip.m_pState.m_central_dir, ZIP_ARRAY_ELEMENT!<uint32>(&pZip.m_pState.m_central_dir_offsets, file_index));
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool zip_reader_is_file_encrypted(ZipArchive* pZip, int32 file_index)
|
static bool zip_reader_is_file_encrypted(ZipArchive* pZip, int32 file_index)
|
||||||
|
@ -3313,7 +3318,7 @@ namespace MiniZ
|
||||||
{
|
{
|
||||||
char8* pR = pR_in;
|
char8* pR = pR_in;
|
||||||
|
|
||||||
uint8* pL = &ZIP_ARRAY_ELEMENT!<uint8>(pCentral_dir_array, ZIP_ARRAY_ELEMENT!<uint32>(pCentral_dir_offsets, l_index));
|
uint8* pL = ZIP_ARRAY_ELEMENT_PTR!<uint8>(pCentral_dir_array, ZIP_ARRAY_ELEMENT!<uint32>(pCentral_dir_offsets, l_index));
|
||||||
uint8* pE;
|
uint8* pE;
|
||||||
int32 l_len = ReadLE16!(pL + ZIP_CDH_FILENAME_LEN_OFS);
|
int32 l_len = ReadLE16!(pL + ZIP_CDH_FILENAME_LEN_OFS);
|
||||||
char8 l = 0, r = 0;
|
char8 l = 0, r = 0;
|
||||||
|
@ -3334,7 +3339,7 @@ namespace MiniZ
|
||||||
ZipInternalState* pState = pZip.m_pState;
|
ZipInternalState* pState = pZip.m_pState;
|
||||||
ZipArray* pCentral_dir_offsets = &pState.m_central_dir_offsets;
|
ZipArray* pCentral_dir_offsets = &pState.m_central_dir_offsets;
|
||||||
ZipArray* pCentral_dir = &pState.m_central_dir;
|
ZipArray* pCentral_dir = &pState.m_central_dir;
|
||||||
uint32* pIndices = &ZIP_ARRAY_ELEMENT!<uint32>(&pState.m_sorted_central_dir_offsets, 0);
|
uint32* pIndices = ZIP_ARRAY_ELEMENT_PTR!<uint32>(&pState.m_sorted_central_dir_offsets, 0);
|
||||||
int32 size = pZip.m_total_files;
|
int32 size = pZip.m_total_files;
|
||||||
int32 filename_len = (int32)Internal.CStrLen(pFilename);
|
int32 filename_len = (int32)Internal.CStrLen(pFilename);
|
||||||
int32 l = 0, h = size - 1;
|
int32 l = 0, h = size - 1;
|
||||||
|
@ -3363,7 +3368,7 @@ namespace MiniZ
|
||||||
comment_len = (pComment != null) ? Internal.CStrLen(pComment) : 0; if (comment_len > 0xFFFF) return -1;
|
comment_len = (pComment != null) ? Internal.CStrLen(pComment) : 0; if (comment_len > 0xFFFF) return -1;
|
||||||
for (file_index = 0; file_index < pZip.m_total_files; file_index++)
|
for (file_index = 0; file_index < pZip.m_total_files; file_index++)
|
||||||
{
|
{
|
||||||
uint8* pHeader = &ZIP_ARRAY_ELEMENT!<uint8>(&pZip.m_pState.m_central_dir, ZIP_ARRAY_ELEMENT!<uint32>(&pZip.m_pState.m_central_dir_offsets, file_index));
|
uint8* pHeader = ZIP_ARRAY_ELEMENT_PTR!<uint8>(&pZip.m_pState.m_central_dir, ZIP_ARRAY_ELEMENT!<uint32>(&pZip.m_pState.m_central_dir_offsets, file_index));
|
||||||
int32 filename_len = ReadLE16!(pHeader + ZIP_CDH_FILENAME_LEN_OFS);
|
int32 filename_len = ReadLE16!(pHeader + ZIP_CDH_FILENAME_LEN_OFS);
|
||||||
char8* pFilename = (char8*)pHeader + ZIP_CENTRAL_DIR_HEADER_SIZE;
|
char8* pFilename = (char8*)pHeader + ZIP_CENTRAL_DIR_HEADER_SIZE;
|
||||||
if (filename_len < name_len)
|
if (filename_len < name_len)
|
||||||
|
|
|
@ -5,8 +5,13 @@ namespace System
|
||||||
{
|
{
|
||||||
interface IRawAllocator
|
interface IRawAllocator
|
||||||
{
|
{
|
||||||
void* Alloc(int size, int align);
|
void* Alloc(int size, int align) mut;
|
||||||
void Free(void* ptr);
|
void Free(void* ptr) mut;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ITypedAllocator : IRawAllocator
|
||||||
|
{
|
||||||
|
void* AllocTyped(Type type, int size, int align) mut;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct StdAllocator : IRawAllocator
|
struct StdAllocator : IRawAllocator
|
||||||
|
@ -22,6 +27,76 @@ namespace System
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class SingleAllocator : ITypedAllocator
|
||||||
|
{
|
||||||
|
void* mPtr;
|
||||||
|
int mSize;
|
||||||
|
Type mType;
|
||||||
|
|
||||||
|
[AllowAppend]
|
||||||
|
public this(int size)
|
||||||
|
{
|
||||||
|
void* ptr = append uint8[size]*(?);
|
||||||
|
mPtr = ptr;
|
||||||
|
mSize = size;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ~this()
|
||||||
|
{
|
||||||
|
if ((mType != null) && (mType.IsObject))
|
||||||
|
{
|
||||||
|
Object obj = Internal.UnsafeCastToObject(mPtr);
|
||||||
|
delete:null obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mSize < 0)
|
||||||
|
delete mPtr;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void* AllocLarge(int size, int align)
|
||||||
|
{
|
||||||
|
return new uint8[size]*;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void FreeLarge(void* ptr)
|
||||||
|
{
|
||||||
|
delete ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void* Alloc(int size, int align)
|
||||||
|
{
|
||||||
|
return AllocTyped(typeof(void), size, align);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Free(void* ptr)
|
||||||
|
{
|
||||||
|
Runtime.Assert(ptr == mPtr);
|
||||||
|
mType = typeof(void);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Optimize]
|
||||||
|
public void* AllocTyped(Type type, int size, int align)
|
||||||
|
{
|
||||||
|
Runtime.Assert(mType == null, "SingleAllocator has been used for multiple allocations");
|
||||||
|
|
||||||
|
mType = type;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if (size > size)
|
||||||
|
break;
|
||||||
|
void* usePtr = (void*)(int)Math.Align((int)mPtr, align);
|
||||||
|
if ((uint8*)usePtr + size > (uint8*)mPtr + mSize)
|
||||||
|
break;
|
||||||
|
mPtr = usePtr;
|
||||||
|
mSize = 0;
|
||||||
|
return mPtr;
|
||||||
|
}
|
||||||
|
mSize = -1;
|
||||||
|
mPtr = AllocLarge(size, align);
|
||||||
|
return mPtr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct AllocWrapper<T> where T : new, delete
|
struct AllocWrapper<T> where T : new, delete
|
||||||
{
|
{
|
||||||
alloctype(T) mVal;
|
alloctype(T) mVal;
|
||||||
|
|
|
@ -425,10 +425,18 @@ namespace System
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[AttributeUsage(.Field | .StaticField | .Method | .Property /*2*/)]
|
[AttributeUsage(.Field | .StaticField | .Method | .Property | .Types)]
|
||||||
public struct NoShowAttribute : Attribute
|
public struct NoShowAttribute : Attribute
|
||||||
{
|
{
|
||||||
|
public this()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public this(bool allowDirect)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[AttributeUsage(.Parameter)]
|
[AttributeUsage(.Parameter)]
|
||||||
|
|
|
@ -71,6 +71,12 @@ namespace System.Collections
|
||||||
Add(item);
|
Add(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[AllowAppend]
|
||||||
|
public this(Span<T> span) : this(span.Length)
|
||||||
|
{
|
||||||
|
AddRange(span);
|
||||||
|
}
|
||||||
|
|
||||||
[AllowAppend]
|
[AllowAppend]
|
||||||
public this(int capacity)
|
public this(int capacity)
|
||||||
{
|
{
|
||||||
|
|
626
BeefLibs/corlib/src/Collections/SplitList.bf
Normal file
626
BeefLibs/corlib/src/Collections/SplitList.bf
Normal file
|
@ -0,0 +1,626 @@
|
||||||
|
using System;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
|
namespace System.Collections
|
||||||
|
{
|
||||||
|
class SplitList<T> : IEnumerable<Entry>, IList, ICollection<T> where T : struct
|
||||||
|
{
|
||||||
|
private const int_cosize cDefaultCapacity = 4;
|
||||||
|
|
||||||
|
private void* mItems;
|
||||||
|
private int_cosize mSize;
|
||||||
|
private int_cosize mAllocSize;
|
||||||
|
#if VERSION_LIST
|
||||||
|
private int32 mVersion;
|
||||||
|
const String cVersionError = "List changed during enumeration";
|
||||||
|
#endif
|
||||||
|
|
||||||
|
[Inline] public int AllocSize => mAllocSize;
|
||||||
|
|
||||||
|
static void GetFields(List<FieldInfo> fieldList)
|
||||||
|
{
|
||||||
|
if (typeof(T).IsUnion)
|
||||||
|
return;
|
||||||
|
for (var field in typeof(T).GetFields())
|
||||||
|
{
|
||||||
|
if (field.IsStatic)
|
||||||
|
continue;
|
||||||
|
fieldList.Add(field);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Comptime, OnCompile(.TypeInit)]
|
||||||
|
static void Init()
|
||||||
|
{
|
||||||
|
var fields = GetFields(.. scope .());
|
||||||
|
String code = scope $"""
|
||||||
|
int_cosize[{Math.Max(0, fields.Count - 1)}] mOffsets;
|
||||||
|
""";
|
||||||
|
Compiler.EmitTypeBody(typeof(Self), code);
|
||||||
|
|
||||||
|
if (typeof(T).IsUnion)
|
||||||
|
Runtime.FatalError("Cannot use SplitList on a union");
|
||||||
|
}
|
||||||
|
|
||||||
|
public struct Data
|
||||||
|
{
|
||||||
|
SelfOuter mList;
|
||||||
|
|
||||||
|
public this(SelfOuter list)
|
||||||
|
{
|
||||||
|
mList = list;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Comptime, OnCompile(.TypeInit)]
|
||||||
|
static void Init()
|
||||||
|
{
|
||||||
|
var fields = GetFields(.. scope .());
|
||||||
|
String code = scope .();
|
||||||
|
for (var field in fields)
|
||||||
|
{
|
||||||
|
code.AppendF($"[Inline] public Span<{field.FieldType}> {field.Name} => .((.)((uint8*)mList.mItems");
|
||||||
|
if (@field.Index > 0)
|
||||||
|
code.AppendF($" + mList.mOffsets[{@field.Index - 1}]");
|
||||||
|
code.AppendF($"), mList.mSize);\n");
|
||||||
|
}
|
||||||
|
Compiler.EmitTypeBody(typeof(Self), code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Comptime]
|
||||||
|
static void Emit_Get(String prefix, String idx, String item)
|
||||||
|
{
|
||||||
|
var fields = GetFields(.. scope .());
|
||||||
|
String code = scope .();
|
||||||
|
for (var field in fields)
|
||||||
|
{
|
||||||
|
code.AppendF($"{item}.[Friend]{field.Name} = (({field.FieldType}*)((uint8*){prefix}mItems");
|
||||||
|
if (@field.Index > 0)
|
||||||
|
code.AppendF($" + {prefix}mOffsets[{@field.Index - 1}]");
|
||||||
|
code.AppendF($"))[{idx}];\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
Compiler.MixinRoot(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Comptime]
|
||||||
|
static void Emit_Set(String prefix, String idx, String item)
|
||||||
|
{
|
||||||
|
String code = scope .();
|
||||||
|
var fields = GetFields(.. scope .());
|
||||||
|
for (var field in fields)
|
||||||
|
{
|
||||||
|
if (field.IsStatic)
|
||||||
|
continue;
|
||||||
|
code.AppendF($"(({field.FieldType}*)((uint8*){prefix}mItems");
|
||||||
|
if (@field.Index > 0)
|
||||||
|
code.AppendF($" + {prefix}mOffsets[{@field.Index - 1}]");
|
||||||
|
code.AppendF($"))[{idx}] = {item}.[Friend]{field.Name};\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
Compiler.MixinRoot(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Comptime]
|
||||||
|
static void Emit_Copy(String destOfs, String srcOfs, String length)
|
||||||
|
{
|
||||||
|
var fields = GetFields(.. scope .());
|
||||||
|
String code = scope .();
|
||||||
|
for (var field in fields)
|
||||||
|
{
|
||||||
|
if (@field.Index > 0)
|
||||||
|
code.AppendF($"Internal.MemMove((uint8*)mItems + mOffsets[{@field.Index - 1}] + {destOfs} * {field.FieldType.Stride}, (uint8*)mItems + mOffsets[{@field.Index - 1}] + {srcOfs} * {field.FieldType.Stride}, mSize * {field.FieldType.Stride});\n");
|
||||||
|
else
|
||||||
|
code.AppendF($"Internal.MemMove((uint8*)mItems + {destOfs} * {field.FieldType.Stride}, (uint8*)mItems + {srcOfs} * {field.FieldType.Stride}, {length} * {field.FieldType.Stride});\n");
|
||||||
|
}
|
||||||
|
Compiler.MixinRoot(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
public struct Entry
|
||||||
|
{
|
||||||
|
SelfOuter mList;
|
||||||
|
int_cosize mIdx;
|
||||||
|
|
||||||
|
[Inline]
|
||||||
|
public this(SelfOuter list, int idx)
|
||||||
|
{
|
||||||
|
mList = list;
|
||||||
|
mIdx = (.)idx;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Comptime, OnCompile(.TypeInit)]
|
||||||
|
static void Init()
|
||||||
|
{
|
||||||
|
var fields = GetFields(.. scope .());
|
||||||
|
String code = scope .();
|
||||||
|
for (var field in fields)
|
||||||
|
{
|
||||||
|
code.AppendF($"[Inline] public ref {field.FieldType} {field.Name} => ref (({field.FieldType}*)((uint8*)mList.mItems");
|
||||||
|
if (@field.Index > 0)
|
||||||
|
code.AppendF($" + mList.mOffsets[{@field.Index - 1}]");
|
||||||
|
code.AppendF($"))[mIdx];\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
Compiler.EmitTypeBody(typeof(Self), code);
|
||||||
|
}
|
||||||
|
|
||||||
|
public T Value
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
T value = ?;
|
||||||
|
Emit_Get("mList.", "mIdx", "value");
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
set
|
||||||
|
{
|
||||||
|
Emit_Set("mList.", "mIdx", "value");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static T operator implicit(Self self) => self.[Inline]Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ~this()
|
||||||
|
{
|
||||||
|
Free(mItems);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Entry this[int index]
|
||||||
|
{
|
||||||
|
[Checked]
|
||||||
|
get
|
||||||
|
{
|
||||||
|
Runtime.Assert((uint)index < (uint)mSize);
|
||||||
|
return .(this, index);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Unchecked, Inline]
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return .(this, index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Count => mSize;
|
||||||
|
|
||||||
|
[Inline] public Data Data => .(this);
|
||||||
|
|
||||||
|
protected virtual void* Alloc(int byteSize)
|
||||||
|
{
|
||||||
|
return new uint8[byteSize]*;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void Free(void* val)
|
||||||
|
{
|
||||||
|
delete val;
|
||||||
|
}
|
||||||
|
|
||||||
|
void* Realloc(int newSize, bool autoFree)
|
||||||
|
{
|
||||||
|
[Comptime]
|
||||||
|
void Emit_Start()
|
||||||
|
{
|
||||||
|
var fields = GetFields(.. scope .());
|
||||||
|
String code = scope $"int_cosize[{Math.Max(0, fields.Count - 1)}] newOffsets;\n";
|
||||||
|
FieldInfo prevFieldInfo = default;
|
||||||
|
for (var field in fields)
|
||||||
|
{
|
||||||
|
if (@field.Index > 0)
|
||||||
|
{
|
||||||
|
code.AppendF($"newOffsets[{@field.Index - 1}] = (.)Math.Align(");
|
||||||
|
if (@field.Index > 1)
|
||||||
|
code.AppendF($"newOffsets[{@field.Index - 2}] + ");
|
||||||
|
code.AppendF($"newSize * {prevFieldInfo.FieldType.Stride}, {field.FieldType.Align});\n");
|
||||||
|
}
|
||||||
|
prevFieldInfo = field;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fields.Count == 0)
|
||||||
|
code.AppendF("int newSizeBytes = 0;\n");
|
||||||
|
else if (fields.Count == 1)
|
||||||
|
code.AppendF($"int newSizeBytes = newSize * {typeof(T).Stride};\n");
|
||||||
|
else
|
||||||
|
code.AppendF($"int newSizeBytes = newOffsets[{fields.Count - 2}] + newSize * {fields[fields.Count - 1].FieldType.Stride};\n");
|
||||||
|
|
||||||
|
Compiler.MixinRoot(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Comptime]
|
||||||
|
void Emit_Copy()
|
||||||
|
{
|
||||||
|
var fields = GetFields(.. scope .());
|
||||||
|
String code = scope .();
|
||||||
|
for (var field in fields)
|
||||||
|
{
|
||||||
|
if (@field.Index > 0)
|
||||||
|
code.AppendF($"Internal.MemCpy((uint8*)newItems + newOffsets[{@field.Index - 1}], (uint8*)mItems + mOffsets[{@field.Index - 1}], mSize * {field.FieldType.Stride});\n");
|
||||||
|
else
|
||||||
|
code.AppendF($"Internal.MemCpy(newItems, mItems, mSize * {field.FieldType.Stride});\n");
|
||||||
|
}
|
||||||
|
Compiler.MixinRoot(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
void* oldAlloc = null;
|
||||||
|
if (newSize > 0)
|
||||||
|
{
|
||||||
|
Emit_Start();
|
||||||
|
void* newItems = Alloc(newSizeBytes);
|
||||||
|
if (mSize > 0)
|
||||||
|
{
|
||||||
|
Emit_Copy();
|
||||||
|
}
|
||||||
|
oldAlloc = mItems;
|
||||||
|
mItems = newItems;
|
||||||
|
mOffsets = newOffsets;
|
||||||
|
mAllocSize = (.)newSize;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
oldAlloc = mItems;
|
||||||
|
mItems = null;
|
||||||
|
mAllocSize = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((autoFree) && (oldAlloc != null))
|
||||||
|
{
|
||||||
|
Free(oldAlloc);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return oldAlloc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void* EnsureCapacity(int min, bool autoFree)
|
||||||
|
{
|
||||||
|
int allocSize = AllocSize;
|
||||||
|
if (allocSize >= min)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
int_cosize newCapacity = (int_cosize)(allocSize == 0 ? cDefaultCapacity : allocSize * 2);
|
||||||
|
// Allow the list to grow to maximum possible capacity (~2G elements) before encountering overflow.
|
||||||
|
// Note that this check works even when mItems.Length overflowed thanks to the (uint) cast
|
||||||
|
//if ((uint)newCapacity > Array.MaxArrayLength) newCapacity = Array.MaxArrayLength;
|
||||||
|
if (newCapacity < min) newCapacity = (int_cosize)min;
|
||||||
|
return Realloc(newCapacity, autoFree);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Reserve(int size)
|
||||||
|
{
|
||||||
|
EnsureCapacity(size, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Adds an item to the back of the list.
|
||||||
|
public void Add(T item)
|
||||||
|
{
|
||||||
|
if (mSize == AllocSize)
|
||||||
|
{
|
||||||
|
// We free after the insert to allow for inserting a ref to another list element
|
||||||
|
let oldPtr = EnsureCapacity(mSize + 1, false);
|
||||||
|
Emit_Set("", "mSize", "item");
|
||||||
|
mSize++;
|
||||||
|
Free(oldPtr);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Emit_Set("", "mSize", "item");
|
||||||
|
mSize++;
|
||||||
|
#if VERSION_LIST
|
||||||
|
mVersion++;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void GCMarkMembers()
|
||||||
|
{
|
||||||
|
[Comptime]
|
||||||
|
void Emit()
|
||||||
|
{
|
||||||
|
String code = scope .();
|
||||||
|
var fields = GetFields(.. scope .());
|
||||||
|
for (var field in fields)
|
||||||
|
{
|
||||||
|
if (!field.FieldType.WantsMark)
|
||||||
|
continue;
|
||||||
|
code.AppendF($"for (int i < mSize) {{ GC.Mark!((({field.FieldType}*)((uint8*)mItems");
|
||||||
|
if (@field.Index > 0)
|
||||||
|
code.AppendF($" + mOffsets[{@field.Index - 1}]");
|
||||||
|
code.Append("))[i]); }\n");
|
||||||
|
}
|
||||||
|
Compiler.MixinRoot(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mItems == null)
|
||||||
|
return;
|
||||||
|
let type = typeof(T);
|
||||||
|
if ((type.[Friend]mTypeFlags & .WantsMark) == 0)
|
||||||
|
return;
|
||||||
|
Emit();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Clear()
|
||||||
|
{
|
||||||
|
if (mSize > 0)
|
||||||
|
{
|
||||||
|
mSize = 0;
|
||||||
|
#if VERSION_LIST
|
||||||
|
mVersion++;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Contains(T item)
|
||||||
|
{
|
||||||
|
for (int i < mSize)
|
||||||
|
if (this[i].Value == item)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CopyTo(Span<T> span)
|
||||||
|
{
|
||||||
|
for (int i < span.Length)
|
||||||
|
span[i] = this[i].Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Remove(T item)
|
||||||
|
{
|
||||||
|
int index = IndexOf(item);
|
||||||
|
if (index >= 0)
|
||||||
|
{
|
||||||
|
RemoveAt(index);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemoveAt(int index)
|
||||||
|
{
|
||||||
|
Debug.Assert((uint)index < (uint)mSize);
|
||||||
|
if (index < mSize - 1)
|
||||||
|
{
|
||||||
|
int copySize = mSize - index - 1;
|
||||||
|
(void)copySize;
|
||||||
|
Emit_Copy("index", "(index + 1)", "copySize");
|
||||||
|
}
|
||||||
|
mSize--;
|
||||||
|
#if VERSION_LIST
|
||||||
|
mVersion++;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemoveRange(int index, int count)
|
||||||
|
{
|
||||||
|
Debug.Assert((uint)index + (uint)count <= (uint)mSize);
|
||||||
|
if (index + count <= mSize - 1)
|
||||||
|
{
|
||||||
|
for (int i = index; i < mSize - count; i++)
|
||||||
|
mItems[i] = mItems[i + count];
|
||||||
|
}
|
||||||
|
mSize -= (.)count;
|
||||||
|
#if VERSION_LIST
|
||||||
|
mVersion++;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Will change the order of items in the list
|
||||||
|
public void RemoveAtFast(int index)
|
||||||
|
{
|
||||||
|
Debug.Assert((uint32)index < (uint32)mSize);
|
||||||
|
if (mSize > 1)
|
||||||
|
this[index].Value = this[mSize - 1].Value;
|
||||||
|
mSize--;
|
||||||
|
#if VERSION_LIST
|
||||||
|
mVersion++;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
Variant IList.this[int index]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return [Unbound]Variant.Create(this[index]);
|
||||||
|
}
|
||||||
|
|
||||||
|
set
|
||||||
|
{
|
||||||
|
ThrowUnimplemented();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Enumerator GetEnumerator()
|
||||||
|
{
|
||||||
|
return .(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int FindIndex(Predicate<T> match)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < mSize; i++)
|
||||||
|
if (match(this[i].Value))
|
||||||
|
return i;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int IndexOf(T item)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < mSize; i++)
|
||||||
|
if (this[i].Value == item)
|
||||||
|
return i;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int IndexOf(T item, int index)
|
||||||
|
{
|
||||||
|
for (int i = index; i < mSize; i++)
|
||||||
|
if (this[i].Value == item)
|
||||||
|
return i;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int IndexOf(T item, int index, int count)
|
||||||
|
{
|
||||||
|
for (int i = index; i < index + count; i++)
|
||||||
|
if (this[i].Value == item)
|
||||||
|
return i;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int IndexOfStrict(T item)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < mSize; i++)
|
||||||
|
if (this[i].Value === item)
|
||||||
|
return i;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int IndexOfStrict(T item, int index)
|
||||||
|
{
|
||||||
|
for (int i = index; i < mSize; i++)
|
||||||
|
if (this[i].Value === item)
|
||||||
|
return i;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int IndexOfStrict(T item, int index, int count)
|
||||||
|
{
|
||||||
|
for (int i = index; i < index + count; i++)
|
||||||
|
if (this[i].Value === item)
|
||||||
|
return i;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int IndexOfAlt<TAlt>(TAlt item) where TAlt : IHashable where bool : operator T == TAlt
|
||||||
|
{
|
||||||
|
for (int i = 0; i < mSize; i++)
|
||||||
|
if (this[i].Value == item)
|
||||||
|
return i;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int LastIndexOf(T item)
|
||||||
|
{
|
||||||
|
for (int i = mSize - 1; i >= 0; i--)
|
||||||
|
if (this[i].Value == item)
|
||||||
|
return i;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int LastIndexOfStrict(T item)
|
||||||
|
{
|
||||||
|
for (int i = mSize - 1; i >= 0; i--)
|
||||||
|
if (this[i].Value === item)
|
||||||
|
return i;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public struct Enumerator : IEnumerator<Entry>, IResettable
|
||||||
|
{
|
||||||
|
private SplitList<T> mList;
|
||||||
|
private int mIndex;
|
||||||
|
#if VERSION_LIST
|
||||||
|
private int32 mVersion;
|
||||||
|
#endif
|
||||||
|
public this(SplitList<T> list)
|
||||||
|
{
|
||||||
|
mList = list;
|
||||||
|
mIndex = 0;
|
||||||
|
#if VERSION_LIST
|
||||||
|
mVersion = list.mVersion;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#if VERSION_LIST
|
||||||
|
void CheckVersion()
|
||||||
|
{
|
||||||
|
if (mVersion != mList.mVersion)
|
||||||
|
Runtime.FatalError(cVersionError);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool MoveNext() mut
|
||||||
|
{
|
||||||
|
var localList = mList;
|
||||||
|
if ((uint(mIndex) < uint(localList.mSize)))
|
||||||
|
{
|
||||||
|
mIndex++;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return MoveNextRare();
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool MoveNextRare() mut
|
||||||
|
{
|
||||||
|
#if VERSION_LIST
|
||||||
|
CheckVersion();
|
||||||
|
#endif
|
||||||
|
mIndex = mList.mSize + 1;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Entry Current
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return mList[mIndex - 1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Index
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return mIndex - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Count
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return mList.Count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Remove() mut
|
||||||
|
{
|
||||||
|
int curIdx = mIndex - 1;
|
||||||
|
mList.RemoveAt(curIdx);
|
||||||
|
#if VERSION_LIST
|
||||||
|
mVersion = mList.mVersion;
|
||||||
|
#endif
|
||||||
|
mIndex = curIdx;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemoveFast() mut
|
||||||
|
{
|
||||||
|
int curIdx = mIndex - 1;
|
||||||
|
int lastIdx = mList.Count - 1;
|
||||||
|
if (curIdx < lastIdx)
|
||||||
|
mList[curIdx].Value = mList[lastIdx].Value;
|
||||||
|
mList.RemoveAt(lastIdx);
|
||||||
|
#if VERSION_LIST
|
||||||
|
mVersion = mList.mVersion;
|
||||||
|
#endif
|
||||||
|
mIndex = curIdx;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Reset() mut
|
||||||
|
{
|
||||||
|
mIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Result<Entry> GetNext() mut
|
||||||
|
{
|
||||||
|
if (!MoveNext())
|
||||||
|
return .Err;
|
||||||
|
return Current;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -259,6 +259,9 @@ namespace System
|
||||||
[LinkName("#CallerExpression")]
|
[LinkName("#CallerExpression")]
|
||||||
public static extern String[0x00FFFFFF] CallerExpression;
|
public static extern String[0x00FFFFFF] CallerExpression;
|
||||||
|
|
||||||
|
[LinkName("#OrigCalleeType")]
|
||||||
|
public static extern Type OrigCalleeType;
|
||||||
|
|
||||||
[LinkName("#ProjectName")]
|
[LinkName("#ProjectName")]
|
||||||
public static extern String ProjectName;
|
public static extern String ProjectName;
|
||||||
|
|
||||||
|
@ -280,6 +283,9 @@ namespace System
|
||||||
[LinkName("#CompileRev")]
|
[LinkName("#CompileRev")]
|
||||||
public static extern int32 CompileRev;
|
public static extern int32 CompileRev;
|
||||||
|
|
||||||
|
[LinkName("#NextId")]
|
||||||
|
public static extern int64 NextId;
|
||||||
|
|
||||||
[Comptime(ConstEval=true)]
|
[Comptime(ConstEval=true)]
|
||||||
public static void Assert(bool cond)
|
public static void Assert(bool cond)
|
||||||
{
|
{
|
||||||
|
@ -287,6 +293,7 @@ namespace System
|
||||||
Runtime.FatalError("Assert failed");
|
Runtime.FatalError("Assert failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static extern void Comptime_SetReturnType(int32 typeId);
|
||||||
static extern void* Comptime_MethodBuilder_EmitStr(void* native, StringView str);
|
static extern void* Comptime_MethodBuilder_EmitStr(void* native, StringView str);
|
||||||
static extern void* Comptime_CreateMethod(int32 typeId, StringView methodName, Type returnType, MethodFlags methodFlags);
|
static extern void* Comptime_CreateMethod(int32 typeId, StringView methodName, Type returnType, MethodFlags methodFlags);
|
||||||
static extern void Comptime_EmitTypeBody(int32 typeId, StringView text);
|
static extern void Comptime_EmitTypeBody(int32 typeId, StringView text);
|
||||||
|
@ -309,6 +316,12 @@ namespace System
|
||||||
Comptime_EmitTypeBody((.)owner.TypeId, text);
|
Comptime_EmitTypeBody((.)owner.TypeId, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Comptime(OnlyFromComptime=true)]
|
||||||
|
public static void SetReturnType(Type type)
|
||||||
|
{
|
||||||
|
Comptime_SetReturnType((.)type.TypeId);
|
||||||
|
}
|
||||||
|
|
||||||
[Comptime(OnlyFromComptime=true)]
|
[Comptime(OnlyFromComptime=true)]
|
||||||
public static void EmitAddInterface(Type owner, Type iface)
|
public static void EmitAddInterface(Type owner, Type iface)
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,6 +5,62 @@ namespace System
|
||||||
{
|
{
|
||||||
struct Enum
|
struct Enum
|
||||||
{
|
{
|
||||||
|
[NoShow(true)]
|
||||||
|
[Comptime(ConstEval=true)]
|
||||||
|
public static int GetCount<T>() where T : Enum
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
for (var field in typeof(T).GetFields())
|
||||||
|
{
|
||||||
|
if (field.IsEnumCase)
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
[NoShow(true)]
|
||||||
|
[Comptime(ConstEval=true)]
|
||||||
|
public static var GetMinValue<T>() where T : Enum
|
||||||
|
{
|
||||||
|
Compiler.SetReturnType(typeof(T));
|
||||||
|
|
||||||
|
int? minValue = null;
|
||||||
|
for (var field in typeof(T).GetFields())
|
||||||
|
{
|
||||||
|
if (field.IsEnumCase)
|
||||||
|
{
|
||||||
|
if (minValue == null)
|
||||||
|
minValue = field.[Friend]mFieldData.mData;
|
||||||
|
else
|
||||||
|
minValue = Math.Min(minValue.Value, field.[Friend]mFieldData.mData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return minValue.ValueOrDefault;
|
||||||
|
}
|
||||||
|
|
||||||
|
[NoShow(true)]
|
||||||
|
[Comptime(ConstEval=true)]
|
||||||
|
public static var GetMaxValue<T>() where T : Enum
|
||||||
|
{
|
||||||
|
Compiler.SetReturnType(typeof(T));
|
||||||
|
|
||||||
|
int? maxValue = null;
|
||||||
|
for (var field in typeof(T).GetFields())
|
||||||
|
{
|
||||||
|
if (field.IsEnumCase)
|
||||||
|
{
|
||||||
|
if (maxValue == null)
|
||||||
|
maxValue = field.[Friend]mFieldData.mData;
|
||||||
|
else
|
||||||
|
maxValue = Math.Max(maxValue.Value, field.[Friend]mFieldData.mData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (maxValue == null)
|
||||||
|
return -1;
|
||||||
|
return maxValue.ValueOrDefault;
|
||||||
|
}
|
||||||
|
|
||||||
|
[NoShow(true)]
|
||||||
public static void EnumToString(Type type, String strBuffer, int64 iVal)
|
public static void EnumToString(Type type, String strBuffer, int64 iVal)
|
||||||
{
|
{
|
||||||
for (var field in type.GetFields())
|
for (var field in type.GetFields())
|
||||||
|
@ -19,6 +75,7 @@ namespace System
|
||||||
iVal.ToString(strBuffer);
|
iVal.ToString(strBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[NoShow(true)]
|
||||||
public static Result<T> Parse<T>(StringView str, bool ignoreCase = false) where T : enum
|
public static Result<T> Parse<T>(StringView str, bool ignoreCase = false) where T : enum
|
||||||
{
|
{
|
||||||
for (var (name, data) in GetEnumerator<T>())
|
for (var (name, data) in GetEnumerator<T>())
|
||||||
|
@ -32,7 +89,8 @@ namespace System
|
||||||
return .Err;
|
return .Err;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool IsDefined<T>(T value)
|
[NoShow(true)]
|
||||||
|
public static bool IsDefined<T>(T value) where T : Enum
|
||||||
where T : enum
|
where T : enum
|
||||||
{
|
{
|
||||||
for (var data in GetValues<T>())
|
for (var data in GetValues<T>())
|
||||||
|
@ -44,24 +102,28 @@ namespace System
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[NoShow(true)]
|
||||||
public static EnumEnumerator<TEnum> GetEnumerator<TEnum>()
|
public static EnumEnumerator<TEnum> GetEnumerator<TEnum>()
|
||||||
where TEnum : enum
|
where TEnum : enum
|
||||||
{
|
{
|
||||||
return .();
|
return .();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[NoShow(true)]
|
||||||
public static EnumValuesEnumerator<TEnum> GetValues<TEnum>()
|
public static EnumValuesEnumerator<TEnum> GetValues<TEnum>()
|
||||||
where TEnum : enum
|
where TEnum : enum
|
||||||
{
|
{
|
||||||
return .();
|
return .();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[NoShow(true)]
|
||||||
public static EnumNamesEnumerator<TEnum> GetNames<TEnum>()
|
public static EnumNamesEnumerator<TEnum> GetNames<TEnum>()
|
||||||
where TEnum : enum
|
where TEnum : enum
|
||||||
{
|
{
|
||||||
return .();
|
return .();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[NoShow(true)]
|
||||||
private struct EnumFieldsEnumerator<TEnum>
|
private struct EnumFieldsEnumerator<TEnum>
|
||||||
where TEnum : enum
|
where TEnum : enum
|
||||||
{
|
{
|
||||||
|
@ -127,6 +189,7 @@ namespace System
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[NoShow(true)]
|
||||||
public struct EnumEnumerator<TEnum> : EnumFieldsEnumerator<TEnum>, IEnumerator<(StringView name, TEnum value)>
|
public struct EnumEnumerator<TEnum> : EnumFieldsEnumerator<TEnum>, IEnumerator<(StringView name, TEnum value)>
|
||||||
where TEnum : enum
|
where TEnum : enum
|
||||||
{
|
{
|
||||||
|
@ -146,6 +209,7 @@ namespace System
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[NoShow(true)]
|
||||||
public struct EnumValuesEnumerator<TEnum> : EnumFieldsEnumerator<TEnum>, IEnumerator<TEnum>
|
public struct EnumValuesEnumerator<TEnum> : EnumFieldsEnumerator<TEnum>, IEnumerator<TEnum>
|
||||||
where TEnum : enum
|
where TEnum : enum
|
||||||
{
|
{
|
||||||
|
@ -165,6 +229,7 @@ namespace System
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[NoShow(true)]
|
||||||
public struct EnumNamesEnumerator<TEnum> : EnumFieldsEnumerator<TEnum>, IEnumerator<StringView>
|
public struct EnumNamesEnumerator<TEnum> : EnumFieldsEnumerator<TEnum>, IEnumerator<StringView>
|
||||||
where TEnum : enum
|
where TEnum : enum
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,10 +13,17 @@ namespace System
|
||||||
// If we are enumerating then mData points to the enumerator.
|
// If we are enumerating then mData points to the enumerator.
|
||||||
int mData;
|
int mData;
|
||||||
|
|
||||||
|
#if BF_64_BIT
|
||||||
|
const int sIsEnumerating = (.)0x8000'0000'0000'0000;
|
||||||
|
const int sHadEnumRemoves = 0x4000'0000'0000'0000;
|
||||||
|
const int sFlagsMask = (.)0xC000'0000'0000'0000;
|
||||||
|
const int sDataMask = ~sFlagsMask;
|
||||||
|
#else
|
||||||
const int sIsEnumerating = 1;
|
const int sIsEnumerating = 1;
|
||||||
const int sHadEnumRemoves = 2;
|
const int sHadEnumRemoves = 2;
|
||||||
const int sFlagsMask = 3;
|
const int sFlagsMask = 3;
|
||||||
const int sDataMask = ~sFlagsMask;
|
const int sDataMask = ~sFlagsMask;
|
||||||
|
#endif
|
||||||
|
|
||||||
public bool HasListeners
|
public bool HasListeners
|
||||||
{
|
{
|
||||||
|
|
|
@ -149,6 +149,22 @@ namespace System
|
||||||
public static void ExcludeThreadId(int thereadId) {}
|
public static void ExcludeThreadId(int thereadId) {}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
[DisableObjectAccessChecks]
|
||||||
|
static void MarkAppendedObject(Object obj)
|
||||||
|
{
|
||||||
|
#if BF_ENABLE_REALTIME_LEAK_CHECK
|
||||||
|
#if BF_ENABLE_OBJECT_DEBUG_FLAGS
|
||||||
|
ClassVData* maskedVData = (ClassVData*)(void*)(obj.[Friend]mClassVData & ~(int)0xFF);
|
||||||
|
if (maskedVData == null)
|
||||||
|
return;
|
||||||
|
#else
|
||||||
|
if (obj.[Friend]mClassVData == null)
|
||||||
|
return;
|
||||||
|
#endif
|
||||||
|
obj.[Friend]GCMarkMembers();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
static void MarkDerefedObject(Object* obj)
|
static void MarkDerefedObject(Object* obj)
|
||||||
{
|
{
|
||||||
#if BF_ENABLE_REALTIME_LEAK_CHECK
|
#if BF_ENABLE_REALTIME_LEAK_CHECK
|
||||||
|
|
|
@ -31,7 +31,7 @@ namespace System.IO
|
||||||
public static Result<void, FileError> ReadAll(StringView path, List<uint8> outData)
|
public static Result<void, FileError> ReadAll(StringView path, List<uint8> outData)
|
||||||
{
|
{
|
||||||
FileStream fs = scope FileStream();
|
FileStream fs = scope FileStream();
|
||||||
var result = fs.Open(path, .Open, .Read);
|
var result = fs.Open(path, .Open, .Read, .ReadWrite);
|
||||||
if (result case .Err(let err))
|
if (result case .Err(let err))
|
||||||
return .Err(.OpenError(err));
|
return .Err(.OpenError(err));
|
||||||
|
|
||||||
|
|
|
@ -110,7 +110,7 @@ namespace System.IO
|
||||||
Windows.SHCreateItemFromParsingName(mSelectedPath.ToScopedNativeWChar!(), null, Windows.COM_IShellItem.sIID, (void**)&folderShellItem);
|
Windows.SHCreateItemFromParsingName(mSelectedPath.ToScopedNativeWChar!(), null, Windows.COM_IShellItem.sIID, (void**)&folderShellItem);
|
||||||
if (folderShellItem != null)
|
if (folderShellItem != null)
|
||||||
{
|
{
|
||||||
fileDialog.VT.SetDefaultFolder(fileDialog, folderShellItem);
|
fileDialog.VT.SetFolder(fileDialog, folderShellItem);
|
||||||
folderShellItem.VT.Release(folderShellItem);
|
folderShellItem.VT.Release(folderShellItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,8 @@ namespace System.IO
|
||||||
{
|
{
|
||||||
class MemoryStream : Stream
|
class MemoryStream : Stream
|
||||||
{
|
{
|
||||||
List<uint8> mMemory ~ delete _;
|
bool mOwns;
|
||||||
|
List<uint8> mMemory ~ { if (mOwns) delete _; }
|
||||||
int mPosition = 0;
|
int mPosition = 0;
|
||||||
|
|
||||||
public override int64 Position
|
public override int64 Position
|
||||||
|
@ -46,14 +47,18 @@ namespace System.IO
|
||||||
|
|
||||||
public this()
|
public this()
|
||||||
{
|
{
|
||||||
|
mOwns = true;
|
||||||
mMemory = new List<uint8>();
|
mMemory = new List<uint8>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public this(List<uint8> memory)
|
public this(List<uint8> memory, bool owns = true)
|
||||||
{
|
{
|
||||||
|
mOwns = owns;
|
||||||
mMemory = memory;
|
mMemory = memory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<uint8> Memory => mMemory;
|
||||||
|
|
||||||
public override Result<int> TryRead(Span<uint8> data)
|
public override Result<int> TryRead(Span<uint8> data)
|
||||||
{
|
{
|
||||||
let count = data.Length;
|
let count = data.Length;
|
||||||
|
|
|
@ -6,7 +6,7 @@ namespace System
|
||||||
interface IRefCounted
|
interface IRefCounted
|
||||||
{
|
{
|
||||||
void AddRef();
|
void AddRef();
|
||||||
void ReleaseRef();
|
void Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
class RefCounted : IRefCounted
|
class RefCounted : IRefCounted
|
||||||
|
@ -63,5 +63,167 @@ namespace System
|
||||||
Debug.Assert(refCount >= 0);
|
Debug.Assert(refCount >= 0);
|
||||||
return refCount;
|
return refCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IRefCounted.Release()
|
||||||
|
{
|
||||||
|
ReleaseRef();
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Alloc
|
||||||
|
{
|
||||||
|
public void* Alloc(Type type, int size, int align)
|
||||||
|
{
|
||||||
|
int sizeAdd = size + Math.Max(align, sizeof(int));
|
||||||
|
|
||||||
|
void* data = Internal.Malloc(sizeAdd);
|
||||||
|
return (uint8*)data + sizeAdd;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class RefCounted<T> : IRefCounted where T : class, delete
|
||||||
|
{
|
||||||
|
public T mVal;
|
||||||
|
public int mRefCount = 1;
|
||||||
|
|
||||||
|
public int RefCount => mRefCount;
|
||||||
|
public T Value => mVal;
|
||||||
|
|
||||||
|
protected this()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ~this()
|
||||||
|
{
|
||||||
|
Debug.Assert(mRefCount == 0);
|
||||||
|
delete mVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
[OnCompile(.TypeInit), Comptime]
|
||||||
|
static void Init()
|
||||||
|
{
|
||||||
|
String emitStr = scope .();
|
||||||
|
|
||||||
|
for (var methodInfo in typeof(T).GetMethods(.Public))
|
||||||
|
{
|
||||||
|
if (methodInfo.IsStatic)
|
||||||
|
continue;
|
||||||
|
if (!methodInfo.IsConstructor)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
emitStr.AppendF("public static RefCounted<T> Create(");
|
||||||
|
methodInfo.GetParamsDecl(emitStr);
|
||||||
|
emitStr.AppendF(")\n");
|
||||||
|
emitStr.AppendF("{{\n");
|
||||||
|
emitStr.AppendF("\treturn new [Friend] RefCountedAppend<T>(");
|
||||||
|
methodInfo.GetArgsList(emitStr);
|
||||||
|
emitStr.AppendF(");\n}}\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
Compiler.EmitTypeBody(typeof(Self), emitStr);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static RefCounted<T> Attach(T val)
|
||||||
|
{
|
||||||
|
return new Self() { mVal = val };
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void DeleteSelf()
|
||||||
|
{
|
||||||
|
delete this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DeleteUnchecked()
|
||||||
|
{
|
||||||
|
mRefCount = 0;
|
||||||
|
DeleteSelf();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddRef()
|
||||||
|
{
|
||||||
|
Interlocked.Increment(ref mRefCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Release()
|
||||||
|
{
|
||||||
|
int refCount = Interlocked.Decrement(ref mRefCount);
|
||||||
|
Debug.Assert(refCount >= 0);
|
||||||
|
if (refCount == 0)
|
||||||
|
DeleteSelf();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ReleaseLastRef()
|
||||||
|
{
|
||||||
|
int refCount = Interlocked.Decrement(ref mRefCount);
|
||||||
|
Debug.Assert(refCount == 0);
|
||||||
|
if (refCount == 0)
|
||||||
|
DeleteSelf();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int ReleaseRefNoDelete()
|
||||||
|
{
|
||||||
|
int refCount = Interlocked.Decrement(ref mRefCount);
|
||||||
|
Debug.Assert(refCount >= 0);
|
||||||
|
return refCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual T Detach()
|
||||||
|
{
|
||||||
|
var val = mVal;
|
||||||
|
mVal = null;
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static T operator->(Self self)
|
||||||
|
{
|
||||||
|
return self.mVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static T operator implicit(Self self)
|
||||||
|
{
|
||||||
|
return self.mVal;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class RefCountedAppend<T> : RefCounted<T> where T : class, new, delete
|
||||||
|
{
|
||||||
|
protected ~this()
|
||||||
|
{
|
||||||
|
Debug.Assert(mRefCount == 0);
|
||||||
|
delete:append mVal;
|
||||||
|
mVal = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
[OnCompile(.TypeInit), Comptime]
|
||||||
|
static void Init()
|
||||||
|
{
|
||||||
|
String emitStr = scope .();
|
||||||
|
|
||||||
|
for (var methodInfo in typeof(T).GetMethods(.Public))
|
||||||
|
{
|
||||||
|
if (methodInfo.IsStatic)
|
||||||
|
continue;
|
||||||
|
if (!methodInfo.IsConstructor)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
emitStr.AppendF("[AllowAppend]\nprotected this(");
|
||||||
|
methodInfo.GetParamsDecl(emitStr);
|
||||||
|
emitStr.AppendF(")\n");
|
||||||
|
emitStr.AppendF("{{\n");
|
||||||
|
emitStr.AppendF("\tvar val = append T(");
|
||||||
|
methodInfo.GetArgsList(emitStr);
|
||||||
|
emitStr.AppendF(");\n");
|
||||||
|
emitStr.AppendF("\tmVal = val;\n");
|
||||||
|
emitStr.AppendF("}}\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
Compiler.EmitTypeBody(typeof(Self), emitStr);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override T Detach()
|
||||||
|
{
|
||||||
|
Runtime.FatalError("Can only detach from objects created via RefCounted<T>.Attach");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,11 +72,6 @@ namespace System
|
||||||
return &mVAList;
|
return &mVAList;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public void* ToVAListPtr() mut
|
|
||||||
{
|
|
||||||
return &mVAList;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[AlwaysInclude]
|
[AlwaysInclude]
|
||||||
|
@ -89,6 +84,8 @@ namespace System
|
||||||
[CallingConvention(.Cdecl), NoReturn]
|
[CallingConvention(.Cdecl), NoReturn]
|
||||||
public static extern void ThrowIndexOutOfRange(int stackOffset = 0);
|
public static extern void ThrowIndexOutOfRange(int stackOffset = 0);
|
||||||
[CallingConvention(.Cdecl), NoReturn]
|
[CallingConvention(.Cdecl), NoReturn]
|
||||||
|
public static extern void ThrowObjectNotInitialized(int stackOffset = 0);
|
||||||
|
[CallingConvention(.Cdecl), NoReturn]
|
||||||
public static extern void FatalError(String error, int stackOffset = 0);
|
public static extern void FatalError(String error, int stackOffset = 0);
|
||||||
[Intrinsic("memcpy")]
|
[Intrinsic("memcpy")]
|
||||||
public static extern void MemCpy(void* dest, void* src, int length, int32 align = 1, bool isVolatile = false);
|
public static extern void MemCpy(void* dest, void* src, int length, int32 align = 1, bool isVolatile = false);
|
||||||
|
|
288
BeefLibs/corlib/src/Lazy.bf
Normal file
288
BeefLibs/corlib/src/Lazy.bf
Normal file
|
@ -0,0 +1,288 @@
|
||||||
|
using System.Threading;
|
||||||
|
|
||||||
|
namespace System
|
||||||
|
{
|
||||||
|
enum LazyThreadMode
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
Lock,
|
||||||
|
Lockless
|
||||||
|
}
|
||||||
|
|
||||||
|
class Lazy<T>
|
||||||
|
{
|
||||||
|
protected struct Entry
|
||||||
|
{
|
||||||
|
public SelfOuter mSingleton;
|
||||||
|
public T mValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Monitor mMonitor ~ delete _;
|
||||||
|
protected LazyThreadMode mThreadMode;
|
||||||
|
protected volatile int mInitId;
|
||||||
|
protected T mValue;
|
||||||
|
delegate T() mCreateDlg ~ delete _;
|
||||||
|
delegate void(T value) mReleaseDlg ~ delete _;
|
||||||
|
|
||||||
|
public this()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public this(LazyThreadMode threadMode)
|
||||||
|
{
|
||||||
|
mThreadMode = threadMode;
|
||||||
|
Init();
|
||||||
|
}
|
||||||
|
|
||||||
|
public this(LazyThreadMode threadMode, delegate T() createDlg = null, delegate void(T value) releaseDlg = null)
|
||||||
|
{
|
||||||
|
mThreadMode = threadMode;
|
||||||
|
mCreateDlg = createDlg;
|
||||||
|
mReleaseDlg = releaseDlg;
|
||||||
|
Init();
|
||||||
|
}
|
||||||
|
|
||||||
|
public this(delegate void(T value) releaseDlg) : this()
|
||||||
|
{
|
||||||
|
mReleaseDlg = releaseDlg;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Init()
|
||||||
|
{
|
||||||
|
switch (mThreadMode)
|
||||||
|
{
|
||||||
|
case .None:
|
||||||
|
case .Lock:
|
||||||
|
mMonitor = new Monitor();
|
||||||
|
case .Lockless:
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public ~this()
|
||||||
|
{
|
||||||
|
ReleaseValue(mut mValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected T DefaultCreateValue()
|
||||||
|
{
|
||||||
|
return default;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected T DefaultCreateValue() where T : struct, new
|
||||||
|
{
|
||||||
|
return T();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected T DefaultCreateValue() where T : class
|
||||||
|
{
|
||||||
|
Runtime.FatalError("No create delegate specified and no public default constructor is available");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected T DefaultCreateValue() where T : class, new
|
||||||
|
{
|
||||||
|
return new T();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual T CreateValue()
|
||||||
|
{
|
||||||
|
return DefaultCreateValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void DefaultReleaseValue(mut T val)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void DefaultReleaseValue(mut T val) where T : struct, IDisposable
|
||||||
|
{
|
||||||
|
val.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void DefaultReleaseValue(mut T val) where T : class
|
||||||
|
{
|
||||||
|
delete (Object)val;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void ReleaseValue(mut T val)
|
||||||
|
{
|
||||||
|
DefaultReleaseValue(mut val);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ref T Value
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (mInitId == -1)
|
||||||
|
return ref mValue;
|
||||||
|
|
||||||
|
switch (mThreadMode)
|
||||||
|
{
|
||||||
|
case .None:
|
||||||
|
mValue = CreateValue();
|
||||||
|
case .Lock:
|
||||||
|
using (mMonitor.Enter())
|
||||||
|
{
|
||||||
|
if (mInitId != -1)
|
||||||
|
{
|
||||||
|
mValue = CreateValue();
|
||||||
|
Interlocked.Fence();
|
||||||
|
mInitId = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case .Lockless:
|
||||||
|
int threadId = Thread.CurrentThreadId;
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
int initId = Interlocked.CompareExchange(ref mInitId, 0, threadId);
|
||||||
|
if (initId == -1)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (initId == 0)
|
||||||
|
{
|
||||||
|
Interlocked.Fence();
|
||||||
|
mValue = CreateValue();
|
||||||
|
Interlocked.Fence();
|
||||||
|
mInitId = -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ref mValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsValueCreated => mInitId != 0;
|
||||||
|
|
||||||
|
public static ref T operator->(Self self) => ref self.[Inline]Value;
|
||||||
|
|
||||||
|
public override void ToString(String strBuffer)
|
||||||
|
{
|
||||||
|
if (IsValueCreated)
|
||||||
|
strBuffer.AppendF($"Value: {Value}");
|
||||||
|
else
|
||||||
|
strBuffer.AppendF($"No Value");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class LazyTLS<T>
|
||||||
|
{
|
||||||
|
protected struct Entry
|
||||||
|
{
|
||||||
|
public SelfOuter mSingleton;
|
||||||
|
public T mValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
void* mData;
|
||||||
|
delegate T() mCreateDlg ~ delete _;
|
||||||
|
delegate void(T value) mReleaseDlg ~ delete _;
|
||||||
|
|
||||||
|
public this()
|
||||||
|
{
|
||||||
|
InitTLS();
|
||||||
|
}
|
||||||
|
|
||||||
|
public this(delegate T() createDlg = null, delegate void(T value) releaseDlg = null)
|
||||||
|
{
|
||||||
|
mCreateDlg = createDlg;
|
||||||
|
mReleaseDlg = releaseDlg;
|
||||||
|
InitTLS();
|
||||||
|
}
|
||||||
|
|
||||||
|
void InitTLS()
|
||||||
|
{
|
||||||
|
mData = Platform.BfpTLS_Create((ptr) =>
|
||||||
|
{
|
||||||
|
var entry = (Entry*)ptr;
|
||||||
|
if (entry.mSingleton.mReleaseDlg != null)
|
||||||
|
entry.mSingleton.mReleaseDlg(entry.mValue);
|
||||||
|
else
|
||||||
|
entry.mSingleton.ReleaseValue(mut entry.mValue);
|
||||||
|
delete entry;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public ~this()
|
||||||
|
{
|
||||||
|
Platform.BfpTLS_Release((.)mData);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected T DefaultCreateValue()
|
||||||
|
{
|
||||||
|
return default;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected T DefaultCreateValue() where T : struct, new
|
||||||
|
{
|
||||||
|
return T();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected T DefaultCreateValue() where T : class
|
||||||
|
{
|
||||||
|
Runtime.FatalError("No create delegate specified and no public default constructor is available");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected T DefaultCreateValue() where T : class, new
|
||||||
|
{
|
||||||
|
return new T();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual T CreateValue()
|
||||||
|
{
|
||||||
|
return DefaultCreateValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void DefaultReleaseValue(mut T val)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void DefaultReleaseValue(mut T val) where T : struct, IDisposable
|
||||||
|
{
|
||||||
|
val.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected void DefaultReleaseValue(mut T val) where T : class
|
||||||
|
{
|
||||||
|
delete (Object)val;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void ReleaseValue(mut T val)
|
||||||
|
{
|
||||||
|
DefaultReleaseValue(mut val);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ref T Value
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
void* ptr = Platform.BfpTLS_GetValue((.)mData);
|
||||||
|
if (ptr != null)
|
||||||
|
return ref ((Entry*)ptr).mValue;
|
||||||
|
|
||||||
|
Entry* entry = new Entry();
|
||||||
|
entry.mSingleton = this;
|
||||||
|
if (mCreateDlg != null)
|
||||||
|
entry.mValue = mCreateDlg();
|
||||||
|
else
|
||||||
|
entry.mValue = CreateValue();
|
||||||
|
Platform.BfpTLS_SetValue((.)mData, entry);
|
||||||
|
return ref entry.mValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsValueCreated => Platform.BfpTLS_GetValue((.)mData) != null;
|
||||||
|
|
||||||
|
public static ref T operator->(Self self) => ref self.[Inline]Value;
|
||||||
|
|
||||||
|
public override void ToString(String strBuffer)
|
||||||
|
{
|
||||||
|
if (IsValueCreated)
|
||||||
|
strBuffer.AppendF($"Value: {Value}");
|
||||||
|
else
|
||||||
|
strBuffer.AppendF($"No Value");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -192,8 +192,18 @@ namespace System
|
||||||
|
|
||||||
[CLink]
|
[CLink]
|
||||||
private static extern double modf(double x, out double intpart);
|
private static extern double modf(double x, out double intpart);
|
||||||
|
|
||||||
|
#if BF_PLATFORM_WINDOWS && BF_64_BIT
|
||||||
[CLink]
|
[CLink]
|
||||||
private static extern float modff(float x, out float intpart);
|
private static extern float modff(float x, out float intpart);
|
||||||
|
#else
|
||||||
|
private static float modff(float x, out float intpart)
|
||||||
|
{
|
||||||
|
var f = modf(x, var i);
|
||||||
|
intpart = (.)i;
|
||||||
|
return (.)f;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
public static float Truncate(float f)
|
public static float Truncate(float f)
|
||||||
{
|
{
|
||||||
|
|
|
@ -35,6 +35,15 @@ namespace System
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public T ValueOrDefault
|
||||||
|
{
|
||||||
|
[Inline]
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return mValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public ref T ValueRef
|
public ref T ValueRef
|
||||||
{
|
{
|
||||||
[Inline]
|
[Inline]
|
||||||
|
@ -96,9 +105,19 @@ namespace System
|
||||||
[Inline]
|
[Inline]
|
||||||
public static explicit operator T(Nullable<T> value)
|
public static explicit operator T(Nullable<T> value)
|
||||||
{
|
{
|
||||||
|
if (!value.mHasValue)
|
||||||
|
Debug.FatalError("Value requested for null nullable.");
|
||||||
return value.mValue;
|
return value.mValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Inline]
|
||||||
|
public static ref T operator->(ref Nullable<T> value)
|
||||||
|
{
|
||||||
|
if (!value.mHasValue)
|
||||||
|
Debug.FatalError("Value requested for null nullable.");
|
||||||
|
return ref value.mValue;
|
||||||
|
}
|
||||||
|
|
||||||
[Inline, Commutable]
|
[Inline, Commutable]
|
||||||
public static bool operator==(Nullable<T> lhs, T rhs)
|
public static bool operator==(Nullable<T> lhs, T rhs)
|
||||||
{
|
{
|
||||||
|
@ -401,31 +420,6 @@ namespace System
|
||||||
return Nullable<TResult>(lhs.mValue | rhs.mValue);
|
return Nullable<TResult>(lhs.mValue | rhs.mValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
|
|
||||||
public static T operator??(Nullable<T> lhs, T rhs)
|
|
||||||
{
|
|
||||||
return (lhs.mHasValue) ? lhs.mValue : rhs;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static TResult? operator??<TOther, TResult>(TOther lhs, Nullable<T> rhs) where TResult : operator TOther ?? T where TResult : struct
|
|
||||||
{
|
|
||||||
if (!rhs.mHasValue) return null;
|
|
||||||
return Nullable<TResult>(lhs ?? rhs.mValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static TResult? operator??<TOther, TResult>(Nullable<T> lhs, TOther rhs) where TResult : operator T ?? TOther where TResult : struct
|
|
||||||
{
|
|
||||||
if (!lhs.mHasValue) return null;
|
|
||||||
return Nullable<TResult>(lhs.mValue ?? rhs);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static TResult? operator??<TOther, TResult>(Nullable<T> lhs, Nullable<TOther> rhs) where TOther : struct where TResult : operator T ?? TOther where TResult : struct
|
|
||||||
{
|
|
||||||
if ((!lhs.mHasValue) || (!rhs.mHasValue)) return null;
|
|
||||||
return Nullable<TResult>(lhs.mValue ?? rhs.mValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
public static TResult? operator<< <TOther, TResult>(TOther lhs, Nullable<T> rhs) where TResult : operator TOther << T where TResult : struct
|
public static TResult? operator<< <TOther, TResult>(TOther lhs, Nullable<T> rhs) where TResult : operator TOther << T where TResult : struct
|
||||||
|
|
|
@ -42,6 +42,7 @@ namespace System
|
||||||
public struct BfpEvent {};
|
public struct BfpEvent {};
|
||||||
public struct BfpFileWatcher {}
|
public struct BfpFileWatcher {}
|
||||||
public struct BfpProcess {}
|
public struct BfpProcess {}
|
||||||
|
public struct BfpTLS;
|
||||||
|
|
||||||
public enum BfpSystemResult : int32
|
public enum BfpSystemResult : int32
|
||||||
{
|
{
|
||||||
|
@ -95,6 +96,18 @@ namespace System
|
||||||
[CallingConvention(.Stdcall), CLink]
|
[CallingConvention(.Stdcall), CLink]
|
||||||
public static extern void BfpSystem_GetComputerName(char8* outStr, int32* inOutStrSize, BfpSystemResult* outResult);
|
public static extern void BfpSystem_GetComputerName(char8* outStr, int32* inOutStrSize, BfpSystemResult* outResult);
|
||||||
|
|
||||||
|
[CallingConvention(.Stdcall), CLink]
|
||||||
|
public static extern int BfpThread_GetCurrentId();
|
||||||
|
|
||||||
|
[CallingConvention(.Stdcall), CLink]
|
||||||
|
public static extern BfpTLS* BfpTLS_Create(function [CallingConvention(.Stdcall)] void(void*) exitProc);
|
||||||
|
[CallingConvention(.Stdcall), CLink]
|
||||||
|
public static extern void BfpTLS_Release(BfpTLS* tls);
|
||||||
|
[CallingConvention(.Stdcall), CLink]
|
||||||
|
public static extern void BfpTLS_SetValue(BfpTLS* tls, void* value);
|
||||||
|
[CallingConvention(.Stdcall), CLink]
|
||||||
|
public static extern void* BfpTLS_GetValue(BfpTLS* tls);
|
||||||
|
|
||||||
public enum BfpFileWatcherFlags : int32
|
public enum BfpFileWatcherFlags : int32
|
||||||
{
|
{
|
||||||
None = 0,
|
None = 0,
|
||||||
|
|
|
@ -225,6 +225,187 @@ namespace System
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct Range<T> where T : operator T + int where int : operator T - T where bool : operator T >= T
|
||||||
|
{
|
||||||
|
protected T mStart;
|
||||||
|
protected T mEnd;
|
||||||
|
|
||||||
|
public this()
|
||||||
|
{
|
||||||
|
mStart = default;
|
||||||
|
mEnd = default;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Inline]
|
||||||
|
public this(T start, T end)
|
||||||
|
{
|
||||||
|
Debug.Assert(end >= start);
|
||||||
|
mStart = start;
|
||||||
|
mEnd = end;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Length
|
||||||
|
{
|
||||||
|
[Inline]
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return mEnd - mStart;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Inline]
|
||||||
|
set mut
|
||||||
|
{
|
||||||
|
mEnd = mStart + value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public T Start
|
||||||
|
{
|
||||||
|
[Inline]
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return mStart;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Inline]
|
||||||
|
set mut
|
||||||
|
{
|
||||||
|
mStart = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public T End
|
||||||
|
{
|
||||||
|
[Inline]
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return mEnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
set mut
|
||||||
|
{
|
||||||
|
mEnd = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsEmpty
|
||||||
|
{
|
||||||
|
[Inline]
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return mEnd == mStart;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReverseEnumerator Reversed
|
||||||
|
{
|
||||||
|
[Inline]
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return ReverseEnumerator(mEnd + -1, mStart);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Contains(T idx)
|
||||||
|
{
|
||||||
|
return (idx >= mStart) && !(idx >= mEnd);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Contains(Range<T> val)
|
||||||
|
{
|
||||||
|
return (val.[Friend]mStart >= mStart) && (val.[Friend]mEnd <= mEnd);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Clear() mut
|
||||||
|
{
|
||||||
|
mStart = default;
|
||||||
|
mEnd = default;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Inline]
|
||||||
|
public Enumerator GetEnumerator()
|
||||||
|
{
|
||||||
|
return Enumerator(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void ToString(String strBuffer)
|
||||||
|
{
|
||||||
|
strBuffer.AppendF($"{mStart}..<{mEnd}");
|
||||||
|
}
|
||||||
|
|
||||||
|
public struct Enumerator : IEnumerator<T>
|
||||||
|
{
|
||||||
|
private T mEnd;
|
||||||
|
private T mIndex;
|
||||||
|
|
||||||
|
[Inline]
|
||||||
|
public this(Range<T> range)
|
||||||
|
{
|
||||||
|
mIndex = range.mStart + -1;
|
||||||
|
mEnd = range.mEnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public ref T Index
|
||||||
|
{
|
||||||
|
get mut
|
||||||
|
{
|
||||||
|
return ref mIndex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public T End => mEnd;
|
||||||
|
|
||||||
|
[Inline]
|
||||||
|
public Result<T> GetNext() mut
|
||||||
|
{
|
||||||
|
if (mIndex + 1 >= mEnd)
|
||||||
|
return .Err;
|
||||||
|
mIndex += 1;
|
||||||
|
return mIndex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public struct ReverseEnumerator : IEnumerator<T>
|
||||||
|
{
|
||||||
|
private T mEnd;
|
||||||
|
private T mIndex;
|
||||||
|
|
||||||
|
[Inline]
|
||||||
|
public this(T start, T end)
|
||||||
|
{
|
||||||
|
mIndex = start + 1;
|
||||||
|
mEnd = end;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public ref T Index
|
||||||
|
{
|
||||||
|
get mut
|
||||||
|
{
|
||||||
|
return ref mIndex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public T End => mEnd;
|
||||||
|
|
||||||
|
[Inline]
|
||||||
|
public Result<T> GetNext() mut
|
||||||
|
{
|
||||||
|
if (mIndex <= mEnd)
|
||||||
|
return .Err;
|
||||||
|
mIndex += -1;
|
||||||
|
return mIndex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct IndexRange : RangeExpression
|
struct IndexRange : RangeExpression
|
||||||
{
|
{
|
||||||
protected Index mStart;
|
protected Index mStart;
|
||||||
|
|
|
@ -8,7 +8,8 @@ namespace System.Reflection
|
||||||
public enum Error
|
public enum Error
|
||||||
{
|
{
|
||||||
InvalidTargetType,
|
InvalidTargetType,
|
||||||
InvalidValueType
|
InvalidValueType,
|
||||||
|
AppendedField
|
||||||
}
|
}
|
||||||
|
|
||||||
TypeInstance mTypeInstance;
|
TypeInstance mTypeInstance;
|
||||||
|
@ -24,6 +25,8 @@ namespace System.Reflection
|
||||||
public int32 MemberOffset => (int32)mFieldData.mData;
|
public int32 MemberOffset => (int32)mFieldData.mData;
|
||||||
public Type FieldType => Type.[Friend]GetType(mFieldData.mFieldTypeId);
|
public Type FieldType => Type.[Friend]GetType(mFieldData.mFieldTypeId);
|
||||||
public bool IsConst => mFieldData.mFlags.HasFlag(.Const);
|
public bool IsConst => mFieldData.mFlags.HasFlag(.Const);
|
||||||
|
public bool IsAppended => mFieldData.mFlags.HasFlag(.Appended);
|
||||||
|
public bool IsEnumCase => mFieldData.mFlags.HasFlag(.EnumCase);
|
||||||
public bool IsReadOnly => mFieldData.mFlags.HasFlag(.ReadOnly);
|
public bool IsReadOnly => mFieldData.mFlags.HasFlag(.ReadOnly);
|
||||||
public bool IsStatic => mFieldData.mFlags.HasFlag(.Static);
|
public bool IsStatic => mFieldData.mFlags.HasFlag(.Static);
|
||||||
public bool IsPublic => (mFieldData.mFlags & .FieldAccessMask) == .Public;
|
public bool IsPublic => (mFieldData.mFlags & .FieldAccessMask) == .Public;
|
||||||
|
@ -85,7 +88,12 @@ namespace System.Reflection
|
||||||
if (valueType == fieldType)
|
if (valueType == fieldType)
|
||||||
{
|
{
|
||||||
if (valueType.IsObject)
|
if (valueType.IsObject)
|
||||||
|
{
|
||||||
|
if (mFieldData.mFlags.HasFlag(.Appended))
|
||||||
|
return .Err(.AppendedField);
|
||||||
|
|
||||||
*((void**)dataAddr) = Internal.UnsafeCastToPtr(value);
|
*((void**)dataAddr) = Internal.UnsafeCastToPtr(value);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
Internal.MemCpy(dataAddr, valueDataAddr, fieldType.[Friend]mSize);
|
Internal.MemCpy(dataAddr, valueDataAddr, fieldType.[Friend]mSize);
|
||||||
}
|
}
|
||||||
|
@ -384,7 +392,10 @@ namespace System.Reflection
|
||||||
if (typeCode == TypeCode.Object)
|
if (typeCode == TypeCode.Object)
|
||||||
{
|
{
|
||||||
value.[Friend]mStructType = 0;
|
value.[Friend]mStructType = 0;
|
||||||
value.[Friend]mData = *(int*)targetDataAddr;
|
if (mFieldData.mFlags.HasFlag(.Appended))
|
||||||
|
value.[Friend]mData = (int)targetDataAddr;
|
||||||
|
else
|
||||||
|
value.[Friend]mData = *(int*)targetDataAddr;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -50,6 +50,9 @@ namespace System.Reflection
|
||||||
public bool IsReadOnly => Compiler.IsComptime ?
|
public bool IsReadOnly => Compiler.IsComptime ?
|
||||||
Type.[Friend]Comptime_Method_GetInfo(mData.mComptimeMethodInstance).mMethodFlags.HasFlag(.ReadOnly) :
|
Type.[Friend]Comptime_Method_GetInfo(mData.mComptimeMethodInstance).mMethodFlags.HasFlag(.ReadOnly) :
|
||||||
mData.mMethodData.[Friend]mFlags.HasFlag(.ReadOnly);
|
mData.mMethodData.[Friend]mFlags.HasFlag(.ReadOnly);
|
||||||
|
public bool IsStatic => Compiler.IsComptime ?
|
||||||
|
Type.[Friend]Comptime_Method_GetInfo(mData.mComptimeMethodInstance).mMethodFlags.HasFlag(.Static) :
|
||||||
|
mData.mMethodData.[Friend]mFlags.HasFlag(.Static);
|
||||||
|
|
||||||
public StringView Name => Compiler.IsComptime ?
|
public StringView Name => Compiler.IsComptime ?
|
||||||
Type.[Friend]Comptime_Method_GetName(mData.mComptimeMethodInstance) :
|
Type.[Friend]Comptime_Method_GetName(mData.mComptimeMethodInstance) :
|
||||||
|
@ -112,6 +115,19 @@ namespace System.Reflection
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TypeInstance.ParamFlags GetParamFlags(int paramIdx)
|
||||||
|
{
|
||||||
|
if (Compiler.IsComptime)
|
||||||
|
{
|
||||||
|
return Type.[Friend]Comptime_Method_GetParamInfo(mData.mComptimeMethodInstance, (.)paramIdx).mParamFlags;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.Assert((uint)paramIdx < (uint)mData.mMethodData.mParamCount);
|
||||||
|
return mData.mMethodData.mParamData[paramIdx].mParamFlags;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Result<T> GetParamCustomAttribute<T>(int paramIdx) where T : Attribute
|
public Result<T> GetParamCustomAttribute<T>(int paramIdx) where T : Attribute
|
||||||
{
|
{
|
||||||
if (Compiler.IsComptime)
|
if (Compiler.IsComptime)
|
||||||
|
@ -967,19 +983,60 @@ namespace System.Reflection
|
||||||
strBuffer.Append(' ');
|
strBuffer.Append(' ');
|
||||||
strBuffer.Append(mData.mMethodData.mName);
|
strBuffer.Append(mData.mMethodData.mName);
|
||||||
strBuffer.Append('(');
|
strBuffer.Append('(');
|
||||||
|
|
||||||
|
int useParamIdx = 0;
|
||||||
for (int paramIdx < mData.mMethodData.mParamCount)
|
for (int paramIdx < mData.mMethodData.mParamCount)
|
||||||
{
|
{
|
||||||
if (paramIdx > 0)
|
|
||||||
strBuffer.Append(", ");
|
|
||||||
let paramData = mData.mMethodData.mParamData[paramIdx];
|
let paramData = mData.mMethodData.mParamData[paramIdx];
|
||||||
let paramType = Type.[Friend]GetType(paramData.mType);
|
let paramType = Type.[Friend]GetType(paramData.mType);
|
||||||
|
if (paramData.mParamFlags.HasFlag(.Implicit))
|
||||||
|
continue;
|
||||||
|
if (useParamIdx > 0)
|
||||||
|
strBuffer.Append(", ");
|
||||||
paramType.ToString(strBuffer);
|
paramType.ToString(strBuffer);
|
||||||
strBuffer.Append(' ');
|
strBuffer.Append(' ');
|
||||||
strBuffer.Append(paramData.mName);
|
strBuffer.Append(paramData.mName);
|
||||||
|
useParamIdx++;
|
||||||
}
|
}
|
||||||
strBuffer.Append(')');
|
strBuffer.Append(')');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void GetParamsDecl(String strBuffer)
|
||||||
|
{
|
||||||
|
int useParamIdx = 0;
|
||||||
|
for (int paramIdx < ParamCount)
|
||||||
|
{
|
||||||
|
var flag = GetParamFlags(paramIdx);
|
||||||
|
if (flag.HasFlag(.Implicit))
|
||||||
|
continue;
|
||||||
|
if (useParamIdx > 0)
|
||||||
|
strBuffer.Append(", ");
|
||||||
|
if (flag.HasFlag(.Params))
|
||||||
|
strBuffer.Append("params ");
|
||||||
|
strBuffer.Append(GetParamType(paramIdx));
|
||||||
|
strBuffer.Append(" ");
|
||||||
|
strBuffer.Append(GetParamName(paramIdx));
|
||||||
|
useParamIdx++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void GetArgsList(String strBuffer)
|
||||||
|
{
|
||||||
|
int useParamIdx = 0;
|
||||||
|
for (int paramIdx < ParamCount)
|
||||||
|
{
|
||||||
|
var flag = GetParamFlags(paramIdx);
|
||||||
|
if (flag.HasFlag(.Implicit))
|
||||||
|
continue;
|
||||||
|
if (useParamIdx > 0)
|
||||||
|
strBuffer.Append(", ");
|
||||||
|
if (flag.HasFlag(.Params))
|
||||||
|
strBuffer.Append("params ");
|
||||||
|
strBuffer.Append(GetParamName(paramIdx));
|
||||||
|
useParamIdx++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public struct Enumerator : IEnumerator<MethodInfo>
|
public struct Enumerator : IEnumerator<MethodInfo>
|
||||||
{
|
{
|
||||||
BindingFlags mBindingFlags;
|
BindingFlags mBindingFlags;
|
||||||
|
|
|
@ -27,6 +27,22 @@ namespace System
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ref T ValueRef
|
||||||
|
{
|
||||||
|
[Inline]
|
||||||
|
get mut
|
||||||
|
{
|
||||||
|
switch (this)
|
||||||
|
{
|
||||||
|
case .Ok(var ref val): return ref val;
|
||||||
|
case .Err:
|
||||||
|
{
|
||||||
|
Internal.FatalError("Unhandled error in result", 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[Inline]
|
[Inline]
|
||||||
public static implicit operator Result<T>(T value)
|
public static implicit operator Result<T>(T value)
|
||||||
{
|
{
|
||||||
|
@ -39,6 +55,19 @@ namespace System
|
||||||
return result.Unwrap();
|
return result.Unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Inline]
|
||||||
|
public static mut T operator->(ref Result<T> result)
|
||||||
|
{
|
||||||
|
switch (result)
|
||||||
|
{
|
||||||
|
case .Ok(var mut val): return mut val;
|
||||||
|
case .Err:
|
||||||
|
{
|
||||||
|
Internal.FatalError("Unhandled error in result", 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[Inline]
|
[Inline]
|
||||||
public void IgnoreError()
|
public void IgnoreError()
|
||||||
{
|
{
|
||||||
|
@ -99,7 +128,7 @@ namespace System
|
||||||
|
|
||||||
extension Result<T> where T : IDisposable
|
extension Result<T> where T : IDisposable
|
||||||
{
|
{
|
||||||
public void Dispose()
|
public new void Dispose()
|
||||||
{
|
{
|
||||||
if (this case .Ok(var val))
|
if (this case .Ok(var val))
|
||||||
val.Dispose();
|
val.Dispose();
|
||||||
|
@ -116,9 +145,9 @@ namespace System
|
||||||
switch (this)
|
switch (this)
|
||||||
{
|
{
|
||||||
case .Ok(var val): return val;
|
case .Ok(var val): return val;
|
||||||
case .Err(var err):
|
case .Err:
|
||||||
{
|
{
|
||||||
Internal.FatalError(scope String()..AppendF("Unhandled error in result:\n {}", err), 2);
|
Internal.FatalError("Unhandled error in result", 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -131,16 +160,47 @@ namespace System
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ref T ValueRef
|
||||||
|
{
|
||||||
|
[Inline]
|
||||||
|
get mut
|
||||||
|
{
|
||||||
|
switch (this)
|
||||||
|
{
|
||||||
|
case .Ok(var ref val): return ref val;
|
||||||
|
case .Err:
|
||||||
|
{
|
||||||
|
Internal.FatalError("Unhandled error in result", 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Inline]
|
||||||
public static implicit operator Result<T, TErr>(T value)
|
public static implicit operator Result<T, TErr>(T value)
|
||||||
{
|
{
|
||||||
return .Ok(value);
|
return .Ok(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Inline]
|
||||||
public static implicit operator T(Result<T, TErr> result)
|
public static implicit operator T(Result<T, TErr> result)
|
||||||
{
|
{
|
||||||
return result.Unwrap();
|
return result.Unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Inline]
|
||||||
|
public static mut T operator->(ref Result<T, TErr> result)
|
||||||
|
{
|
||||||
|
switch (result)
|
||||||
|
{
|
||||||
|
case .Ok(var mut val): return mut val;
|
||||||
|
case .Err:
|
||||||
|
{
|
||||||
|
Internal.FatalError("Unhandled error in result", 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void IgnoreError()
|
public void IgnoreError()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -203,7 +263,7 @@ namespace System
|
||||||
|
|
||||||
extension Result<T, TErr> where T : IDisposable
|
extension Result<T, TErr> where T : IDisposable
|
||||||
{
|
{
|
||||||
public void Dispose()
|
public new void Dispose()
|
||||||
{
|
{
|
||||||
if (this case .Ok(var val))
|
if (this case .Ok(var val))
|
||||||
val.Dispose();
|
val.Dispose();
|
||||||
|
@ -212,7 +272,7 @@ namespace System
|
||||||
|
|
||||||
extension Result<T, TErr> where TErr : IDisposable
|
extension Result<T, TErr> where TErr : IDisposable
|
||||||
{
|
{
|
||||||
public void Dispose()
|
public new void Dispose()
|
||||||
{
|
{
|
||||||
if (this case .Err(var err))
|
if (this case .Err(var err))
|
||||||
err.Dispose();
|
err.Dispose();
|
||||||
|
@ -221,7 +281,7 @@ namespace System
|
||||||
|
|
||||||
extension Result<T, TErr> where T : IDisposable where TErr : IDisposable
|
extension Result<T, TErr> where T : IDisposable where TErr : IDisposable
|
||||||
{
|
{
|
||||||
public void Dispose()
|
public new void Dispose()
|
||||||
{
|
{
|
||||||
if (this case .Ok(var val))
|
if (this case .Ok(var val))
|
||||||
val.Dispose();
|
val.Dispose();
|
||||||
|
|
|
@ -9,7 +9,7 @@ namespace System
|
||||||
[StaticInitPriority(101)]
|
[StaticInitPriority(101)]
|
||||||
static class Runtime
|
static class Runtime
|
||||||
{
|
{
|
||||||
const int32 cVersion = 9;
|
const int32 cVersion = 10;
|
||||||
|
|
||||||
[CRepr, AlwaysInclude]
|
[CRepr, AlwaysInclude]
|
||||||
struct BfDebugMessageData
|
struct BfDebugMessageData
|
||||||
|
@ -118,6 +118,7 @@ namespace System
|
||||||
function bool (Object thread) mThread_IsAutoDelete;
|
function bool (Object thread) mThread_IsAutoDelete;
|
||||||
function void (Object thread) mThread_AutoDelete;
|
function void (Object thread) mThread_AutoDelete;
|
||||||
function int32 (Object thread) mThread_GetMaxStackSize;
|
function int32 (Object thread) mThread_GetMaxStackSize;
|
||||||
|
function void () mThread_Exiting;
|
||||||
function void () mGC_MarkAllStaticMembers;
|
function void () mGC_MarkAllStaticMembers;
|
||||||
function bool () mGC_CallRootCallbacks;
|
function bool () mGC_CallRootCallbacks;
|
||||||
function void () mGC_Shutdown;
|
function void () mGC_Shutdown;
|
||||||
|
@ -146,7 +147,7 @@ namespace System
|
||||||
static Type Object_GetType(Object obj)
|
static Type Object_GetType(Object obj)
|
||||||
{
|
{
|
||||||
#if BF_DBG_RUNTIME
|
#if BF_DBG_RUNTIME
|
||||||
return obj.[Friend]RawGetType();
|
return obj.[Friend, DisableObjectAccessChecks]RawGetType();
|
||||||
#else
|
#else
|
||||||
return null;
|
return null;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -276,6 +276,7 @@ namespace System
|
||||||
|
|
||||||
public void RemoveFromEnd(int length) mut
|
public void RemoveFromEnd(int length) mut
|
||||||
{
|
{
|
||||||
|
Debug.Assert((uint)length <= (uint)mLength);
|
||||||
mLength -= length;
|
mLength -= length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ namespace System
|
||||||
[Ordered]
|
[Ordered]
|
||||||
class String : IHashable, IFormattable, IPrintable
|
class String : IHashable, IFormattable, IPrintable
|
||||||
{
|
{
|
||||||
enum CreateFlags
|
public enum CreateFlags
|
||||||
{
|
{
|
||||||
None = 0,
|
None = 0,
|
||||||
NullTerminate = 1
|
NullTerminate = 1
|
||||||
|
@ -48,7 +48,7 @@ namespace System
|
||||||
|
|
||||||
int_strsize mLength;
|
int_strsize mLength;
|
||||||
uint_strsize mAllocSizeAndFlags;
|
uint_strsize mAllocSizeAndFlags;
|
||||||
char8* mPtr = null;
|
char8* mPtrOrBuffer = null;
|
||||||
|
|
||||||
extern const String* sStringLiterals;
|
extern const String* sStringLiterals;
|
||||||
extern const String* sIdStringLiterals;
|
extern const String* sIdStringLiterals;
|
||||||
|
@ -210,8 +210,8 @@ namespace System
|
||||||
[AllowAppend]
|
[AllowAppend]
|
||||||
public this(StringView strView)
|
public this(StringView strView)
|
||||||
{
|
{
|
||||||
let tryBufferSize = strView.Length - sizeof(char8*);
|
let count = strView.Length;
|
||||||
let bufferSize = (tryBufferSize >= 0) ? tryBufferSize : 0;
|
int bufferSize = (count == 0) ? 0 : (count - 1) & ~(sizeof(char8*) - 1);
|
||||||
#unwarn
|
#unwarn
|
||||||
char8* addlPtr = append char8[bufferSize]*(?);
|
char8* addlPtr = append char8[bufferSize]*(?);
|
||||||
Init(bufferSize);
|
Init(bufferSize);
|
||||||
|
@ -326,7 +326,7 @@ namespace System
|
||||||
public ~this()
|
public ~this()
|
||||||
{
|
{
|
||||||
if (IsDynAlloc)
|
if (IsDynAlloc)
|
||||||
delete:this mPtr;
|
delete:this mPtrOrBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FakeMethod ()
|
void FakeMethod ()
|
||||||
|
@ -390,7 +390,7 @@ namespace System
|
||||||
//[Optimize]
|
//[Optimize]
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return ((mAllocSizeAndFlags & cStrPtrFlag) != 0) ? mPtr : (char8*)&mPtr;
|
return ((mAllocSizeAndFlags & cStrPtrFlag) != 0) ? mPtrOrBuffer : (char8*)&mPtrOrBuffer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -660,10 +660,10 @@ namespace System
|
||||||
{
|
{
|
||||||
if (str.IsDynAlloc)
|
if (str.IsDynAlloc)
|
||||||
{
|
{
|
||||||
delete str.mPtr;
|
delete str.mPtrOrBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
str.mPtr = mPtr;
|
str.mPtrOrBuffer = mPtrOrBuffer;
|
||||||
str.mAllocSizeAndFlags = mAllocSizeAndFlags;
|
str.mAllocSizeAndFlags = mAllocSizeAndFlags;
|
||||||
str.mLength = mLength;
|
str.mLength = mLength;
|
||||||
|
|
||||||
|
@ -673,7 +673,7 @@ namespace System
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mPtr = null;
|
mPtrOrBuffer = null;
|
||||||
mAllocSizeAndFlags = (int_strsize)sizeof(char8*);
|
mAllocSizeAndFlags = (int_strsize)sizeof(char8*);
|
||||||
mLength = 0;
|
mLength = 0;
|
||||||
}
|
}
|
||||||
|
@ -689,8 +689,8 @@ namespace System
|
||||||
public void Reference(String str)
|
public void Reference(String str)
|
||||||
{
|
{
|
||||||
if (IsDynAlloc)
|
if (IsDynAlloc)
|
||||||
delete:this mPtr;
|
delete:this mPtrOrBuffer;
|
||||||
mPtr = str.Ptr;
|
mPtrOrBuffer = str.Ptr;
|
||||||
mLength = str.mLength;
|
mLength = str.mLength;
|
||||||
mAllocSizeAndFlags = cStrPtrFlag;
|
mAllocSizeAndFlags = cStrPtrFlag;
|
||||||
}
|
}
|
||||||
|
@ -698,8 +698,8 @@ namespace System
|
||||||
public void Reference(char8* ptr, int length, int allocSize)
|
public void Reference(char8* ptr, int length, int allocSize)
|
||||||
{
|
{
|
||||||
if (IsDynAlloc)
|
if (IsDynAlloc)
|
||||||
delete:this mPtr;
|
delete:this mPtrOrBuffer;
|
||||||
mPtr = ptr;
|
mPtrOrBuffer = ptr;
|
||||||
mLength = (int_strsize)length;
|
mLength = (int_strsize)length;
|
||||||
mAllocSizeAndFlags = cStrPtrFlag;
|
mAllocSizeAndFlags = cStrPtrFlag;
|
||||||
}
|
}
|
||||||
|
@ -707,8 +707,8 @@ namespace System
|
||||||
public void Reference(char8* ptr, int length)
|
public void Reference(char8* ptr, int length)
|
||||||
{
|
{
|
||||||
if (IsDynAlloc)
|
if (IsDynAlloc)
|
||||||
delete:this mPtr;
|
delete:this mPtrOrBuffer;
|
||||||
mPtr = ptr;
|
mPtrOrBuffer = ptr;
|
||||||
mLength = (int_strsize)length;
|
mLength = (int_strsize)length;
|
||||||
mAllocSizeAndFlags = cStrPtrFlag;
|
mAllocSizeAndFlags = cStrPtrFlag;
|
||||||
}
|
}
|
||||||
|
@ -721,8 +721,8 @@ namespace System
|
||||||
public void Reference(char8* ptr)
|
public void Reference(char8* ptr)
|
||||||
{
|
{
|
||||||
if (IsDynAlloc)
|
if (IsDynAlloc)
|
||||||
delete:this mPtr;
|
delete:this mPtrOrBuffer;
|
||||||
mPtr = ptr;
|
mPtrOrBuffer = ptr;
|
||||||
mLength = StrLen(ptr);
|
mLength = StrLen(ptr);
|
||||||
mAllocSizeAndFlags = cStrPtrFlag;
|
mAllocSizeAndFlags = cStrPtrFlag;
|
||||||
}
|
}
|
||||||
|
@ -734,7 +734,7 @@ namespace System
|
||||||
Debug.Assert(!IsDynAlloc);
|
Debug.Assert(!IsDynAlloc);
|
||||||
Debug.Assert(AllocSize == 0); // Assert is reference
|
Debug.Assert(AllocSize == 0); // Assert is reference
|
||||||
Debug.Assert((uint)mLength >= (uint)adjBytes);
|
Debug.Assert((uint)mLength >= (uint)adjBytes);
|
||||||
mPtr += adjBytes;
|
mPtrOrBuffer += adjBytes;
|
||||||
mLength -= (int_strsize)adjBytes;
|
mLength -= (int_strsize)adjBytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -763,8 +763,8 @@ namespace System
|
||||||
Internal.MemSet(newPtr + mLength, 0, newSize - mLength);
|
Internal.MemSet(newPtr + mLength, 0, newSize - mLength);
|
||||||
#endif
|
#endif
|
||||||
if (IsDynAlloc)
|
if (IsDynAlloc)
|
||||||
delete:this mPtr;
|
delete:this mPtrOrBuffer;
|
||||||
mPtr = newPtr;
|
mPtrOrBuffer = newPtr;
|
||||||
mAllocSizeAndFlags = (uint_strsize)newSize | cDynAllocFlag | cStrPtrFlag;
|
mAllocSizeAndFlags = (uint_strsize)newSize | cDynAllocFlag | cStrPtrFlag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -780,8 +780,8 @@ namespace System
|
||||||
Debug.Assert((uint)newSize <= cSizeFlags);
|
Debug.Assert((uint)newSize <= cSizeFlags);
|
||||||
Internal.MemCpy(newPtr, Ptr, mLength);
|
Internal.MemCpy(newPtr, Ptr, mLength);
|
||||||
if (IsDynAlloc)
|
if (IsDynAlloc)
|
||||||
delete:this mPtr;
|
delete:this mPtrOrBuffer;
|
||||||
mPtr = newPtr;
|
mPtrOrBuffer = newPtr;
|
||||||
mAllocSizeAndFlags = (uint_strsize)newSize | cDynAllocFlag | cStrPtrFlag;
|
mAllocSizeAndFlags = (uint_strsize)newSize | cDynAllocFlag | cStrPtrFlag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1313,7 +1313,7 @@ namespace System
|
||||||
if (pos == len || (ch = format[pos]) < '0' || ch > '9')
|
if (pos == len || (ch = format[pos]) < '0' || ch > '9')
|
||||||
{
|
{
|
||||||
if ((pos < len) &&
|
if ((pos < len) &&
|
||||||
((ch == '}') || (ch == ':')))
|
((ch == '}') || (ch == ':') || (ch == ',')))
|
||||||
index = autoArgIdx++;
|
index = autoArgIdx++;
|
||||||
else
|
else
|
||||||
return FormatError();
|
return FormatError();
|
||||||
|
@ -1603,8 +1603,8 @@ namespace System
|
||||||
newPtr[outIdx] = '\0';
|
newPtr[outIdx] = '\0';
|
||||||
|
|
||||||
if (IsDynAlloc)
|
if (IsDynAlloc)
|
||||||
delete mPtr;
|
delete mPtrOrBuffer;
|
||||||
mPtr = newPtr;
|
mPtrOrBuffer = newPtr;
|
||||||
mAllocSizeAndFlags = (uint_strsize)newSize | cDynAllocFlag | cStrPtrFlag;
|
mAllocSizeAndFlags = (uint_strsize)newSize | cDynAllocFlag | cStrPtrFlag;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1633,8 +1633,8 @@ namespace System
|
||||||
int newLen = UTF8Map(Ptr, mLength, newStr, allocSize, (int32)unicodeNormalizationOptions);
|
int newLen = UTF8Map(Ptr, mLength, newStr, allocSize, (int32)unicodeNormalizationOptions);
|
||||||
|
|
||||||
if (IsDynAlloc)
|
if (IsDynAlloc)
|
||||||
delete:this mPtr;
|
delete:this mPtrOrBuffer;
|
||||||
mPtr = newStr;
|
mPtrOrBuffer = newStr;
|
||||||
mLength = (int_strsize)newLen;
|
mLength = (int_strsize)newLen;
|
||||||
mAllocSizeAndFlags = (uint32)(allocSize) | cDynAllocFlag | cStrPtrFlag;
|
mAllocSizeAndFlags = (uint32)(allocSize) | cDynAllocFlag | cStrPtrFlag;
|
||||||
return .Ok;
|
return .Ok;
|
||||||
|
@ -1656,8 +1656,8 @@ namespace System
|
||||||
int newLen = UTF8Map(Ptr, mLength, newStr, allocSize, (int32)unicodeNormalizationOptions);
|
int newLen = UTF8Map(Ptr, mLength, newStr, allocSize, (int32)unicodeNormalizationOptions);
|
||||||
|
|
||||||
if (destStr.IsDynAlloc)
|
if (destStr.IsDynAlloc)
|
||||||
delete:destStr destStr.mPtr;
|
delete:destStr destStr.mPtrOrBuffer;
|
||||||
destStr.mPtr = newStr;
|
destStr.mPtrOrBuffer = newStr;
|
||||||
destStr.mLength = (int_strsize)newLen;
|
destStr.mLength = (int_strsize)newLen;
|
||||||
destStr.mAllocSizeAndFlags = (uint_strsize)(newLen + 1) | cDynAllocFlag | cStrPtrFlag;
|
destStr.mAllocSizeAndFlags = (uint_strsize)(newLen + 1) | cDynAllocFlag | cStrPtrFlag;
|
||||||
return .Ok;
|
return .Ok;
|
||||||
|
@ -2059,7 +2059,7 @@ namespace System
|
||||||
{
|
{
|
||||||
if (mLength != str.[Friend]mLength)
|
if (mLength != str.[Friend]mLength)
|
||||||
return false;
|
return false;
|
||||||
return EqualsHelper(str.Ptr, mPtr, mLength);
|
return EqualsHelper(str.Ptr, Ptr, mLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Equals(StringView str, StringComparison comparisonType = StringComparison.Ordinal)
|
public bool Equals(StringView str, StringComparison comparisonType = StringComparison.Ordinal)
|
||||||
|
@ -2067,8 +2067,8 @@ namespace System
|
||||||
if (mLength != str.[Friend]mLength)
|
if (mLength != str.[Friend]mLength)
|
||||||
return false;
|
return false;
|
||||||
if (comparisonType == StringComparison.OrdinalIgnoreCase)
|
if (comparisonType == StringComparison.OrdinalIgnoreCase)
|
||||||
return EqualsIgnoreCaseHelper(str.Ptr, mPtr, mLength);
|
return EqualsIgnoreCaseHelper(str.Ptr, Ptr, mLength);
|
||||||
return EqualsHelper(str.Ptr, mPtr, mLength);
|
return EqualsHelper(str.Ptr, Ptr, mLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool StartsWith(StringView b, StringComparison comparisonType = StringComparison.Ordinal)
|
public bool StartsWith(StringView b, StringComparison comparisonType = StringComparison.Ordinal)
|
||||||
|
@ -2488,6 +2488,56 @@ namespace System
|
||||||
return StringSplitEnumerator(Ptr, Length, separators, count, options);
|
return StringSplitEnumerator(Ptr, Length, separators, count, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public StringSplitEnumerator Split(char8[] separators, StringSplitOptions options)
|
||||||
|
{
|
||||||
|
return StringSplitEnumerator(Ptr, Length, separators, Int32.MaxValue, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
public StringStringSplitEnumerator Split(StringView sv)
|
||||||
|
{
|
||||||
|
return StringStringSplitEnumerator(Ptr, Length, sv, Int32.MaxValue, StringSplitOptions.None);
|
||||||
|
}
|
||||||
|
|
||||||
|
public StringStringSplitEnumerator Split(StringView separator, int count)
|
||||||
|
{
|
||||||
|
return StringStringSplitEnumerator(Ptr, Length, separator, count, StringSplitOptions.None);
|
||||||
|
}
|
||||||
|
|
||||||
|
public StringStringSplitEnumerator Split(StringView separator, StringSplitOptions options)
|
||||||
|
{
|
||||||
|
return StringStringSplitEnumerator(Ptr, Length, separator, Int32.MaxValue, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
public StringStringSplitEnumerator Split(StringView separator, int count, StringSplitOptions options)
|
||||||
|
{
|
||||||
|
return StringStringSplitEnumerator(Ptr, Length, separator, count, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
public StringStringSplitEnumerator Split(params StringView[] separators)
|
||||||
|
{
|
||||||
|
return StringStringSplitEnumerator(Ptr, Length, separators, Int32.MaxValue, StringSplitOptions.None);
|
||||||
|
}
|
||||||
|
|
||||||
|
public StringStringSplitEnumerator Split(StringView[] separators)
|
||||||
|
{
|
||||||
|
return StringStringSplitEnumerator(Ptr, Length, separators, Int32.MaxValue, StringSplitOptions.None);
|
||||||
|
}
|
||||||
|
|
||||||
|
public StringStringSplitEnumerator Split(StringView[] separators, int count)
|
||||||
|
{
|
||||||
|
return StringStringSplitEnumerator(Ptr, Length, separators, count, StringSplitOptions.None);
|
||||||
|
}
|
||||||
|
|
||||||
|
public StringStringSplitEnumerator Split(StringView[] separators, int count, StringSplitOptions options)
|
||||||
|
{
|
||||||
|
return StringStringSplitEnumerator(Ptr, Length, separators, count, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
public StringStringSplitEnumerator Split(StringView[] separators, StringSplitOptions options)
|
||||||
|
{
|
||||||
|
return StringStringSplitEnumerator(Ptr, Length, separators, Int32.MaxValue, options);
|
||||||
|
}
|
||||||
|
|
||||||
public static mixin NewOrSet(var target, var source)
|
public static mixin NewOrSet(var target, var source)
|
||||||
{
|
{
|
||||||
if (target == null)
|
if (target == null)
|
||||||
|
@ -2914,11 +2964,11 @@ namespace System
|
||||||
RemoveEmptyEntries = 1
|
RemoveEmptyEntries = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
struct StringSplitEnumerator : IEnumerator<StringView>
|
public struct StringSplitEnumerator : IEnumerator<StringView>
|
||||||
{
|
{
|
||||||
StringSplitOptions mSplitOptions;
|
StringSplitOptions mSplitOptions;
|
||||||
char8 mSplitChar0;
|
char8 mFirstSeparator;
|
||||||
char8[] mSplitChars;
|
char8[] mSeparators;
|
||||||
char8* mPtr;
|
char8* mPtr;
|
||||||
int_strsize mStrLen;
|
int_strsize mStrLen;
|
||||||
int32 mCurCount;
|
int32 mCurCount;
|
||||||
|
@ -2926,15 +2976,15 @@ namespace System
|
||||||
int_strsize mPos;
|
int_strsize mPos;
|
||||||
int_strsize mMatchPos;
|
int_strsize mMatchPos;
|
||||||
|
|
||||||
public this(char8* ptr, int strLength, char8[] splitChars, int count, StringSplitOptions splitOptions)
|
public this(char8* ptr, int strLength, char8[] separators, int count, StringSplitOptions splitOptions)
|
||||||
{
|
{
|
||||||
mPtr = ptr;
|
mPtr = ptr;
|
||||||
mStrLen = (int_strsize)strLength;
|
mStrLen = (int_strsize)strLength;
|
||||||
if (splitChars.Count > 0)
|
if (separators?.Count > 0)
|
||||||
mSplitChar0 = splitChars[0];
|
mFirstSeparator = separators[0];
|
||||||
else
|
else
|
||||||
mSplitChar0 = '\0';
|
mFirstSeparator = '\0';
|
||||||
mSplitChars = splitChars;
|
mSeparators = separators;
|
||||||
mCurCount = 0;
|
mCurCount = 0;
|
||||||
mMaxCount = (int32)count;
|
mMaxCount = (int32)count;
|
||||||
mPos = 0;
|
mPos = 0;
|
||||||
|
@ -2942,12 +2992,12 @@ namespace System
|
||||||
mSplitOptions = splitOptions;
|
mSplitOptions = splitOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
public this(char8* ptr, int strLength, char8 splitChar, int count, StringSplitOptions splitOptions)
|
public this(char8* ptr, int strLength, char8 separator, int count, StringSplitOptions splitOptions)
|
||||||
{
|
{
|
||||||
mPtr = ptr;
|
mPtr = ptr;
|
||||||
mStrLen = (int_strsize)strLength;
|
mStrLen = (int_strsize)strLength;
|
||||||
mSplitChar0 = splitChar;
|
mFirstSeparator = separator;
|
||||||
mSplitChars = null;
|
mSeparators = null;
|
||||||
mCurCount = 0;
|
mCurCount = 0;
|
||||||
mMaxCount = (int32)count;
|
mMaxCount = (int32)count;
|
||||||
mPos = 0;
|
mPos = 0;
|
||||||
|
@ -3028,14 +3078,18 @@ namespace System
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char8 c = mPtr[mMatchPos];
|
char8 c = mPtr[mMatchPos];
|
||||||
if (c == mSplitChar0)
|
if (c.IsWhiteSpace && mFirstSeparator == '\0' && (mSeparators == null || mSeparators.IsEmpty))
|
||||||
{
|
{
|
||||||
foundMatch = true;
|
foundMatch = true;
|
||||||
}
|
}
|
||||||
else if (mSplitChars != null)
|
else if (c == mFirstSeparator)
|
||||||
{
|
{
|
||||||
for (int i = 1; i < mSplitChars.Count; i++)
|
foundMatch = true;
|
||||||
if (c == mSplitChars[i])
|
}
|
||||||
|
else if (mSeparators != null)
|
||||||
|
{
|
||||||
|
for (int i = 1; i < mSeparators.Count; i++)
|
||||||
|
if (c == mSeparators[i])
|
||||||
foundMatch = true;
|
foundMatch = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3070,6 +3124,179 @@ namespace System
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public struct StringStringSplitEnumerator : IEnumerator<StringView>
|
||||||
|
{
|
||||||
|
StringSplitOptions mSplitOptions;
|
||||||
|
StringView mFirstSeparator;
|
||||||
|
StringView[] mSeparators;
|
||||||
|
char8* mPtr;
|
||||||
|
int_strsize mStrLen;
|
||||||
|
int32 mCurCount;
|
||||||
|
int32 mMaxCount;
|
||||||
|
int_strsize mPos;
|
||||||
|
int_strsize mMatchPos;
|
||||||
|
int_strsize mMatchLen;
|
||||||
|
|
||||||
|
public this(char8* ptr, int strLength, StringView[] separators, int count, StringSplitOptions splitOptions)
|
||||||
|
{
|
||||||
|
mPtr = ptr;
|
||||||
|
mStrLen = (int_strsize)strLength;
|
||||||
|
if (separators?.Count > 0)
|
||||||
|
mFirstSeparator = separators[0];
|
||||||
|
else
|
||||||
|
mFirstSeparator = .();
|
||||||
|
mSeparators = separators;
|
||||||
|
mCurCount = 0;
|
||||||
|
mMaxCount = (int32)count;
|
||||||
|
mPos = 0;
|
||||||
|
mMatchPos = -1;
|
||||||
|
mMatchLen = 1;
|
||||||
|
mSplitOptions = splitOptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public this(char8* ptr, int strLength, StringView separator, int count, StringSplitOptions splitOptions)
|
||||||
|
{
|
||||||
|
mPtr = ptr;
|
||||||
|
mStrLen = (int_strsize)strLength;
|
||||||
|
mFirstSeparator = separator;
|
||||||
|
mSeparators = null;
|
||||||
|
mCurCount = 0;
|
||||||
|
mMaxCount = (int32)count;
|
||||||
|
mPos = 0;
|
||||||
|
mMatchPos = -1;
|
||||||
|
mMatchLen = 1;
|
||||||
|
mSplitOptions = splitOptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StringView Current
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return StringView(mPtr + mPos, mMatchPos - mPos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int_strsize Pos
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return mPos;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int_strsize MatchPos
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return mMatchPos;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int32 MatchIndex
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return mCurCount - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool HasMore
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return mMatchPos < mStrLen;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool MoveNext() mut
|
||||||
|
{
|
||||||
|
if (mCurCount >= mMaxCount)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
mPos = mMatchPos + mMatchLen;
|
||||||
|
|
||||||
|
mCurCount++;
|
||||||
|
if (mCurCount == mMaxCount)
|
||||||
|
{
|
||||||
|
mMatchPos = (int_strsize)mStrLen;
|
||||||
|
if (mPos > mMatchPos)
|
||||||
|
return false;
|
||||||
|
if ((mMatchPos == mPos) && (mSplitOptions.HasFlag(.RemoveEmptyEntries)))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int endDiff = mStrLen - mMatchPos;
|
||||||
|
if (endDiff == 0)
|
||||||
|
return false;
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
mMatchPos++;
|
||||||
|
endDiff--;
|
||||||
|
bool foundMatch = false;
|
||||||
|
if (endDiff == 0)
|
||||||
|
{
|
||||||
|
foundMatch = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (mFirstSeparator.IsNull && (mSeparators == null || mSeparators.IsEmpty) && mPtr[mMatchPos].IsWhiteSpace)
|
||||||
|
{
|
||||||
|
foundMatch = true;
|
||||||
|
mMatchLen = 1;
|
||||||
|
}
|
||||||
|
else if (mFirstSeparator.Length <= mStrLen - mMatchPos && StringView(&mPtr[mMatchPos], mFirstSeparator.Length) == mFirstSeparator)
|
||||||
|
{
|
||||||
|
foundMatch = true;
|
||||||
|
mMatchLen = (int_strsize)mFirstSeparator.Length;
|
||||||
|
}
|
||||||
|
else if (mSeparators != null)
|
||||||
|
{
|
||||||
|
for (int i = 1; i < mSeparators.Count; i++)
|
||||||
|
{
|
||||||
|
if (mSeparators[i].Length <= mStrLen - mMatchPos && StringView(&mPtr[mMatchPos], mSeparators[i].Length) == mSeparators[i])
|
||||||
|
{
|
||||||
|
foundMatch = true;
|
||||||
|
mMatchLen = (int_strsize)mSeparators[i].Length;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (foundMatch)
|
||||||
|
{
|
||||||
|
if ((mMatchPos >= mPos + 1) || (!mSplitOptions.HasFlag(StringSplitOptions.RemoveEmptyEntries)))
|
||||||
|
return true;
|
||||||
|
mPos = mMatchPos + mMatchLen;
|
||||||
|
if (mPos >= mStrLen)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mMatchLen = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Reset() mut
|
||||||
|
{
|
||||||
|
mPos = 0;
|
||||||
|
mMatchPos = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Result<StringView> GetNext() mut
|
||||||
|
{
|
||||||
|
if (!MoveNext())
|
||||||
|
return .Err;
|
||||||
|
return Current;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public struct StringView : Span<char8>, IFormattable, IPrintable, IHashable
|
public struct StringView : Span<char8>, IFormattable, IPrintable, IHashable
|
||||||
{
|
{
|
||||||
public this()
|
public this()
|
||||||
|
@ -3080,12 +3307,23 @@ namespace System
|
||||||
|
|
||||||
public this(String string)
|
public this(String string)
|
||||||
{
|
{
|
||||||
|
if (string == null)
|
||||||
|
{
|
||||||
|
this = default;
|
||||||
|
return;
|
||||||
|
}
|
||||||
mPtr = string.Ptr;
|
mPtr = string.Ptr;
|
||||||
mLength = string.Length;
|
mLength = string.Length;
|
||||||
}
|
}
|
||||||
|
|
||||||
public this(String string, int offset)
|
public this(String string, int offset)
|
||||||
{
|
{
|
||||||
|
if (string == null)
|
||||||
|
{
|
||||||
|
Debug.Assert(offset == 0);
|
||||||
|
this = default;
|
||||||
|
return;
|
||||||
|
}
|
||||||
Debug.Assert((uint)offset <= (uint)string.Length);
|
Debug.Assert((uint)offset <= (uint)string.Length);
|
||||||
mPtr = string.Ptr + offset;
|
mPtr = string.Ptr + offset;
|
||||||
mLength = string.Length - offset;
|
mLength = string.Length - offset;
|
||||||
|
@ -3093,6 +3331,12 @@ namespace System
|
||||||
|
|
||||||
public this(String string, int offset, int length)
|
public this(String string, int offset, int length)
|
||||||
{
|
{
|
||||||
|
if (string == null)
|
||||||
|
{
|
||||||
|
Debug.Assert(offset == 0 && length == 0);
|
||||||
|
this = default;
|
||||||
|
return;
|
||||||
|
}
|
||||||
Debug.Assert((uint)offset + (uint)length <= (uint)string.Length);
|
Debug.Assert((uint)offset + (uint)length <= (uint)string.Length);
|
||||||
mPtr = string.Ptr + offset;
|
mPtr = string.Ptr + offset;
|
||||||
mLength = length;
|
mLength = length;
|
||||||
|
@ -3120,6 +3364,12 @@ namespace System
|
||||||
|
|
||||||
public this(char8[] arr, int offset, int length)
|
public this(char8[] arr, int offset, int length)
|
||||||
{
|
{
|
||||||
|
if (arr == null)
|
||||||
|
{
|
||||||
|
Debug.Assert(offset == 0 && length == 0);
|
||||||
|
this = default;
|
||||||
|
return;
|
||||||
|
}
|
||||||
Debug.Assert((uint)offset + (uint)length <= (uint)arr.Count);
|
Debug.Assert((uint)offset + (uint)length <= (uint)arr.Count);
|
||||||
mPtr = arr.CArray() + offset;
|
mPtr = arr.CArray() + offset;
|
||||||
mLength = length;
|
mLength = length;
|
||||||
|
@ -3127,13 +3377,23 @@ namespace System
|
||||||
|
|
||||||
public this(char8* ptr)
|
public this(char8* ptr)
|
||||||
{
|
{
|
||||||
|
if (ptr == null)
|
||||||
|
{
|
||||||
|
this = default;
|
||||||
|
return;
|
||||||
|
}
|
||||||
mPtr = ptr;
|
mPtr = ptr;
|
||||||
mLength = String.StrLen(ptr);
|
mLength = String.StrLen(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
public this(char8* ptr, int length)
|
public this(char8* ptr, int length)
|
||||||
|
|
||||||
{
|
{
|
||||||
|
if (ptr == null)
|
||||||
|
{
|
||||||
|
Debug.Assert(length == 0);
|
||||||
|
this = default;
|
||||||
|
return;
|
||||||
|
}
|
||||||
mPtr = ptr;
|
mPtr = ptr;
|
||||||
mLength = length;
|
mLength = length;
|
||||||
}
|
}
|
||||||
|
@ -3749,11 +4009,71 @@ namespace System
|
||||||
return StringSplitEnumerator(Ptr, Length, separators, Int32.MaxValue, StringSplitOptions.None);
|
return StringSplitEnumerator(Ptr, Length, separators, Int32.MaxValue, StringSplitOptions.None);
|
||||||
}
|
}
|
||||||
|
|
||||||
public StringSplitEnumerator Split(char8[] separators, int count = Int32.MaxValue, StringSplitOptions options = .None)
|
public StringSplitEnumerator Split(char8[] separators)
|
||||||
|
{
|
||||||
|
return StringSplitEnumerator(Ptr, Length, separators, Int32.MaxValue, StringSplitOptions.None);
|
||||||
|
}
|
||||||
|
|
||||||
|
public StringSplitEnumerator Split(char8[] separators, int count)
|
||||||
|
{
|
||||||
|
return StringSplitEnumerator(Ptr, Length, separators, count, StringSplitOptions.None);
|
||||||
|
}
|
||||||
|
|
||||||
|
public StringSplitEnumerator Split(char8[] separators, int count, StringSplitOptions options)
|
||||||
{
|
{
|
||||||
return StringSplitEnumerator(Ptr, Length, separators, count, options);
|
return StringSplitEnumerator(Ptr, Length, separators, count, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public StringSplitEnumerator Split(char8[] separators, StringSplitOptions options)
|
||||||
|
{
|
||||||
|
return StringSplitEnumerator(Ptr, Length, separators, Int32.MaxValue, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
public StringStringSplitEnumerator Split(StringView c)
|
||||||
|
{
|
||||||
|
return StringStringSplitEnumerator(Ptr, Length, c, Int32.MaxValue, StringSplitOptions.None);
|
||||||
|
}
|
||||||
|
|
||||||
|
public StringStringSplitEnumerator Split(StringView separator, int count)
|
||||||
|
{
|
||||||
|
return StringStringSplitEnumerator(Ptr, Length, separator, count, StringSplitOptions.None);
|
||||||
|
}
|
||||||
|
|
||||||
|
public StringStringSplitEnumerator Split(StringView separator, StringSplitOptions options)
|
||||||
|
{
|
||||||
|
return StringStringSplitEnumerator(Ptr, Length, separator, Int32.MaxValue, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
public StringStringSplitEnumerator Split(StringView separator, int count, StringSplitOptions options)
|
||||||
|
{
|
||||||
|
return StringStringSplitEnumerator(Ptr, Length, separator, count, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
public StringStringSplitEnumerator Split(params StringView[] separators)
|
||||||
|
{
|
||||||
|
return StringStringSplitEnumerator(Ptr, Length, separators, Int32.MaxValue, StringSplitOptions.None);
|
||||||
|
}
|
||||||
|
|
||||||
|
public StringStringSplitEnumerator Split(StringView[] separators)
|
||||||
|
{
|
||||||
|
return StringStringSplitEnumerator(Ptr, Length, separators, Int32.MaxValue, StringSplitOptions.None);
|
||||||
|
}
|
||||||
|
|
||||||
|
public StringStringSplitEnumerator Split(StringView[] separators, int count)
|
||||||
|
{
|
||||||
|
return StringStringSplitEnumerator(Ptr, Length, separators, count, StringSplitOptions.None);
|
||||||
|
}
|
||||||
|
|
||||||
|
public StringStringSplitEnumerator Split(StringView[] separators, int count, StringSplitOptions options)
|
||||||
|
{
|
||||||
|
return StringStringSplitEnumerator(Ptr, Length, separators, count, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
public StringStringSplitEnumerator Split(StringView[] separators, StringSplitOptions options)
|
||||||
|
{
|
||||||
|
return StringStringSplitEnumerator(Ptr, Length, separators, Int32.MaxValue, options);
|
||||||
|
}
|
||||||
|
|
||||||
public String Intern()
|
public String Intern()
|
||||||
{
|
{
|
||||||
using (String.[Friend]sMonitor.Enter())
|
using (String.[Friend]sMonitor.Enter())
|
||||||
|
@ -3820,18 +4140,21 @@ namespace System
|
||||||
public mixin ToScopedNativeWChar()
|
public mixin ToScopedNativeWChar()
|
||||||
{
|
{
|
||||||
int encodedLen = UTF16.GetEncodedLen(this);
|
int encodedLen = UTF16.GetEncodedLen(this);
|
||||||
char16* buf;
|
c_wchar* buf;
|
||||||
if (encodedLen < 128)
|
if (encodedLen < 128)
|
||||||
{
|
{
|
||||||
buf = scope:mixin char16[encodedLen+1]* ( ? );
|
buf = scope:mixin c_wchar[encodedLen+1]* ( ? );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
buf = new char16[encodedLen+1]* ( ? );
|
buf = new c_wchar[encodedLen+1]* ( ? );
|
||||||
defer:mixin delete buf;
|
defer:mixin delete buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
UTF16.Encode(this, buf, encodedLen);
|
if (sizeof(c_wchar) == 2)
|
||||||
|
UTF16.Encode(this, (.)buf, encodedLen);
|
||||||
|
else
|
||||||
|
UTF32.Encode(this, (.)buf, encodedLen);
|
||||||
buf[encodedLen] = 0;
|
buf[encodedLen] = 0;
|
||||||
buf
|
buf
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,8 +20,13 @@ namespace System.Threading
|
||||||
private Object mThreadStartArg;
|
private Object mThreadStartArg;
|
||||||
|
|
||||||
bool mAutoDelete;
|
bool mAutoDelete;
|
||||||
public static Thread sMainThread = new Thread() ~ delete _;
|
|
||||||
|
static Monitor sMonitor = new .() ~ delete _;
|
||||||
|
static Event<delegate void()> sOnExit ~ _.Dispose();
|
||||||
|
Event<delegate void()> mOnExit ~ _.Dispose();
|
||||||
|
|
||||||
|
public static Thread sMainThread = new Thread() ~ delete _;
|
||||||
|
|
||||||
[StaticInitPriority(102)]
|
[StaticInitPriority(102)]
|
||||||
struct RuntimeThreadInit
|
struct RuntimeThreadInit
|
||||||
{
|
{
|
||||||
|
@ -62,6 +67,14 @@ namespace System.Threading
|
||||||
return ((Thread)thread).mMaxStackSize;
|
return ((Thread)thread).mMaxStackSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void Thread_Exiting()
|
||||||
|
{
|
||||||
|
using (sMonitor.Enter())
|
||||||
|
{
|
||||||
|
sOnExit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void Thread_StartProc(Object threadObj)
|
static void Thread_StartProc(Object threadObj)
|
||||||
{
|
{
|
||||||
Thread thread = (Thread)threadObj;
|
Thread thread = (Thread)threadObj;
|
||||||
|
@ -103,6 +116,7 @@ namespace System.Threading
|
||||||
cb.[Friend]mThread_IsAutoDelete = => Thread_IsAutoDelete;
|
cb.[Friend]mThread_IsAutoDelete = => Thread_IsAutoDelete;
|
||||||
cb.[Friend]mThread_AutoDelete = => Thread_AutoDelete;
|
cb.[Friend]mThread_AutoDelete = => Thread_AutoDelete;
|
||||||
cb.[Friend]mThread_GetMaxStackSize = => Thread_GetMaxStackSize;
|
cb.[Friend]mThread_GetMaxStackSize = => Thread_GetMaxStackSize;
|
||||||
|
cb.[Friend]mThread_Exiting = => Thread_Exiting;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,6 +192,38 @@ namespace System.Threading
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void AddExitNotify(delegate void() dlg)
|
||||||
|
{
|
||||||
|
using (sMonitor.Enter())
|
||||||
|
{
|
||||||
|
mOnExit.Add(dlg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Result<void> RemovedExitNotify(delegate void() dlg, bool delegateDelegate = false)
|
||||||
|
{
|
||||||
|
using (sMonitor.Enter())
|
||||||
|
{
|
||||||
|
return mOnExit.Remove(dlg, delegateDelegate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void AddGlobalExitNotify(delegate void() dlg)
|
||||||
|
{
|
||||||
|
using (sMonitor.Enter())
|
||||||
|
{
|
||||||
|
sOnExit.Add(dlg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Result<void> RemoveGlobalExitNotify(delegate void() dlg, bool delegateDelegate = false)
|
||||||
|
{
|
||||||
|
using (sMonitor.Enter())
|
||||||
|
{
|
||||||
|
return sOnExit.Remove(dlg, delegateDelegate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
extern void ManualThreadInit();
|
extern void ManualThreadInit();
|
||||||
extern void StartInternal();
|
extern void StartInternal();
|
||||||
extern void SetStackStart(void* ptr);
|
extern void SetStackStart(void* ptr);
|
||||||
|
@ -217,6 +263,7 @@ namespace System.Threading
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static extern void RequestExitNotify();
|
||||||
public extern void Suspend();
|
public extern void Suspend();
|
||||||
public extern void Resume();
|
public extern void Resume();
|
||||||
|
|
||||||
|
@ -316,9 +363,10 @@ namespace System.Threading
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int32 GetThreadId();
|
[CallingConvention(.Cdecl)]
|
||||||
|
extern int GetThreadId();
|
||||||
|
|
||||||
public int32 Id
|
public int Id
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
@ -326,6 +374,8 @@ namespace System.Threading
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int CurrentThreadId => Platform.BfpThread_GetCurrentId();
|
||||||
|
|
||||||
[CallingConvention(.Cdecl)]
|
[CallingConvention(.Cdecl)]
|
||||||
private static extern Thread GetCurrentThreadNative();
|
private static extern Thread GetCurrentThreadNative();
|
||||||
|
|
||||||
|
@ -337,6 +387,12 @@ namespace System.Threading
|
||||||
|
|
||||||
public ~this()
|
public ~this()
|
||||||
{
|
{
|
||||||
|
using (sMonitor.Enter())
|
||||||
|
{
|
||||||
|
mOnExit();
|
||||||
|
sOnExit();
|
||||||
|
}
|
||||||
|
|
||||||
// Make sure we're not deleting manually if mAutoDelete is set
|
// Make sure we're not deleting manually if mAutoDelete is set
|
||||||
Debug.Assert((!mAutoDelete) || (CurrentThread == this));
|
Debug.Assert((!mAutoDelete) || (CurrentThread == this));
|
||||||
// Delegate to the unmanaged portion.
|
// Delegate to the unmanaged portion.
|
||||||
|
|
|
@ -196,5 +196,7 @@ namespace System
|
||||||
{
|
{
|
||||||
TimeSpanFormat.[Friend]Format(this, format, formatProvider, outStr);
|
TimeSpanFormat.[Friend]Format(this, format, formatProvider, outStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static TimeSpan operator-(Self lhs, Self rhs) => .((int64)lhs - (int64)rhs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1942,7 +1942,8 @@ namespace System {
|
||||||
}
|
}
|
||||||
// the data returned from the PAL is completely bogus; return a dummy entry
|
// the data returned from the PAL is completely bogus; return a dummy entry
|
||||||
return CreateCustomTimeZone(c_localId, TimeSpan.Zero, c_localId, c_localId);*/
|
return CreateCustomTimeZone(c_localId, TimeSpan.Zero, c_localId, c_localId);*/
|
||||||
Runtime.NotImplemented();
|
// TODO: Not implemented.
|
||||||
|
return Utc;
|
||||||
}
|
}
|
||||||
#endif // !FEATURE_WIN32_REGISTRY
|
#endif // !FEATURE_WIN32_REGISTRY
|
||||||
|
|
||||||
|
|
|
@ -852,7 +852,8 @@ namespace System.Reflection
|
||||||
None = 0,
|
None = 0,
|
||||||
Splat = 1,
|
Splat = 1,
|
||||||
Implicit = 2,
|
Implicit = 2,
|
||||||
AppendIdx = 4
|
AppendIdx = 4,
|
||||||
|
Params = 8
|
||||||
}
|
}
|
||||||
|
|
||||||
[CRepr, AlwaysInclude]
|
[CRepr, AlwaysInclude]
|
||||||
|
@ -1479,6 +1480,7 @@ namespace System.Reflection
|
||||||
EnumDiscriminator = 0x0200,
|
EnumDiscriminator = 0x0200,
|
||||||
EnumCase = 0x0400,
|
EnumCase = 0x0400,
|
||||||
ReadOnly = 0x0800,
|
ReadOnly = 0x0800,
|
||||||
|
Appended = 0x1000,
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum MethodFlags : uint16
|
public enum MethodFlags : uint16
|
||||||
|
|
|
@ -2,6 +2,7 @@ namespace System
|
||||||
{
|
{
|
||||||
struct ValueType
|
struct ValueType
|
||||||
{
|
{
|
||||||
|
[NoShow(true)]
|
||||||
public static extern bool Equals<T>(T val1, T val2);
|
public static extern bool Equals<T>(T val1, T val2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,6 +94,7 @@
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
|
@ -112,6 +113,7 @@
|
||||||
<SupportJustMyCode>false</SupportJustMyCode>
|
<SupportJustMyCode>false</SupportJustMyCode>
|
||||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
|
@ -128,6 +130,7 @@
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
|
@ -149,6 +152,7 @@
|
||||||
<AdditionalIncludeDirectories>../;../BeefySysLib;../BeefySysLib/platform/win;../BeefySysLib/third_party;..\extern\llvm\include;..\extern\llvm_win64\include;..\extern\llvm\lib\Target;..\extern\llvm_win64\lib\Target\X86;..\extern\llvm\tools\clang\include</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>../;../BeefySysLib;../BeefySysLib/platform/win;../BeefySysLib/third_party;..\extern\llvm\include;..\extern\llvm_win64\include;..\extern\llvm\lib\Target;..\extern\llvm_win64\lib\Target\X86;..\extern\llvm\tools\clang\include</AdditionalIncludeDirectories>
|
||||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
|
|
|
@ -140,6 +140,7 @@
|
||||||
<ClCompile Include="..\..\BeefySysLib\platform\win\CrashCatcher.cpp" />
|
<ClCompile Include="..\..\BeefySysLib\platform\win\CrashCatcher.cpp" />
|
||||||
<ClCompile Include="..\..\BeefySysLib\platform\win\Platform.cpp" />
|
<ClCompile Include="..\..\BeefySysLib\platform\win\Platform.cpp" />
|
||||||
<ClCompile Include="..\..\BeefySysLib\third_party\utf8proc\utf8proc.c" />
|
<ClCompile Include="..\..\BeefySysLib\third_party\utf8proc\utf8proc.c" />
|
||||||
|
<ClCompile Include="..\..\BeefySysLib\third_party\putty\wildcard.c" />
|
||||||
<ClCompile Include="..\..\BeefySysLib\util\BeefPerf.cpp" />
|
<ClCompile Include="..\..\BeefySysLib\util\BeefPerf.cpp" />
|
||||||
<ClCompile Include="..\..\BeefySysLib\util\String.cpp" />
|
<ClCompile Include="..\..\BeefySysLib\util\String.cpp" />
|
||||||
<ClCompile Include="..\..\BeefySysLib\util\UTF8.cpp" />
|
<ClCompile Include="..\..\BeefySysLib\util\UTF8.cpp" />
|
||||||
|
@ -356,6 +357,7 @@
|
||||||
<ClInclude Include="..\..\BeefySysLib\platform\win\BFPlatform.h" />
|
<ClInclude Include="..\..\BeefySysLib\platform\win\BFPlatform.h" />
|
||||||
<ClInclude Include="..\..\BeefySysLib\platform\win\CrashCatcher.h" />
|
<ClInclude Include="..\..\BeefySysLib\platform\win\CrashCatcher.h" />
|
||||||
<ClInclude Include="..\..\BeefySysLib\third_party\utf8proc\utf8proc.h" />
|
<ClInclude Include="..\..\BeefySysLib\third_party\utf8proc\utf8proc.h" />
|
||||||
|
<ClInclude Include="..\..\BeefySysLib\third_party\putty\wildcard.h" />
|
||||||
<ClInclude Include="..\..\BeefySysLib\util\BeefPerf.h" />
|
<ClInclude Include="..\..\BeefySysLib\util\BeefPerf.h" />
|
||||||
<ClInclude Include="..\..\BeefySysLib\util\String.h" />
|
<ClInclude Include="..\..\BeefySysLib\util\String.h" />
|
||||||
<ClInclude Include="..\..\BeefySysLib\util\UTF8.h" />
|
<ClInclude Include="..\..\BeefySysLib\util\UTF8.h" />
|
||||||
|
@ -526,6 +528,7 @@
|
||||||
<AdditionalIncludeDirectories>.;../;../..;../../BeefySysLib/third_party;../../BeefySysLib;../../BeefySysLib/platform/win;../gperftools/src;../gperftools/src/windows</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>.;../;../..;../../BeefySysLib/third_party;../../BeefySysLib;../../BeefySysLib/platform/win;../gperftools/src;../gperftools/src/windows</AdditionalIncludeDirectories>
|
||||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
@ -589,6 +592,7 @@
|
||||||
<SupportJustMyCode>false</SupportJustMyCode>
|
<SupportJustMyCode>false</SupportJustMyCode>
|
||||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
@ -664,6 +668,7 @@
|
||||||
<AdditionalIncludeDirectories>.;../;../..;../../BeefySysLib/third_party;../../BeefySysLib;../../BeefySysLib/platform/win;../gperftools/src;../gperftools/src/windows</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>.;../;../..;../../BeefySysLib/third_party;../../BeefySysLib;../../BeefySysLib/platform/win;../gperftools/src;../gperftools/src/windows</AdditionalIncludeDirectories>
|
||||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
@ -724,6 +729,7 @@
|
||||||
<AdditionalIncludeDirectories>.;../;../..;../../BeefySysLib/third_party;../../BeefySysLib;../../BeefySysLib/platform/win;../gperftools/src;../gperftools/src/windows</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>.;../;../..;../../BeefySysLib/third_party;../../BeefySysLib;../../BeefySysLib/platform/win;../gperftools/src;../gperftools/src/windows</AdditionalIncludeDirectories>
|
||||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
|
|
@ -25,6 +25,9 @@
|
||||||
<Filter Include="BeefySysLib\third_party\utf8proc">
|
<Filter Include="BeefySysLib\third_party\utf8proc">
|
||||||
<UniqueIdentifier>{0027c869-120a-44d3-80e6-e2ab12ce83bc}</UniqueIdentifier>
|
<UniqueIdentifier>{0027c869-120a-44d3-80e6-e2ab12ce83bc}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
<Filter Include="BeefySysLib\third_party\putty">
|
||||||
|
<UniqueIdentifier>{59aee039-211d-47df-abb4-ca95d75d2c56}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
<Filter Include="BeefySysLib\util">
|
<Filter Include="BeefySysLib\util">
|
||||||
<UniqueIdentifier>{8e5503bc-1b01-46f1-be03-bb504d93f05d}</UniqueIdentifier>
|
<UniqueIdentifier>{8e5503bc-1b01-46f1-be03-bb504d93f05d}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
@ -105,6 +108,9 @@
|
||||||
<ClCompile Include="..\..\BeefySysLib\third_party\utf8proc\utf8proc.c">
|
<ClCompile Include="..\..\BeefySysLib\third_party\utf8proc\utf8proc.c">
|
||||||
<Filter>BeefySysLib\third_party\utf8proc</Filter>
|
<Filter>BeefySysLib\third_party\utf8proc</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\BeefySysLib\third_party\putty\wildcard.c">
|
||||||
|
<Filter>BeefySysLib\third_party\putty</Filter>
|
||||||
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\BeefySysLib\util\BeefPerf.cpp">
|
<ClCompile Include="..\..\BeefySysLib\util\BeefPerf.cpp">
|
||||||
<Filter>BeefySysLib\util</Filter>
|
<Filter>BeefySysLib\util</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -326,6 +332,9 @@
|
||||||
<ClInclude Include="..\..\BeefySysLib\third_party\utf8proc\utf8proc.h">
|
<ClInclude Include="..\..\BeefySysLib\third_party\utf8proc\utf8proc.h">
|
||||||
<Filter>BeefySysLib\third_party\utf8proc</Filter>
|
<Filter>BeefySysLib\third_party\utf8proc</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\BeefySysLib\third_party\putty\wildcard.h">
|
||||||
|
<Filter>BeefySysLib\third_party\putty</Filter>
|
||||||
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\BeefySysLib\util\BeefPerf.h">
|
<ClInclude Include="..\..\BeefySysLib\util\BeefPerf.h">
|
||||||
<Filter>BeefySysLib\util</Filter>
|
<Filter>BeefySysLib\util</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
|
|
@ -252,6 +252,7 @@
|
||||||
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Release Static CStatic|x64'">TurnOffAllWarnings</WarningLevel>
|
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Release Static CStatic|x64'">TurnOffAllWarnings</WarningLevel>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\BeefySysLib\third_party\utf8proc\utf8proc.c" />
|
<ClCompile Include="..\BeefySysLib\third_party\utf8proc\utf8proc.c" />
|
||||||
|
<ClCompile Include="..\BeefySysLib\third_party\putty\wildcard.c" />
|
||||||
<ClCompile Include="..\BeefySysLib\util\AllocDebug.cpp" />
|
<ClCompile Include="..\BeefySysLib\util\AllocDebug.cpp" />
|
||||||
<ClCompile Include="..\BeefySysLib\util\BeefPerf.cpp" />
|
<ClCompile Include="..\BeefySysLib\util\BeefPerf.cpp" />
|
||||||
<ClCompile Include="..\BeefySysLib\util\String.cpp" />
|
<ClCompile Include="..\BeefySysLib\util\String.cpp" />
|
||||||
|
@ -271,6 +272,7 @@
|
||||||
<ClInclude Include="..\BeefySysLib\third_party\libffi\i686-pc-cygwin\include\ffi.h" />
|
<ClInclude Include="..\BeefySysLib\third_party\libffi\i686-pc-cygwin\include\ffi.h" />
|
||||||
<ClInclude Include="..\BeefySysLib\third_party\libffi\i686-pc-cygwin\include\ffitarget.h" />
|
<ClInclude Include="..\BeefySysLib\third_party\libffi\i686-pc-cygwin\include\ffitarget.h" />
|
||||||
<ClInclude Include="..\BeefySysLib\third_party\utf8proc\utf8proc.h" />
|
<ClInclude Include="..\BeefySysLib\third_party\utf8proc\utf8proc.h" />
|
||||||
|
<ClInclude Include="..\BeefySysLib\third_party\putty\wildcard.h" />
|
||||||
<ClInclude Include="..\BeefySysLib\util\BeefPerf.h" />
|
<ClInclude Include="..\BeefySysLib\util\BeefPerf.h" />
|
||||||
<ClInclude Include="..\BeefySysLib\util\String.h" />
|
<ClInclude Include="..\BeefySysLib\util\String.h" />
|
||||||
<ClInclude Include="..\BeefySysLib\util\UTF8.h" />
|
<ClInclude Include="..\BeefySysLib\util\UTF8.h" />
|
||||||
|
@ -479,6 +481,7 @@
|
||||||
<SupportJustMyCode>false</SupportJustMyCode>
|
<SupportJustMyCode>false</SupportJustMyCode>
|
||||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
@ -541,6 +544,7 @@
|
||||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
@ -612,6 +616,7 @@
|
||||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
@ -681,6 +686,7 @@
|
||||||
<ExceptionHandling>false</ExceptionHandling>
|
<ExceptionHandling>false</ExceptionHandling>
|
||||||
<FloatingPointExceptions>false</FloatingPointExceptions>
|
<FloatingPointExceptions>false</FloatingPointExceptions>
|
||||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
|
|
@ -28,6 +28,9 @@
|
||||||
<Filter Include="BeefySysLib\third_party\libffi\x86">
|
<Filter Include="BeefySysLib\third_party\libffi\x86">
|
||||||
<UniqueIdentifier>{f94ea9c5-428b-4925-a59e-b7688752d7d7}</UniqueIdentifier>
|
<UniqueIdentifier>{f94ea9c5-428b-4925-a59e-b7688752d7d7}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
<Filter Include="BeefySysLib\third_party\putty">
|
||||||
|
<UniqueIdentifier>{e790c845-8b10-4edd-b2c0-71e35b0d80b2}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="rt\Internal.cpp">
|
<ClCompile Include="rt\Internal.cpp">
|
||||||
|
@ -87,6 +90,9 @@
|
||||||
<ClCompile Include="..\BeefySysLib\third_party\libffi\src\types.c">
|
<ClCompile Include="..\BeefySysLib\third_party\libffi\src\types.c">
|
||||||
<Filter>BeefySysLib\third_party\libffi</Filter>
|
<Filter>BeefySysLib\third_party\libffi</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\BeefySysLib\third_party\putty\wildcard.c">
|
||||||
|
<Filter>BeefySysLib\third_party\putty</Filter>
|
||||||
|
</ClCompile>
|
||||||
<ClCompile Include="rt\Chars.cpp">
|
<ClCompile Include="rt\Chars.cpp">
|
||||||
<Filter>rt</Filter>
|
<Filter>rt</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -148,6 +154,9 @@
|
||||||
<CustomBuild Include="..\BeefySysLib\third_party\libffi\i686-pc-cygwin\src\x86\win32.asm">
|
<CustomBuild Include="..\BeefySysLib\third_party\libffi\i686-pc-cygwin\src\x86\win32.asm">
|
||||||
<Filter>BeefySysLib\third_party\libffi\x86</Filter>
|
<Filter>BeefySysLib\third_party\libffi\x86</Filter>
|
||||||
</CustomBuild>
|
</CustomBuild>
|
||||||
|
<ClInclude Include="..\BeefySysLib\third_party\putty\wildcard.h">
|
||||||
|
<Filter>BeefySysLib\third_party\putty</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="BeefRT.def" />
|
<None Include="BeefRT.def" />
|
||||||
|
|
|
@ -25,9 +25,9 @@ if(NOT CMAKE_BUILD_TYPE)
|
||||||
endif(NOT CMAKE_BUILD_TYPE)
|
endif(NOT CMAKE_BUILD_TYPE)
|
||||||
|
|
||||||
# Definition of Macros
|
# Definition of Macros
|
||||||
add_definitions(
|
add_definitions(
|
||||||
-DIDEHELPER_EXPORTS
|
-DIDEHELPER_EXPORTS
|
||||||
-DBFSYSLIB_DYNAMIC
|
-DBFSYSLIB_DYNAMIC
|
||||||
-DUNICODE
|
-DUNICODE
|
||||||
-D_UNICODE
|
-D_UNICODE
|
||||||
-DBF_NO_FBX
|
-DBF_NO_FBX
|
||||||
|
@ -45,16 +45,16 @@ if (HAVE_BACKTRACE_HEADERS)
|
||||||
add_definitions(-DBFP_HAS_BACKTRACE)
|
add_definitions(-DBFP_HAS_BACKTRACE)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
if (${IOS})
|
if (${IOS})
|
||||||
include_directories(
|
include_directories(
|
||||||
.
|
.
|
||||||
../BeefySysLib/
|
../BeefySysLib/
|
||||||
../BeefySysLib/third_party
|
../BeefySysLib/third_party
|
||||||
../BeefySysLib/third_party/freetype/include
|
../BeefySysLib/third_party/freetype/include
|
||||||
../BeefySysLib/third_party/libffi/build_iphoneos-arm64/include
|
../BeefySysLib/third_party/libffi/build_iphoneos-arm64/include
|
||||||
../
|
../
|
||||||
../extern
|
../extern
|
||||||
../extern/llvm/include
|
../extern/llvm/include
|
||||||
../extern/llvm_linux/include
|
../extern/llvm_linux/include
|
||||||
../extern/llvm/lib/Target
|
../extern/llvm/lib/Target
|
||||||
|
|
||||||
|
@ -63,13 +63,13 @@ if (${IOS})
|
||||||
elseif (${APPLE})
|
elseif (${APPLE})
|
||||||
include_directories(
|
include_directories(
|
||||||
.
|
.
|
||||||
../BeefySysLib/
|
../BeefySysLib/
|
||||||
../BeefySysLib/third_party
|
../BeefySysLib/third_party
|
||||||
../BeefySysLib/third_party/freetype/include
|
../BeefySysLib/third_party/freetype/include
|
||||||
../BeefySysLib/third_party/libffi/x86_64-apple-darwin${CMAKE_HOST_SYSTEM_VERSION}/include
|
../BeefySysLib/third_party/libffi/x86_64-apple-darwin${CMAKE_HOST_SYSTEM_VERSION}/include
|
||||||
../
|
../
|
||||||
../extern
|
../extern
|
||||||
../extern/llvm/include
|
../extern/llvm/include
|
||||||
../extern/llvm_linux/include
|
../extern/llvm_linux/include
|
||||||
../extern/llvm/lib/Target
|
../extern/llvm/lib/Target
|
||||||
|
|
||||||
|
@ -79,13 +79,13 @@ elseif (${ANDROID})
|
||||||
if (ANDROID_ABI STREQUAL "x86")
|
if (ANDROID_ABI STREQUAL "x86")
|
||||||
include_directories(
|
include_directories(
|
||||||
.
|
.
|
||||||
../BeefySysLib/
|
../BeefySysLib/
|
||||||
../BeefySysLib/third_party
|
../BeefySysLib/third_party
|
||||||
../BeefySysLib/third_party/freetype/include
|
../BeefySysLib/third_party/freetype/include
|
||||||
../BeefySysLib/third_party/libffi/i686-pc-linux-gnu/include
|
../BeefySysLib/third_party/libffi/i686-pc-linux-gnu/include
|
||||||
../
|
../
|
||||||
../extern
|
../extern
|
||||||
../extern/llvm/include
|
../extern/llvm/include
|
||||||
../extern/llvm_linux/include
|
../extern/llvm_linux/include
|
||||||
../extern/llvm/lib/Target
|
../extern/llvm/lib/Target
|
||||||
|
|
||||||
|
@ -94,13 +94,13 @@ elseif (${ANDROID})
|
||||||
elseif (ANDROID_ABI STREQUAL "x86_64")
|
elseif (ANDROID_ABI STREQUAL "x86_64")
|
||||||
include_directories(
|
include_directories(
|
||||||
.
|
.
|
||||||
../BeefySysLib/
|
../BeefySysLib/
|
||||||
../BeefySysLib/third_party
|
../BeefySysLib/third_party
|
||||||
../BeefySysLib/third_party/freetype/include
|
../BeefySysLib/third_party/freetype/include
|
||||||
../BeefySysLib/third_party/libffi/x86_64-pc-linux-gnu/include
|
../BeefySysLib/third_party/libffi/x86_64-pc-linux-gnu/include
|
||||||
../
|
../
|
||||||
../extern
|
../extern
|
||||||
../extern/llvm/include
|
../extern/llvm/include
|
||||||
../extern/llvm_linux/include
|
../extern/llvm_linux/include
|
||||||
../extern/llvm/lib/Target
|
../extern/llvm/lib/Target
|
||||||
|
|
||||||
|
@ -109,28 +109,28 @@ elseif (${ANDROID})
|
||||||
elseif (ANDROID_ABI STREQUAL "armeabi-v7a")
|
elseif (ANDROID_ABI STREQUAL "armeabi-v7a")
|
||||||
include_directories(
|
include_directories(
|
||||||
.
|
.
|
||||||
../BeefySysLib/
|
../BeefySysLib/
|
||||||
../BeefySysLib/third_party
|
../BeefySysLib/third_party
|
||||||
../BeefySysLib/third_party/freetype/include
|
../BeefySysLib/third_party/freetype/include
|
||||||
../BeefySysLib/third_party/libffi/arm-unknown-linux-gnu/include
|
../BeefySysLib/third_party/libffi/arm-unknown-linux-gnu/include
|
||||||
../
|
../
|
||||||
../extern
|
../extern
|
||||||
../extern/llvm/include
|
../extern/llvm/include
|
||||||
../extern/llvm_linux/include
|
../extern/llvm_linux/include
|
||||||
../extern/llvm/lib/Target
|
../extern/llvm/lib/Target
|
||||||
|
|
||||||
../BeefySysLib/platform/android
|
../BeefySysLib/platform/android
|
||||||
)
|
)
|
||||||
else()
|
else()
|
||||||
include_directories(
|
include_directories(
|
||||||
.
|
.
|
||||||
../BeefySysLib/
|
../BeefySysLib/
|
||||||
../BeefySysLib/third_party
|
../BeefySysLib/third_party
|
||||||
../BeefySysLib/third_party/freetype/include
|
../BeefySysLib/third_party/freetype/include
|
||||||
../BeefySysLib/third_party/libffi/aarch64-unknown-linux-gnu/include
|
../BeefySysLib/third_party/libffi/aarch64-unknown-linux-gnu/include
|
||||||
../
|
../
|
||||||
../extern
|
../extern
|
||||||
../extern/llvm/include
|
../extern/llvm/include
|
||||||
../extern/llvm_linux/include
|
../extern/llvm_linux/include
|
||||||
../extern/llvm/lib/Target
|
../extern/llvm/lib/Target
|
||||||
|
|
||||||
|
@ -140,13 +140,13 @@ elseif (${ANDROID})
|
||||||
else()
|
else()
|
||||||
include_directories(
|
include_directories(
|
||||||
.
|
.
|
||||||
../BeefySysLib/
|
../BeefySysLib/
|
||||||
../BeefySysLib/third_party
|
../BeefySysLib/third_party
|
||||||
../BeefySysLib/third_party/freetype/include
|
../BeefySysLib/third_party/freetype/include
|
||||||
../BeefySysLib/third_party/libffi/x86_64-unknown-linux-gnu/include
|
../BeefySysLib/third_party/libffi/x86_64-unknown-linux-gnu/include
|
||||||
../
|
../
|
||||||
../extern
|
../extern
|
||||||
../extern/llvm/include
|
../extern/llvm/include
|
||||||
../extern/llvm_linux/include
|
../extern/llvm_linux/include
|
||||||
../extern/llvm/lib/Target
|
../extern/llvm/lib/Target
|
||||||
|
|
||||||
|
@ -175,16 +175,16 @@ endif()
|
||||||
# Add Dependencies to project. #
|
# Add Dependencies to project. #
|
||||||
###################################################
|
###################################################
|
||||||
|
|
||||||
option(BUILD_DEPENDS
|
option(BUILD_DEPENDS
|
||||||
"Build other CMake project."
|
"Build other CMake project."
|
||||||
ON
|
ON
|
||||||
)
|
)
|
||||||
|
|
||||||
# Dependencies : disable BUILD_DEPENDS to link with lib already build.
|
# Dependencies : disable BUILD_DEPENDS to link with lib already build.
|
||||||
if(BUILD_DEPENDS)
|
if(BUILD_DEPENDS)
|
||||||
|
|
||||||
else()
|
else()
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
################# Flags ################
|
################# Flags ################
|
||||||
|
@ -196,14 +196,14 @@ if(MSVC)
|
||||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /W3 /GL /Od /Oi /Gy /EHsc")
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /W3 /GL /Od /Oi /Gy /EHsc")
|
||||||
endif(MSVC)
|
endif(MSVC)
|
||||||
if(NOT MSVC)
|
if(NOT MSVC)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-rtti -Wno-multichar -Wno-invalid-offsetof")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-rtti -Wno-multichar -Wno-invalid-offsetof")
|
||||||
endif(NOT MSVC)
|
endif(NOT MSVC)
|
||||||
|
|
||||||
################ Files ################
|
################ Files ################
|
||||||
# -- Add files to project. -- #
|
# -- Add files to project. -- #
|
||||||
#######################################
|
#######################################
|
||||||
|
|
||||||
file(GLOB SRC_FILES
|
file(GLOB SRC_FILES
|
||||||
rt/Internal.cpp
|
rt/Internal.cpp
|
||||||
rt/Chars.cpp
|
rt/Chars.cpp
|
||||||
rt/Object.cpp
|
rt/Object.cpp
|
||||||
|
@ -219,8 +219,9 @@ file(GLOB SRC_FILES
|
||||||
../BeefySysLib/util/BeefPerf.cpp
|
../BeefySysLib/util/BeefPerf.cpp
|
||||||
../BeefySysLib/util/String.cpp
|
../BeefySysLib/util/String.cpp
|
||||||
../BeefySysLib/util/UTF8.cpp
|
../BeefySysLib/util/UTF8.cpp
|
||||||
../BeefySysLib/util/Hash.cpp
|
../BeefySysLib/util/Hash.cpp
|
||||||
../BeefySysLib/third_party/utf8proc/utf8proc.c
|
../BeefySysLib/third_party/utf8proc/utf8proc.c
|
||||||
|
../BeefySysLib/third_party/putty/wildcard.c
|
||||||
)
|
)
|
||||||
|
|
||||||
if (${IOS})
|
if (${IOS})
|
||||||
|
@ -282,10 +283,10 @@ endif()
|
||||||
|
|
||||||
if (${APPLE})
|
if (${APPLE})
|
||||||
target_link_libraries(${PROJECT_NAME} pthread ffi)
|
target_link_libraries(${PROJECT_NAME} pthread ffi)
|
||||||
elseif (${ANDROID})
|
elseif (${ANDROID})
|
||||||
#target_link_libraries(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/../BeefySysLib/third_party/libffi/aarch64-unknown-linux-gnu/.libs/libffi.a)
|
#target_link_libraries(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/../BeefySysLib/third_party/libffi/aarch64-unknown-linux-gnu/.libs/libffi.a)
|
||||||
#target_link_libraries(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/../BeefySysLib/third_party/libffi/i686-pc-linux-gnu/.libs/libffi.a)
|
#target_link_libraries(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/../BeefySysLib/third_party/libffi/i686-pc-linux-gnu/.libs/libffi.a)
|
||||||
else()
|
else()
|
||||||
target_link_libraries(${PROJECT_NAME} pthread ffi ${TARGET_LIBS_OS})
|
target_link_libraries(${PROJECT_NAME} pthread ffi ${TARGET_LIBS_OS})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
|
@ -275,6 +275,9 @@
|
||||||
<AdditionalIncludeDirectories>include;include\msvc_compat;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>include;include\msvc_compat;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<DisableSpecificWarnings>4090;4146;4267;4334</DisableSpecificWarnings>
|
<DisableSpecificWarnings>4090;4146;4267;4334</DisableSpecificWarnings>
|
||||||
<ProgramDataBaseFileName>$(OutputPath)$(TargetName).pdb</ProgramDataBaseFileName>
|
<ProgramDataBaseFileName>$(OutputPath)$(TargetName).pdb</ProgramDataBaseFileName>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
@ -292,6 +295,7 @@
|
||||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
<DisableSpecificWarnings>4090;4146;4267;4334</DisableSpecificWarnings>
|
<DisableSpecificWarnings>4090;4146;4267;4334</DisableSpecificWarnings>
|
||||||
<ProgramDataBaseFileName>$(OutputPath)$(TargetName).pdb</ProgramDataBaseFileName>
|
<ProgramDataBaseFileName>$(OutputPath)$(TargetName).pdb</ProgramDataBaseFileName>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
@ -310,6 +314,7 @@
|
||||||
<ProgramDataBaseFileName>$(OutputPath)$(TargetName).pdb</ProgramDataBaseFileName>
|
<ProgramDataBaseFileName>$(OutputPath)$(TargetName).pdb</ProgramDataBaseFileName>
|
||||||
<SupportJustMyCode>false</SupportJustMyCode>
|
<SupportJustMyCode>false</SupportJustMyCode>
|
||||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
@ -329,6 +334,7 @@
|
||||||
<DebugInformationFormat>OldStyle</DebugInformationFormat>
|
<DebugInformationFormat>OldStyle</DebugInformationFormat>
|
||||||
<MinimalRebuild>false</MinimalRebuild>
|
<MinimalRebuild>false</MinimalRebuild>
|
||||||
<SupportJustMyCode>false</SupportJustMyCode>
|
<SupportJustMyCode>false</SupportJustMyCode>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
@ -348,6 +354,7 @@
|
||||||
<DebugInformationFormat>OldStyle</DebugInformationFormat>
|
<DebugInformationFormat>OldStyle</DebugInformationFormat>
|
||||||
<MinimalRebuild>false</MinimalRebuild>
|
<MinimalRebuild>false</MinimalRebuild>
|
||||||
<SupportJustMyCode>false</SupportJustMyCode>
|
<SupportJustMyCode>false</SupportJustMyCode>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
@ -366,6 +373,7 @@
|
||||||
<AdditionalIncludeDirectories>include;include\msvc_compat;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>include;include\msvc_compat;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<DisableSpecificWarnings>4090;4146;4267;4334</DisableSpecificWarnings>
|
<DisableSpecificWarnings>4090;4146;4267;4334</DisableSpecificWarnings>
|
||||||
<ProgramDataBaseFileName>$(OutputPath)$(TargetName).pdb</ProgramDataBaseFileName>
|
<ProgramDataBaseFileName>$(OutputPath)$(TargetName).pdb</ProgramDataBaseFileName>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
@ -387,6 +395,7 @@
|
||||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
<DisableSpecificWarnings>4090;4146;4267;4334</DisableSpecificWarnings>
|
<DisableSpecificWarnings>4090;4146;4267;4334</DisableSpecificWarnings>
|
||||||
<ProgramDataBaseFileName>$(OutputPath)$(TargetName).pdb</ProgramDataBaseFileName>
|
<ProgramDataBaseFileName>$(OutputPath)$(TargetName).pdb</ProgramDataBaseFileName>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
@ -408,6 +417,7 @@
|
||||||
<DisableSpecificWarnings>4090;4146;4267;4334</DisableSpecificWarnings>
|
<DisableSpecificWarnings>4090;4146;4267;4334</DisableSpecificWarnings>
|
||||||
<ProgramDataBaseFileName>$(OutputPath)$(TargetName).pdb</ProgramDataBaseFileName>
|
<ProgramDataBaseFileName>$(OutputPath)$(TargetName).pdb</ProgramDataBaseFileName>
|
||||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
@ -429,6 +439,7 @@
|
||||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||||
<DisableSpecificWarnings>4090;4146;4267;4334</DisableSpecificWarnings>
|
<DisableSpecificWarnings>4090;4146;4267;4334</DisableSpecificWarnings>
|
||||||
<DebugInformationFormat>OldStyle</DebugInformationFormat>
|
<DebugInformationFormat>OldStyle</DebugInformationFormat>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
@ -450,6 +461,7 @@
|
||||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
<DisableSpecificWarnings>4090;4146;4267;4334</DisableSpecificWarnings>
|
<DisableSpecificWarnings>4090;4146;4267;4334</DisableSpecificWarnings>
|
||||||
<DebugInformationFormat>OldStyle</DebugInformationFormat>
|
<DebugInformationFormat>OldStyle</DebugInformationFormat>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
|
|
@ -173,6 +173,7 @@
|
||||||
<PreprocessorDefinitions>MINRT_CONSOLE;BF_NO_BFAPP;BFSYSLIB_DYNAMIC;BFRT_DYNAMIC;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>MINRT_CONSOLE;BF_NO_BFAPP;BFSYSLIB_DYNAMIC;BFRT_DYNAMIC;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<AdditionalIncludeDirectories>.;..;../BeefySysLib/third_party;../BeefySysLib;../BeefySysLib/platform/win;gperftools/src;gperftools/src/windows;../BeefySysLib/third_party/libffi/i686-pc-cygwin;../BeefySysLib/third_party/libffi/i686-pc-cygwin/include;../BeefySysLib/third_party/libffi/include;C:\Program Files (x86)\Microsoft Visual Studio\Preview\Professional\VC\Tools\MSVC\14.14.26412\crt\src\vcruntime</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>.;..;../BeefySysLib/third_party;../BeefySysLib;../BeefySysLib/platform/win;gperftools/src;gperftools/src/windows;../BeefySysLib/third_party/libffi/i686-pc-cygwin;../BeefySysLib/third_party/libffi/i686-pc-cygwin/include;../BeefySysLib/third_party/libffi/include;C:\Program Files (x86)\Microsoft Visual Studio\Preview\Professional\VC\Tools\MSVC\14.14.26412\crt\src\vcruntime</AdditionalIncludeDirectories>
|
||||||
<SupportJustMyCode>false</SupportJustMyCode>
|
<SupportJustMyCode>false</SupportJustMyCode>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
@ -188,6 +189,7 @@
|
||||||
<PreprocessorDefinitions>MINRT_GUI;BF_NO_BFAPP;BFSYSLIB_DYNAMIC;BFRT_DYNAMIC;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>MINRT_GUI;BF_NO_BFAPP;BFSYSLIB_DYNAMIC;BFRT_DYNAMIC;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<AdditionalIncludeDirectories>.;..;../BeefySysLib/third_party;../BeefySysLib;../BeefySysLib/platform/win;gperftools/src;gperftools/src/windows;../BeefySysLib/third_party/libffi/i686-pc-cygwin;../BeefySysLib/third_party/libffi/i686-pc-cygwin/include;../BeefySysLib/third_party/libffi/include;C:\Program Files (x86)\Microsoft Visual Studio\Preview\Professional\VC\Tools\MSVC\14.14.26412\crt\src\vcruntime</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>.;..;../BeefySysLib/third_party;../BeefySysLib;../BeefySysLib/platform/win;gperftools/src;gperftools/src/windows;../BeefySysLib/third_party/libffi/i686-pc-cygwin;../BeefySysLib/third_party/libffi/i686-pc-cygwin/include;../BeefySysLib/third_party/libffi/include;C:\Program Files (x86)\Microsoft Visual Studio\Preview\Professional\VC\Tools\MSVC\14.14.26412\crt\src\vcruntime</AdditionalIncludeDirectories>
|
||||||
<SupportJustMyCode>false</SupportJustMyCode>
|
<SupportJustMyCode>false</SupportJustMyCode>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
@ -208,6 +210,7 @@
|
||||||
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
|
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
|
||||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||||
<AdditionalOptions>/Zc:threadSafeInit- %(AdditionalOptions)</AdditionalOptions>
|
<AdditionalOptions>/Zc:threadSafeInit- %(AdditionalOptions)</AdditionalOptions>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
@ -233,6 +236,7 @@
|
||||||
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
|
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
|
||||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||||
<AdditionalOptions>/Zc:threadSafeInit- %(AdditionalOptions)</AdditionalOptions>
|
<AdditionalOptions>/Zc:threadSafeInit- %(AdditionalOptions)</AdditionalOptions>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
@ -254,6 +258,7 @@
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<PreprocessorDefinitions>MINRT_CONSOLE;BF_SMALL;BF_NO_BFAPP;BFSYSLIB_DYNAMIC;BFRT_DYNAMIC;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>MINRT_CONSOLE;BF_SMALL;BF_NO_BFAPP;BFSYSLIB_DYNAMIC;BFRT_DYNAMIC;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<AdditionalIncludeDirectories>.;..;../BeefySysLib/third_party;../BeefySysLib;../BeefySysLib/platform/win;gperftools/src;gperftools/src/windows;../BeefySysLib/third_party/libffi/i686-pc-cygwin;../BeefySysLib/third_party/libffi/i686-pc-cygwin/include;../BeefySysLib/third_party/libffi/include;C:\Program Files (x86)\Microsoft Visual Studio\Preview\Professional\VC\Tools\MSVC\14.14.26412\crt\src\vcruntime</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>.;..;../BeefySysLib/third_party;../BeefySysLib;../BeefySysLib/platform/win;gperftools/src;gperftools/src/windows;../BeefySysLib/third_party/libffi/i686-pc-cygwin;../BeefySysLib/third_party/libffi/i686-pc-cygwin/include;../BeefySysLib/third_party/libffi/include;C:\Program Files (x86)\Microsoft Visual Studio\Preview\Professional\VC\Tools\MSVC\14.14.26412\crt\src\vcruntime</AdditionalIncludeDirectories>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
@ -272,6 +277,7 @@
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<PreprocessorDefinitions>MINRT_GUI;BF_SMALL;BF_NO_BFAPP;BFSYSLIB_DYNAMIC;BFRT_DYNAMIC;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>MINRT_GUI;BF_SMALL;BF_NO_BFAPP;BFSYSLIB_DYNAMIC;BFRT_DYNAMIC;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<AdditionalIncludeDirectories>.;..;../BeefySysLib/third_party;../BeefySysLib;../BeefySysLib/platform/win;gperftools/src;gperftools/src/windows;../BeefySysLib/third_party/libffi/i686-pc-cygwin;../BeefySysLib/third_party/libffi/i686-pc-cygwin/include;../BeefySysLib/third_party/libffi/include;C:\Program Files (x86)\Microsoft Visual Studio\Preview\Professional\VC\Tools\MSVC\14.14.26412\crt\src\vcruntime</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>.;..;../BeefySysLib/third_party;../BeefySysLib;../BeefySysLib/platform/win;gperftools/src;gperftools/src/windows;../BeefySysLib/third_party/libffi/i686-pc-cygwin;../BeefySysLib/third_party/libffi/i686-pc-cygwin/include;../BeefySysLib/third_party/libffi/include;C:\Program Files (x86)\Microsoft Visual Studio\Preview\Professional\VC\Tools\MSVC\14.14.26412\crt\src\vcruntime</AdditionalIncludeDirectories>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
@ -291,6 +297,7 @@
|
||||||
<PreprocessorDefinitions>MINRT_CONSOLE;BF_SMALL;BF_NO_BFAPP;BFSYSLIB_DYNAMIC;BFRT_DYNAMIC;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>MINRT_CONSOLE;BF_SMALL;BF_NO_BFAPP;BFSYSLIB_DYNAMIC;BFRT_DYNAMIC;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<AdditionalIncludeDirectories>.;..;../BeefySysLib/third_party;../BeefySysLib;../BeefySysLib/platform/win;gperftools/src;gperftools/src/windows;../BeefySysLib/third_party/libffi/i686-pc-cygwin;../BeefySysLib/third_party/libffi/i686-pc-cygwin/include;../BeefySysLib/third_party/libffi/include;C:\Program Files (x86)\Microsoft Visual Studio\Preview\Professional\VC\Tools\MSVC\14.14.26412\crt\src\vcruntime</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>.;..;../BeefySysLib/third_party;../BeefySysLib;../BeefySysLib/platform/win;gperftools/src;gperftools/src/windows;../BeefySysLib/third_party/libffi/i686-pc-cygwin;../BeefySysLib/third_party/libffi/i686-pc-cygwin/include;../BeefySysLib/third_party/libffi/include;C:\Program Files (x86)\Microsoft Visual Studio\Preview\Professional\VC\Tools\MSVC\14.14.26412\crt\src\vcruntime</AdditionalIncludeDirectories>
|
||||||
<AdditionalOptions>/Zc:threadSafeInit- %(AdditionalOptions)</AdditionalOptions>
|
<AdditionalOptions>/Zc:threadSafeInit- %(AdditionalOptions)</AdditionalOptions>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
@ -316,6 +323,7 @@
|
||||||
<AdditionalIncludeDirectories>.;..;../BeefySysLib/third_party;../BeefySysLib;../BeefySysLib/platform/win;gperftools/src;gperftools/src/windows;../BeefySysLib/third_party/libffi/i686-pc-cygwin;../BeefySysLib/third_party/libffi/i686-pc-cygwin/include;../BeefySysLib/third_party/libffi/include;C:\Program Files (x86)\Microsoft Visual Studio\Preview\Professional\VC\Tools\MSVC\14.14.26412\crt\src\vcruntime</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>.;..;../BeefySysLib/third_party;../BeefySysLib;../BeefySysLib/platform/win;gperftools/src;gperftools/src/windows;../BeefySysLib/third_party/libffi/i686-pc-cygwin;../BeefySysLib/third_party/libffi/i686-pc-cygwin/include;../BeefySysLib/third_party/libffi/include;C:\Program Files (x86)\Microsoft Visual Studio\Preview\Professional\VC\Tools\MSVC\14.14.26412\crt\src\vcruntime</AdditionalIncludeDirectories>
|
||||||
<AdditionalOptions>/Zc:threadSafeInit- %(AdditionalOptions)</AdditionalOptions>
|
<AdditionalOptions>/Zc:threadSafeInit- %(AdditionalOptions)</AdditionalOptions>
|
||||||
<ExceptionHandling>false</ExceptionHandling>
|
<ExceptionHandling>false</ExceptionHandling>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
|
|
@ -502,6 +502,7 @@
|
||||||
<AdditionalIncludeDirectories>.;../;../..;../../BeefySysLib/third_party;../../BeefySysLib;../../BeefySysLib/platform/win;../gperftools/src;../gperftools/src/windows</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>.;../;../..;../../BeefySysLib/third_party;../../BeefySysLib;../../BeefySysLib/platform/win;../gperftools/src;../gperftools/src/windows</AdditionalIncludeDirectories>
|
||||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
@ -522,6 +523,7 @@
|
||||||
<AdditionalIncludeDirectories>.;../;../..;../../BeefySysLib/third_party;../../BeefySysLib;../../BeefySysLib/platform/win;../gperftools/src;../gperftools/src/windows</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>.;../;../..;../../BeefySysLib/third_party;../../BeefySysLib;../../BeefySysLib/platform/win;../gperftools/src;../gperftools/src/windows</AdditionalIncludeDirectories>
|
||||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
@ -542,6 +544,7 @@
|
||||||
<AdditionalIncludeDirectories>.;../;../..;../../BeefySysLib/third_party;../../BeefySysLib;../../BeefySysLib/platform/win;../gperftools/src;../gperftools/src/windows</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>.;../;../..;../../BeefySysLib/third_party;../../BeefySysLib;../../BeefySysLib/platform/win;../gperftools/src;../gperftools/src/windows</AdditionalIncludeDirectories>
|
||||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
@ -565,6 +568,7 @@
|
||||||
<SupportJustMyCode>false</SupportJustMyCode>
|
<SupportJustMyCode>false</SupportJustMyCode>
|
||||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
@ -591,6 +595,7 @@
|
||||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
@ -616,6 +621,7 @@
|
||||||
<SupportJustMyCode>false</SupportJustMyCode>
|
<SupportJustMyCode>false</SupportJustMyCode>
|
||||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
@ -640,6 +646,7 @@
|
||||||
<AdditionalIncludeDirectories>.;../;../..;../../BeefySysLib/third_party;../../BeefySysLib;../../BeefySysLib/platform/win;../gperftools/src;../gperftools/src/windows</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>.;../;../..;../../BeefySysLib/third_party;../../BeefySysLib;../../BeefySysLib/platform/win;../gperftools/src;../gperftools/src/windows</AdditionalIncludeDirectories>
|
||||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
@ -660,6 +667,7 @@
|
||||||
<AdditionalIncludeDirectories>.;../;../..;../../BeefySysLib/third_party;../../BeefySysLib;../../BeefySysLib/platform/win;../gperftools/src;../gperftools/src/windows</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>.;../;../..;../../BeefySysLib/third_party;../../BeefySysLib;../../BeefySysLib/platform/win;../gperftools/src;../gperftools/src/windows</AdditionalIncludeDirectories>
|
||||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
@ -680,6 +688,7 @@
|
||||||
<AdditionalIncludeDirectories>.;../;../..;../../BeefySysLib/third_party;../../BeefySysLib;../../BeefySysLib/platform/win;../gperftools/src;../gperftools/src/windows</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>.;../;../..;../../BeefySysLib/third_party;../../BeefySysLib;../../BeefySysLib/platform/win;../gperftools/src;../gperftools/src/windows</AdditionalIncludeDirectories>
|
||||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
@ -700,6 +709,7 @@
|
||||||
<AdditionalIncludeDirectories>.;../;../..;../../BeefySysLib/third_party;../../BeefySysLib;../../BeefySysLib/platform/win;../gperftools/src;../gperftools/src/windows</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>.;../;../..;../../BeefySysLib/third_party;../../BeefySysLib;../../BeefySysLib/platform/win;../gperftools/src;../gperftools/src/windows</AdditionalIncludeDirectories>
|
||||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
@ -722,6 +732,7 @@
|
||||||
<AdditionalIncludeDirectories>.;../;../..;../../BeefySysLib/third_party;../../BeefySysLib;../../BeefySysLib/platform/win;../gperftools/src;../gperftools/src/windows</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>.;../;../..;../../BeefySysLib/third_party;../../BeefySysLib;../../BeefySysLib/platform/win;../gperftools/src;../gperftools/src/windows</AdditionalIncludeDirectories>
|
||||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
@ -744,6 +755,7 @@
|
||||||
<AdditionalIncludeDirectories>.;../;../..;../../BeefySysLib/third_party;../../BeefySysLib;../../BeefySysLib/platform/win;../gperftools/src;../gperftools/src/windows</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>.;../;../..;../../BeefySysLib/third_party;../../BeefySysLib;../../BeefySysLib/platform/win;../gperftools/src;../gperftools/src/windows</AdditionalIncludeDirectories>
|
||||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#include "BeefySysLib/Common.h"
|
#include "BeefySysLib/Common.h"
|
||||||
#include "BeefySysLib/util/String.h"
|
#include "BeefySysLib/util/String.h"
|
||||||
|
|
||||||
#define BFRT_VERSION 9
|
#define BFRT_VERSION 10
|
||||||
|
|
||||||
#ifdef BFRT_DYNAMIC
|
#ifdef BFRT_DYNAMIC
|
||||||
#define BFRT_EXPORT __declspec(dllexport)
|
#define BFRT_EXPORT __declspec(dllexport)
|
||||||
|
@ -99,6 +99,7 @@ namespace bf
|
||||||
bool(*Thread_IsAutoDelete)(bf::System::Threading::Thread* thread);
|
bool(*Thread_IsAutoDelete)(bf::System::Threading::Thread* thread);
|
||||||
void(*Thread_AutoDelete)(bf::System::Threading::Thread* thread);
|
void(*Thread_AutoDelete)(bf::System::Threading::Thread* thread);
|
||||||
int32(*Thread_GetMaxStackSize)(bf::System::Threading::Thread* thread);
|
int32(*Thread_GetMaxStackSize)(bf::System::Threading::Thread* thread);
|
||||||
|
void(*Thread_Exiting)();
|
||||||
void(*GC_MarkAllStaticMembers)();
|
void(*GC_MarkAllStaticMembers)();
|
||||||
bool(*GC_CallRootCallbacks)();
|
bool(*GC_CallRootCallbacks)();
|
||||||
void(*GC_Shutdown)();
|
void(*GC_Shutdown)();
|
||||||
|
@ -107,7 +108,7 @@ namespace bf
|
||||||
void(*DebugMessageData_SetupProfilerCmd)(const char* str);
|
void(*DebugMessageData_SetupProfilerCmd)(const char* str);
|
||||||
void(*DebugMessageData_Fatal)();
|
void(*DebugMessageData_Fatal)();
|
||||||
void(*DebugMessageData_Clear)();
|
void(*DebugMessageData_Clear)();
|
||||||
int(*CheckErrorHandler)(const char* kind, const char* arg1, const char* arg2, intptr arg3);
|
int(*CheckErrorHandler)(const char* kind, const char* arg1, const char* arg2, intptr arg3);
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -55,6 +55,12 @@ static Beefy::StringT<0> gCmdLineString;
|
||||||
bf::System::Runtime::BfRtCallbacks gBfRtCallbacks;
|
bf::System::Runtime::BfRtCallbacks gBfRtCallbacks;
|
||||||
BfRtFlags gBfRtFlags = (BfRtFlags)0;
|
BfRtFlags gBfRtFlags = (BfRtFlags)0;
|
||||||
|
|
||||||
|
#ifdef BF_PLATFORM_WINDOWS
|
||||||
|
DWORD gBfTLSKey = 0;
|
||||||
|
#else
|
||||||
|
pthread_key_t gBfTLSKey = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
static int gTestMethodIdx = -1;
|
static int gTestMethodIdx = -1;
|
||||||
static uint32 gTestStartTick = 0;
|
static uint32 gTestStartTick = 0;
|
||||||
static bool gTestBreakOnFailure = false;
|
static bool gTestBreakOnFailure = false;
|
||||||
|
@ -86,6 +92,7 @@ namespace bf
|
||||||
BFRT_EXPORT static void ObjectDynCheck(Object* object, int typeId, bool allowNull);
|
BFRT_EXPORT static void ObjectDynCheck(Object* object, int typeId, bool allowNull);
|
||||||
BFRT_EXPORT static void ObjectDynCheckFailed(Object* object, int typeId);
|
BFRT_EXPORT static void ObjectDynCheckFailed(Object* object, int typeId);
|
||||||
BFRT_EXPORT static void ThrowIndexOutOfRange(intptr stackOffset);
|
BFRT_EXPORT static void ThrowIndexOutOfRange(intptr stackOffset);
|
||||||
|
BFRT_EXPORT static void ThrowObjectNotInitialized(intptr stackOffset);
|
||||||
BFRT_EXPORT static void FatalError(String* error, intptr stackOffset = 0);
|
BFRT_EXPORT static void FatalError(String* error, intptr stackOffset = 0);
|
||||||
BFRT_EXPORT static void MemCpy(void* dest, void* src, intptr length);
|
BFRT_EXPORT static void MemCpy(void* dest, void* src, intptr length);
|
||||||
BFRT_EXPORT static void MemMove(void* dest, void* src, intptr length);
|
BFRT_EXPORT static void MemMove(void* dest, void* src, intptr length);
|
||||||
|
@ -286,6 +293,11 @@ static void GetCrashInfo()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void NTAPI TlsFreeFunc(void* ptr)
|
||||||
|
{
|
||||||
|
gBfRtCallbacks.Thread_Exiting();
|
||||||
|
}
|
||||||
|
|
||||||
void bf::System::Runtime::Init(int version, int flags, BfRtCallbacks* callbacks)
|
void bf::System::Runtime::Init(int version, int flags, BfRtCallbacks* callbacks)
|
||||||
{
|
{
|
||||||
BfpSystemInitFlags sysInitFlags = BfpSystemInitFlag_InstallCrashCatcher;
|
BfpSystemInitFlags sysInitFlags = BfpSystemInitFlag_InstallCrashCatcher;
|
||||||
|
@ -342,6 +354,12 @@ void bf::System::Runtime::Init(int version, int flags, BfRtCallbacks* callbacks)
|
||||||
useCmdLineStr++;
|
useCmdLineStr++;
|
||||||
}
|
}
|
||||||
gCmdLineString = useCmdLineStr;
|
gCmdLineString = useCmdLineStr;
|
||||||
|
|
||||||
|
#ifdef BF_PLATFORM_WINDOWS
|
||||||
|
gBfTLSKey = FlsAlloc(TlsFreeFunc);
|
||||||
|
#else
|
||||||
|
pthread_key_create(&gBfTLSKey, TlsFreeFunc);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void bf::System::Runtime::SetErrorString(char* errorStr)
|
void bf::System::Runtime::SetErrorString(char* errorStr)
|
||||||
|
@ -423,6 +441,30 @@ void Internal::ThrowIndexOutOfRange(intptr stackOffset)
|
||||||
Internal_FatalError("Index out of range");
|
Internal_FatalError("Index out of range");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Internal::ThrowObjectNotInitialized(intptr stackOffset)
|
||||||
|
{
|
||||||
|
if (gClientPipe != NULL)
|
||||||
|
{
|
||||||
|
if (gTestBreakOnFailure)
|
||||||
|
{
|
||||||
|
SETUP_ERROR("Object not initialized", (int)(2 + stackOffset));
|
||||||
|
BF_DEBUG_BREAK();
|
||||||
|
}
|
||||||
|
|
||||||
|
Beefy::String str = ":TestFail\tObject not initialized\n";
|
||||||
|
TestString(str);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((stackOffset != -1) && (::IsDebuggerPresent()))
|
||||||
|
{
|
||||||
|
SETUP_ERROR("Object not initialized", (int)(2 + stackOffset));
|
||||||
|
BF_DEBUG_BREAK();
|
||||||
|
}
|
||||||
|
|
||||||
|
Internal_FatalError("Object not initialized");
|
||||||
|
}
|
||||||
|
|
||||||
void Internal::FatalError(bf::System::String* error, intptr stackOffset)
|
void Internal::FatalError(bf::System::String* error, intptr stackOffset)
|
||||||
{
|
{
|
||||||
if (gClientPipe != NULL)
|
if (gClientPipe != NULL)
|
||||||
|
|
|
@ -19,6 +19,12 @@ BF_TLS_DECLSPEC Thread* Thread::sCurrentThread;
|
||||||
static volatile int gLiveThreadCount;
|
static volatile int gLiveThreadCount;
|
||||||
static Beefy::SyncEvent gThreadsDoneEvent;
|
static Beefy::SyncEvent gThreadsDoneEvent;
|
||||||
|
|
||||||
|
#ifdef BF_PLATFORM_WINDOWS
|
||||||
|
extern DWORD gBfTLSKey;
|
||||||
|
#else
|
||||||
|
extern pthread_key_t gBfTLSKey;
|
||||||
|
#endif
|
||||||
|
|
||||||
bf::System::Threading::Thread* BfGetCurrentThread()
|
bf::System::Threading::Thread* BfGetCurrentThread()
|
||||||
{
|
{
|
||||||
#ifdef BF_THREAD_TLS
|
#ifdef BF_THREAD_TLS
|
||||||
|
@ -133,7 +139,8 @@ static void BF_CALLTYPE CStartProc(void* threadParam)
|
||||||
bool wantsDelete = false;
|
bool wantsDelete = false;
|
||||||
//
|
//
|
||||||
{
|
{
|
||||||
internalThread->ThreadStopped();
|
internalThread->ThreadStopped();
|
||||||
|
|
||||||
Beefy::AutoCrit autoCrit(internalThread->mCritSect);
|
Beefy::AutoCrit autoCrit(internalThread->mCritSect);
|
||||||
if (isAutoDelete)
|
if (isAutoDelete)
|
||||||
gBfRtCallbacks.Thread_AutoDelete(thread);
|
gBfRtCallbacks.Thread_AutoDelete(thread);
|
||||||
|
@ -207,15 +214,28 @@ void Thread::StartInternal()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Thread::RequestExitNotify()
|
||||||
|
{
|
||||||
|
// Do we already have implicit exiting notification?
|
||||||
|
if (BfGetCurrentThread() != NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
#ifdef BF_PLATFORM_WINDOWS
|
||||||
|
FlsSetValue(gBfTLSKey, (void*)&gBfRtCallbacks);
|
||||||
|
#else
|
||||||
|
pthread_setspecific(gBfTLSKey, (void*)&gBfRtCallbacks);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void Thread::ThreadStarted()
|
void Thread::ThreadStarted()
|
||||||
{
|
{
|
||||||
auto internalThread = GetInternalThread();
|
auto internalThread = GetInternalThread();
|
||||||
internalThread->mCritSect.Unlock();
|
internalThread->mCritSect.Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
int Thread::GetThreadId()
|
intptr Thread::GetThreadId()
|
||||||
{
|
{
|
||||||
return (int)GetInternalThread()->mThreadId;
|
return GetInternalThread()->mThreadId;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Thread::SetStackStart(void* ptr)
|
void Thread::SetStackStart(void* ptr)
|
||||||
|
|
|
@ -39,7 +39,7 @@ namespace bf
|
||||||
private:
|
private:
|
||||||
BfInternalThread* SetupInternalThread();
|
BfInternalThread* SetupInternalThread();
|
||||||
|
|
||||||
BFRT_EXPORT void ManualThreadInit();
|
BFRT_EXPORT void ManualThreadInit();
|
||||||
BFRT_EXPORT int GetPriorityNative();
|
BFRT_EXPORT int GetPriorityNative();
|
||||||
BFRT_EXPORT void SetPriorityNative(int priority);
|
BFRT_EXPORT void SetPriorityNative(int priority);
|
||||||
BFRT_EXPORT void SetJoinOnDelete(bool joinOnDelete);
|
BFRT_EXPORT void SetJoinOnDelete(bool joinOnDelete);
|
||||||
|
@ -59,7 +59,7 @@ namespace bf
|
||||||
BFRT_EXPORT void SetBackgroundNative(bool isBackground);
|
BFRT_EXPORT void SetBackgroundNative(bool isBackground);
|
||||||
BFRT_EXPORT int GetThreadStateNative();
|
BFRT_EXPORT int GetThreadStateNative();
|
||||||
BFRT_EXPORT void InformThreadNameChange(String* name);
|
BFRT_EXPORT void InformThreadNameChange(String* name);
|
||||||
BFRT_EXPORT int GetThreadId();
|
BFRT_EXPORT intptr GetThreadId();
|
||||||
|
|
||||||
BFRT_EXPORT void Dbg_CreateInternal();
|
BFRT_EXPORT void Dbg_CreateInternal();
|
||||||
|
|
||||||
|
@ -68,6 +68,7 @@ namespace bf
|
||||||
BFRT_EXPORT void Resume();
|
BFRT_EXPORT void Resume();
|
||||||
BFRT_EXPORT void Abort();
|
BFRT_EXPORT void Abort();
|
||||||
|
|
||||||
|
BFRT_EXPORT static void RequestExitNotify();
|
||||||
BFRT_EXPORT static void MemoryBarrier();
|
BFRT_EXPORT static void MemoryBarrier();
|
||||||
|
|
||||||
static Thread* Alloc()
|
static Thread* Alloc()
|
||||||
|
|
|
@ -35,7 +35,7 @@ uint32 BfTLSManager::Alloc()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mAllocatedKeys[idx] = BfpTLS_Create();
|
mAllocatedKeys[idx] = BfpTLS_Create(NULL);
|
||||||
mAssociatedTLSDatums[idx] = NULL;
|
mAssociatedTLSDatums[idx] = NULL;
|
||||||
return idx;
|
return idx;
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ public:
|
||||||
|
|
||||||
BfTLSManager()
|
BfTLSManager()
|
||||||
{
|
{
|
||||||
sInternalThreadKey = BfpTLS_Create();
|
sInternalThreadKey = BfpTLS_Create(NULL);
|
||||||
mAssociatedTLSDatums = NULL;
|
mAssociatedTLSDatums = NULL;
|
||||||
mAllocSize = 0;
|
mAllocSize = 0;
|
||||||
mAllocIdx = 1;
|
mAllocIdx = 1;
|
||||||
|
|
|
@ -23,9 +23,9 @@ endif(NOT CMAKE_BUILD_TYPE)
|
||||||
|
|
||||||
# Definition of Macros
|
# Definition of Macros
|
||||||
add_definitions(
|
add_definitions(
|
||||||
-D_DEBUG
|
-D_DEBUG
|
||||||
-DIDEHELPER_EXPORTS
|
-DIDEHELPER_EXPORTS
|
||||||
-DBFSYSLIB_DYNAMIC
|
-DBFSYSLIB_DYNAMIC
|
||||||
-DUNICODE
|
-DUNICODE
|
||||||
-D_UNICODE
|
-D_UNICODE
|
||||||
-DBF_NO_FBX
|
-DBF_NO_FBX
|
||||||
|
@ -40,9 +40,9 @@ include_directories(
|
||||||
../BeefySysLib/third_party
|
../BeefySysLib/third_party
|
||||||
../BeefySysLib/third_party/freetype/include
|
../BeefySysLib/third_party/freetype/include
|
||||||
../BeefySysLib/third_party/libffi/x86_64-unknown-linux-gnu/include
|
../BeefySysLib/third_party/libffi/x86_64-unknown-linux-gnu/include
|
||||||
../
|
../
|
||||||
../extern
|
../extern
|
||||||
../extern/llvm/include
|
../extern/llvm/include
|
||||||
../extern/llvm_linux/include
|
../extern/llvm_linux/include
|
||||||
../extern/llvm/lib/Target
|
../extern/llvm/lib/Target
|
||||||
../extern/llvm_linux/lib/Target/X86
|
../extern/llvm_linux/lib/Target/X86
|
||||||
|
@ -66,16 +66,16 @@ endif()
|
||||||
# Add Dependencies to project. #
|
# Add Dependencies to project. #
|
||||||
###################################################
|
###################################################
|
||||||
|
|
||||||
option(BUILD_DEPENDS
|
option(BUILD_DEPENDS
|
||||||
"Build other CMake project."
|
"Build other CMake project."
|
||||||
ON
|
ON
|
||||||
)
|
)
|
||||||
|
|
||||||
# Dependencies : disable BUILD_DEPENDS to link with lib already build.
|
# Dependencies : disable BUILD_DEPENDS to link with lib already build.
|
||||||
if(BUILD_DEPENDS)
|
if(BUILD_DEPENDS)
|
||||||
|
|
||||||
else()
|
else()
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
################# Flags ################
|
################# Flags ################
|
||||||
|
@ -87,7 +87,7 @@ if(MSVC)
|
||||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /W3 /GL /Od /Oi /Gy /EHsc")
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /W3 /GL /Od /Oi /Gy /EHsc")
|
||||||
endif(MSVC)
|
endif(MSVC)
|
||||||
if(NOT MSVC)
|
if(NOT MSVC)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-rtti -Wno-multichar -Wno-invalid-offsetof")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-rtti -Wno-multichar -Wno-invalid-offsetof")
|
||||||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
|
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
|
||||||
endif()
|
endif()
|
||||||
|
@ -97,8 +97,8 @@ endif(NOT MSVC)
|
||||||
# -- Add files to project. -- #
|
# -- Add files to project. -- #
|
||||||
#######################################
|
#######################################
|
||||||
|
|
||||||
file(GLOB SRC_FILES
|
file(GLOB SRC_FILES
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Add library to build.
|
# Add library to build.
|
||||||
|
|
|
@ -106,11 +106,6 @@ namespace BeefPerf
|
||||||
delete client;
|
delete client;
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget.RemoveAndDelete(mWorkspacePanel);
|
|
||||||
Widget.RemoveAndDelete(mBoard);
|
|
||||||
Widget.RemoveAndDelete(mProfilePanel);
|
|
||||||
Widget.RemoveAndDelete(mFindPanel);
|
|
||||||
|
|
||||||
if (!mLogLines.IsEmpty)
|
if (!mLogLines.IsEmpty)
|
||||||
{
|
{
|
||||||
var fs = scope FileStream();
|
var fs = scope FileStream();
|
||||||
|
@ -122,7 +117,7 @@ namespace BeefPerf
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32 TimeToUnixTime(DateTime ft)
|
static uint32 TimeToUnixTime(DateTime ft)
|
||||||
{
|
{
|
||||||
// takes the last modified date
|
// takes the last modified date
|
||||||
|
@ -267,6 +262,15 @@ namespace BeefPerf
|
||||||
{
|
{
|
||||||
base.Stop();
|
base.Stop();
|
||||||
mListenSocket.Close();
|
mListenSocket.Close();
|
||||||
|
|
||||||
|
Widget.RemoveAndDelete(mWorkspacePanel);
|
||||||
|
mWorkspacePanel = null;
|
||||||
|
Widget.RemoveAndDelete(mBoard);
|
||||||
|
mBoard = null;
|
||||||
|
Widget.RemoveAndDelete(mProfilePanel);
|
||||||
|
mProfilePanel = null;
|
||||||
|
Widget.RemoveAndDelete(mFindPanel);
|
||||||
|
mFindPanel = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShowWorkspacePanel()
|
void ShowWorkspacePanel()
|
||||||
|
@ -517,7 +521,6 @@ namespace BeefPerf
|
||||||
public override void Shutdown()
|
public override void Shutdown()
|
||||||
{
|
{
|
||||||
base.Shutdown();
|
base.Shutdown();
|
||||||
|
|
||||||
mShutdownEvent.Set(true);
|
mShutdownEvent.Set(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -138,9 +138,7 @@ void TestMem()
|
||||||
char* mem = (char*)::VirtualAlloc(0, 4096 * 2, MEM_RESERVE, PAGE_READWRITE);
|
char* mem = (char*)::VirtualAlloc(0, 4096 * 2, MEM_RESERVE, PAGE_READWRITE);
|
||||||
::VirtualAlloc(mem, 4096, MEM_COMMIT, PAGE_READWRITE);
|
::VirtualAlloc(mem, 4096, MEM_COMMIT, PAGE_READWRITE);
|
||||||
|
|
||||||
char* str = "Hey";
|
|
||||||
char* cPtr = mem + 4096 - 3;
|
|
||||||
memcpy(cPtr, str, 3);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Test6()
|
void Test6()
|
||||||
|
@ -163,10 +161,41 @@ void Test3(int a)
|
||||||
Test4(100, 200, 300);
|
Test4(100, 200, 300);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#pragma pack(1)
|
||||||
|
class TestStruct
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
int mA;
|
||||||
|
int mB;
|
||||||
|
int mC;
|
||||||
|
int mD;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum EnumVal
|
||||||
|
{
|
||||||
|
EnumVal_A,
|
||||||
|
EnumVal_B,
|
||||||
|
EnumVal_C
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Color
|
||||||
|
{
|
||||||
|
float r, g, b, a;
|
||||||
|
};
|
||||||
|
|
||||||
// THIS IS VERSION 6.
|
// THIS IS VERSION 6.
|
||||||
extern "C"
|
extern "C"
|
||||||
__declspec(dllexport) void Test2(int aa, int bb, int cc, int dd)
|
__declspec(dllexport) void Test2(int aa, int bb, int cc, int dd, Color func(int a, int b))
|
||||||
{
|
{
|
||||||
|
Color clr = func(100, 200);
|
||||||
|
|
||||||
|
EnumVal ev = EnumVal_A;
|
||||||
|
|
||||||
|
TestStruct ts;
|
||||||
|
ts.mA = 123;
|
||||||
|
ts.mB = 234;
|
||||||
|
|
||||||
int a = 1234;
|
int a = 1234;
|
||||||
|
|
||||||
for (int i = 0; i < 100; i++)
|
for (int i = 0; i < 100; i++)
|
||||||
|
@ -174,9 +203,7 @@ __declspec(dllexport) void Test2(int aa, int bb, int cc, int dd)
|
||||||
a++;
|
a++;
|
||||||
}
|
}
|
||||||
|
|
||||||
Test3(10);
|
Test3(10);
|
||||||
|
|
||||||
char* strP = "Hey yo";
|
|
||||||
|
|
||||||
TestMem();
|
TestMem();
|
||||||
|
|
||||||
|
|
|
@ -22,32 +22,32 @@
|
||||||
<ProjectGuid>{14700A80-0FC4-4A3D-99EF-8B78D4B070F1}</ProjectGuid>
|
<ProjectGuid>{14700A80-0FC4-4A3D-99EF-8B78D4B070F1}</ProjectGuid>
|
||||||
<Keyword>Win32Proj</Keyword>
|
<Keyword>Win32Proj</Keyword>
|
||||||
<RootNamespace>TestDLL</RootNamespace>
|
<RootNamespace>TestDLL</RootNamespace>
|
||||||
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
|
<WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
<PlatformToolset>v141</PlatformToolset>
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
<PlatformToolset>v141</PlatformToolset>
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
<PlatformToolset>v141</PlatformToolset>
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
<PlatformToolset>v141</PlatformToolset>
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
@ -104,7 +104,7 @@
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<AdditionalIncludeDirectories>\Beef\BeefySysLib;\Beef\BeefySysLib\third_party</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>\Beef\BeefySysLib;\Beef\BeefySysLib\third_party;C:\temp\Chipmunk-7.0.3\include</AdditionalIncludeDirectories>
|
||||||
<LanguageStandard>stdcpplatest</LanguageStandard>
|
<LanguageStandard>stdcpplatest</LanguageStandard>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
|
@ -112,7 +112,8 @@
|
||||||
<GenerateDebugInformation>DebugFull</GenerateDebugInformation>
|
<GenerateDebugInformation>DebugFull</GenerateDebugInformation>
|
||||||
</Link>
|
</Link>
|
||||||
<PostBuildEvent>
|
<PostBuildEvent>
|
||||||
<Command>copy C:\Beef\BeefTools\TestDLL\x64\Debug\TestDLL.dll c:\beef\ide\mintest\build\release_win64\mintest</Command>
|
<Command>
|
||||||
|
</Command>
|
||||||
</PostBuildEvent>
|
</PostBuildEvent>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
@ -152,6 +153,7 @@
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClCompile Include="demo.c" />
|
||||||
<ClCompile Include="TestDLL.cpp" />
|
<ClCompile Include="TestDLL.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
|
|
@ -222,7 +222,7 @@ void BFApp::Process()
|
||||||
mClientUpdateCntF = mUpdateCntF - 1;
|
mClientUpdateCntF = mUpdateCntF - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((int)mClientUpdateCntF < (int)mUpdateCntF)
|
while ((mRunning) && ((int)mClientUpdateCntF < (int)mUpdateCntF))
|
||||||
{
|
{
|
||||||
Update(didUpdateCnt == 0);
|
Update(didUpdateCnt == 0);
|
||||||
didUpdateCnt++;
|
didUpdateCnt++;
|
||||||
|
@ -232,7 +232,7 @@ void BFApp::Process()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only attempt UpdateF updates if our rates aren't nearly the same
|
// Only attempt UpdateF updates if our rates aren't nearly the same
|
||||||
if ((mRefreshRate != 0) && (fabs(physRefreshRate - mRefreshRate) / (float)mRefreshRate > 0.1f))
|
if ((mRunning) && (mRefreshRate != 0) && (fabs(physRefreshRate - mRefreshRate) / (float)mRefreshRate > 0.1f))
|
||||||
{
|
{
|
||||||
float updateFAmt = (float)(mUpdateCntF - mClientUpdateCntF);
|
float updateFAmt = (float)(mUpdateCntF - mClientUpdateCntF);
|
||||||
if ((updateFAmt > 0.05f) && (updateFAmt < 1.0f) && (didUpdateCnt < maxUpdates))
|
if ((updateFAmt > 0.05f) && (updateFAmt < 1.0f) && (didUpdateCnt < maxUpdates))
|
||||||
|
|
|
@ -188,6 +188,7 @@
|
||||||
<AdditionalIncludeDirectories>./;./platform/win/;./platform/sdl/;third_party/agg-2.4/include;third_party/agg-2.4/include/platform/win32;third_party/;third_party/libffi/i686-pc-cygwin;third_party/libffi/i686-pc-cygwin/include;third_party/libffi/include;third_party/SDL2-2.0.1/include;../extern/fbxsdk/include;third_party/freetype/include</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>./;./platform/win/;./platform/sdl/;third_party/agg-2.4/include;third_party/agg-2.4/include/platform/win32;third_party/;third_party/libffi/i686-pc-cygwin;third_party/libffi/i686-pc-cygwin/include;third_party/libffi/include;third_party/SDL2-2.0.1/include;../extern/fbxsdk/include;third_party/freetype/include</AdditionalIncludeDirectories>
|
||||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||||
<SupportJustMyCode>false</SupportJustMyCode>
|
<SupportJustMyCode>false</SupportJustMyCode>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
@ -224,6 +225,7 @@ copy /y "$(OutDir)$(TargetName).lib" "$(SolutionDir)\BeefLibs\Beefy2D\dist\"</Co
|
||||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
<SupportJustMyCode>false</SupportJustMyCode>
|
<SupportJustMyCode>false</SupportJustMyCode>
|
||||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
@ -311,6 +313,7 @@ copy /y "$(OutDir)$(TargetName).lib" "$(SolutionDir)\BeefLibs\Beefy2D\dist\"</Co
|
||||||
<PreprocessorDefinitions>BFP_NOEXPORT;_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_WINDOWS;_USRDLL;BFSYSLIB_DYNAMIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>BFP_NOEXPORT;_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_WINDOWS;_USRDLL;BFSYSLIB_DYNAMIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||||
<AdditionalIncludeDirectories>./; ./platform/win/; ./platform/sdl/; third_party/agg-2.4/include; third_party/agg-2.4/include/platform/win32; third_party/; third_party/libffi/i686-pc-cygwin; third_party/libffi/i686-pc-cygwin/include; third_party/libffi/include; third_party/SDL2-2.0.1/include;;../extern/fbxsdk/include</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>./; ./platform/win/; ./platform/sdl/; third_party/agg-2.4/include; third_party/agg-2.4/include/platform/win32; third_party/; third_party/libffi/i686-pc-cygwin; third_party/libffi/i686-pc-cygwin/include; third_party/libffi/include; third_party/SDL2-2.0.1/include;;../extern/fbxsdk/include</AdditionalIncludeDirectories>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
@ -348,6 +351,7 @@ copy /y "$(OutDir)$(TargetName).lib" "$(SolutionDir)\BeefLibs\Beefy2D\dist\"</Co
|
||||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
<AdditionalIncludeDirectories>./;./platform/win/;./platform/sdl/;third_party/agg-2.4/include;third_party/agg-2.4/include/platform/win32;third_party/;third_party/libffi/i686-pc-cygwin;third_party/libffi/i686-pc-cygwin/include;third_party/libffi/include;third_party/SDL2-2.0.1/include;../extern/fbxsdk/include;third_party/freetype/include</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>./;./platform/win/;./platform/sdl/;third_party/agg-2.4/include;third_party/agg-2.4/include/platform/win32;third_party/;third_party/libffi/i686-pc-cygwin;third_party/libffi/i686-pc-cygwin/include;third_party/libffi/include;third_party/SDL2-2.0.1/include;../extern/fbxsdk/include;third_party/freetype/include</AdditionalIncludeDirectories>
|
||||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
@ -1926,6 +1930,7 @@ copy /y "$(OutDir)$(TargetName).lib" "$(SolutionDir)\BeefLibs\Beefy2D\dist\"</Co
|
||||||
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Release Static|x64'">TurnOffAllWarnings</WarningLevel>
|
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Release Static|x64'">TurnOffAllWarnings</WarningLevel>
|
||||||
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Release|x64'">TurnOffAllWarnings</WarningLevel>
|
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Release|x64'">TurnOffAllWarnings</WarningLevel>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="third_party\putty\wildcard.c" />
|
||||||
<ClCompile Include="util\AllocDebug.cpp" />
|
<ClCompile Include="util\AllocDebug.cpp" />
|
||||||
<ClCompile Include="util\BeefPerf.cpp" />
|
<ClCompile Include="util\BeefPerf.cpp" />
|
||||||
<ClCompile Include="util\BSpline.cpp" />
|
<ClCompile Include="util\BSpline.cpp" />
|
||||||
|
@ -2152,6 +2157,7 @@ copy /y "$(OutDir)$(TargetName).lib" "$(SolutionDir)\BeefLibs\Beefy2D\dist\"</Co
|
||||||
<ClInclude Include="third_party\zlib\zconf.h" />
|
<ClInclude Include="third_party\zlib\zconf.h" />
|
||||||
<ClInclude Include="third_party\zlib\zlib.h" />
|
<ClInclude Include="third_party\zlib\zlib.h" />
|
||||||
<ClInclude Include="third_party\zlib\zutil.h" />
|
<ClInclude Include="third_party\zlib\zutil.h" />
|
||||||
|
<ClInclude Include="third_party\putty\wildcard.h" />
|
||||||
<ClInclude Include="Util\AllocDebug.h" />
|
<ClInclude Include="Util\AllocDebug.h" />
|
||||||
<ClInclude Include="util\Array.h" />
|
<ClInclude Include="util\Array.h" />
|
||||||
<ClInclude Include="util\BeefPerf.h" />
|
<ClInclude Include="util\BeefPerf.h" />
|
||||||
|
|
|
@ -78,6 +78,9 @@
|
||||||
<Filter Include="src\third_party\miniz">
|
<Filter Include="src\third_party\miniz">
|
||||||
<UniqueIdentifier>{a159b9ee-1a71-44f5-a412-1e01e20b70c7}</UniqueIdentifier>
|
<UniqueIdentifier>{a159b9ee-1a71-44f5-a412-1e01e20b70c7}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
<Filter Include="src\third_party\putty">
|
||||||
|
<UniqueIdentifier>{0007a912-9292-4e32-8884-0f0cd276e42d}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="platform\win\DXRenderDevice.cpp">
|
<ClCompile Include="platform\win\DXRenderDevice.cpp">
|
||||||
|
@ -731,6 +734,9 @@
|
||||||
<ClCompile Include="util\ZipFile.cpp">
|
<ClCompile Include="util\ZipFile.cpp">
|
||||||
<Filter>src\util</Filter>
|
<Filter>src\util</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="third_party\putty\wildcard.c">
|
||||||
|
<Filter>src\third_party\putty</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="Common.h">
|
<ClInclude Include="Common.h">
|
||||||
|
@ -1123,6 +1129,9 @@
|
||||||
<ClInclude Include="util\ZipFile.h">
|
<ClInclude Include="util\ZipFile.h">
|
||||||
<Filter>src\util</Filter>
|
<Filter>src\util</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="third_party\putty\wildcard.h">
|
||||||
|
<Filter>src\third_party\putty</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<CustomBuild Include="third_party\libffi\i686-pc-cygwin\src\x86\win32.asm">
|
<CustomBuild Include="third_party\libffi\i686-pc-cygwin\src\x86\win32.asm">
|
||||||
|
|
|
@ -102,6 +102,7 @@
|
||||||
<PreprocessorDefinitions>BFP_INTERNAL;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_WINDOWS;_USRDLL;BF_NO_FBX;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>BFP_INTERNAL;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_WINDOWS;_USRDLL;BF_NO_FBX;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<AdditionalIncludeDirectories>./;./platform/win/;./platform/sdl/;third_party/agg-2.4/include;third_party/agg-2.4/include/platform/win32;third_party/;third_party/libffi/i686-pc-cygwin;third_party/libffi/i686-pc-cygwin/include;third_party/libffi/include;third_party/SDL2-2.0.1/include;../extern/fbxsdk/include;third_party/freetype/include</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>./;./platform/win/;./platform/sdl/;third_party/agg-2.4/include;third_party/agg-2.4/include/platform/win32;third_party/;third_party/libffi/i686-pc-cygwin;third_party/libffi/i686-pc-cygwin/include;third_party/libffi/include;third_party/SDL2-2.0.1/include;../extern/fbxsdk/include;third_party/freetype/include</AdditionalIncludeDirectories>
|
||||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
@ -125,6 +126,7 @@
|
||||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
<SupportJustMyCode>false</SupportJustMyCode>
|
<SupportJustMyCode>false</SupportJustMyCode>
|
||||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
@ -143,6 +145,7 @@
|
||||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_WINDOWS;_USRDLL;BFSYSLIB_DYNAMIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_WINDOWS;_USRDLL;BFSYSLIB_DYNAMIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
<AdditionalIncludeDirectories>./; ./platform/win/; ./platform/sdl/; third_party/agg-2.4/include; third_party/agg-2.4/include/platform/win32; third_party/; third_party/libffi/i686-pc-cygwin; third_party/libffi/i686-pc-cygwin/include; third_party/libffi/include; third_party/SDL2-2.0.1/include;;../extern/fbxsdk/include</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>./; ./platform/win/; ./platform/sdl/; third_party/agg-2.4/include; third_party/agg-2.4/include/platform/win32; third_party/; third_party/libffi/i686-pc-cygwin; third_party/libffi/i686-pc-cygwin/include; third_party/libffi/include; third_party/SDL2-2.0.1/include;;../extern/fbxsdk/include</AdditionalIncludeDirectories>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
@ -167,6 +170,7 @@
|
||||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
<AdditionalIncludeDirectories>./;./platform/win/;./platform/sdl/;third_party/agg-2.4/include;third_party/agg-2.4/include/platform/win32;third_party/;third_party/libffi/i686-pc-cygwin;third_party/libffi/i686-pc-cygwin/include;third_party/libffi/include;third_party/SDL2-2.0.1/include;../extern/fbxsdk/include;third_party/freetype/include</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>./;./platform/win/;./platform/sdl/;third_party/agg-2.4/include;third_party/agg-2.4/include/platform/win32;third_party/;third_party/libffi/i686-pc-cygwin;third_party/libffi/i686-pc-cygwin/include;third_party/libffi/include;third_party/SDL2-2.0.1/include;../extern/fbxsdk/include;third_party/freetype/include</AdditionalIncludeDirectories>
|
||||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
@ -859,6 +863,7 @@
|
||||||
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Level1</WarningLevel>
|
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Level1</WarningLevel>
|
||||||
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Level1</WarningLevel>
|
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Level1</WarningLevel>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="third_party\putty\wildcard.c" />
|
||||||
<ClCompile Include="util\AllocDebug.cpp" />
|
<ClCompile Include="util\AllocDebug.cpp" />
|
||||||
<ClCompile Include="util\BeefPerf.cpp" />
|
<ClCompile Include="util\BeefPerf.cpp" />
|
||||||
<ClCompile Include="util\BSpline.cpp" />
|
<ClCompile Include="util\BSpline.cpp" />
|
||||||
|
@ -1025,6 +1030,7 @@
|
||||||
<ClInclude Include="third_party\zlib\zconf.h" />
|
<ClInclude Include="third_party\zlib\zconf.h" />
|
||||||
<ClInclude Include="third_party\zlib\zlib.h" />
|
<ClInclude Include="third_party\zlib\zlib.h" />
|
||||||
<ClInclude Include="third_party\zlib\zutil.h" />
|
<ClInclude Include="third_party\zlib\zutil.h" />
|
||||||
|
<ClInclude Include="third_party\putty\wildcard.h" />
|
||||||
<ClInclude Include="util\BeefPerf.h" />
|
<ClInclude Include="util\BeefPerf.h" />
|
||||||
<ClInclude Include="util\BSpline.h" />
|
<ClInclude Include="util\BSpline.h" />
|
||||||
<ClInclude Include="util\CabUtil.h" />
|
<ClInclude Include="util\CabUtil.h" />
|
||||||
|
|
|
@ -69,6 +69,9 @@
|
||||||
<Filter Include="src\third_party\miniz">
|
<Filter Include="src\third_party\miniz">
|
||||||
<UniqueIdentifier>{d32cb9b0-e79b-49fe-82e2-33302be0baf6}</UniqueIdentifier>
|
<UniqueIdentifier>{d32cb9b0-e79b-49fe-82e2-33302be0baf6}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
<Filter Include="src\third_party\putty">
|
||||||
|
<UniqueIdentifier>{bec18ceb-a7ca-4150-99ee-60a16944b93c}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="platform\win\DXRenderDevice.cpp">
|
<ClCompile Include="platform\win\DXRenderDevice.cpp">
|
||||||
|
@ -584,6 +587,9 @@
|
||||||
<ClCompile Include="third_party\miniz\miniz.c">
|
<ClCompile Include="third_party\miniz\miniz.c">
|
||||||
<Filter>src\third_party\miniz</Filter>
|
<Filter>src\third_party\miniz</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="third_party\putty\wildcard.c">
|
||||||
|
<Filter>src\third_party\putty</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="Common.h">
|
<ClInclude Include="Common.h">
|
||||||
|
@ -898,6 +904,9 @@
|
||||||
<ClInclude Include="third_party\miniz\miniz.h">
|
<ClInclude Include="third_party\miniz\miniz.h">
|
||||||
<Filter>src\third_party\miniz</Filter>
|
<Filter>src\third_party\miniz</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="third_party\putty\wildcard.h">
|
||||||
|
<Filter>src\third_party\putty</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<CustomBuild Include="third_party\libffi\i686-pc-cygwin\src\x86\win32.asm">
|
<CustomBuild Include="third_party\libffi\i686-pc-cygwin\src\x86\win32.asm">
|
||||||
|
|
|
@ -16,7 +16,7 @@ set(OUTPUT_RELEASE Release/bin)
|
||||||
|
|
||||||
project(${PROJECT_NAME} CXX C)
|
project(${PROJECT_NAME} CXX C)
|
||||||
|
|
||||||
# Define Release by default.
|
# Define Debug by default.
|
||||||
if(NOT CMAKE_BUILD_TYPE)
|
if(NOT CMAKE_BUILD_TYPE)
|
||||||
set(CMAKE_BUILD_TYPE "Debug")
|
set(CMAKE_BUILD_TYPE "Debug")
|
||||||
message(STATUS "Build type not specified: Use Debug by default.")
|
message(STATUS "Build type not specified: Use Debug by default.")
|
||||||
|
@ -24,8 +24,8 @@ endif(NOT CMAKE_BUILD_TYPE)
|
||||||
|
|
||||||
# Definition of Macros
|
# Definition of Macros
|
||||||
add_definitions(
|
add_definitions(
|
||||||
-DIDEHELPER_EXPORTS
|
-DIDEHELPER_EXPORTS
|
||||||
-DBFSYSLIB_DYNAMIC
|
-DBFSYSLIB_DYNAMIC
|
||||||
-DUNICODE
|
-DUNICODE
|
||||||
-D_UNICODE
|
-D_UNICODE
|
||||||
-DBF_NO_FBX
|
-DBF_NO_FBX
|
||||||
|
@ -82,16 +82,16 @@ endif()
|
||||||
# Add Dependencies to project. #
|
# Add Dependencies to project. #
|
||||||
###################################################
|
###################################################
|
||||||
|
|
||||||
option(BUILD_DEPENDS
|
option(BUILD_DEPENDS
|
||||||
"Build other CMake project."
|
"Build other CMake project."
|
||||||
ON
|
ON
|
||||||
)
|
)
|
||||||
|
|
||||||
# Dependencies : disable BUILD_DEPENDS to link with lib already build.
|
# Dependencies : disable BUILD_DEPENDS to link with lib already build.
|
||||||
if(BUILD_DEPENDS)
|
if(BUILD_DEPENDS)
|
||||||
|
|
||||||
else()
|
else()
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
################# Flags ################
|
################# Flags ################
|
||||||
|
@ -103,7 +103,7 @@ if(MSVC)
|
||||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /W3 /GL /Od /Oi /Gy /EHsc")
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /W3 /GL /Od /Oi /Gy /EHsc")
|
||||||
endif(MSVC)
|
endif(MSVC)
|
||||||
if(NOT MSVC)
|
if(NOT MSVC)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-multichar")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-multichar")
|
||||||
endif(NOT MSVC)
|
endif(NOT MSVC)
|
||||||
|
|
||||||
################ Files ################
|
################ Files ################
|
||||||
|
@ -119,9 +119,9 @@ file(GLOB SRC_FILES
|
||||||
DataStream.cpp
|
DataStream.cpp
|
||||||
FileStream.cpp
|
FileStream.cpp
|
||||||
HeadlessApp.cpp
|
HeadlessApp.cpp
|
||||||
MemStream.cpp
|
MemStream.cpp
|
||||||
ResLib.cpp
|
ResLib.cpp
|
||||||
Startup.cpp
|
Startup.cpp
|
||||||
|
|
||||||
fbx/FBXReader.cpp
|
fbx/FBXReader.cpp
|
||||||
gfx/DrawLayer.cpp
|
gfx/DrawLayer.cpp
|
||||||
|
@ -132,7 +132,7 @@ file(GLOB SRC_FILES
|
||||||
gfx/RenderDevice.cpp
|
gfx/RenderDevice.cpp
|
||||||
gfx/RenderTarget.cpp
|
gfx/RenderTarget.cpp
|
||||||
gfx/Shader.cpp
|
gfx/Shader.cpp
|
||||||
gfx/Texture.cpp
|
gfx/Texture.cpp
|
||||||
img/BFIData.cpp
|
img/BFIData.cpp
|
||||||
img/ImageAdjustments.cpp
|
img/ImageAdjustments.cpp
|
||||||
img/ImageData.cpp
|
img/ImageData.cpp
|
||||||
|
@ -142,8 +142,8 @@ file(GLOB SRC_FILES
|
||||||
img/PNGData.cpp
|
img/PNGData.cpp
|
||||||
img/PSDReader.cpp
|
img/PSDReader.cpp
|
||||||
img/PVRData.cpp
|
img/PVRData.cpp
|
||||||
img/TGAData.cpp
|
img/TGAData.cpp
|
||||||
|
|
||||||
third_party/freetype/src/autofit/autofit.c
|
third_party/freetype/src/autofit/autofit.c
|
||||||
third_party/freetype/src/base/ftbase.c
|
third_party/freetype/src/base/ftbase.c
|
||||||
third_party/freetype/src/base/ftbbox.c
|
third_party/freetype/src/base/ftbbox.c
|
||||||
|
@ -274,6 +274,7 @@ file(GLOB SRC_FILES
|
||||||
third_party/zlib/uncompr.c
|
third_party/zlib/uncompr.c
|
||||||
third_party/zlib/zutil.c
|
third_party/zlib/zutil.c
|
||||||
third_party/miniz/miniz.c
|
third_party/miniz/miniz.c
|
||||||
|
third_party/putty/wildcard.c
|
||||||
util/AllocDebug.cpp
|
util/AllocDebug.cpp
|
||||||
util/BeefPerf.cpp
|
util/BeefPerf.cpp
|
||||||
util/BSpline.cpp
|
util/BSpline.cpp
|
||||||
|
@ -323,6 +324,6 @@ add_library(${PROJECT_NAME} SHARED
|
||||||
|
|
||||||
# Link with other dependencies.
|
# Link with other dependencies.
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
target_link_libraries(${PROJECT_NAME} imm32.lib version.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib
|
target_link_libraries(${PROJECT_NAME} imm32.lib version.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib
|
||||||
)
|
)
|
||||||
endif(MSVC)
|
endif(MSVC)
|
||||||
|
|
|
@ -15,10 +15,10 @@
|
||||||
|
|
||||||
inline size_t HashBytes(const uint8* ptr, size_t count) noexcept
|
inline size_t HashBytes(const uint8* ptr, size_t count) noexcept
|
||||||
{
|
{
|
||||||
#ifdef BF64
|
#ifdef BF64
|
||||||
const size_t _FNV_offset_basis = 14695981039346656037ULL;
|
const size_t _FNV_offset_basis = 14695981039346656037ULL;
|
||||||
const size_t _FNV_prime = 1099511628211ULL;
|
const size_t _FNV_prime = 1099511628211ULL;
|
||||||
#else
|
#else
|
||||||
const size_t _FNV_offset_basis = 2166136261U;
|
const size_t _FNV_offset_basis = 2166136261U;
|
||||||
const size_t _FNV_prime = 16777619U;
|
const size_t _FNV_prime = 16777619U;
|
||||||
#endif
|
#endif
|
||||||
|
@ -29,7 +29,7 @@ inline size_t HashBytes(const uint8* ptr, size_t count) noexcept
|
||||||
val ^= (size_t)ptr[_Next];
|
val ^= (size_t)ptr[_Next];
|
||||||
val *= _FNV_prime;
|
val *= _FNV_prime;
|
||||||
}
|
}
|
||||||
return (val);
|
return (val);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
@ -245,7 +245,7 @@ int16 EndianSwap(int16 val);
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct RemoveTypePointer
|
struct RemoveTypePointer
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
|
|
@ -223,6 +223,7 @@ enum BfpThreadCreateFlags
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef void (BFP_CALLTYPE *BfpThreadStartProc)(void* threadParam);
|
typedef void (BFP_CALLTYPE *BfpThreadStartProc)(void* threadParam);
|
||||||
|
typedef void (BFP_CALLTYPE* BfpTLSProc)(void* threadParam);
|
||||||
|
|
||||||
enum BfpThreadPriority
|
enum BfpThreadPriority
|
||||||
{
|
{
|
||||||
|
@ -273,8 +274,9 @@ BFP_EXPORT void BFP_CALLTYPE BfpCritSect_Enter(BfpCritSect* critSect);
|
||||||
BFP_EXPORT bool BFP_CALLTYPE BfpCritSect_TryEnter(BfpCritSect* critSect, int waitMS);
|
BFP_EXPORT bool BFP_CALLTYPE BfpCritSect_TryEnter(BfpCritSect* critSect, int waitMS);
|
||||||
BFP_EXPORT void BFP_CALLTYPE BfpCritSect_Leave(BfpCritSect* critSect);
|
BFP_EXPORT void BFP_CALLTYPE BfpCritSect_Leave(BfpCritSect* critSect);
|
||||||
|
|
||||||
|
|
||||||
struct BfpTLS;
|
struct BfpTLS;
|
||||||
BFP_EXPORT BfpTLS* BFP_CALLTYPE BfpTLS_Create();
|
BFP_EXPORT BfpTLS* BFP_CALLTYPE BfpTLS_Create(BfpTLSProc exitProc);
|
||||||
BFP_EXPORT void BFP_CALLTYPE BfpTLS_Release(BfpTLS* tls);
|
BFP_EXPORT void BFP_CALLTYPE BfpTLS_Release(BfpTLS* tls);
|
||||||
BFP_EXPORT void BFP_CALLTYPE BfpTLS_SetValue(BfpTLS* tls, void* value);
|
BFP_EXPORT void BFP_CALLTYPE BfpTLS_SetValue(BfpTLS* tls, void* value);
|
||||||
BFP_EXPORT void* BFP_CALLTYPE BfpTLS_GetValue(BfpTLS* tls);
|
BFP_EXPORT void* BFP_CALLTYPE BfpTLS_GetValue(BfpTLS* tls);
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include "../../util/CritSect.h"
|
#include "../../util/CritSect.h"
|
||||||
#include "../../util/Dictionary.h"
|
#include "../../util/Dictionary.h"
|
||||||
#include "../../util/Hash.h"
|
#include "../../util/Hash.h"
|
||||||
|
#include "../../third_party/putty/wildcard.h"
|
||||||
#ifdef BFP_HAS_EXECINFO
|
#ifdef BFP_HAS_EXECINFO
|
||||||
#include <execinfo.h>
|
#include <execinfo.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -1528,10 +1529,10 @@ BFP_EXPORT void BFP_CALLTYPE BfpCritSect_Leave(BfpCritSect* critSect)
|
||||||
pthread_mutex_unlock(&critSect->mPMutex);
|
pthread_mutex_unlock(&critSect->mPMutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
BFP_EXPORT BfpTLS* BFP_CALLTYPE BfpTLS_Create()
|
BFP_EXPORT BfpTLS* BFP_CALLTYPE BfpTLS_Create(BfpTLSProc exitProc)
|
||||||
{
|
{
|
||||||
pthread_key_t key = 0;
|
pthread_key_t key = 0;
|
||||||
pthread_key_create(&key, NULL);
|
pthread_key_create(&key, exitProc);
|
||||||
return (BfpTLS*)(intptr)key;
|
return (BfpTLS*)(intptr)key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2378,9 +2379,10 @@ static bool BfpFindFileData_CheckFilter(BfpFindFileData* findData)
|
||||||
{
|
{
|
||||||
if ((findData->mFlags & BfpFindFileFlag_Files) == 0)
|
if ((findData->mFlags & BfpFindFileFlag_Files) == 0)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: Check actual wildcards.
|
if (!wc_match(findData->mWildcard.c_str(), findData->mDirEnt->d_name))
|
||||||
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include "../util/CritSect.h"
|
#include "../util/CritSect.h"
|
||||||
#include "../util/Dictionary.h"
|
#include "../util/Dictionary.h"
|
||||||
#include "../util/HashSet.h"
|
#include "../util/HashSet.h"
|
||||||
|
#include "../../third_party/putty/wildcard.h"
|
||||||
|
|
||||||
#include "util/AllocDebug.h"
|
#include "util/AllocDebug.h"
|
||||||
|
|
||||||
|
@ -2530,24 +2531,24 @@ BFP_EXPORT void BFP_CALLTYPE BfpCritSect_Leave(BfpCritSect* critSect)
|
||||||
#define BFPTLS_TO_DWORD(val) ((DWORD)(intptr)(val))
|
#define BFPTLS_TO_DWORD(val) ((DWORD)(intptr)(val))
|
||||||
|
|
||||||
struct BfpTLS;
|
struct BfpTLS;
|
||||||
BFP_EXPORT BfpTLS* BFP_CALLTYPE BfpTLS_Create()
|
BFP_EXPORT BfpTLS* BFP_CALLTYPE BfpTLS_Create(BfpTLSProc exitProc)
|
||||||
{
|
{
|
||||||
return DWORD_TO_BFPTLS(::TlsAlloc());
|
return DWORD_TO_BFPTLS(::FlsAlloc(exitProc));
|
||||||
}
|
}
|
||||||
|
|
||||||
BFP_EXPORT void BFP_CALLTYPE BfpTLS_Release(BfpTLS* tls)
|
BFP_EXPORT void BFP_CALLTYPE BfpTLS_Release(BfpTLS* tls)
|
||||||
{
|
{
|
||||||
::TlsFree(BFPTLS_TO_DWORD(tls));
|
::FlsFree(BFPTLS_TO_DWORD(tls));
|
||||||
}
|
}
|
||||||
|
|
||||||
BFP_EXPORT void BFP_CALLTYPE BfpTLS_SetValue(BfpTLS* tls, void* value)
|
BFP_EXPORT void BFP_CALLTYPE BfpTLS_SetValue(BfpTLS* tls, void* value)
|
||||||
{
|
{
|
||||||
::TlsSetValue(BFPTLS_TO_DWORD(tls), value);
|
::FlsSetValue(BFPTLS_TO_DWORD(tls), value);
|
||||||
}
|
}
|
||||||
|
|
||||||
BFP_EXPORT void* BFP_CALLTYPE BfpTLS_GetValue(BfpTLS* tls)
|
BFP_EXPORT void* BFP_CALLTYPE BfpTLS_GetValue(BfpTLS* tls)
|
||||||
{
|
{
|
||||||
return ::TlsGetValue(BFPTLS_TO_DWORD(tls));
|
return ::FlsGetValue(BFPTLS_TO_DWORD(tls));
|
||||||
}
|
}
|
||||||
|
|
||||||
BFP_EXPORT BfpEvent* BFP_CALLTYPE BfpEvent_Create(BfpEventFlags flags)
|
BFP_EXPORT BfpEvent* BFP_CALLTYPE BfpEvent_Create(BfpEventFlags flags)
|
||||||
|
@ -3485,6 +3486,7 @@ struct BfpFindFileData
|
||||||
{
|
{
|
||||||
BfpFindFileFlags mFlags;
|
BfpFindFileFlags mFlags;
|
||||||
WIN32_FIND_DATA mFindData;
|
WIN32_FIND_DATA mFindData;
|
||||||
|
Beefy::String mWildcard;
|
||||||
HANDLE mHandle;
|
HANDLE mHandle;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3496,29 +3498,45 @@ static bool BfpFindFileData_CheckFilter(BfpFindFileData* findData)
|
||||||
bool isDir = (findData->mFindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
|
bool isDir = (findData->mFindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
|
||||||
if (isDir)
|
if (isDir)
|
||||||
{
|
{
|
||||||
if ((findData->mFlags & BfpFindFileFlag_Directories) != 0)
|
if ((findData->mFlags & BfpFindFileFlag_Directories) == 0)
|
||||||
{
|
return false;
|
||||||
if ((wcscmp(findData->mFindData.cFileName, L".") == 0) || (wcscmp(findData->mFindData.cFileName, L"..") == 0))
|
|
||||||
{
|
if ((wcscmp(findData->mFindData.cFileName, L".") == 0) || (wcscmp(findData->mFindData.cFileName, L"..") == 0))
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ((findData->mFlags & BfpFindFileFlag_Files) != 0)
|
if ((findData->mFlags & BfpFindFileFlag_Files) == 0)
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
|
Beefy::String fileName = UTF8Encode(findData->mFindData.cFileName);
|
||||||
|
Beefy::MakeUpper(fileName);
|
||||||
|
if (!wc_match(findData->mWildcard.c_str(), fileName.c_str()))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
BFP_EXPORT BfpFindFileData* BFP_CALLTYPE BfpFindFileData_FindFirstFile(const char* path, BfpFindFileFlags flags, BfpFileResult* outResult)
|
BFP_EXPORT BfpFindFileData* BFP_CALLTYPE BfpFindFileData_FindFirstFile(const char* path, BfpFindFileFlags flags, BfpFileResult* outResult)
|
||||||
{
|
{
|
||||||
UTF16String wPath = UTF8Decode(path);
|
Beefy::String findStr = path;
|
||||||
|
Beefy::String wildcard;
|
||||||
|
|
||||||
|
int lastSlashPos = std::max((int)findStr.LastIndexOf('/'), (int)findStr.LastIndexOf('\\'));
|
||||||
|
if (lastSlashPos != -1)
|
||||||
|
{
|
||||||
|
wildcard = findStr.Substring(lastSlashPos + 1);
|
||||||
|
findStr = findStr.Substring(0, lastSlashPos + 1);
|
||||||
|
findStr.Append("*");
|
||||||
|
}
|
||||||
|
if (wildcard == "*.*")
|
||||||
|
wildcard = "*";
|
||||||
|
|
||||||
BfpFindFileData* findData = new BfpFindFileData();
|
BfpFindFileData* findData = new BfpFindFileData();
|
||||||
findData->mFlags = flags;
|
findData->mFlags = flags;
|
||||||
|
findData->mWildcard = wildcard;
|
||||||
|
Beefy::MakeUpper(findData->mWildcard);
|
||||||
|
|
||||||
FINDEX_SEARCH_OPS searchOps;
|
FINDEX_SEARCH_OPS searchOps;
|
||||||
if ((flags & BfpFindFileFlag_Files) == 0)
|
if ((flags & BfpFindFileFlag_Files) == 0)
|
||||||
|
@ -3526,6 +3544,7 @@ BFP_EXPORT BfpFindFileData* BFP_CALLTYPE BfpFindFileData_FindFirstFile(const cha
|
||||||
else
|
else
|
||||||
searchOps = FindExSearchNameMatch;
|
searchOps = FindExSearchNameMatch;
|
||||||
|
|
||||||
|
UTF16String wPath = UTF8Decode(findStr);
|
||||||
findData->mHandle = ::FindFirstFileExW(wPath.c_str(), FindExInfoBasic, &findData->mFindData, searchOps, NULL, 0);
|
findData->mHandle = ::FindFirstFileExW(wPath.c_str(), FindExInfoBasic, &findData->mFindData, searchOps, NULL, 0);
|
||||||
if (findData->mHandle == INVALID_HANDLE_VALUE)
|
if (findData->mHandle == INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
|
|
File diff suppressed because it is too large
Load diff
28
BeefySysLib/third_party/putty/LICENSE
vendored
Normal file
28
BeefySysLib/third_party/putty/LICENSE
vendored
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
PuTTY is copyright 1997-2020 Simon Tatham.
|
||||||
|
|
||||||
|
Portions copyright Robert de Bath, Joris van Rantwijk, Delian
|
||||||
|
Delchev, Andreas Schultz, Jeroen Massar, Wez Furlong, Nicolas Barry,
|
||||||
|
Justin Bradford, Ben Harris, Malcolm Smith, Ahmad Khalifa, Markus
|
||||||
|
Kuhn, Colin Watson, Christopher Staite, Lorenz Diener, Christian
|
||||||
|
Brabandt, Jeff Smith, Pavel Kryukov, Maxim Kuznetsov, Svyatoslav
|
||||||
|
Kuzmich, Nico Williams, Viktor Dukhovni, Josh Dersch, Lars Brinkhoff,
|
||||||
|
and CORE SDI S.A.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person
|
||||||
|
obtaining a copy of this software and associated documentation files
|
||||||
|
(the "Software"), to deal in the Software without restriction,
|
||||||
|
including without limitation the rights to use, copy, modify, merge,
|
||||||
|
publish, distribute, sublicense, and/or sell copies of the Software,
|
||||||
|
and to permit persons to whom the Software is furnished to do so,
|
||||||
|
subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE
|
||||||
|
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
||||||
|
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
340
BeefySysLib/third_party/putty/wildcard.c
vendored
Normal file
340
BeefySysLib/third_party/putty/wildcard.c
vendored
Normal file
|
@ -0,0 +1,340 @@
|
||||||
|
/*
|
||||||
|
* Wildcard matching engine for use with SFTP-based file transfer
|
||||||
|
* programs (PSFTP, new-look PSCP): since SFTP has no notion of
|
||||||
|
* getting the remote side to do globbing (and rightly so) we have
|
||||||
|
* to do it locally, by retrieving all the filenames in a directory
|
||||||
|
* and checking each against the wildcard pattern.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "wildcard.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Definition of wildcard syntax:
|
||||||
|
*
|
||||||
|
* - * matches any sequence of characters, including zero.
|
||||||
|
* - ? matches exactly one character which can be anything.
|
||||||
|
* - [abc] matches exactly one character which is a, b or c.
|
||||||
|
* - [a-f] matches anything from a through f.
|
||||||
|
* - [^a-f] matches anything _except_ a through f.
|
||||||
|
* - [-_] matches - or _; [^-_] matches anything else. (The - is
|
||||||
|
* non-special if it occurs immediately after the opening
|
||||||
|
* bracket or ^.)
|
||||||
|
* - [a^] matches an a or a ^. (The ^ is non-special if it does
|
||||||
|
* _not_ occur immediately after the opening bracket.)
|
||||||
|
* - \*, \?, \[, \], \\ match the single characters *, ?, [, ], \.
|
||||||
|
* - All other characters are non-special and match themselves.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Some notes on differences from POSIX globs (IEEE Std 1003.1, 2003 ed.):
|
||||||
|
* - backslashes act as escapes even within [] bracket expressions
|
||||||
|
* - does not support [!...] for non-matching list (POSIX are weird);
|
||||||
|
* NB POSIX allows [^...] as well via "A bracket expression starting
|
||||||
|
* with an unquoted circumflex character produces unspecified
|
||||||
|
* results". If we wanted to allow [!...] we might want to define
|
||||||
|
* [^!] as having its literal meaning (match '^' or '!').
|
||||||
|
* - none of the scary [[:class:]] stuff, etc
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The wildcard matching technique we use is very simple and
|
||||||
|
* potentially O(N^2) in running time, but I don't anticipate it
|
||||||
|
* being that bad in reality (particularly since N will be the size
|
||||||
|
* of a filename, which isn't all that much). Perhaps one day, once
|
||||||
|
* PuTTY has grown a regexp matcher for some other reason, I might
|
||||||
|
* come back and reimplement wildcards by translating them into
|
||||||
|
* regexps or directly into NFAs; but for the moment, in the
|
||||||
|
* absence of any other need for the NFA->DFA translation engine,
|
||||||
|
* anything more than the simplest possible wildcard matcher is
|
||||||
|
* vast code-size overkill.
|
||||||
|
*
|
||||||
|
* Essentially, these wildcards are much simpler than regexps in
|
||||||
|
* that they consist of a sequence of rigid fragments (? and [...]
|
||||||
|
* can never match more or less than one character) separated by
|
||||||
|
* asterisks. It is therefore extremely simple to look at a rigid
|
||||||
|
* fragment and determine whether or not it begins at a particular
|
||||||
|
* point in the test string; so we can search along the string
|
||||||
|
* until we find each fragment, then search for the next. As long
|
||||||
|
* as we find each fragment in the _first_ place it occurs, there
|
||||||
|
* will never be a danger of having to backpedal and try to find it
|
||||||
|
* again somewhere else.
|
||||||
|
*/
|
||||||
|
|
||||||
|
enum {
|
||||||
|
WC_TRAILINGBACKSLASH = 1,
|
||||||
|
WC_UNCLOSEDCLASS,
|
||||||
|
WC_INVALIDRANGE
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Error reporting is done by returning various negative values
|
||||||
|
* from the wildcard routines. Passing any such value to wc_error
|
||||||
|
* will give a human-readable message.
|
||||||
|
*/
|
||||||
|
const char *wc_error(int value)
|
||||||
|
{
|
||||||
|
value = abs(value);
|
||||||
|
switch (value) {
|
||||||
|
case WC_TRAILINGBACKSLASH:
|
||||||
|
return "'\' occurred at end of string (expected another character)";
|
||||||
|
case WC_UNCLOSEDCLASS:
|
||||||
|
return "expected ']' to close character class";
|
||||||
|
case WC_INVALIDRANGE:
|
||||||
|
return "character range was not terminated (']' just after '-')";
|
||||||
|
}
|
||||||
|
return "INTERNAL ERROR: unrecognised wildcard error number";
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This is the routine that tests a target string to see if an
|
||||||
|
* initial substring of it matches a fragment. If successful, it
|
||||||
|
* returns 1, and advances both `fragment' and `target' past the
|
||||||
|
* fragment and matching substring respectively. If unsuccessful it
|
||||||
|
* returns zero. If the wildcard fragment suffers a syntax error,
|
||||||
|
* it returns <0 and the precise value indexes into wc_error.
|
||||||
|
*/
|
||||||
|
static int wc_match_fragment(const char **fragment, const char **target,
|
||||||
|
const char *target_end)
|
||||||
|
{
|
||||||
|
const char *f, *t;
|
||||||
|
|
||||||
|
f = *fragment;
|
||||||
|
t = *target;
|
||||||
|
/*
|
||||||
|
* The fragment terminates at either the end of the string, or
|
||||||
|
* the first (unescaped) *.
|
||||||
|
*/
|
||||||
|
while (*f && *f != '*' && t < target_end) {
|
||||||
|
/*
|
||||||
|
* Extract one character from t, and one character's worth
|
||||||
|
* of pattern from f, and step along both. Return 0 if they
|
||||||
|
* fail to match.
|
||||||
|
*/
|
||||||
|
if (*f == '\\') {
|
||||||
|
/*
|
||||||
|
* Backslash, which means f[1] is to be treated as a
|
||||||
|
* literal character no matter what it is. It may not
|
||||||
|
* be the end of the string.
|
||||||
|
*/
|
||||||
|
if (!f[1])
|
||||||
|
return -WC_TRAILINGBACKSLASH; /* error */
|
||||||
|
if (f[1] != *t)
|
||||||
|
return 0; /* failed to match */
|
||||||
|
f += 2;
|
||||||
|
} else if (*f == '?') {
|
||||||
|
/*
|
||||||
|
* Question mark matches anything.
|
||||||
|
*/
|
||||||
|
f++;
|
||||||
|
} else if (*f == '[') {
|
||||||
|
bool invert = false;
|
||||||
|
bool matched = false;
|
||||||
|
/*
|
||||||
|
* Open bracket introduces a character class.
|
||||||
|
*/
|
||||||
|
f++;
|
||||||
|
if (*f == '^') {
|
||||||
|
invert = true;
|
||||||
|
f++;
|
||||||
|
}
|
||||||
|
while (*f != ']') {
|
||||||
|
if (*f == '\\')
|
||||||
|
f++; /* backslashes still work */
|
||||||
|
if (!*f)
|
||||||
|
return -WC_UNCLOSEDCLASS; /* error again */
|
||||||
|
if (f[1] == '-') {
|
||||||
|
int lower, upper, ourchr;
|
||||||
|
lower = (unsigned char) *f++;
|
||||||
|
f++; /* eat the minus */
|
||||||
|
if (*f == ']')
|
||||||
|
return -WC_INVALIDRANGE; /* different error! */
|
||||||
|
if (*f == '\\')
|
||||||
|
f++; /* backslashes _still_ work */
|
||||||
|
if (!*f)
|
||||||
|
return -WC_UNCLOSEDCLASS; /* error again */
|
||||||
|
upper = (unsigned char) *f++;
|
||||||
|
ourchr = (unsigned char) *t;
|
||||||
|
if (lower > upper) {
|
||||||
|
int t = lower; lower = upper; upper = t;
|
||||||
|
}
|
||||||
|
if (ourchr >= lower && ourchr <= upper)
|
||||||
|
matched = true;
|
||||||
|
} else {
|
||||||
|
matched |= (*t == *f++);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (invert == matched)
|
||||||
|
return 0; /* failed to match character class */
|
||||||
|
f++; /* eat the ] */
|
||||||
|
} else {
|
||||||
|
/*
|
||||||
|
* Non-special character matches itself.
|
||||||
|
*/
|
||||||
|
if (*f != *t)
|
||||||
|
return 0;
|
||||||
|
f++;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* Now we've done that, increment t past the character we
|
||||||
|
* matched.
|
||||||
|
*/
|
||||||
|
t++;
|
||||||
|
}
|
||||||
|
if (!*f || *f == '*') {
|
||||||
|
/*
|
||||||
|
* We have reached the end of f without finding a mismatch;
|
||||||
|
* so we're done. Update the caller pointers and return 1.
|
||||||
|
*/
|
||||||
|
*fragment = f;
|
||||||
|
*target = t;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* Otherwise, we must have reached the end of t before we
|
||||||
|
* reached the end of f; so we've failed. Return 0.
|
||||||
|
*/
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This is the real wildcard matching routine. It returns 1 for a
|
||||||
|
* successful match, 0 for an unsuccessful match, and <0 for a
|
||||||
|
* syntax error in the wildcard.
|
||||||
|
*/
|
||||||
|
static int wc_match_inner(
|
||||||
|
const char *wildcard, const char *target, size_t target_len)
|
||||||
|
{
|
||||||
|
const char *target_end = target + target_len;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Every time we see a '*' _followed_ by a fragment, we just
|
||||||
|
* search along the string for a location at which the fragment
|
||||||
|
* matches. The only special case is when we see a fragment
|
||||||
|
* right at the start, in which case we just call the matching
|
||||||
|
* routine once and give up if it fails.
|
||||||
|
*/
|
||||||
|
if (*wildcard != '*') {
|
||||||
|
ret = wc_match_fragment(&wildcard, &target, target_end);
|
||||||
|
if (ret <= 0)
|
||||||
|
return ret; /* pass back failure or error alike */
|
||||||
|
}
|
||||||
|
|
||||||
|
while (*wildcard) {
|
||||||
|
assert(*wildcard == '*');
|
||||||
|
while (*wildcard == '*')
|
||||||
|
wildcard++;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* It's possible we've just hit the end of the wildcard
|
||||||
|
* after seeing a *, in which case there's no need to
|
||||||
|
* bother searching any more because we've won.
|
||||||
|
*/
|
||||||
|
if (!*wildcard)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Now `wildcard' points at the next fragment. So we
|
||||||
|
* attempt to match it against `target', and if that fails
|
||||||
|
* we increment `target' and try again, and so on. When we
|
||||||
|
* find we're about to try matching against the empty
|
||||||
|
* string, we give up and return 0.
|
||||||
|
*/
|
||||||
|
ret = 0;
|
||||||
|
while (*target) {
|
||||||
|
const char *save_w = wildcard, *save_t = target;
|
||||||
|
|
||||||
|
ret = wc_match_fragment(&wildcard, &target, target_end);
|
||||||
|
|
||||||
|
if (ret < 0)
|
||||||
|
return ret; /* syntax error */
|
||||||
|
|
||||||
|
if (ret > 0 && !*wildcard && target != target_end) {
|
||||||
|
/*
|
||||||
|
* Final special case - literally.
|
||||||
|
*
|
||||||
|
* This situation arises when we are matching a
|
||||||
|
* _terminal_ fragment of the wildcard (that is,
|
||||||
|
* there is nothing after it, e.g. "*a"), and it
|
||||||
|
* has matched _too early_. For example, matching
|
||||||
|
* "*a" against "parka" will match the "a" fragment
|
||||||
|
* against the _first_ a, and then (if it weren't
|
||||||
|
* for this special case) matching would fail
|
||||||
|
* because we're at the end of the wildcard but not
|
||||||
|
* at the end of the target string.
|
||||||
|
*
|
||||||
|
* In this case what we must do is measure the
|
||||||
|
* length of the fragment in the target (which is
|
||||||
|
* why we saved `target'), jump straight to that
|
||||||
|
* distance from the end of the string using
|
||||||
|
* strlen, and match the same fragment again there
|
||||||
|
* (which is why we saved `wildcard'). Then we
|
||||||
|
* return whatever that operation returns.
|
||||||
|
*/
|
||||||
|
target = target_end - (target - save_t);
|
||||||
|
wildcard = save_w;
|
||||||
|
return wc_match_fragment(&wildcard, &target, target_end);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ret > 0)
|
||||||
|
break;
|
||||||
|
target++;
|
||||||
|
}
|
||||||
|
if (ret > 0)
|
||||||
|
continue;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If we reach here, it must be because we successfully matched
|
||||||
|
* a fragment and then found ourselves right at the end of the
|
||||||
|
* wildcard. Hence, we return 1 if and only if we are also
|
||||||
|
* right at the end of the target.
|
||||||
|
*/
|
||||||
|
return target == target_end;
|
||||||
|
}
|
||||||
|
|
||||||
|
int wc_match(const char *wildcard, const char *target)
|
||||||
|
{
|
||||||
|
return wc_match_inner(wildcard, target, strlen(target));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Another utility routine that translates a non-wildcard string
|
||||||
|
* into its raw equivalent by removing any escaping backslashes.
|
||||||
|
* Expects a target string buffer of anything up to the length of
|
||||||
|
* the original wildcard. You can also pass NULL as the output
|
||||||
|
* buffer if you're only interested in the return value.
|
||||||
|
*
|
||||||
|
* Returns true on success, or false if a wildcard character was
|
||||||
|
* encountered. In the latter case the output string MAY not be
|
||||||
|
* zero-terminated and you should not use it for anything!
|
||||||
|
*/
|
||||||
|
bool wc_unescape(char *output, const char *wildcard)
|
||||||
|
{
|
||||||
|
while (*wildcard) {
|
||||||
|
if (*wildcard == '\\') {
|
||||||
|
wildcard++;
|
||||||
|
/* We are lenient about trailing backslashes in non-wildcards. */
|
||||||
|
if (*wildcard) {
|
||||||
|
if (output)
|
||||||
|
*output++ = *wildcard;
|
||||||
|
wildcard++;
|
||||||
|
}
|
||||||
|
} else if (*wildcard == '*' || *wildcard == '?' ||
|
||||||
|
*wildcard == '[' || *wildcard == ']') {
|
||||||
|
return false; /* it's a wildcard! */
|
||||||
|
} else {
|
||||||
|
if (output)
|
||||||
|
*output++ = *wildcard;
|
||||||
|
wildcard++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (output)
|
||||||
|
*output = '\0';
|
||||||
|
return true; /* it's clean */
|
||||||
|
}
|
18
BeefySysLib/third_party/putty/wildcard.h
vendored
Normal file
18
BeefySysLib/third_party/putty/wildcard.h
vendored
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
#ifndef PUTTY_WILDCARD_H_INCLUDE
|
||||||
|
#define PUTTY_WILDCARD_H_INCLUDE
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
const char *wc_error(int value);
|
||||||
|
int wc_match(const char *wildcard, const char *target);
|
||||||
|
bool wc_unescape(char *output, const char *wildcard);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // PUTTY_WILDCARD_H_INCLUDE
|
|
@ -757,10 +757,15 @@ bool BpManager::Connect()
|
||||||
if (mShutdownEvent.WaitFor(0))
|
if (mShutdownEvent.WaitFor(0))
|
||||||
{
|
{
|
||||||
// We are shutting down - have we waited enough?
|
// We are shutting down - have we waited enough?
|
||||||
int minWaitMS = isLocalhost ? 50 : 20*1000;
|
int minWaitMS = isLocalhost ? 50 : 5*1000;
|
||||||
if (totalWaitedMS >= minWaitMS)
|
if (totalWaitedMS >= minWaitMS)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We don't want to wait too long, otherwise we will buffer up too much
|
||||||
|
int maxWaitMS = isLocalhost ? 5*1000 : 15*1000;
|
||||||
|
if (totalWaitedMS >= maxWaitMS)
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -925,6 +925,8 @@ public:
|
||||||
this->mSize = val.mSize;
|
this->mSize = val.mSize;
|
||||||
this->mAllocSize = val.mAllocSize;
|
this->mAllocSize = val.mAllocSize;
|
||||||
val.mVals = (T*)&val.mFirstVal;
|
val.mVals = (T*)&val.mFirstVal;
|
||||||
|
val.mSize = 0;
|
||||||
|
val.mAllocSize = TInternalSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1006,6 +1008,8 @@ public:
|
||||||
this->mAllocSize = val.mAllocSize;
|
this->mAllocSize = val.mAllocSize;
|
||||||
|
|
||||||
val.mVals = NULL;
|
val.mVals = NULL;
|
||||||
|
val.mSize = 0;
|
||||||
|
val.mAllocSize = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1079,6 +1083,8 @@ public:
|
||||||
this->mAllocSize = val.mAllocSize;
|
this->mAllocSize = val.mAllocSize;
|
||||||
|
|
||||||
val.mVals = &val.mInternalBuffer;
|
val.mVals = &val.mInternalBuffer;
|
||||||
|
val.mSize = 0;
|
||||||
|
val.mAllocSize = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -132,6 +132,7 @@
|
||||||
<PreprocessorDefinitions>BF_DBG_32;WIN32;_DEBUG;_WINDOWS;_USRDLL;IDEHELPER_EXPORTS;BFSYSLIB_DYNAMIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>BF_DBG_32;WIN32;_DEBUG;_WINDOWS;_USRDLL;IDEHELPER_EXPORTS;BFSYSLIB_DYNAMIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<AdditionalIncludeDirectories>../;../IDEHelper;../BeefySysLib/platform/win;../BeefySysLib/third_party;C:\llvm-3.8\llvm\include;C:\llvm-3.8\bin64\include;C:\llvm-3.8\llvm\lib\Target;C:\llvm-3.8\bin64\lib\Target\X86;C:\llvm-3.8\llvm\tools\clang\include</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>../;../IDEHelper;../BeefySysLib/platform/win;../BeefySysLib/third_party;C:\llvm-3.8\llvm\include;C:\llvm-3.8\bin64\include;C:\llvm-3.8\llvm\lib\Target;C:\llvm-3.8\bin64\lib\Target\X86;C:\llvm-3.8\llvm\tools\clang\include</AdditionalIncludeDirectories>
|
||||||
<SupportJustMyCode>false</SupportJustMyCode>
|
<SupportJustMyCode>false</SupportJustMyCode>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
@ -150,6 +151,7 @@
|
||||||
<AdditionalOptions>-D_SCL_SECURE_NO_WARNINGS %(AdditionalOptions)</AdditionalOptions>
|
<AdditionalOptions>-D_SCL_SECURE_NO_WARNINGS %(AdditionalOptions)</AdditionalOptions>
|
||||||
<SupportJustMyCode>false</SupportJustMyCode>
|
<SupportJustMyCode>false</SupportJustMyCode>
|
||||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
@ -166,6 +168,7 @@
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<PreprocessorDefinitions>BF_DBG_32;WIN32;NDEBUG;_WINDOWS;_USRDLL;IDEHELPER_EXPORTS;BFSYSLIB_DYNAMIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>BF_DBG_32;WIN32;NDEBUG;_WINDOWS;_USRDLL;IDEHELPER_EXPORTS;BFSYSLIB_DYNAMIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<AdditionalIncludeDirectories>../;../IDEHelper;../BeefySysLib/platform/win;../BeefySysLib/third_party;C:\llvm-3.8\llvm\include;C:\llvm-3.8\bin64\include;C:\llvm-3.8\llvm\lib\Target;C:\llvm-3.8\bin64\lib\Target\X86;C:\llvm-3.8\llvm\tools\clang\include</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>../;../IDEHelper;../BeefySysLib/platform/win;../BeefySysLib/third_party;C:\llvm-3.8\llvm\include;C:\llvm-3.8\bin64\include;C:\llvm-3.8\llvm\lib\Target;C:\llvm-3.8\bin64\lib\Target\X86;C:\llvm-3.8\llvm\tools\clang\include</AdditionalIncludeDirectories>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
@ -186,6 +189,7 @@
|
||||||
<AdditionalIncludeDirectories>../;../IDEHelper;../BeefySysLib/platform/win;../BeefySysLib/third_party;..\extern\llvm-project_13_0_1\llvm\include;..\extern\llvm_win64_13_0_1\include;..\extern\llvm-project_13_0_1\llvm\lib\Target;..\extern\llvm_win64_13_0_1\lib\Target\X86;..\extern\llvm-project_13_0_1\llvm\tools\clang\include</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>../;../IDEHelper;../BeefySysLib/platform/win;../BeefySysLib/third_party;..\extern\llvm-project_13_0_1\llvm\include;..\extern\llvm_win64_13_0_1\include;..\extern\llvm-project_13_0_1\llvm\lib\Target;..\extern\llvm_win64_13_0_1\lib\Target\X86;..\extern\llvm-project_13_0_1\llvm\tools\clang\include</AdditionalIncludeDirectories>
|
||||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
|
|
@ -132,6 +132,7 @@
|
||||||
<PreprocessorDefinitions>BF_DBG_64;WIN32;_DEBUG;_WINDOWS;_USRDLL;IDEHELPER_EXPORTS;BFSYSLIB_DYNAMIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>BF_DBG_64;WIN32;_DEBUG;_WINDOWS;_USRDLL;IDEHELPER_EXPORTS;BFSYSLIB_DYNAMIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<AdditionalIncludeDirectories>../;../IDEHelper;../BeefySysLib/platform/win;../BeefySysLib/third_party;C:\llvm-3.8\llvm\include;C:\llvm-3.8\bin64\include;C:\llvm-3.8\llvm\lib\Target;C:\llvm-3.8\bin64\lib\Target\X86;C:\llvm-3.8\llvm\tools\clang\include</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>../;../IDEHelper;../BeefySysLib/platform/win;../BeefySysLib/third_party;C:\llvm-3.8\llvm\include;C:\llvm-3.8\bin64\include;C:\llvm-3.8\llvm\lib\Target;C:\llvm-3.8\bin64\lib\Target\X86;C:\llvm-3.8\llvm\tools\clang\include</AdditionalIncludeDirectories>
|
||||||
<SupportJustMyCode>false</SupportJustMyCode>
|
<SupportJustMyCode>false</SupportJustMyCode>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
@ -150,6 +151,7 @@
|
||||||
<AdditionalOptions>-D_SCL_SECURE_NO_WARNINGS %(AdditionalOptions)</AdditionalOptions>
|
<AdditionalOptions>-D_SCL_SECURE_NO_WARNINGS %(AdditionalOptions)</AdditionalOptions>
|
||||||
<SupportJustMyCode>false</SupportJustMyCode>
|
<SupportJustMyCode>false</SupportJustMyCode>
|
||||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
@ -166,6 +168,7 @@
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<PreprocessorDefinitions>BF_DBG_64;WIN32;NDEBUG;_WINDOWS;_USRDLL;IDEHELPER_EXPORTS;BFSYSLIB_DYNAMIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>BF_DBG_64;WIN32;NDEBUG;_WINDOWS;_USRDLL;IDEHELPER_EXPORTS;BFSYSLIB_DYNAMIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<AdditionalIncludeDirectories>../;../IDEHelper;../BeefySysLib/platform/win;../BeefySysLib/third_party;C:\llvm-3.8\llvm\include;C:\llvm-3.8\bin64\include;C:\llvm-3.8\llvm\lib\Target;C:\llvm-3.8\bin64\lib\Target\X86;C:\llvm-3.8\llvm\tools\clang\include</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>../;../IDEHelper;../BeefySysLib/platform/win;../BeefySysLib/third_party;C:\llvm-3.8\llvm\include;C:\llvm-3.8\bin64\include;C:\llvm-3.8\llvm\lib\Target;C:\llvm-3.8\bin64\lib\Target\X86;C:\llvm-3.8\llvm\tools\clang\include</AdditionalIncludeDirectories>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
@ -186,6 +189,7 @@
|
||||||
<AdditionalIncludeDirectories>../;../IDEHelper;../BeefySysLib/platform/win;../BeefySysLib/third_party;..\extern\llvm-project_13_0_1\llvm\include;..\extern\llvm_win64_13_0_1\include;..\extern\llvm-project_13_0_1\llvm\lib\Target;..\extern\llvm_win64_13_0_1\lib\Target\X86;..\extern\llvm-project_13_0_1\llvm\tools\clang\include</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>../;../IDEHelper;../BeefySysLib/platform/win;../BeefySysLib/third_party;..\extern\llvm-project_13_0_1\llvm\include;..\extern\llvm_win64_13_0_1\include;..\extern\llvm-project_13_0_1\llvm\lib\Target;..\extern\llvm_win64_13_0_1\lib\Target\X86;..\extern\llvm-project_13_0_1\llvm\tools\clang\include</AdditionalIncludeDirectories>
|
||||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||||
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
|
|
@ -13,7 +13,7 @@ Description = "Beef IDE"
|
||||||
Company = "BeefyTech LLC"
|
Company = "BeefyTech LLC"
|
||||||
Product = "Beef IDE"
|
Product = "Beef IDE"
|
||||||
Copyright = "Copyright 2019 BeefyTech"
|
Copyright = "Copyright 2019 BeefyTech"
|
||||||
FileVersion = "0.43.3"
|
FileVersion = "0.43.4"
|
||||||
ProductVersion = "0000000000000000"
|
ProductVersion = "0000000000000000"
|
||||||
|
|
||||||
[Configs.Debug.Win32]
|
[Configs.Debug.Win32]
|
||||||
|
@ -24,7 +24,7 @@ OtherLinkFlags = ""
|
||||||
TargetDirectory = "$(WorkspaceDir)/dist"
|
TargetDirectory = "$(WorkspaceDir)/dist"
|
||||||
TargetName = "BeefIDE_d"
|
TargetName = "BeefIDE_d"
|
||||||
OtherLinkFlags = "$(LinkFlags) Comdlg32.lib kernel32.lib user32.lib advapi32.lib shell32.lib IDEHelper64_d.lib"
|
OtherLinkFlags = "$(LinkFlags) Comdlg32.lib kernel32.lib user32.lib advapi32.lib shell32.lib IDEHelper64_d.lib"
|
||||||
DebugCommandArguments = "-proddir=\"$(WorkspaceDir)\\..\\IDEHelper\\Tests\""
|
DebugCommandArguments = "-proddir=\"$(WorkspaceDir)\\..\\IDE\""
|
||||||
DebugWorkingDirectory = "$(WorkspaceDir)\\.."
|
DebugWorkingDirectory = "$(WorkspaceDir)\\.."
|
||||||
EnvironmentVars = ["_NO_DEBUG_HEAP=1"]
|
EnvironmentVars = ["_NO_DEBUG_HEAP=1"]
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ OtherLinkFlags = ""
|
||||||
TargetDirectory = "$(WorkspaceDir)/dist"
|
TargetDirectory = "$(WorkspaceDir)/dist"
|
||||||
TargetName = "BeefIDE"
|
TargetName = "BeefIDE"
|
||||||
OtherLinkFlags = "Comdlg32.lib kernel32.lib user32.lib advapi32.lib shell32.lib Beef042RT64.lib IDEHelper64.lib BeefySysLib64.lib"
|
OtherLinkFlags = "Comdlg32.lib kernel32.lib user32.lib advapi32.lib shell32.lib Beef042RT64.lib IDEHelper64.lib BeefySysLib64.lib"
|
||||||
DebugCommandArguments = "-proddir=C:\\Beef\\IDE\\Tests\\Rando"
|
DebugCommandArguments = "-workspace=C:\\proj\\BeefTest"
|
||||||
DebugWorkingDirectory = "$(ProjectDir)\\dist"
|
DebugWorkingDirectory = "$(ProjectDir)\\dist"
|
||||||
EnvironmentVars = ["_NO_DEBUG_HEAP=1"]
|
EnvironmentVars = ["_NO_DEBUG_HEAP=1"]
|
||||||
|
|
||||||
|
@ -48,8 +48,9 @@ OtherLinkFlags = ""
|
||||||
TargetDirectory = "$(WorkspaceDir)/dist"
|
TargetDirectory = "$(WorkspaceDir)/dist"
|
||||||
TargetName = "BeefIDE_d2"
|
TargetName = "BeefIDE_d2"
|
||||||
OtherLinkFlags = "$(LinkFlags) Comdlg32.lib kernel32.lib user32.lib advapi32.lib shell32.lib IDEHelper64_d.lib BeefySysLib64_d.lib wsock32.lib"
|
OtherLinkFlags = "$(LinkFlags) Comdlg32.lib kernel32.lib user32.lib advapi32.lib shell32.lib IDEHelper64_d.lib BeefySysLib64_d.lib wsock32.lib"
|
||||||
DebugCommandArguments = "-workspace=c:\\proj\\BeefTest"
|
BeefLibType = "DynamicDebug"
|
||||||
DebugWorkingDirectory = "$(ProjectDir)\\dist"
|
DebugCommandArguments = "-proddir=C:\\proj\\BeefTest"
|
||||||
|
DebugWorkingDirectory = "c:\\Beef\\IDE\\Tests\\EmptyTest"
|
||||||
EnvironmentVars = ["_NO_DEBUG_HEAP=1"]
|
EnvironmentVars = ["_NO_DEBUG_HEAP=1"]
|
||||||
|
|
||||||
[Configs.Paranoid.Win64]
|
[Configs.Paranoid.Win64]
|
||||||
|
|
|
@ -119,6 +119,38 @@ namespace IDETest
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class TestExt<T> where T : struct
|
||||||
|
{
|
||||||
|
public struct InnerA
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public struct InnerB<T2> where T2 : struct
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension TestExt<T>
|
||||||
|
where T : Int
|
||||||
|
{
|
||||||
|
public int a = 0;
|
||||||
|
|
||||||
|
public struct InnerC
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void TestExtMethod()
|
||||||
|
{
|
||||||
|
TestExt<String>.InnerA a; //FAIL
|
||||||
|
TestExt<String>.InnerB<int> b; //FAIL
|
||||||
|
TestExt<int>.InnerB<int> c;
|
||||||
|
TestExt<int>.InnerC d;
|
||||||
|
TestExt<float>.InnerC e; //FAIL
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -342,5 +342,112 @@ namespace IDETest
|
||||||
int b3 = b; //FAIL
|
int b3 = b; //FAIL
|
||||||
int c3 = c; //FAIL
|
int c3 = c; //FAIL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Result<int> Read()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Local8()
|
||||||
|
{
|
||||||
|
int read;
|
||||||
|
loop: repeat
|
||||||
|
{
|
||||||
|
switch (Read())
|
||||||
|
{
|
||||||
|
case .Err: return;
|
||||||
|
case .Ok(let val): read = val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (read > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Local9()
|
||||||
|
{
|
||||||
|
int read;
|
||||||
|
loop: repeat
|
||||||
|
{
|
||||||
|
switch (Read())
|
||||||
|
{
|
||||||
|
case .Err: break loop;
|
||||||
|
case .Ok(let val): read = val;
|
||||||
|
}
|
||||||
|
int a = read;
|
||||||
|
}
|
||||||
|
while (read > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Local10()
|
||||||
|
{
|
||||||
|
int read;
|
||||||
|
loop: repeat
|
||||||
|
{
|
||||||
|
switch (Read())
|
||||||
|
{
|
||||||
|
case .Err: break;
|
||||||
|
case .Ok(let val): read = val;
|
||||||
|
}
|
||||||
|
int a = read; //FAIL
|
||||||
|
}
|
||||||
|
while (read > 0); //FAIL
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Local11()
|
||||||
|
{
|
||||||
|
int a = 123;
|
||||||
|
|
||||||
|
int read;
|
||||||
|
Loop: repeat
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
while (read > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Local12()
|
||||||
|
{
|
||||||
|
int a = 123;
|
||||||
|
|
||||||
|
int read;
|
||||||
|
Loop: repeat
|
||||||
|
{
|
||||||
|
if (a == 123)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
while (read > 0); //FAIL
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Local13()
|
||||||
|
{
|
||||||
|
int a = 123;
|
||||||
|
int b;
|
||||||
|
switch (a)
|
||||||
|
{
|
||||||
|
default: b = 0;
|
||||||
|
}
|
||||||
|
int c = b;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Local14()
|
||||||
|
{
|
||||||
|
int a = 123;
|
||||||
|
int b;
|
||||||
|
switch (a)
|
||||||
|
{
|
||||||
|
default: b = 0; break;
|
||||||
|
}
|
||||||
|
int c = b;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Local15()
|
||||||
|
{
|
||||||
|
int a = 123;
|
||||||
|
int b;
|
||||||
|
switch (a)
|
||||||
|
{
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
int c = b; //FAIL
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
13
IDE/Tests/Test1/scripts/UsingFields.txt
Normal file
13
IDE/Tests/Test1/scripts/UsingFields.txt
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
ShowFile("src/UsingFields.bf")
|
||||||
|
GotoText("//Test_Start")
|
||||||
|
ToggleBreakpoint()
|
||||||
|
RunWithCompiling()
|
||||||
|
|
||||||
|
AssertEvalEquals("v0.x", "123")
|
||||||
|
AssertEvalEquals("v1.x", "345")
|
||||||
|
|
||||||
|
# Temporarily broken in LLVM
|
||||||
|
if (platform != "Win64") Stop()
|
||||||
|
|
||||||
|
AssertEvalEquals("v0.GetX()", "123")
|
||||||
|
AssertEvalEquals("v1.GetX()", "345")
|
|
@ -31,6 +31,7 @@ namespace IDETest
|
||||||
Stepping_Scope.Test();
|
Stepping_Scope.Test();
|
||||||
TypedPrimitives.Test();
|
TypedPrimitives.Test();
|
||||||
Unions.Test();
|
Unions.Test();
|
||||||
|
UsingFields.Test();
|
||||||
Virtuals.Test();
|
Virtuals.Test();
|
||||||
|
|
||||||
Bug001.Test();
|
Bug001.Test();
|
||||||
|
|
43
IDE/Tests/Test1/src/UsingFields.bf
Normal file
43
IDE/Tests/Test1/src/UsingFields.bf
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
#pragma warning disable 168
|
||||||
|
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace IDETest
|
||||||
|
{
|
||||||
|
class UsingFields
|
||||||
|
{
|
||||||
|
struct Vector2Int
|
||||||
|
{
|
||||||
|
[Union]
|
||||||
|
struct XWidth
|
||||||
|
{
|
||||||
|
public int x;
|
||||||
|
public int width;
|
||||||
|
|
||||||
|
public int GetX() => x;
|
||||||
|
}
|
||||||
|
[Union] struct YHeight : this(int y, int height);
|
||||||
|
|
||||||
|
public using XWidth xWidth;
|
||||||
|
public using YHeight yHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct TestVec : Vector2Int
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Test()
|
||||||
|
{
|
||||||
|
Vector2Int v0;
|
||||||
|
v0.x = 123;
|
||||||
|
v0.y = 234;
|
||||||
|
|
||||||
|
TestVec v1;
|
||||||
|
v1.x = 345;
|
||||||
|
v0.y = 456;
|
||||||
|
|
||||||
|
//Test_Start
|
||||||
|
int v = v0.GetX();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
22
IDE/dist/BeefDbgVis.toml
vendored
22
IDE/dist/BeefDbgVis.toml
vendored
|
@ -21,18 +21,18 @@ ValuePointer = "/*(mMethodId < 0) ? &this :*/ __cast(\"_BF_DeferredData_\", mMet
|
||||||
|
|
||||||
[[Type]]
|
[[Type]]
|
||||||
Name = "System.Event<*>"
|
Name = "System.Event<*>"
|
||||||
DisplayString = "{{ data={__cast(\"System.Object\", mData & ~3)} }}"
|
DisplayString = "{{ data={__cast(\"System.Object\", mData & sDataMask)} }}"
|
||||||
[[Type.Expand.Item]]
|
[[Type.Expand.Item]]
|
||||||
Name = "[target]"
|
Name = "[target]"
|
||||||
Value = "__cast(\"System.Object\", mData)"
|
Value = "__cast(\"System.Object\", mData)"
|
||||||
Condition = "(mData & 1) == 0"
|
Condition = "(mData & sIsEnumerating) == 0"
|
||||||
[[Type.Expand.Item]]
|
[[Type.Expand.Item]]
|
||||||
Name = "[target]"
|
Name = "[target]"
|
||||||
Value = "((System.Event<$T1>.Enumerator*)(mData & ~3)).mTarget"
|
Value = "((System.Event<$T1>.Enumerator*)(mData & sDataMask)).mTarget"
|
||||||
Condition = "(mData & 1) != 0"
|
Condition = "(mData & sIsEnumerating) != 0"
|
||||||
[[Type.Expand.Item]]
|
[[Type.Expand.Item]]
|
||||||
Name = "[flags]"
|
Name = "[flags]"
|
||||||
Value = "mData & 3"
|
Value = "mData & sFlagsMask"
|
||||||
|
|
||||||
[[Type]]
|
[[Type]]
|
||||||
Name = "_BF_DeferredData_*"
|
Name = "_BF_DeferredData_*"
|
||||||
|
@ -52,14 +52,14 @@ String = "{{ {__demangleFakeMember(this)} }}"
|
||||||
Name = "System.String"
|
Name = "System.String"
|
||||||
[[Type.DisplayString]]
|
[[Type.DisplayString]]
|
||||||
Condition = "(__getHighBits(mAllocSizeAndFlags, 2) & 1) == 0"
|
Condition = "(__getHighBits(mAllocSizeAndFlags, 2) & 1) == 0"
|
||||||
String = "{(char8*)&mPtr,s8,count=mLength}"
|
String = "{(char8*)&mPtrOrBuffer,s8,count=mLength}"
|
||||||
[[Type.DisplayString]]
|
[[Type.DisplayString]]
|
||||||
String = "{mPtr,s8,count=mLength}"
|
String = "{mPtrOrBuffer,s8,count=mLength}"
|
||||||
[[Type.StringView]]
|
[[Type.StringView]]
|
||||||
Condition = "(__getHighBits(mAllocSizeAndFlags, 2) & 1) == 0"
|
Condition = "(__getHighBits(mAllocSizeAndFlags, 2) & 1) == 0"
|
||||||
String = "{(char8*)&mPtr,s8,count=mLength}"
|
String = "{(char8*)&mPtrOrBuffer,s8,count=mLength}"
|
||||||
[[Type.StringView]]
|
[[Type.StringView]]
|
||||||
String = "{mPtr,s8,count=mLength}"
|
String = "{mPtrOrBuffer,s8,count=mLength}"
|
||||||
[[Type.Expand.Item]]
|
[[Type.Expand.Item]]
|
||||||
Name = "[Length]"
|
Name = "[Length]"
|
||||||
Value = "mLength"
|
Value = "mLength"
|
||||||
|
@ -78,11 +78,11 @@ Value = "__clearHighBits(mAllocSizeAndFlags, 2)"
|
||||||
[[Type.Expand.Item]]
|
[[Type.Expand.Item]]
|
||||||
Condition = "(__getHighBits(mAllocSizeAndFlags, 2) & 1) == 0"
|
Condition = "(__getHighBits(mAllocSizeAndFlags, 2) & 1) == 0"
|
||||||
Name = "[RawChars]"
|
Name = "[RawChars]"
|
||||||
Value = "(char8*)&mPtr,arraysize=mLength"
|
Value = "(char8*)&mPtrOrBuffer,arraysize=mLength"
|
||||||
[[Type.Expand.Item]]
|
[[Type.Expand.Item]]
|
||||||
Condition = "(__getHighBits(mAllocSizeAndFlags, 2) & 1) != 0"
|
Condition = "(__getHighBits(mAllocSizeAndFlags, 2) & 1) != 0"
|
||||||
Name = "[RawChars]"
|
Name = "[RawChars]"
|
||||||
Value = "mPtr,arraysize=mLength"
|
Value = "mPtrOrBuffer,arraysize=mLength"
|
||||||
|
|
||||||
[[Type]]
|
[[Type]]
|
||||||
Name = "System.StringView"
|
Name = "System.StringView"
|
||||||
|
|
|
@ -38,7 +38,7 @@ namespace System.Diagnostics
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Result<ProfileId> StartSampling(int32 threadId, StringView profileDesc)
|
static Result<ProfileId> StartSampling(int threadId, StringView profileDesc)
|
||||||
{
|
{
|
||||||
//int32 curId = Interlocked.Increment(ref gProfileId);
|
//int32 curId = Interlocked.Increment(ref gProfileId);
|
||||||
int32 curId = gProfileId++;
|
int32 curId = gProfileId++;
|
||||||
|
|
|
@ -95,7 +95,7 @@ namespace System
|
||||||
|
|
||||||
extension Result<T> where T : IDisposable
|
extension Result<T> where T : IDisposable
|
||||||
{
|
{
|
||||||
public void Dispose()
|
public new void Dispose()
|
||||||
{
|
{
|
||||||
if (this case .Ok(var val))
|
if (this case .Ok(var val))
|
||||||
val.Dispose();
|
val.Dispose();
|
||||||
|
@ -199,7 +199,7 @@ namespace System
|
||||||
|
|
||||||
extension Result<T, TErr> where T : IDisposable
|
extension Result<T, TErr> where T : IDisposable
|
||||||
{
|
{
|
||||||
public void Dispose()
|
public new void Dispose()
|
||||||
{
|
{
|
||||||
if (this case .Ok(var val))
|
if (this case .Ok(var val))
|
||||||
val.Dispose();
|
val.Dispose();
|
||||||
|
@ -208,7 +208,7 @@ namespace System
|
||||||
|
|
||||||
extension Result<T, TErr> where TErr : IDisposable
|
extension Result<T, TErr> where TErr : IDisposable
|
||||||
{
|
{
|
||||||
public void Dispose()
|
public new void Dispose()
|
||||||
{
|
{
|
||||||
if (this case .Err(var err))
|
if (this case .Err(var err))
|
||||||
err.Dispose();
|
err.Dispose();
|
||||||
|
@ -217,7 +217,7 @@ namespace System
|
||||||
|
|
||||||
extension Result<T, TErr> where T : IDisposable where TErr : IDisposable
|
extension Result<T, TErr> where T : IDisposable where TErr : IDisposable
|
||||||
{
|
{
|
||||||
public void Dispose()
|
public new void Dispose()
|
||||||
{
|
{
|
||||||
if (this case .Ok(var val))
|
if (this case .Ok(var val))
|
||||||
val.Dispose();
|
val.Dispose();
|
||||||
|
|
|
@ -7,7 +7,7 @@ namespace System
|
||||||
[StaticInitPriority(100)]
|
[StaticInitPriority(100)]
|
||||||
class Runtime
|
class Runtime
|
||||||
{
|
{
|
||||||
const int32 cVersion = 9;
|
const int32 cVersion = 10;
|
||||||
|
|
||||||
[CRepr, AlwaysInclude]
|
[CRepr, AlwaysInclude]
|
||||||
struct BfDebugMessageData
|
struct BfDebugMessageData
|
||||||
|
@ -116,6 +116,7 @@ namespace System
|
||||||
function bool (Object thread) mThread_IsAutoDelete;
|
function bool (Object thread) mThread_IsAutoDelete;
|
||||||
function void (Object thread) mThread_AutoDelete;
|
function void (Object thread) mThread_AutoDelete;
|
||||||
function int32 (Object thread) mThread_GetMaxStackSize;
|
function int32 (Object thread) mThread_GetMaxStackSize;
|
||||||
|
function void () mThread_Exiting;
|
||||||
function void () mGC_MarkAllStaticMembers;
|
function void () mGC_MarkAllStaticMembers;
|
||||||
function bool () mGC_CallRootCallbacks;
|
function bool () mGC_CallRootCallbacks;
|
||||||
function void () mGC_Shutdown;
|
function void () mGC_Shutdown;
|
||||||
|
|
|
@ -78,6 +78,11 @@ namespace System.Threading
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void Thread_Exiting()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public static this()
|
public static this()
|
||||||
{
|
{
|
||||||
var cb = ref Runtime.BfRtCallbacks.[Friend]sCallbacks;
|
var cb = ref Runtime.BfRtCallbacks.[Friend]sCallbacks;
|
||||||
|
@ -90,6 +95,7 @@ namespace System.Threading
|
||||||
cb.[Friend]mThread_IsAutoDelete = => Thread_IsAutoDelete;
|
cb.[Friend]mThread_IsAutoDelete = => Thread_IsAutoDelete;
|
||||||
cb.[Friend]mThread_AutoDelete = => Thread_AutoDelete;
|
cb.[Friend]mThread_AutoDelete = => Thread_AutoDelete;
|
||||||
cb.[Friend]mThread_GetMaxStackSize = => Thread_GetMaxStackSize;
|
cb.[Friend]mThread_GetMaxStackSize = => Thread_GetMaxStackSize;
|
||||||
|
cb.[Friend]mThread_Exiting = => Thread_Exiting;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -280,9 +286,10 @@ namespace System.Threading
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int32 GetThreadId();
|
[CallingConvention(.Cdecl)]
|
||||||
|
extern int GetThreadId();
|
||||||
|
|
||||||
public int32 Id
|
public int Id
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
|
|
@ -21,6 +21,11 @@ namespace Hey.Dude.Bro
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct Color
|
||||||
|
{
|
||||||
|
public float r, g, b, a;
|
||||||
|
}
|
||||||
|
|
||||||
class TestClass
|
class TestClass
|
||||||
{
|
{
|
||||||
/*static void TestFunc()
|
/*static void TestFunc()
|
||||||
|
@ -37,8 +42,27 @@ namespace Hey.Dude.Bro
|
||||||
|
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
//private const uint16[] DebugIndexes = scope uint16[](0, 1, 2, 1, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 6, 5, 6, 7);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[Import(@"C:\Beef\BeefTools\TestDLL\x64\Debug\TestDLL.dll"), LinkName("Test2")]
|
||||||
|
public static extern void Test2(int32 a, int32 b, int32 c, int32 d, function Color(int32 a, int32 b) func);
|
||||||
|
|
||||||
|
public static Color GetColor(int32 a, int32 b)
|
||||||
|
{
|
||||||
|
Color c;
|
||||||
|
c.r = 1.2f;
|
||||||
|
c.g = 2.3f;
|
||||||
|
c.b = 3.4f;
|
||||||
|
c.a = 4.5f;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
public static int Main(String[] args)
|
public static int Main(String[] args)
|
||||||
{
|
{
|
||||||
|
Test2(1, 2, 3, 4, => GetColor);
|
||||||
|
|
||||||
//Blurg.Hey();
|
//Blurg.Hey();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ namespace IDE
|
||||||
public class RegistryEntry
|
public class RegistryEntry
|
||||||
{
|
{
|
||||||
public String mProjName ~ delete _;
|
public String mProjName ~ delete _;
|
||||||
|
public Project.TargetType mTargetType;
|
||||||
public SemVer mVersion ~ delete _;
|
public SemVer mVersion ~ delete _;
|
||||||
public VerSpec mLocation ~ _.Dispose();
|
public VerSpec mLocation ~ _.Dispose();
|
||||||
public ConfigFile mConfigFile;
|
public ConfigFile mConfigFile;
|
||||||
|
@ -51,6 +52,29 @@ namespace IDE
|
||||||
using (mMonitor.Enter())
|
using (mMonitor.Enter())
|
||||||
entry.mProjName.Set(projName);
|
entry.mProjName.Set(projName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sd.Contains("StartupObject"))
|
||||||
|
entry.mTargetType = .BeefConsoleApplication;
|
||||||
|
else
|
||||||
|
entry.mTargetType = .BeefLib;
|
||||||
|
|
||||||
|
var targetTypeName = scope String();
|
||||||
|
sd.GetString("TargetType", targetTypeName);
|
||||||
|
|
||||||
|
if (!targetTypeName.IsEmpty)
|
||||||
|
{
|
||||||
|
switch (targetTypeName)
|
||||||
|
{ // Handle Legacy names first
|
||||||
|
case "BeefWindowsApplication":
|
||||||
|
entry.mTargetType = .BeefGUIApplication;
|
||||||
|
case "C_WindowsApplication":
|
||||||
|
entry.mTargetType = .C_GUIApplication;
|
||||||
|
case "BeefDynLib":
|
||||||
|
entry.mTargetType = .BeefLib;
|
||||||
|
default:
|
||||||
|
entry.mTargetType = sd.GetEnum<Project.TargetType>("TargetType", entry.mTargetType);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -627,15 +627,7 @@ namespace IDE
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
String compilerExePath = scope String();
|
String compilerExePath = scope String();
|
||||||
#if BF_PLATFORM_WINDOWS
|
|
||||||
String llvmDir = scope String(IDEApp.sApp.mInstallDir);
|
|
||||||
IDEUtils.FixFilePath(llvmDir);
|
|
||||||
llvmDir.Append("llvm/");
|
|
||||||
#else
|
|
||||||
String llvmDir = "";
|
|
||||||
#endif
|
|
||||||
if (gApp.mSettings.mEmscriptenPath.IsEmpty)
|
if (gApp.mSettings.mEmscriptenPath.IsEmpty)
|
||||||
{
|
{
|
||||||
gApp.OutputErrorLine("Emscripten path not configured. Check Wasm configuration in File\\Preferences\\Settings.");
|
gApp.OutputErrorLine("Emscripten path not configured. Check Wasm configuration in File\\Preferences\\Settings.");
|
||||||
|
|
|
@ -90,10 +90,11 @@ namespace IDE
|
||||||
{
|
{
|
||||||
if (mParent == null)
|
if (mParent == null)
|
||||||
return;
|
return;
|
||||||
|
int startIdx = strBuffer.Length;
|
||||||
mParent.ToString(strBuffer);
|
mParent.ToString(strBuffer);
|
||||||
if (mBoundKeyState != null)
|
if (mBoundKeyState != null)
|
||||||
{
|
{
|
||||||
if (!strBuffer.IsEmpty)
|
if (strBuffer.Length > startIdx)
|
||||||
strBuffer.Append(", ");
|
strBuffer.Append(", ");
|
||||||
mBoundKeyState.ToString(strBuffer);
|
mBoundKeyState.ToString(strBuffer);
|
||||||
}
|
}
|
||||||
|
|
|
@ -156,7 +156,7 @@ namespace IDE.Compiler
|
||||||
static extern int32 BfCompiler_GetEmitSourceVersion(void* bfCompiler, char8* fileName);
|
static extern int32 BfCompiler_GetEmitSourceVersion(void* bfCompiler, char8* fileName);
|
||||||
|
|
||||||
[CallingConvention(.Stdcall), CLink]
|
[CallingConvention(.Stdcall), CLink]
|
||||||
static extern char8* BfCompiler_GetEmitLocation(void* bfCompiler, char8* typeName, int32 line, out int32 embedLine, out int32 embedLineChar);
|
static extern char8* BfCompiler_GetEmitLocation(void* bfCompiler, char8* typeName, int32 line, out int32 embedLine, out int32 embedLineChar, out uint64 hash);
|
||||||
|
|
||||||
[CallingConvention(.Stdcall), CLink]
|
[CallingConvention(.Stdcall), CLink]
|
||||||
static extern void BfCompiler_WriteEmitData(void* bfCompiler, char8* filePath, void* bfProject);
|
static extern void BfCompiler_WriteEmitData(void* bfCompiler, char8* filePath, void* bfProject);
|
||||||
|
@ -362,11 +362,11 @@ namespace IDE.Compiler
|
||||||
return BfCompiler_GetEmitSourceVersion(mNativeBfCompiler, fileName.ToScopeCStr!());
|
return BfCompiler_GetEmitSourceVersion(mNativeBfCompiler, fileName.ToScopeCStr!());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GetEmitLocation(StringView typeName, int line, String outFilePath, out int embedLine, out int embedLineChar)
|
public void GetEmitLocation(StringView typeName, int line, String outFilePath, out int embedLine, out int embedLineChar, out uint64 hash)
|
||||||
{
|
{
|
||||||
int32 embedLine32;
|
int32 embedLine32;
|
||||||
int32 embedLineChar32;
|
int32 embedLineChar32;
|
||||||
outFilePath.Append(BfCompiler_GetEmitLocation(mNativeBfCompiler, typeName.ToScopeCStr!(), (.)line, out embedLine32, out embedLineChar32));
|
outFilePath.Append(BfCompiler_GetEmitLocation(mNativeBfCompiler, typeName.ToScopeCStr!(), (.)line, out embedLine32, out embedLineChar32, out hash));
|
||||||
embedLine = embedLine32;
|
embedLine = embedLine32;
|
||||||
embedLineChar = embedLineChar32;
|
embedLineChar = embedLineChar32;
|
||||||
}
|
}
|
||||||
|
@ -603,6 +603,8 @@ namespace IDE.Compiler
|
||||||
UpdateRebuildFileWatches();
|
UpdateRebuildFileWatches();
|
||||||
mBfSystem.RemoveOldParsers();
|
mBfSystem.RemoveOldParsers();
|
||||||
mBfSystem.RemoveOldData();
|
mBfSystem.RemoveOldData();
|
||||||
|
if (gApp.mSettings.mEditorSettings.mEmitCompiler == .Build)
|
||||||
|
QueueRefreshViewCommand(.Collapse);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command is ResolveAllCommand)
|
if (command is ResolveAllCommand)
|
||||||
|
|
|
@ -239,6 +239,16 @@ namespace IDE.Compiler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BfParser GetParser(ProjectSource projectSource)
|
||||||
|
{
|
||||||
|
using (mMonitor.Enter())
|
||||||
|
{
|
||||||
|
BfParser parser;
|
||||||
|
mParserMap.TryGetValue(projectSource, out parser);
|
||||||
|
return parser;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public BfParser CreateNewParserRevision(BfParser prevParser)
|
public BfParser CreateNewParserRevision(BfParser prevParser)
|
||||||
{
|
{
|
||||||
using (mMonitor.Enter())
|
using (mMonitor.Enter())
|
||||||
|
|
|
@ -57,6 +57,14 @@ namespace IDE
|
||||||
String mWorkspaceDir = new String() ~ delete _;
|
String mWorkspaceDir = new String() ~ delete _;
|
||||||
bool mWantWorkspaceCleanup;
|
bool mWantWorkspaceCleanup;
|
||||||
public bool mDisabled;
|
public bool mDisabled;
|
||||||
|
Dictionary<String, List<uint8>> mDB = new .() ~ DeleteDictionaryAndKeysAndValues!(_);
|
||||||
|
public bool mDBDirty;
|
||||||
|
public String mDBWorkspaceDir = new String() ~ delete _;
|
||||||
|
|
||||||
|
public this()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public ~this()
|
public ~this()
|
||||||
{
|
{
|
||||||
|
@ -84,6 +92,26 @@ namespace IDE
|
||||||
bool wantWorkspaceCleanup = false;
|
bool wantWorkspaceCleanup = false;
|
||||||
using (mMonitor.Enter())
|
using (mMonitor.Enter())
|
||||||
{
|
{
|
||||||
|
if (mDBDirty)
|
||||||
|
{
|
||||||
|
String recoverPath = scope String();
|
||||||
|
recoverPath.Append(mWorkspaceDir);
|
||||||
|
recoverPath.Append("/recovery/db.bin");
|
||||||
|
|
||||||
|
FileStream fs = scope .();
|
||||||
|
if (fs.Create(recoverPath) case .Ok)
|
||||||
|
{
|
||||||
|
fs.Write((uint32)0xBEEF0701);
|
||||||
|
for (var kv in mDB)
|
||||||
|
{
|
||||||
|
fs.WriteStrSized32(kv.key).IgnoreError();
|
||||||
|
fs.Write((int32)kv.value.Count);
|
||||||
|
fs.TryWrite(kv.value).IgnoreError();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mDBDirty = false;
|
||||||
|
}
|
||||||
|
|
||||||
for (var entry in mFileSet)
|
for (var entry in mFileSet)
|
||||||
{
|
{
|
||||||
if (entry.mRecoveryFileName == null)
|
if (entry.mRecoveryFileName == null)
|
||||||
|
@ -250,6 +278,104 @@ namespace IDE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void CheckDB()
|
||||||
|
{
|
||||||
|
if (mDBWorkspaceDir == gApp.mWorkspace.mDir)
|
||||||
|
return;
|
||||||
|
|
||||||
|
using (mMonitor.Enter())
|
||||||
|
{
|
||||||
|
for (var kv in mDB)
|
||||||
|
{
|
||||||
|
delete kv.key;
|
||||||
|
delete kv.value;
|
||||||
|
}
|
||||||
|
mDB.Clear();
|
||||||
|
|
||||||
|
mDBWorkspaceDir.Set(gApp.mWorkspace.mDir);
|
||||||
|
if (mDBWorkspaceDir.IsEmpty)
|
||||||
|
return;
|
||||||
|
|
||||||
|
String recoverPath = scope String();
|
||||||
|
recoverPath.Append(mDBWorkspaceDir);
|
||||||
|
recoverPath.Append("/recovery/db.bin");
|
||||||
|
|
||||||
|
FileStream fs = scope .();
|
||||||
|
if (fs.Open(recoverPath) case .Ok)
|
||||||
|
{
|
||||||
|
if (fs.Read<uint32>() == 0xBEEF0701)
|
||||||
|
{
|
||||||
|
String filePath = scope .();
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
filePath.Clear();
|
||||||
|
if (fs.ReadStrSized32(filePath) case .Err)
|
||||||
|
break;
|
||||||
|
if (filePath.IsEmpty)
|
||||||
|
break;
|
||||||
|
|
||||||
|
int32 dataSize = fs.Read<int32>();
|
||||||
|
List<uint8> list = new List<uint8>();
|
||||||
|
mDB[new String(filePath)] = list;
|
||||||
|
|
||||||
|
list.Resize(dataSize);
|
||||||
|
if (fs.TryRead(.(list.Ptr, dataSize)) case .Err)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetDB(StringView key, Span<uint8> data)
|
||||||
|
{
|
||||||
|
using (mMonitor.Enter())
|
||||||
|
{
|
||||||
|
CheckDB();
|
||||||
|
|
||||||
|
if (mDB.TryAddAlt(key, var keyPtr, var valuePtr))
|
||||||
|
{
|
||||||
|
*keyPtr = new .(key);
|
||||||
|
*valuePtr = new .();
|
||||||
|
}
|
||||||
|
(*valuePtr).Clear();
|
||||||
|
(*valuePtr).AddRange(data);
|
||||||
|
mDBDirty = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool GetDB(StringView key, List<uint8> data)
|
||||||
|
{
|
||||||
|
using (mMonitor.Enter())
|
||||||
|
{
|
||||||
|
CheckDB();
|
||||||
|
|
||||||
|
if (mDB.TryGetAlt(key, var matchKey, var value))
|
||||||
|
{
|
||||||
|
data.AddRange(value);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool DeleteDB(StringView key)
|
||||||
|
{
|
||||||
|
using (mMonitor.Enter())
|
||||||
|
{
|
||||||
|
CheckDB();
|
||||||
|
|
||||||
|
if (mDB.GetAndRemoveAlt(key) case .Ok((var mapKey, var value)))
|
||||||
|
{
|
||||||
|
mDBDirty = true;
|
||||||
|
delete mapKey;
|
||||||
|
delete value;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void Update()
|
public void Update()
|
||||||
{
|
{
|
||||||
if (mProcessingEvent != null)
|
if (mProcessingEvent != null)
|
||||||
|
@ -261,7 +387,7 @@ namespace IDE
|
||||||
|
|
||||||
using (mMonitor.Enter())
|
using (mMonitor.Enter())
|
||||||
{
|
{
|
||||||
if ((!mDirty) && (!mWantWorkspaceCleanup))
|
if ((!mDirty) && (!mDBDirty) && (!mWantWorkspaceCleanup))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -95,6 +95,16 @@ namespace IDE
|
||||||
FileChanged(starPath, null, .Changed);
|
FileChanged(starPath, null, .Changed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((isDirectory) && (changeType == .Renamed))
|
||||||
|
{
|
||||||
|
// On Windows, renaming a directory with only case changes will result in a remove before a rename
|
||||||
|
var dirName = scope String();
|
||||||
|
Path.GetDirectoryPath(newPath.Substring(0, newPath.Length - 1), dirName);
|
||||||
|
dirName.Append(Path.DirectorySeparatorChar);
|
||||||
|
|
||||||
|
FileChanged(dirName, newPath, .DirectoryCreated);
|
||||||
|
}
|
||||||
|
|
||||||
var newPath;
|
var newPath;
|
||||||
if (isDirectory)
|
if (isDirectory)
|
||||||
{
|
{
|
||||||
|
|
|
@ -119,7 +119,7 @@ namespace IDE
|
||||||
public class IDEApp : BFApp
|
public class IDEApp : BFApp
|
||||||
{
|
{
|
||||||
public static String sRTVersionStr = "042";
|
public static String sRTVersionStr = "042";
|
||||||
public const String cVersion = "0.43.3";
|
public const String cVersion = "0.43.4";
|
||||||
|
|
||||||
#if BF_PLATFORM_WINDOWS
|
#if BF_PLATFORM_WINDOWS
|
||||||
public static readonly String sPlatform64Name = "Win64";
|
public static readonly String sPlatform64Name = "Win64";
|
||||||
|
@ -1475,6 +1475,14 @@ namespace IDE
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetEmbedCompiler(Settings.EditorSettings.CompilerKind emitCompiler)
|
||||||
|
{
|
||||||
|
gApp.mSettings.mEditorSettings.mEmitCompiler = emitCompiler;
|
||||||
|
mBfResolveCompiler?.QueueRefreshViewCommand(.Collapse);
|
||||||
|
if (emitCompiler == .Resolve)
|
||||||
|
mBfResolveCompiler?.QueueRefreshViewCommand(.FullRefresh);
|
||||||
|
}
|
||||||
|
|
||||||
public Result<void, FileError> LoadTextFile(String fileName, String outBuffer, bool autoRetry = true, delegate void() onPreFilter = null)
|
public Result<void, FileError> LoadTextFile(String fileName, String outBuffer, bool autoRetry = true, delegate void() onPreFilter = null)
|
||||||
{
|
{
|
||||||
if (mWorkspace.IsSingleFileWorkspace)
|
if (mWorkspace.IsSingleFileWorkspace)
|
||||||
|
@ -1490,9 +1498,23 @@ namespace IDE
|
||||||
|
|
||||||
if (fileName.StartsWith("$Emit$"))
|
if (fileName.StartsWith("$Emit$"))
|
||||||
{
|
{
|
||||||
BfCompiler compiler = mBfResolveCompiler;
|
String useFileName = fileName;
|
||||||
|
|
||||||
|
BfCompiler compiler = (gApp.mSettings.mEditorSettings.mEmitCompiler == .Resolve) ? mBfResolveCompiler : mBfBuildCompiler;
|
||||||
|
|
||||||
|
if (useFileName.StartsWith("$Emit$Build$"))
|
||||||
|
{
|
||||||
|
useFileName = scope:: $"$Emit${useFileName.Substring("$Emit$Build$".Length)}";
|
||||||
|
compiler = mBfBuildCompiler;
|
||||||
|
}
|
||||||
|
else if (useFileName.StartsWith("$Emit$Resolve$"))
|
||||||
|
{
|
||||||
|
useFileName = scope:: $"$Emit${useFileName.Substring("$Emit$Resolve$".Length)}";
|
||||||
|
compiler = mBfResolveCompiler;
|
||||||
|
}
|
||||||
|
|
||||||
if (!compiler.IsPerformingBackgroundOperation())
|
if (!compiler.IsPerformingBackgroundOperation())
|
||||||
compiler.GetEmitSource(fileName, outBuffer);
|
compiler.GetEmitSource(useFileName, outBuffer);
|
||||||
|
|
||||||
if (onPreFilter != null)
|
if (onPreFilter != null)
|
||||||
onPreFilter();
|
onPreFilter();
|
||||||
|
@ -2299,7 +2321,7 @@ namespace IDE
|
||||||
AddNewProjectToWorkspace(project);
|
AddNewProjectToWorkspace(project);
|
||||||
project.FinishCreate();
|
project.FinishCreate();
|
||||||
|
|
||||||
mProjectPanel.InitProject(project);
|
mProjectPanel.InitProject(project, mProjectPanel.GetSelectedWorkspaceFolder());
|
||||||
mProjectPanel.Sort();
|
mProjectPanel.Sort();
|
||||||
mWorkspace.FixOptions();
|
mWorkspace.FixOptions();
|
||||||
mWorkspace.mHasChanged = true;
|
mWorkspace.mHasChanged = true;
|
||||||
|
@ -2693,7 +2715,7 @@ namespace IDE
|
||||||
|
|
||||||
AddProjectToWorkspace(project, false);
|
AddProjectToWorkspace(project, false);
|
||||||
if (addToUI)
|
if (addToUI)
|
||||||
mProjectPanel.InitProject(project);
|
mProjectPanel.InitProject(project, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!hadLoad)
|
if (!hadLoad)
|
||||||
|
@ -2977,6 +2999,8 @@ namespace IDE
|
||||||
{
|
{
|
||||||
using (mBeefConfig.mRegistry.mMonitor.Enter())
|
using (mBeefConfig.mRegistry.mMonitor.Enter())
|
||||||
{
|
{
|
||||||
|
BeefConfig.RegistryEntry matchedEntry = null;
|
||||||
|
|
||||||
for (int regEntryIdx = mBeefConfig.mRegistry.mEntries.Count - 1; regEntryIdx >= 0; regEntryIdx--)
|
for (int regEntryIdx = mBeefConfig.mRegistry.mEntries.Count - 1; regEntryIdx >= 0; regEntryIdx--)
|
||||||
{
|
{
|
||||||
var regEntry = mBeefConfig.mRegistry.mEntries[regEntryIdx];
|
var regEntry = mBeefConfig.mRegistry.mEntries[regEntryIdx];
|
||||||
|
@ -2986,11 +3010,19 @@ namespace IDE
|
||||||
|
|
||||||
if (regEntry.mProjName == projectName)
|
if (regEntry.mProjName == projectName)
|
||||||
{
|
{
|
||||||
useVerSpec = regEntry.mLocation;
|
// Prioritize a lib file over a non-lib
|
||||||
verConfigDir = regEntry.mConfigFile.mConfigDir;
|
if ((matchedEntry == null) ||
|
||||||
break FindLoop;
|
((!matchedEntry.mTargetType.IsLib) && (regEntry.mTargetType.IsLib)))
|
||||||
|
matchedEntry = regEntry;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (matchedEntry != null)
|
||||||
|
{
|
||||||
|
useVerSpec = matchedEntry.mLocation;
|
||||||
|
verConfigDir = matchedEntry.mConfigFile.mConfigDir;
|
||||||
|
break FindLoop;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
mBeefConfig.mRegistry.WaitFor();
|
mBeefConfig.mRegistry.WaitFor();
|
||||||
}
|
}
|
||||||
|
@ -5429,6 +5461,20 @@ namespace IDE
|
||||||
sysMenu.Modify(null, null, null, true, checkVal ? 1 : 0);
|
sysMenu.Modify(null, null, null, true, checkVal ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Menu AddMenuItem(Menu menu, StringView label, StringView command = default)
|
||||||
|
{
|
||||||
|
var command;
|
||||||
|
if (command.IsEmpty)
|
||||||
|
command = label;
|
||||||
|
String labelStr = scope String(label);
|
||||||
|
if (mCommands.mCommandMap.TryGetAlt(command, var matchKey, var ideCommand))
|
||||||
|
{
|
||||||
|
labelStr.Append("|");
|
||||||
|
ideCommand.ToString(labelStr);
|
||||||
|
}
|
||||||
|
return menu.AddItem(labelStr);
|
||||||
|
}
|
||||||
|
|
||||||
public bool AreTestsRunning()
|
public bool AreTestsRunning()
|
||||||
{
|
{
|
||||||
return (mTestManager != null);
|
return (mTestManager != null);
|
||||||
|
@ -5683,6 +5729,17 @@ namespace IDE
|
||||||
AddMenuItem(bookmarkMenu, "&Previous Bookmark", "Bookmark Prev");
|
AddMenuItem(bookmarkMenu, "&Previous Bookmark", "Bookmark Prev");
|
||||||
AddMenuItem(bookmarkMenu, "&Clear Bookmarks", "Bookmark Clear");
|
AddMenuItem(bookmarkMenu, "&Clear Bookmarks", "Bookmark Clear");
|
||||||
|
|
||||||
|
var comptimeMenu = subMenu.AddMenuItem("Comptime");
|
||||||
|
var emitViewCompiler = comptimeMenu.AddMenuItem("Emit View Compiler");
|
||||||
|
var subItem = emitViewCompiler.AddMenuItem("Resolve", null,
|
||||||
|
new (menu) => { SetEmbedCompiler(.Resolve); } ,
|
||||||
|
new (menu) => { menu.SetCheckState((mSettings.mEditorSettings.mEmitCompiler == .Resolve) ? 1 : 0); },
|
||||||
|
null, true, (mSettings.mEditorSettings.mEmitCompiler == .Resolve) ? 1 : 0);
|
||||||
|
subItem = emitViewCompiler.AddMenuItem("Build", null,
|
||||||
|
new (menu) => { SetEmbedCompiler(.Build); } ,
|
||||||
|
new (menu) => { menu.SetCheckState((mSettings.mEditorSettings.mEmitCompiler == .Build) ? 1 : 0); },
|
||||||
|
null, true, (mSettings.mEditorSettings.mEmitCompiler == .Build) ? 1 : 0);
|
||||||
|
|
||||||
var advancedEditMenu = subMenu.AddMenuItem("Advanced");
|
var advancedEditMenu = subMenu.AddMenuItem("Advanced");
|
||||||
AddMenuItem(advancedEditMenu, "Duplicate Line", "Duplicate Line");
|
AddMenuItem(advancedEditMenu, "Duplicate Line", "Duplicate Line");
|
||||||
AddMenuItem(advancedEditMenu, "Move Line Up", "Move Line Up");
|
AddMenuItem(advancedEditMenu, "Move Line Up", "Move Line Up");
|
||||||
|
@ -6285,6 +6342,11 @@ namespace IDE
|
||||||
let process = scope SpawnedProcess();
|
let process = scope SpawnedProcess();
|
||||||
process.Start(procInfo).IgnoreError();
|
process.Start(procInfo).IgnoreError();
|
||||||
});
|
});
|
||||||
|
item = menu.AddItem("Show in Workspace Panel");
|
||||||
|
item.mOnMenuItemSelected.Add(new (menu) =>
|
||||||
|
{
|
||||||
|
sourceViewPanel.SyncWithWorkspacePanel();
|
||||||
|
});
|
||||||
item = menu.AddItem("Close");
|
item = menu.AddItem("Close");
|
||||||
item.mOnMenuItemSelected.Add(new (menu) =>
|
item.mOnMenuItemSelected.Add(new (menu) =>
|
||||||
{
|
{
|
||||||
|
@ -7155,10 +7217,11 @@ namespace IDE
|
||||||
|
|
||||||
public SourceViewPanel ShowSourceFileLocation(String filePath, int showHotIdx, int refHotIdx, int line, int column, LocatorType hilitePosition, bool showTemp = false)
|
public SourceViewPanel ShowSourceFileLocation(String filePath, int showHotIdx, int refHotIdx, int line, int column, LocatorType hilitePosition, bool showTemp = false)
|
||||||
{
|
{
|
||||||
|
var useFilePath = filePath;
|
||||||
|
|
||||||
if (filePath.StartsWith("$Emit$"))
|
if (filePath.StartsWith("$Emit$"))
|
||||||
{
|
{
|
||||||
var compiler = mBfResolveCompiler;
|
if ((mBfBuildCompiler.IsPerformingBackgroundOperation()) || (mBfResolveCompiler.IsPerformingBackgroundOperation()))
|
||||||
if (compiler.IsPerformingBackgroundOperation())
|
|
||||||
{
|
{
|
||||||
DeleteAndNullify!(mDeferredShowSource);
|
DeleteAndNullify!(mDeferredShowSource);
|
||||||
mDeferredShowSource = new DeferredShowSource()
|
mDeferredShowSource = new DeferredShowSource()
|
||||||
|
@ -7174,18 +7237,76 @@ namespace IDE
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var itr = filePath.Split('$');
|
String embedFilePath;
|
||||||
itr.GetNext();
|
bool isViewValid = true;
|
||||||
itr.GetNext();
|
StringView typeName;
|
||||||
var typeName = itr.GetNext().Value;
|
int embedLine;
|
||||||
|
int embedLineChar;
|
||||||
|
|
||||||
//var compiler = (kindStr == "Emit") ? mBfBuildCompiler : mBfResolveCompiler;
|
if (filePath.StartsWith("$Emit$Resolve$"))
|
||||||
|
{
|
||||||
compiler.mBfSystem.Lock(0);
|
if (gApp.mSettings.mEditorSettings.mEmitCompiler == .Resolve)
|
||||||
var embedFilePath = compiler.GetEmitLocation(typeName, line, .. scope .(), var embedLine, var embedLineChar);
|
{
|
||||||
compiler.mBfSystem.Unlock();
|
var itr = filePath.Split('$');
|
||||||
|
itr.GetNext();
|
||||||
|
itr.GetNext();
|
||||||
|
itr.GetNext();
|
||||||
|
typeName = itr.GetNext().Value;
|
||||||
|
|
||||||
|
mBfResolveCompiler.mBfSystem.Lock(0);
|
||||||
|
embedFilePath = mBfResolveCompiler.GetEmitLocation(typeName, line, .. scope:: .(), out embedLine, out embedLineChar, var embedHash);
|
||||||
|
mBfResolveCompiler.mBfSystem.Unlock();
|
||||||
|
|
||||||
|
useFilePath = scope:: $"$Emit${useFilePath.Substring("$Emit$Resolve$".Length)}";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
isViewValid = false;
|
||||||
|
}
|
||||||
|
else if (filePath.StartsWith("$Emit$Build$"))
|
||||||
|
{
|
||||||
|
if (gApp.mSettings.mEditorSettings.mEmitCompiler == .Build)
|
||||||
|
{
|
||||||
|
var itr = filePath.Split('$');
|
||||||
|
itr.GetNext();
|
||||||
|
itr.GetNext();
|
||||||
|
itr.GetNext();
|
||||||
|
typeName = itr.GetNext().Value;
|
||||||
|
|
||||||
|
mBfBuildCompiler.mBfSystem.Lock(0);
|
||||||
|
embedFilePath = mBfBuildCompiler.GetEmitLocation(typeName, line, .. scope:: .(), out embedLine, out embedLineChar, var embedHash);
|
||||||
|
mBfBuildCompiler.mBfSystem.Unlock();
|
||||||
|
|
||||||
|
useFilePath = scope:: $"$Emit${useFilePath.Substring("$Emit$Build$".Length)}";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
isViewValid = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var itr = filePath.Split('$');
|
||||||
|
itr.GetNext();
|
||||||
|
itr.GetNext();
|
||||||
|
typeName = itr.GetNext().Value;
|
||||||
|
|
||||||
if (!embedFilePath.IsEmpty)
|
mBfBuildCompiler.mBfSystem.Lock(0);
|
||||||
|
embedFilePath = mBfBuildCompiler.GetEmitLocation(typeName, line, .. scope:: .(), out embedLine, out embedLineChar, var embedHash);
|
||||||
|
mBfBuildCompiler.mBfSystem.Unlock();
|
||||||
|
|
||||||
|
if (gApp.mSettings.mEditorSettings.mEmitCompiler == .Resolve)
|
||||||
|
{
|
||||||
|
mBfResolveCompiler.mBfSystem.Lock(0);
|
||||||
|
mBfResolveCompiler.GetEmitLocation(typeName, line, scope .(), var resolveLine, var resolveLineChar, var resolveHash);
|
||||||
|
mBfResolveCompiler.mBfSystem.Unlock();
|
||||||
|
|
||||||
|
if ((resolveLine != embedLine) || (resolveLineChar != embedLineChar) || (embedHash != resolveHash))
|
||||||
|
{
|
||||||
|
isViewValid = false;
|
||||||
|
useFilePath = scope:: $"$Emit$Build${useFilePath.Substring("$Emit$".Length)}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((isViewValid) && (!embedFilePath.IsEmpty))
|
||||||
{
|
{
|
||||||
var sourceViewPanel = ShowSourceFile(scope .(embedFilePath), null, showTemp ? SourceShowType.Temp : SourceShowType.ShowExisting).panel;
|
var sourceViewPanel = ShowSourceFile(scope .(embedFilePath), null, showTemp ? SourceShowType.Temp : SourceShowType.ShowExisting).panel;
|
||||||
if (sourceViewPanel == null)
|
if (sourceViewPanel == null)
|
||||||
|
@ -7201,11 +7322,7 @@ namespace IDE
|
||||||
emitShowData.mColumn = (.)column;
|
emitShowData.mColumn = (.)column;
|
||||||
DeleteAndNullify!(sourceViewPanel.[Friend]mQueuedEmitShowData);
|
DeleteAndNullify!(sourceViewPanel.[Friend]mQueuedEmitShowData);
|
||||||
sourceViewPanel.[Friend]mQueuedEmitShowData = emitShowData;
|
sourceViewPanel.[Friend]mQueuedEmitShowData = emitShowData;
|
||||||
|
|
||||||
//sourceViewPanel.ShowHotFileIdx(showHotIdx);
|
|
||||||
sourceViewPanel.ShowFileLocation(refHotIdx, embedLine, embedLineChar, .None);
|
sourceViewPanel.ShowFileLocation(refHotIdx, embedLine, embedLineChar, .None);
|
||||||
//sourceViewPanel.QueueFullRefresh(false);
|
|
||||||
//sourceViewPanel.mBackgroundDelay = 1; // Don't immediately perform the full classify
|
|
||||||
|
|
||||||
if (typeName.Contains('<'))
|
if (typeName.Contains('<'))
|
||||||
{
|
{
|
||||||
|
@ -7220,7 +7337,7 @@ namespace IDE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var (sourceViewPanel, tabButton) = ShowSourceFile(filePath, null, showTemp ? SourceShowType.Temp : SourceShowType.ShowExisting);
|
var (sourceViewPanel, tabButton) = ShowSourceFile(useFilePath, null, showTemp ? SourceShowType.Temp : SourceShowType.ShowExisting);
|
||||||
if (sourceViewPanel == null)
|
if (sourceViewPanel == null)
|
||||||
return null;
|
return null;
|
||||||
if (((filePath.StartsWith("$")) && (var svTabButton = tabButton as SourceViewTabButton)))
|
if (((filePath.StartsWith("$")) && (var svTabButton = tabButton as SourceViewTabButton)))
|
||||||
|
@ -14259,7 +14376,8 @@ namespace IDE
|
||||||
if (IDEApp.sApp.mSpellChecker != null)
|
if (IDEApp.sApp.mSpellChecker != null)
|
||||||
IDEApp.sApp.mSpellChecker.CheckThreadDone();
|
IDEApp.sApp.mSpellChecker.CheckThreadDone();
|
||||||
|
|
||||||
if ((mDeferredShowSource != null) && (mBfResolveCompiler?.IsPerformingBackgroundOperation() == false))
|
if ((mDeferredShowSource != null) && (!mBfBuildCompiler.IsPerformingBackgroundOperation()) &&
|
||||||
|
(mBfResolveCompiler?.IsPerformingBackgroundOperation() != true))
|
||||||
{
|
{
|
||||||
var deferredShowSource = mDeferredShowSource;
|
var deferredShowSource = mDeferredShowSource;
|
||||||
mDeferredShowSource = null;
|
mDeferredShowSource = null;
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue