Adding IOStream + String library (needed to have proper iostream)
This commit is contained in:
@@ -114,9 +114,13 @@
|
|||||||
<ClInclude Include="include\Core\Common\NonMovable.h"/>
|
<ClInclude Include="include\Core\Common\NonMovable.h"/>
|
||||||
<ClInclude Include="include\Core\Common\NonNullPtr.h"/>
|
<ClInclude Include="include\Core\Common\NonNullPtr.h"/>
|
||||||
<ClInclude Include="include\Core\Common\Singleton.h"/>
|
<ClInclude Include="include\Core\Common\Singleton.h"/>
|
||||||
|
<ClInclude Include="include\Core\Common\String.h"/>
|
||||||
<ClInclude Include="include\Core\Container\Vector.h"/>
|
<ClInclude Include="include\Core\Container\Vector.h"/>
|
||||||
<ClInclude Include="include\Core\HAL\Display\Display.h"/>
|
<ClInclude Include="include\Core\HAL\Display\Display.h"/>
|
||||||
|
<ClInclude Include="include\Core\HAL\DynLib\DynamicLibrary.h"/>
|
||||||
<ClInclude Include="include\Core\HAL\Event\SystemEvent.h"/>
|
<ClInclude Include="include\Core\HAL\Event\SystemEvent.h"/>
|
||||||
|
<ClInclude Include="include\Core\HAL\Filesystem\Filesystem.h"/>
|
||||||
|
<ClInclude Include="include\Core\HAL\IO\IOStream.h"/>
|
||||||
<ClInclude Include="include\Core\HAL\Keyboard\Keyboard.h"/>
|
<ClInclude Include="include\Core\HAL\Keyboard\Keyboard.h"/>
|
||||||
<ClInclude Include="include\Core\HAL\Keyboard\KeyCode.h"/>
|
<ClInclude Include="include\Core\HAL\Keyboard\KeyCode.h"/>
|
||||||
<ClInclude Include="include\Core\HAL\Keyboard\ScanCode.h"/>
|
<ClInclude Include="include\Core\HAL\Keyboard\ScanCode.h"/>
|
||||||
@@ -156,6 +160,7 @@
|
|||||||
<ClInclude Include="src\Core\HAL\Event\WindowEvent.h"/>
|
<ClInclude Include="src\Core\HAL\Event\WindowEvent.h"/>
|
||||||
<ClInclude Include="src\Core\HAL\Filesystem\Filesystem_Platform.h"/>
|
<ClInclude Include="src\Core\HAL\Filesystem\Filesystem_Platform.h"/>
|
||||||
<ClInclude Include="src\Core\HAL\Filesystem\Filesystem_Private.h"/>
|
<ClInclude Include="src\Core\HAL\Filesystem\Filesystem_Private.h"/>
|
||||||
|
<ClInclude Include="src\Core\HAL\IO\IOStream_Private.h"/>
|
||||||
<ClInclude Include="src\Core\Networking\SocketPlatformImpl.h"/>
|
<ClInclude Include="src\Core\Networking\SocketPlatformImpl.h"/>
|
||||||
<ClInclude Include="src\Core\HAL\Win32.h"/>
|
<ClInclude Include="src\Core\HAL\Win32.h"/>
|
||||||
<ClInclude Include="src\Graphics\D3D12\D3D12Common.h"/>
|
<ClInclude Include="src\Graphics\D3D12\D3D12Common.h"/>
|
||||||
@@ -173,6 +178,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="src\Core\Application\ApplicationManager.cpp"/>
|
<ClCompile Include="src\Core\Application\ApplicationManager.cpp"/>
|
||||||
<ClCompile Include="src\Core\Common\CoreUtils.cpp"/>
|
<ClCompile Include="src\Core\Common\CoreUtils.cpp"/>
|
||||||
|
<ClCompile Include="src\Core\Common\String.cpp" />
|
||||||
<ClCompile Include="src\Core\HAL\Display\Display.cpp"/>
|
<ClCompile Include="src\Core\HAL\Display\Display.cpp"/>
|
||||||
<ClCompile Include="src\Core\HAL\Display\Win32\Win32DisplayDevice.cpp"/>
|
<ClCompile Include="src\Core\HAL\Display\Win32\Win32DisplayDevice.cpp"/>
|
||||||
<ClCompile Include="src\Core\HAL\Display\Win32\Win32DisplayEvent.cpp"/>
|
<ClCompile Include="src\Core\HAL\Display\Win32\Win32DisplayEvent.cpp"/>
|
||||||
@@ -185,6 +191,8 @@
|
|||||||
<ClCompile Include="src\Core\HAL\Event\WindowEvent.cpp"/>
|
<ClCompile Include="src\Core\HAL\Event\WindowEvent.cpp"/>
|
||||||
<ClCompile Include="src\Core\HAL\Filesystem\Filesystem.cpp"/>
|
<ClCompile Include="src\Core\HAL\Filesystem\Filesystem.cpp"/>
|
||||||
<ClCompile Include="src\Core\HAL\Filesystem\Win32\Win32Filesystem.cpp"/>
|
<ClCompile Include="src\Core\HAL\Filesystem\Win32\Win32Filesystem.cpp"/>
|
||||||
|
<ClCompile Include="src\Core\HAL\IO\IOStream.cpp"/>
|
||||||
|
<ClCompile Include="src\Core\HAL\IO\Win32\Win32IOStream.cpp"/>
|
||||||
<ClCompile Include="src\Core\HotReload\HotReload.cpp"/>
|
<ClCompile Include="src\Core\HotReload\HotReload.cpp"/>
|
||||||
<ClCompile Include="src\Core\HotReload\Win32\Win32HotReload.cpp"/>
|
<ClCompile Include="src\Core\HotReload\Win32\Win32HotReload.cpp"/>
|
||||||
<ClCompile Include="src\Core\Juliet.cpp"/>
|
<ClCompile Include="src\Core\Juliet.cpp"/>
|
||||||
|
|||||||
@@ -24,14 +24,6 @@ struct ByteBuffer
|
|||||||
size_t Size;
|
size_t Size;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename CharType>
|
|
||||||
struct StringBuffer
|
|
||||||
{
|
|
||||||
CharType* Data;
|
|
||||||
size_t Size;
|
|
||||||
};
|
|
||||||
#define StringBufferParam(str) { (str), sizeof(str) }
|
|
||||||
|
|
||||||
using FunctionPtr = auto (*)(void) -> void;
|
using FunctionPtr = auto (*)(void) -> void;
|
||||||
|
|
||||||
// Limits
|
// Limits
|
||||||
|
|||||||
132
Juliet/include/Core/Common/String.h
Normal file
132
Juliet/include/Core/Common/String.h
Normal file
@@ -0,0 +1,132 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <Core/Memory/Utils.h>
|
||||||
|
|
||||||
|
namespace Juliet
|
||||||
|
{
|
||||||
|
#define ConstString(str) { const_cast<char*>((str)), sizeof(str) - 1 }
|
||||||
|
#define CStr(str) ((str).Data)
|
||||||
|
#define InplaceString(name, size) \
|
||||||
|
char name##_[size]; \
|
||||||
|
String name = { name##_, sizeof(name##_) }
|
||||||
|
|
||||||
|
struct String
|
||||||
|
{
|
||||||
|
char* Data;
|
||||||
|
size_t Size;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct String16
|
||||||
|
{
|
||||||
|
char16_t* Data;
|
||||||
|
size_t Size;
|
||||||
|
};
|
||||||
|
|
||||||
|
inline size_t StringLength(String str)
|
||||||
|
{
|
||||||
|
return str.Size;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline size_t StringLength(const char* str)
|
||||||
|
{
|
||||||
|
size_t counter = 0;
|
||||||
|
if (str)
|
||||||
|
{
|
||||||
|
while (*str++)
|
||||||
|
{
|
||||||
|
++counter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return counter;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool StringIsValid(String str)
|
||||||
|
{
|
||||||
|
return str.Size > 0 && str.Data != nullptr && *str.Data;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline String WrapString(const char* str)
|
||||||
|
{
|
||||||
|
String result = {};
|
||||||
|
result.Data = const_cast<char*>(str);
|
||||||
|
result.Size = StringLength(str);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline String FindChar(String str, char c)
|
||||||
|
{
|
||||||
|
String result = str;
|
||||||
|
while (result.Size)
|
||||||
|
{
|
||||||
|
if (*result.Data != c)
|
||||||
|
{
|
||||||
|
++result.Data;
|
||||||
|
--result.Size;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool ContainsChar(String str, char c)
|
||||||
|
{
|
||||||
|
return StringIsValid(FindChar(str, c));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return:
|
||||||
|
// - < 0 if str1 < str2
|
||||||
|
// - = 0 : Both strings are equals
|
||||||
|
// - > 0 if str1 > str2
|
||||||
|
inline int32 StringCompare(String str1, String str2)
|
||||||
|
{
|
||||||
|
size_t len1 = StringLength(str1);
|
||||||
|
size_t len2 = StringLength(str2);
|
||||||
|
size_t minLen = Min(len1, len2);
|
||||||
|
int32 result = MemCompare(CStr(str1), CStr(str2), minLen);
|
||||||
|
if (result == 0)
|
||||||
|
{
|
||||||
|
if (len1 > len2)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (len1 < len2)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int8 StringCompareCaseInsensitive(String str1, String str2)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Do not allocate anything, you must allocate your out buffer yourself
|
||||||
|
// TODO: Version taking arena that can allocate
|
||||||
|
extern JULIET_API bool ConvertString(String from, String to, String in, String& out);
|
||||||
|
|
||||||
|
} // namespace Juliet
|
||||||
|
|
||||||
|
#ifdef UNIT_TEST
|
||||||
|
namespace Juliet::UnitTest
|
||||||
|
{
|
||||||
|
inline void TestFindChar()
|
||||||
|
{
|
||||||
|
String s1 = ConstString("");
|
||||||
|
String s2 = ConstString("abcdefabcdef");
|
||||||
|
String s3 = ConstString("11111111111111111111");
|
||||||
|
|
||||||
|
Assert(FindChar(s1, 'x').Data == nullptr);
|
||||||
|
Assert(FindChar(s2, 'y').Data == nullptr);
|
||||||
|
Assert(FindChar(s2, 'a').Data - s2.Data == 0);
|
||||||
|
Assert(FindChar(s2, 'd').Data - s2.Data == 3);
|
||||||
|
Assert(FindChar(s2, 'f').Data - s2.Data == 5);
|
||||||
|
Assert(FindChar(s3, '1').Data - s3.Data == 0);
|
||||||
|
}
|
||||||
|
} // namespace Juliet::UnitTest
|
||||||
|
#endif
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <Core/Common/String.h>
|
||||||
|
|
||||||
namespace Juliet
|
namespace Juliet
|
||||||
{
|
{
|
||||||
// Returns the path to the application directory
|
// Returns the path to the application directory
|
||||||
extern JULIET_API char * GetBasePath();
|
extern JULIET_API String GetBasePath();
|
||||||
}
|
} // namespace Juliet
|
||||||
|
|||||||
12
Juliet/include/Core/HAL/IO/IOStream.h
Normal file
12
Juliet/include/Core/HAL/IO/IOStream.h
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <Core/Common/String.h>
|
||||||
|
#include <Juliet.h>
|
||||||
|
|
||||||
|
namespace Juliet
|
||||||
|
{
|
||||||
|
// Opaque type
|
||||||
|
struct IOStream;
|
||||||
|
|
||||||
|
extern JULIET_API IOStream* IOFromFile(String filename, String mode);
|
||||||
|
} // namespace Juliet
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <Core/Common/String.h>
|
||||||
|
|
||||||
namespace Juliet
|
namespace Juliet
|
||||||
{
|
{
|
||||||
// Fwd Declare
|
// Fwd Declare
|
||||||
@@ -7,9 +9,9 @@ namespace Juliet
|
|||||||
|
|
||||||
struct HotReloadCode
|
struct HotReloadCode
|
||||||
{
|
{
|
||||||
StringBuffer<char> DLLFullPath;
|
String DLLFullPath;
|
||||||
StringBuffer<char> LockFullPath;
|
String LockFullPath;
|
||||||
StringBuffer<const char> TransientDLLName;
|
String TransientDLLName;
|
||||||
|
|
||||||
uint64 LastWriteTime;
|
uint64 LastWriteTime;
|
||||||
|
|
||||||
@@ -24,8 +26,8 @@ namespace Juliet
|
|||||||
bool IsValid : 1;
|
bool IsValid : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern JULIET_API void InitHotReloadCode(HotReloadCode& code, StringBuffer<const char> dllName,
|
extern JULIET_API void InitHotReloadCode(HotReloadCode& code, String dllName,
|
||||||
StringBuffer<const char> transientDllName, StringBuffer<const char> lockFilename);
|
String transientDllName, String lockFilename);
|
||||||
extern JULIET_API void ShutdownHotReloadCode(HotReloadCode& code);
|
extern JULIET_API void ShutdownHotReloadCode(HotReloadCode& code);
|
||||||
|
|
||||||
extern JULIET_API void LoadCode(HotReloadCode& code);
|
extern JULIET_API void LoadCode(HotReloadCode& code);
|
||||||
|
|||||||
@@ -1,3 +1,18 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define ArraySize(array) (sizeof(array) / sizeof(array[0]))
|
#define ArraySize(array) (sizeof(array) / sizeof(array[0]))
|
||||||
|
|
||||||
|
namespace Juliet
|
||||||
|
{
|
||||||
|
inline int32 MemCompare(const void* leftValue, const void* rightValue, size_t size)
|
||||||
|
{
|
||||||
|
const unsigned char* left = static_cast<const unsigned char*>(leftValue);
|
||||||
|
const unsigned char* right = static_cast<const unsigned char*>(rightValue);
|
||||||
|
while (size && *left == *right)
|
||||||
|
{
|
||||||
|
++left;
|
||||||
|
++right;
|
||||||
|
}
|
||||||
|
return size ? *left - *right : 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
88
Juliet/src/Core/Common/String.cpp
Normal file
88
Juliet/src/Core/Common/String.cpp
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
#include <pch.h>
|
||||||
|
|
||||||
|
#include <Core/Common/String.h>
|
||||||
|
#include <Core/Memory/Utils.h>
|
||||||
|
|
||||||
|
namespace Juliet
|
||||||
|
{
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
enum class Encoding : uint8
|
||||||
|
{
|
||||||
|
Unknown = 0,
|
||||||
|
ASCII,
|
||||||
|
LATIN1,
|
||||||
|
UTF8,
|
||||||
|
UTF16,
|
||||||
|
UTF32,
|
||||||
|
UCS2,
|
||||||
|
UCS4,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
const char* name;
|
||||||
|
Encoding format;
|
||||||
|
} Encodings[] = {
|
||||||
|
/* *INDENT-OFF* */ // clang-format off
|
||||||
|
{ "ASCII", Encoding::ASCII },
|
||||||
|
{ "US-ASCII", Encoding::ASCII },
|
||||||
|
{ "8859-1", Encoding::LATIN1 },
|
||||||
|
{ "ISO-8859-1", Encoding::LATIN1 },
|
||||||
|
#if defined(JULIET_WIN32)
|
||||||
|
{ "WCHAR_T", Encoding::UTF16 },
|
||||||
|
#else
|
||||||
|
{ "WCHAR_T", Encoding::UCS4 },
|
||||||
|
#endif
|
||||||
|
{ "UTF8", Encoding::UTF8 },
|
||||||
|
{ "UTF-8", Encoding::UTF8 },
|
||||||
|
{ "UTF16", Encoding::UTF16 },
|
||||||
|
{ "UTF-16", Encoding::UTF16 },
|
||||||
|
{ "UTF32", Encoding::UTF32 },
|
||||||
|
{ "UTF-32", Encoding::UTF32 },
|
||||||
|
{ "UCS2", Encoding::UCS2 },
|
||||||
|
{ "UCS-2", Encoding::UCS2 },
|
||||||
|
{ "UCS-2-INTERNAL", Encoding::UCS2 },
|
||||||
|
{ "UCS4", Encoding::UCS4 },
|
||||||
|
{ "UCS-4", Encoding::UCS4 },
|
||||||
|
{ "UCS-4-INTERNAL", Encoding::UCS4 },
|
||||||
|
/* *INDENT-ON* */ // clang-format on
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
bool ConvertString(String from, String to, String in, String& out)
|
||||||
|
{
|
||||||
|
Assert(in.Size <= out.Size);
|
||||||
|
Assert(StringIsValid(from));
|
||||||
|
Assert(StringIsValid(to));
|
||||||
|
Assert(StringIsValid(in));
|
||||||
|
|
||||||
|
for (size_t idx = 0; idx < ArraySize(Encodings); ++idx)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
// for (i = 0; i < SDL_arraysize(encodings); ++i) {
|
||||||
|
// if (SDL_strcasecmp(fromcode, encodings[i].name) == 0) {
|
||||||
|
// src_fmt = encodings[i].format;
|
||||||
|
// if (dst_fmt != ENCODING_UNKNOWN) {
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// if (SDL_strcasecmp(tocode, encodings[i].name) == 0) {
|
||||||
|
// dst_fmt = encodings[i].format;
|
||||||
|
// if (src_fmt != ENCODING_UNKNOWN) {
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// if (src_fmt != ENCODING_UNKNOWN && dst_fmt != ENCODING_UNKNOWN) {
|
||||||
|
// SDL_iconv_t cd = (SDL_iconv_t)SDL_malloc(sizeof(*cd));
|
||||||
|
// if (cd) {
|
||||||
|
// cd->src_fmt = src_fmt;
|
||||||
|
// cd->dst_fmt = dst_fmt;
|
||||||
|
// return cd;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
} // namespace Juliet
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
#include <pch.h>
|
#include <pch.h>
|
||||||
|
|
||||||
|
#include <Core/Common/String.h>
|
||||||
#include <Core/HAL/Filesystem/Filesystem.h>
|
#include <Core/HAL/Filesystem/Filesystem.h>
|
||||||
#include <Core/HAL/Filesystem/Filesystem_Platform.h>
|
#include <Core/HAL/Filesystem/Filesystem_Platform.h>
|
||||||
#include <Core/HAL/Filesystem/Filesystem_Private.h>
|
#include <Core/HAL/Filesystem/Filesystem_Private.h>
|
||||||
@@ -9,11 +10,12 @@ namespace Juliet
|
|||||||
{
|
{
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
char* CachedBasePath = nullptr;
|
String CachedBasePath = {};
|
||||||
}
|
}
|
||||||
char* GetBasePath()
|
|
||||||
|
String GetBasePath()
|
||||||
{
|
{
|
||||||
if (CachedBasePath == nullptr)
|
if (!StringIsValid(CachedBasePath))
|
||||||
{
|
{
|
||||||
CachedBasePath = Platform::GetBasePath();
|
CachedBasePath = Platform::GetBasePath();
|
||||||
}
|
}
|
||||||
@@ -24,9 +26,10 @@ namespace Juliet
|
|||||||
|
|
||||||
void ShutdownFilesystem()
|
void ShutdownFilesystem()
|
||||||
{
|
{
|
||||||
if (CachedBasePath != nullptr)
|
if (StringIsValid(CachedBasePath))
|
||||||
{
|
{
|
||||||
SafeFree(CachedBasePath);
|
CachedBasePath.Size = 0;
|
||||||
|
SafeFree(CachedBasePath.Data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // namespace Juliet
|
} // namespace Juliet
|
||||||
|
|||||||
@@ -2,5 +2,5 @@
|
|||||||
|
|
||||||
namespace Juliet::Platform
|
namespace Juliet::Platform
|
||||||
{
|
{
|
||||||
extern char* GetBasePath();
|
extern String GetBasePath();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include <pch.h>
|
#include <pch.h>
|
||||||
|
|
||||||
|
#include <Core/Common/String.h>
|
||||||
#include <Core/HAL/Filesystem/Filesystem_Platform.h>
|
#include <Core/HAL/Filesystem/Filesystem_Platform.h>
|
||||||
#include <Core/HAL/Win32.h>
|
#include <Core/HAL/Win32.h>
|
||||||
#include <Core/Memory/Allocator.h>
|
#include <Core/Memory/Allocator.h>
|
||||||
@@ -11,10 +12,10 @@ namespace Juliet::Platform
|
|||||||
// TODO : Move into string file
|
// TODO : Move into string file
|
||||||
// Use portable code + pass the memory array into parameter and not use new
|
// Use portable code + pass the memory array into parameter and not use new
|
||||||
// From: https://stackoverflow.com/questions/215963/how-do-you-properly-use-widechartomultibyte
|
// From: https://stackoverflow.com/questions/215963/how-do-you-properly-use-widechartomultibyte
|
||||||
char* WideCharToUTF8(wchar_t* wcharStr)
|
char* WideCharToUTF8(char16_t* wcharStr)
|
||||||
{
|
{
|
||||||
char* result = nullptr;
|
char* result = nullptr;
|
||||||
size_t length = WideCharToMultiByte(CP_UTF8, 0, wcharStr, -1, nullptr, 0, nullptr, nullptr);
|
size_t length = WideCharToMultiByte(CP_UTF8, 0, reinterpret_cast<LPCWCH>(wcharStr), -1, nullptr, 0, nullptr, nullptr);
|
||||||
if (length <= 0)
|
if (length <= 0)
|
||||||
{
|
{
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@@ -26,7 +27,7 @@ namespace Juliet::Platform
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (WideCharToMultiByte(CP_UTF8, 0, wcharStr, -1, result, length, nullptr, nullptr) <= 0)
|
if (WideCharToMultiByte(CP_UTF8, 0, reinterpret_cast<LPCWCH>(wcharStr), -1, result, length, nullptr, nullptr) <= 0)
|
||||||
{
|
{
|
||||||
delete[] result;
|
delete[] result;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@@ -36,27 +37,28 @@ namespace Juliet::Platform
|
|||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
char* GetBasePath()
|
String GetBasePath()
|
||||||
{
|
{
|
||||||
// Allocate a buffer that could fit the module size.
|
// Allocate a buffer that could fit the module size.
|
||||||
// Max Path is a good start but could be bigger if the path include long path prefix
|
// Max Path is a good start but could be bigger if the path include long path prefix
|
||||||
StringBuffer<WCHAR> buffer{ .Data = nullptr, .Size = MAX_PATH };
|
String16 buffer{ .Data = nullptr, .Size = MAX_PATH };
|
||||||
buffer.Data = static_cast<WCHAR*>(Calloc(MAX_PATH, sizeof(WCHAR)));
|
buffer.Data = static_cast<char16_t*>(Calloc(MAX_PATH, sizeof(WCHAR)));
|
||||||
if (buffer.Data == nullptr)
|
if (buffer.Data == nullptr)
|
||||||
{
|
{
|
||||||
return nullptr;
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t moduleFilenameLength = 0;
|
size_t moduleFilenameLength = 0;
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
moduleFilenameLength = GetModuleFileNameW(nullptr, buffer.Data, static_cast<uint32>(buffer.Size));
|
moduleFilenameLength =
|
||||||
|
GetModuleFileNameW(nullptr, reinterpret_cast<LPWSTR>(buffer.Data), static_cast<uint32>(buffer.Size));
|
||||||
|
|
||||||
// If the module filename length is bigger than the buffer size, we need to reallocate a bigger buffer
|
// If the module filename length is bigger than the buffer size, we need to reallocate a bigger buffer
|
||||||
if (moduleFilenameLength >= buffer.Size - 1)
|
if (moduleFilenameLength >= buffer.Size - 1)
|
||||||
{
|
{
|
||||||
buffer.Size *= 2;
|
buffer.Size *= 2;
|
||||||
buffer.Data = static_cast<WCHAR*>(Realloc(buffer.Data, buffer.Size * sizeof(WCHAR)));
|
buffer.Data = static_cast<char16_t*>(Realloc(buffer.Data, buffer.Size * sizeof(WCHAR)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -85,6 +87,7 @@ namespace Juliet::Platform
|
|||||||
// TODO: Add utils to Convert to/from UTF8W
|
// TODO: Add utils to Convert to/from UTF8W
|
||||||
char* basePath = WideCharToUTF8(buffer.Data);
|
char* basePath = WideCharToUTF8(buffer.Data);
|
||||||
SafeFree(buffer.Data);
|
SafeFree(buffer.Data);
|
||||||
return basePath;
|
|
||||||
|
return WrapString(basePath);
|
||||||
}
|
}
|
||||||
} // namespace Juliet::Platform
|
} // namespace Juliet::Platform
|
||||||
|
|||||||
24
Juliet/src/Core/HAL/IO/IOStream.cpp
Normal file
24
Juliet/src/Core/HAL/IO/IOStream.cpp
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
#include <pch.h>
|
||||||
|
|
||||||
|
#include <Core/Common/String.h>
|
||||||
|
#include <Core/HAL/IO/IOStream.h>
|
||||||
|
#include <Core/HAL/IO/IOStream_Private.h>
|
||||||
|
|
||||||
|
namespace Juliet
|
||||||
|
{
|
||||||
|
IOStream* IOFromFile(String filename, String mode)
|
||||||
|
{
|
||||||
|
if (!StringIsValid(filename))
|
||||||
|
{
|
||||||
|
Log(LogLevel::Error, LogCategory::Core, "Trying to open IOStream on invalid filename");
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
if (!StringIsValid(mode))
|
||||||
|
{
|
||||||
|
Log(LogLevel::Error, LogCategory::Core, "Trying to open IOStream with invalid mode");
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Internal::IOFromFile(filename, mode);
|
||||||
|
}
|
||||||
|
} // namespace Juliet
|
||||||
12
Juliet/src/Core/HAL/IO/IOStream_Private.h
Normal file
12
Juliet/src/Core/HAL/IO/IOStream_Private.h
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <Core/Common/String.h>
|
||||||
|
|
||||||
|
namespace Juliet
|
||||||
|
{
|
||||||
|
struct IOStream;
|
||||||
|
}
|
||||||
|
namespace Juliet::Internal
|
||||||
|
{
|
||||||
|
extern JULIET_API IOStream* IOFromFile(String filename, String mode);
|
||||||
|
}
|
||||||
68
Juliet/src/Core/HAL/IO/Win32/Win32IOStream.cpp
Normal file
68
Juliet/src/Core/HAL/IO/Win32/Win32IOStream.cpp
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
#include <pch.h>
|
||||||
|
|
||||||
|
#include <Core/Common/String.h>
|
||||||
|
#include <Core/HAL/IO/IOStream.h>
|
||||||
|
#include <Core/HAL/Win32.h>
|
||||||
|
|
||||||
|
namespace Juliet::Internal
|
||||||
|
{
|
||||||
|
IOStream* IOFromFile(String filename, String mode)
|
||||||
|
{
|
||||||
|
HANDLE hFile;
|
||||||
|
|
||||||
|
// "r" = reading, file must exist
|
||||||
|
// "w" = writing, truncate existing, file may not exist
|
||||||
|
// "r+"= reading or writing, file must exist
|
||||||
|
// "a" = writing, append file may not exist
|
||||||
|
// "a+"= append + read, file may not exist
|
||||||
|
// "w+" = read, write, truncate. file may not exist
|
||||||
|
|
||||||
|
#if _DEBUG
|
||||||
|
// Making sure the mode is valid
|
||||||
|
String modeView = mode;
|
||||||
|
size_t modeLength = StringLength(modeView);
|
||||||
|
Assert(!ContainsChar(mode, 'b') && "Binary mode note supported");
|
||||||
|
Assert((modeLength <= 2) &&
|
||||||
|
"Mode should have at most 2 characters, one being either r,w or a and the other can only be +");
|
||||||
|
if (modeLength == 1)
|
||||||
|
{
|
||||||
|
Assert(modeView.Data[0] == 'r' || modeView.Data[0] == 'w' ||
|
||||||
|
modeView.Data[0] == 'a' && "Invalid Mode. First char is not r,w or a");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Assert(modeView.Data[1] == '+' && "Invalid Mode. Second char is not +");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
DWORD openExisting = ContainsChar(mode, 'r') ? OPEN_EXISTING : 0;
|
||||||
|
DWORD createAlways = ContainsChar(mode, 'w') ? CREATE_ALWAYS : 0;
|
||||||
|
DWORD openAlways = ContainsChar(mode, 'a') ? OPEN_ALWAYS : 0;
|
||||||
|
|
||||||
|
bool hasPlus = ContainsChar(mode, '+');
|
||||||
|
DWORD canRead = openExisting || hasPlus ? GENERIC_READ : 0;
|
||||||
|
DWORD canWrite = createAlways || openAlways || hasPlus ? GENERIC_WRITE : 0;
|
||||||
|
|
||||||
|
if (!canRead && !canWrite)
|
||||||
|
{
|
||||||
|
Log(LogLevel::Error, LogCategory::Core, "IOFromFile: Invalid Mode (cannot read nor write)");
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prevent opening a dialog box when file doesnt exits (windows does that)
|
||||||
|
// old_error_mode = SetErrorMode(SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS);
|
||||||
|
{
|
||||||
|
// LPWSTR str = WIN_UTF8ToStringW(filename);
|
||||||
|
// h = CreateFileW(str,
|
||||||
|
// (w_right | r_right),
|
||||||
|
// (w_right) ? 0 : FILE_SHARE_READ,
|
||||||
|
// NULL,
|
||||||
|
// (must_exist | truncate | a_mode),
|
||||||
|
// FILE_ATTRIBUTE_NORMAL,
|
||||||
|
// NULL);
|
||||||
|
// SDL_free(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
} // namespace Juliet::Internal
|
||||||
@@ -9,33 +9,32 @@
|
|||||||
|
|
||||||
namespace Juliet
|
namespace Juliet
|
||||||
{
|
{
|
||||||
void InitHotReloadCode(HotReloadCode& code, StringBuffer<const char> dllName,
|
void InitHotReloadCode(HotReloadCode& code, String dllName, String transientDllName, String lockFilename)
|
||||||
StringBuffer<const char> transientDllName, StringBuffer<const char> lockFilename)
|
|
||||||
{
|
{
|
||||||
// Get the app base path and build the dll path from there.
|
// Get the app base path and build the dll path from there.
|
||||||
const char* basePath = GetBasePath();
|
String basePath = GetBasePath();
|
||||||
size_t basePathLength = strlen(basePath);
|
size_t basePathLength = StringLength(basePath);
|
||||||
|
|
||||||
// Assign Transient dll path
|
// Assign Transient dll path
|
||||||
code.TransientDLLName = transientDllName;
|
code.TransientDLLName = transientDllName;
|
||||||
|
|
||||||
// First allocate all the full path.
|
// First allocate all the full path.
|
||||||
// TODO: Add path composition into filesystem + string format + string builder
|
// TODO: Add path composition into filesystem + string format + string builder
|
||||||
const size_t dllFullPathLength = basePathLength + dllName.Size;
|
const size_t dllFullPathLength = basePathLength + StringLength(dllName) + 1; // Need +1 because snprintf needs 0 terminated strings
|
||||||
code.DLLFullPath.Data = static_cast<char*>(Calloc(dllFullPathLength, sizeof(char)));
|
code.DLLFullPath.Data = static_cast<char*>(Calloc(dllFullPathLength, sizeof(char)));
|
||||||
int writtenSize = snprintf(code.DLLFullPath.Data, dllFullPathLength, "%s%s", basePath, dllName.Data);
|
int writtenSize = snprintf(CStr(code.DLLFullPath), dllFullPathLength, "%s%s", CStr(basePath), CStr(dllName));
|
||||||
if (writtenSize < static_cast<int>(dllFullPathLength) - 1)
|
if (writtenSize < static_cast<int>(dllFullPathLength) - 1)
|
||||||
{
|
{
|
||||||
SafeFree(code.DLLFullPath.Data);
|
SafeFree(code.DLLFullPath.Data);
|
||||||
Log(LogLevel::Error, LogCategory::Core, "Cannot create DLL Full Path");
|
Log(LogLevel::Error, LogCategory::Core, "Cannot create DLL Full Path");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
code.DLLFullPath.Size = writtenSize + 1;
|
code.DLLFullPath.Size = writtenSize;
|
||||||
|
|
||||||
// Lock filename path
|
// Lock filename path
|
||||||
const size_t lockPathLength = basePathLength + lockFilename.Size;
|
const size_t lockPathLength = basePathLength + StringLength(lockFilename) + 1; // Need +1 because snprintf needs 0 terminated strings
|
||||||
code.LockFullPath.Data = static_cast<char*>(Calloc(lockPathLength, sizeof(char)));
|
code.LockFullPath.Data = static_cast<char*>(Calloc(lockPathLength, sizeof(char)));
|
||||||
writtenSize = snprintf(code.LockFullPath.Data, lockPathLength, "%s%s", basePath, lockFilename.Data);
|
writtenSize = snprintf(CStr(code.LockFullPath), lockPathLength, "%s%s", CStr(basePath), CStr(lockFilename));
|
||||||
if (writtenSize < static_cast<int>(lockPathLength) - 1)
|
if (writtenSize < static_cast<int>(lockPathLength) - 1)
|
||||||
{
|
{
|
||||||
code.LockFullPath.Size = 0;
|
code.LockFullPath.Size = 0;
|
||||||
@@ -43,7 +42,7 @@ namespace Juliet
|
|||||||
Log(LogLevel::Error, LogCategory::Core, "Cannot create lock file full path");
|
Log(LogLevel::Error, LogCategory::Core, "Cannot create lock file full path");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
code.LockFullPath.Size = writtenSize + 1;
|
code.LockFullPath.Size = writtenSize;
|
||||||
|
|
||||||
LoadCode(code);
|
LoadCode(code);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ namespace Juliet
|
|||||||
|
|
||||||
constexpr size_t kMaxAttempts = 256;
|
constexpr size_t kMaxAttempts = 256;
|
||||||
constexpr size_t kMaxDLLID = 256;
|
constexpr size_t kMaxDLLID = 256;
|
||||||
constexpr size_t kTempDLLBufferSizeForID = 6; // ID numbers + \0
|
constexpr size_t kTempDLLBufferSizeForID = 5; // Max ID numbers
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
void LoadCode(HotReloadCode& code)
|
void LoadCode(HotReloadCode& code)
|
||||||
@@ -48,20 +48,21 @@ namespace Juliet
|
|||||||
// We'll see for better later.
|
// We'll see for better later.
|
||||||
|
|
||||||
// Get the app base path and build the dll path from there.
|
// Get the app base path and build the dll path from there.
|
||||||
const char* basePath = GetBasePath();
|
String basePath = GetBasePath();
|
||||||
size_t basePathLength = strlen(basePath);
|
size_t basePathLength = StringLength(basePath);
|
||||||
|
|
||||||
const size_t tempDllMaxBufferSize = basePathLength + code.TransientDLLName.Size + kTempDLLBufferSizeForID;
|
const size_t tempDllMaxBufferSize =
|
||||||
auto tempDllPath = static_cast<char*>(Calloc(tempDllMaxBufferSize, sizeof(char)));
|
basePathLength + StringLength(code.TransientDLLName) + /* _ */ 1 + kTempDLLBufferSizeForID + 1 /* \0 */;
|
||||||
|
auto tempDllPath = static_cast<char*>(Calloc(tempDllMaxBufferSize, sizeof(char)));
|
||||||
for (uint32 attempt = 0; attempt < kMaxAttempts; ++attempt)
|
for (uint32 attempt = 0; attempt < kMaxAttempts; ++attempt)
|
||||||
{
|
{
|
||||||
// int to char
|
// int to char
|
||||||
char idToStr[kTempDLLBufferSizeForID];
|
char idToStr[kTempDLLBufferSizeForID + 1];
|
||||||
int idLength = snprintf(idToStr, sizeof(idToStr), "%u", code.UniqueID);
|
int idLength = snprintf(idToStr, sizeof(idToStr), "%u", code.UniqueID);
|
||||||
|
|
||||||
int writtenSize = snprintf(tempDllPath, tempDllMaxBufferSize, "%s%u_%s", basePath, code.UniqueID,
|
int writtenSize = snprintf(tempDllPath, tempDllMaxBufferSize, "%s%s_%s", CStr(basePath), idToStr,
|
||||||
code.TransientDLLName.Data);
|
CStr(code.TransientDLLName));
|
||||||
if (writtenSize < static_cast<int>(basePathLength + idLength + code.TransientDLLName.Size))
|
if (writtenSize < static_cast<int>(basePathLength + idLength + code.TransientDLLName.Size) - 1)
|
||||||
{
|
{
|
||||||
SafeFree(tempDllPath);
|
SafeFree(tempDllPath);
|
||||||
Log(LogLevel::Error, LogCategory::Core, "Cannot create temp full path");
|
Log(LogLevel::Error, LogCategory::Core, "Cannot create temp full path");
|
||||||
@@ -107,7 +108,10 @@ namespace Juliet
|
|||||||
void UnloadCode(HotReloadCode& code)
|
void UnloadCode(HotReloadCode& code)
|
||||||
{
|
{
|
||||||
code.IsValid = false;
|
code.IsValid = false;
|
||||||
UnloadDynamicLibrary(code.Dll);
|
if (code.Dll)
|
||||||
|
{
|
||||||
|
UnloadDynamicLibrary(code.Dll);
|
||||||
|
}
|
||||||
code.Dll = nullptr;
|
code.Dll = nullptr;
|
||||||
|
|
||||||
code.LastWriteTime = 0;
|
code.LastWriteTime = 0;
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
#include <D3D12Texture.h>
|
|
||||||
#include <pch.h>
|
#include <pch.h>
|
||||||
|
|
||||||
#include <core/Memory/Allocator.h>
|
#include <core/Memory/Allocator.h>
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
Rename DX12 files to D3D12
|
- Rename DX12 files to D3D12
|
||||||
|
- Create Simple vector class to make the vector stuff a bit more easier than writing Capacity and Count
|
||||||
- Create Simple vector class to make the vector stuff a bit more easier than writing Capacity and Count
|
- Make a string struct instead of StringBuffer.
|
||||||
|
- Support wchar and char (template is ok) conversions, printf, compare, etc.
|
||||||
|
|||||||
@@ -12,8 +12,8 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Game\Game.vcxproj">
|
<ProjectReference Include="..\Game\Game.vcxproj">
|
||||||
<Project>{b7b12dcc-1a69-4371-a9fe-d6e7671497b0}</Project>
|
<Project>{b7b12dcc-1a69-4371-a9fe-d6e7671497b0}</Project>
|
||||||
<Name>Game</Name>
|
<Name>Game</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
<ProjectReference Include="..\Juliet\Juliet.vcxproj">
|
<ProjectReference Include="..\Juliet\Juliet.vcxproj">
|
||||||
<Project>{1bbc0b92-e4d8-4838-974b-439c5c501e82}</Project>
|
<Project>{1bbc0b92-e4d8-4838-974b-439c5c501e82}</Project>
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
#include <Core/Application/ApplicationManager.h>
|
#include <Core/Application/ApplicationManager.h>
|
||||||
#include <Core/HAL/Display/Display.h>
|
#include <Core/HAL/Display/Display.h>
|
||||||
#include <Core/HAL/DynLib/DynamicLibrary.h>
|
|
||||||
#include <Core/HAL/Event/SystemEvent.h>
|
#include <Core/HAL/Event/SystemEvent.h>
|
||||||
#include <Core/HAL/Filesystem/Filesystem.h>
|
#include <Core/HAL/Filesystem/Filesystem.h>
|
||||||
#include <Core/JulietInit.h>
|
#include <Core/JulietInit.h>
|
||||||
@@ -13,6 +12,7 @@
|
|||||||
#include <Graphics/RenderPass.h>
|
#include <Graphics/RenderPass.h>
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
|
||||||
|
#include <Core/Common/String.h>
|
||||||
#include <Core/Memory/Utils.h>
|
#include <Core/Memory/Utils.h>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
@@ -58,12 +58,11 @@ void JulietApplication::Init()
|
|||||||
if (Running)
|
if (Running)
|
||||||
{
|
{
|
||||||
AttachToWindow(GraphicsDevice, MainWindow);
|
AttachToWindow(GraphicsDevice, MainWindow);
|
||||||
// Game = LoadDynamicLibrary("Game.dll");
|
|
||||||
|
|
||||||
GameCode.Functions = reinterpret_cast<void**>(&Game);
|
GameCode.Functions = reinterpret_cast<void**>(&Game);
|
||||||
GameCode.FunctionCount = ArraySize(GameFunctionTable);
|
GameCode.FunctionCount = ArraySize(GameFunctionTable);
|
||||||
GameCode.FunctionNames = GameFunctionTable;
|
GameCode.FunctionNames = GameFunctionTable;
|
||||||
InitHotReloadCode(GameCode, StringBufferParam("Game.dll"), StringBufferParam("Game_Temp.dll"), StringBufferParam("lock.tmp"));
|
InitHotReloadCode(GameCode, ConstString("Game.dll"), ConstString("Game_Temp.dll"), ConstString("lock.tmp"));
|
||||||
if ((Running = GameCode.IsValid))
|
if ((Running = GameCode.IsValid))
|
||||||
{
|
{
|
||||||
Game.Init();
|
Game.Init();
|
||||||
|
|||||||
@@ -66,6 +66,7 @@
|
|||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||||
<AdditionalIncludeDirectories>$(SolutionDir)Juliet\include\;$(SolutionDir)JulietShaderCompiler;</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(SolutionDir)Juliet\include\;$(SolutionDir)JulietShaderCompiler;</AdditionalIncludeDirectories>
|
||||||
|
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
@@ -85,6 +86,7 @@
|
|||||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<ConformanceMode>true</ConformanceMode>
|
<ConformanceMode>true</ConformanceMode>
|
||||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||||
|
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
@@ -102,12 +104,12 @@
|
|||||||
<ClInclude Include="DXCompiler.h"/>
|
<ClInclude Include="DXCompiler.h"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<CopyFileToFolders Include="DXShaderCompiler\dxcompiler.dll">
|
<CopyFileToFolders Include="DXShaderCompiler\dxcompiler.dll">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</CopyFileToFolders>
|
</CopyFileToFolders>
|
||||||
<CopyFileToFolders Include="DXShaderCompiler\dxil.dll">
|
<CopyFileToFolders Include="DXShaderCompiler\dxil.dll">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</CopyFileToFolders>
|
</CopyFileToFolders>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets"/>
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets"/>
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
|||||||
@@ -1,49 +1,49 @@
|
|||||||
|
#include <Core/Common/String.h>
|
||||||
//#include <Core/Common/CoreTypes.h>
|
#include <Core/HAL/IO/IOStream.h>
|
||||||
//#include <Core/Logging/LogManager.h>
|
#include <Core/Logging/LogManager.h>
|
||||||
//#include <Core/Logging/LogTypes.h>
|
#include <Core/Logging/LogTypes.h>
|
||||||
|
|
||||||
// Must be before everything else.
|
// Must be before everything else.
|
||||||
// Cannot include DX12Includes because we redefine everything.
|
// Cannot include DX12Includes because we redefine everything.
|
||||||
// TODO : Separate lib
|
// TODO : Separate lib
|
||||||
// TODO : Only when not shipping
|
// TODO : Only when not shipping
|
||||||
// Check if we just load the dll and not link against?
|
// Check if we just load the dll and not link against?
|
||||||
|
#include <DXCompiler.h>
|
||||||
|
|
||||||
//#include <DXCompiler.h>
|
#pragma comment(lib, "dxcompiler.lib")
|
||||||
//#pragma comment(lib, "dxcompiler.lib")
|
|
||||||
|
|
||||||
//using namespace Juliet;
|
using namespace Juliet;
|
||||||
|
|
||||||
void Compile()
|
void Compile()
|
||||||
{
|
{
|
||||||
// IDxcCompiler3* compiler = nullptr;
|
IDxcCompiler3* compiler = nullptr;
|
||||||
// DxcCreateInstance(&CLSID_DxcCompiler, IID_IDxcCompiler3, reinterpret_cast<void**>(&compiler));
|
DxcCreateInstance(&CLSID_DxcCompiler, IID_IDxcCompiler3, reinterpret_cast<void**>(&compiler));
|
||||||
//
|
|
||||||
// IDxcUtils* utils = nullptr;
|
IDxcUtils* utils = nullptr;
|
||||||
// DxcCreateInstance(&CLSID_DxcUtils, &IID_IDxcUtils, reinterpret_cast<void**>(&utils));
|
DxcCreateInstance(&CLSID_DxcUtils, &IID_IDxcUtils, reinterpret_cast<void**>(&utils));
|
||||||
//
|
|
||||||
// if (compiler == nullptr)
|
if (compiler == nullptr)
|
||||||
// {
|
{
|
||||||
// Juliet::Log(LogLevel::Error, LogCategory::Graphics, "Cannot create DXCompiler instance");
|
Juliet::Log(LogLevel::Error, LogCategory::Graphics, "Cannot create DXCompiler instance");
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// if (utils == nullptr)
|
if (utils == nullptr)
|
||||||
// {
|
{
|
||||||
// Log(LogLevel::Error, LogCategory::Graphics, "Cannot create IDxcUtils instance");
|
Log(LogLevel::Error, LogCategory::Graphics, "Cannot create IDxcUtils instance");
|
||||||
// compiler->lpVtbl->Release(compiler);
|
compiler->lpVtbl->Release(compiler);
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// IDxcIncludeHandler* includeHandler;
|
IDxcIncludeHandler* includeHandler;
|
||||||
// utils->lpVtbl->CreateDefaultIncludeHandler(utils, &includeHandler);
|
utils->lpVtbl->CreateDefaultIncludeHandler(utils, &includeHandler);
|
||||||
// if (includeHandler == nullptr)
|
if (includeHandler == nullptr)
|
||||||
// {
|
{
|
||||||
// compiler->lpVtbl->Release(compiler);
|
compiler->lpVtbl->Release(compiler);
|
||||||
// utils->lpVtbl->Release(utils);
|
utils->lpVtbl->Release(utils);
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
|
auto* stream = IOFromFile(ConstString("bleeblou"), ConstString("w"));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user