mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-20 16:15:43 +00:00
Compare commits
No commits in common. "main" and "v0.20.0" have entirely different histories.
@ -177,7 +177,7 @@ The following section specify which assets are supported to be dumped to disk (u
|
||||
| ComWorld | ❌ | ❌ | |
|
||||
| GameWorldSp | ❌ | ❌ | |
|
||||
| GameWorldMp | ❌ | ❌ | |
|
||||
| MapEnts | ✅ | ❌ | |
|
||||
| MapEnts | ❌ | ❌ | |
|
||||
| GfxWorld | ❌ | ❌ | |
|
||||
| GfxLightDef | ❌ | ❌ | |
|
||||
| Font_s | ❌ | ❌ | |
|
||||
|
@ -16,7 +16,7 @@ workspace "OpenAssetTools"
|
||||
objdir "%{wks.location}/obj"
|
||||
symbols "On"
|
||||
systemversion "latest"
|
||||
cppdialect "C++23"
|
||||
cppdialect "C++20"
|
||||
largeaddressaware "on"
|
||||
|
||||
flags {
|
||||
@ -54,10 +54,6 @@ workspace "OpenAssetTools"
|
||||
symbols "On"
|
||||
filter {}
|
||||
|
||||
filter {"system:windows", "configurations:Debug" }
|
||||
buildoptions { "/bigobj" }
|
||||
filter {}
|
||||
|
||||
filter "configurations:Release"
|
||||
defines "NDEBUG"
|
||||
optimize "Full"
|
||||
|
@ -1,23 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Go to repository root
|
||||
cd "$(dirname "$0")/.." || exit 2
|
||||
|
||||
TARGET='all'
|
||||
ARCHITECTURE='x86'
|
||||
CONFIG='debug'
|
||||
|
||||
for var in "$@"
|
||||
do
|
||||
if [ "$var" == "debug" ] || [ "$var" == "release" ]; then
|
||||
CONFIG="$var"
|
||||
elif [ "$var" == "x86" ] || [ "$var" == "x64" ]; then
|
||||
ARCHITECTURE="$var"
|
||||
else
|
||||
TARGET="$var"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Building config=${CONFIG} architecture=${ARCHITECTURE} target=${TARGET}"
|
||||
make -C build -j$(nproc) config=${CONFIG}_${ARCHITECTURE} "${TARGET}"
|
||||
|
@ -4,6 +4,4 @@
|
||||
cd "$(dirname "$0")/.." || exit 2
|
||||
|
||||
make -C build -j$(nproc) config=debug_x86 clean
|
||||
make -C build -j$(nproc) config=release_x86 clean
|
||||
make -C build -j$(nproc) config=debug_x64 clean
|
||||
make -C build -j$(nproc) config=release_x64 clean
|
||||
make -C build -j$(nproc) config=release_x86 clean
|
@ -3,4 +3,4 @@
|
||||
# Go to repository root
|
||||
cd "$(dirname "$0")/.." || exit 2
|
||||
|
||||
make -C build -j$(nproc) config=debug_x86 all
|
||||
make -C build -j$(nproc) config=debug_x86 all
|
@ -4,4 +4,4 @@
|
||||
cd "$(dirname "$0")/.." || exit 2
|
||||
|
||||
echo "Start building with $(nproc) threads"
|
||||
make -C build -j$(nproc) config=release_x86 all
|
||||
make -C build -j$(nproc) config=release_x86 all
|
@ -3814,8 +3814,7 @@ namespace T6
|
||||
uint16_t dynEntId;
|
||||
};
|
||||
|
||||
// Usually __m128, but that is not portable
|
||||
union gcc_align(8) custom_m128
|
||||
union gcc_align(8) __m128
|
||||
{
|
||||
float m128_f32[4];
|
||||
uint64_t m128_u64[2];
|
||||
@ -3828,12 +3827,19 @@ namespace T6
|
||||
unsigned int m128_u32[4];
|
||||
};
|
||||
|
||||
struct vector3
|
||||
{
|
||||
__m128 x;
|
||||
__m128 y;
|
||||
__m128 z;
|
||||
};
|
||||
|
||||
struct vector4
|
||||
{
|
||||
custom_m128 x;
|
||||
custom_m128 y;
|
||||
custom_m128 z;
|
||||
custom_m128 w;
|
||||
__m128 x;
|
||||
__m128 y;
|
||||
__m128 z;
|
||||
__m128 w;
|
||||
};
|
||||
|
||||
struct type_align(16) SSkinInstance
|
||||
|
@ -1,6 +1,5 @@
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
#include <limits>
|
||||
|
||||
struct ZoneHeader
|
||||
{
|
||||
@ -8,11 +7,21 @@ struct ZoneHeader
|
||||
uint32_t m_version;
|
||||
};
|
||||
|
||||
#ifdef ARCH_x64
|
||||
typedef uint32_t scr_string_t;
|
||||
typedef uint64_t xchunk_size_t;
|
||||
typedef uint64_t xblock_size_t;
|
||||
typedef uint64_t zone_pointer_t;
|
||||
|
||||
constexpr uint16_t SCR_STRING_MAX = UINT32_MAX;
|
||||
#elif ARCH_x86
|
||||
typedef uint16_t scr_string_t;
|
||||
typedef uint32_t xchunk_size_t;
|
||||
typedef uint32_t xblock_size_t;
|
||||
typedef uint32_t zone_pointer_t;
|
||||
|
||||
constexpr uint16_t SCR_STRING_MAX = std::numeric_limits<scr_string_t>::max();
|
||||
constexpr uint16_t SCR_STRING_MAX = UINT16_MAX;
|
||||
#endif
|
||||
|
||||
typedef int block_t;
|
||||
typedef int asset_type_t;
|
||||
|
@ -32,8 +32,7 @@ namespace base64
|
||||
|
||||
size_t DecodeBase64(const void* base64Data, const size_t inputLength, void* outputBuffer, const size_t outputBufferSize)
|
||||
{
|
||||
unsigned long outLength = GetBase64DecodeOutputLength(base64Data, inputLength);
|
||||
assert(outLength <= outputBufferSize);
|
||||
unsigned long outLength = GetBase64DecodeOutputLength(inputLength);
|
||||
if (outLength > outputBufferSize)
|
||||
return 0u;
|
||||
|
||||
@ -43,28 +42,8 @@ namespace base64
|
||||
return static_cast<size_t>(outLength);
|
||||
}
|
||||
|
||||
size_t GetBase64DecodeOutputLength(const void* base64Data, const size_t inputLength)
|
||||
{
|
||||
assert(base64Data);
|
||||
assert(inputLength);
|
||||
|
||||
if (!base64Data || inputLength == 0u)
|
||||
return 0u;
|
||||
|
||||
auto padding = 0u;
|
||||
if (inputLength >= 1 && static_cast<const char*>(base64Data)[inputLength - 1] == '=')
|
||||
{
|
||||
if (inputLength >= 2 && static_cast<const char*>(base64Data)[inputLength - 2] == '=')
|
||||
padding = 2u;
|
||||
else
|
||||
padding = 1u;
|
||||
}
|
||||
|
||||
return ((inputLength / 4u) * 3u) - padding;
|
||||
}
|
||||
|
||||
size_t GetBase64DecodeOutputLength(const size_t inputLength)
|
||||
{
|
||||
return (inputLength / 4u) * 3u;
|
||||
return inputLength / 4u;
|
||||
}
|
||||
} // namespace base64
|
||||
|
@ -8,6 +8,5 @@ namespace base64
|
||||
size_t GetBase64EncodeOutputLength(size_t inputLength);
|
||||
|
||||
size_t DecodeBase64(const void* base64Data, size_t inputLength, void* outputBuffer, size_t outputBufferSize);
|
||||
size_t GetBase64DecodeOutputLength(const void* base64Data, const size_t inputLength);
|
||||
size_t GetBase64DecodeOutputLength(size_t inputLength);
|
||||
} // namespace base64
|
||||
|
@ -3,7 +3,6 @@
|
||||
#include "SearchPath/IWD.h"
|
||||
#include "SearchPath/SearchPathFilesystem.h"
|
||||
#include "SearchPath/SearchPaths.h"
|
||||
#include "Utils/StringUtils.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
@ -216,10 +215,7 @@ namespace
|
||||
{
|
||||
if (!curTemplate.CanRender(PROJECT_MASK) && curTemplate.CanRender(GAME_MASK))
|
||||
{
|
||||
std::string gameName(GameId_Names[static_cast<unsigned>(game)]);
|
||||
utils::MakeStringLowerCase(gameName);
|
||||
|
||||
auto renderedTemplate = curTemplate.Render(m_bin_dir, m_base_dir, projectName, gameName);
|
||||
auto renderedTemplate = curTemplate.Render(m_bin_dir, m_base_dir, projectName, GameId_Names[static_cast<unsigned>(game)]);
|
||||
if (AddSearchPath(addedSearchPaths, searchPaths, renderedTemplate))
|
||||
hasSearchPath = true;
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ namespace ipak_consts
|
||||
static constexpr size_t IPAK_CHUNK_SIZE = 0x8000;
|
||||
static constexpr size_t IPAK_CHUNK_COUNT_PER_READ = 0x8;
|
||||
|
||||
static constexpr size_t IPAK_COMMAND_DEFAULT_SIZE = 0x7F00;
|
||||
static constexpr uint32_t IPAK_COMMAND_DEFAULT_SIZE = 0x7F00;
|
||||
static constexpr uint32_t IPAK_COMMAND_UNCOMPRESSED = 0;
|
||||
static constexpr uint32_t IPAK_COMMAND_COMPRESSED = 1;
|
||||
static constexpr uint32_t IPAK_COMMAND_SKIP = 0xCF;
|
||||
|
@ -68,7 +68,7 @@ namespace
|
||||
T result;
|
||||
} data{};
|
||||
|
||||
const auto byteCount = utils::Align(bitCount, 8uz) / 8uz;
|
||||
const auto byteCount = utils::Align(bitCount, 8u) / 8u;
|
||||
assert(byteCount <= sizeof(T));
|
||||
|
||||
const auto shiftCount = (8u - bitCount % 8) % 8;
|
||||
@ -83,7 +83,7 @@ namespace
|
||||
|
||||
while (remainingBits > 0)
|
||||
{
|
||||
const auto curBits = static_cast<uint8_t>(std::min(remainingBits, 8uz));
|
||||
const auto curBits = static_cast<uint8_t>(std::min(remainingBits, 8u));
|
||||
|
||||
if (m_remaining_bits_last_byte > 0)
|
||||
{
|
||||
|
@ -59,7 +59,7 @@ size_t CommonStructuredDataType::GetSizeInBits(const CommonStructuredDataDef& de
|
||||
return 0u;
|
||||
}
|
||||
const auto& indexedArray = def.m_indexed_arrays[m_info.type_index];
|
||||
return utils::Align(indexedArray.m_element_size_in_bits * indexedArray.m_element_count, 8uz);
|
||||
return utils::Align(indexedArray.m_element_size_in_bits * indexedArray.m_element_count, 8u);
|
||||
}
|
||||
case CommonStructuredDataTypeCategory::ENUM_ARRAY:
|
||||
{
|
||||
@ -69,7 +69,7 @@ size_t CommonStructuredDataType::GetSizeInBits(const CommonStructuredDataDef& de
|
||||
return 0u;
|
||||
}
|
||||
const auto& enumedArray = def.m_enumed_arrays[m_info.type_index];
|
||||
return utils::Align(enumedArray.m_element_size_in_bits * enumedArray.m_element_count, 8uz);
|
||||
return utils::Align(enumedArray.m_element_size_in_bits * enumedArray.m_element_count, 8u);
|
||||
}
|
||||
|
||||
case CommonStructuredDataTypeCategory::UNKNOWN:
|
||||
|
@ -216,7 +216,7 @@ namespace
|
||||
const auto remainingSize = dataSize - dataOffset;
|
||||
const auto remainingChunkBufferWindowSize = std::max((ipak_consts::IPAK_CHUNK_COUNT_PER_READ * ipak_consts::IPAK_CHUNK_SIZE)
|
||||
- static_cast<size_t>(m_current_offset - m_chunk_buffer_window_start),
|
||||
0uz);
|
||||
0u);
|
||||
|
||||
if (remainingChunkBufferWindowSize == 0)
|
||||
{
|
||||
|
@ -184,11 +184,7 @@ namespace dds
|
||||
m_width = header.dwWidth;
|
||||
m_height = header.dwHeight;
|
||||
m_depth = header.dwDepth;
|
||||
|
||||
// Best thing to do here would be to check (header.dwCaps & DDSCAPS_MIPMAP) != 0 but some tools just create bad files
|
||||
// I encountered both files that have the flag without them actually having mipmaps (mipMapCount == 1)
|
||||
// and also files that have mipMapCount > 1 but not the flag
|
||||
m_has_mip_maps = header.dwMipMapCount > 1;
|
||||
m_has_mip_maps = (header.dwCaps & DDSCAPS_MIPMAP) != 0 || header.dwMipMapCount > 1;
|
||||
|
||||
if (header.dwCaps2 & DDSCAPS2_CUBEMAP)
|
||||
m_texture_type = TextureType::T_CUBE;
|
||||
|
@ -65,10 +65,8 @@ std::unique_ptr<XAssetInfoGeneric> GenericAssetRegistration::CreateXAssetInfo()
|
||||
AssetCreationContext::AssetCreationContext(Zone& zone, const AssetCreatorCollection* creators, const IgnoredAssetLookup* ignoredAssetLookup)
|
||||
: ZoneAssetCreationStateContainer(zone),
|
||||
m_zone(zone),
|
||||
m_forced_asset_pools(ZoneAssetPools::CreateForGame(zone.m_game->GetId(), &zone, zone.m_priority)),
|
||||
m_creators(creators),
|
||||
m_ignored_asset_lookup(ignoredAssetLookup),
|
||||
m_forced_load_depth(0u)
|
||||
m_ignored_asset_lookup(ignoredAssetLookup)
|
||||
{
|
||||
}
|
||||
|
||||
@ -80,14 +78,10 @@ XAssetInfoGeneric* AssetCreationContext::AddAssetGeneric(GenericAssetRegistratio
|
||||
const auto assetType = xAssetInfo->m_type;
|
||||
const auto* pAssetName = xAssetInfo->m_name.c_str();
|
||||
|
||||
XAssetInfoGeneric* addedAsset;
|
||||
if (m_forced_load_depth > 0)
|
||||
addedAsset = m_forced_asset_pools->AddAsset(std::move(xAssetInfo));
|
||||
else
|
||||
addedAsset = m_zone.m_pools->AddAsset(std::move(xAssetInfo));
|
||||
|
||||
auto* addedAsset = m_zone.m_pools->AddAsset(std::move(xAssetInfo));
|
||||
if (addedAsset == nullptr)
|
||||
std::cerr << std::format("Failed to add asset of type \"{}\" to pool: \"{}\"\n", *m_zone.m_pools->GetAssetTypeName(assetType), pAssetName);
|
||||
|
||||
return addedAsset;
|
||||
}
|
||||
|
||||
@ -108,16 +102,6 @@ XAssetInfoGeneric* AssetCreationContext::LoadDependencyGeneric(const asset_type_
|
||||
if (alreadyLoadedAsset)
|
||||
return alreadyLoadedAsset;
|
||||
|
||||
if (m_forced_load_depth > 0)
|
||||
{
|
||||
alreadyLoadedAsset = m_forced_asset_pools->GetAssetOrAssetReference(assetType, assetName);
|
||||
if (alreadyLoadedAsset)
|
||||
return alreadyLoadedAsset;
|
||||
|
||||
// If we are already force loading an asset we should not load its dependencies
|
||||
return LoadDefaultAssetDependency(assetType, std::format(",{}", assetName));
|
||||
}
|
||||
|
||||
if (m_ignored_asset_lookup->IsAssetIgnored(assetType, assetName))
|
||||
return LoadDefaultAssetDependency(assetType, std::format(",{}", assetName));
|
||||
|
||||
@ -137,9 +121,9 @@ XAssetInfoGeneric* AssetCreationContext::LoadDependencyGeneric(const asset_type_
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
IndirectAssetReference AssetCreationContext::LoadIndirectAssetReferenceGeneric(const asset_type_t assetType, const std::string& assetName)
|
||||
IndirectAssetReference AssetCreationContext::LoadIndirectAssetReferenceGeneric(asset_type_t assetType, const std::string& assetName)
|
||||
{
|
||||
const auto* alreadyLoadedAsset = m_zone.m_pools->GetAssetOrAssetReference(assetType, assetName);
|
||||
auto* alreadyLoadedAsset = m_zone.m_pools->GetAssetOrAssetReference(assetType, assetName);
|
||||
if (alreadyLoadedAsset)
|
||||
return IndirectAssetReference(assetType, assetName);
|
||||
|
||||
@ -153,44 +137,3 @@ IndirectAssetReference AssetCreationContext::LoadIndirectAssetReferenceGeneric(c
|
||||
}
|
||||
return IndirectAssetReference(assetType, assetName);
|
||||
}
|
||||
|
||||
XAssetInfoGeneric* AssetCreationContext::ForceLoadDependencyGeneric(const asset_type_t assetType, const std::string& assetName)
|
||||
{
|
||||
auto* alreadyLoadedAsset = m_zone.m_pools->GetAssetOrAssetReference(assetType, assetName);
|
||||
if (alreadyLoadedAsset && !alreadyLoadedAsset->IsReference())
|
||||
return alreadyLoadedAsset;
|
||||
alreadyLoadedAsset = m_forced_asset_pools->GetAssetOrAssetReference(assetType, assetName);
|
||||
if (alreadyLoadedAsset && !alreadyLoadedAsset->IsReference())
|
||||
return alreadyLoadedAsset;
|
||||
|
||||
auto result = AssetCreationResult::NoAction();
|
||||
if (m_ignored_asset_lookup->IsAssetIgnored(assetType, assetName))
|
||||
{
|
||||
// Load default asset to zone
|
||||
if (!LoadDefaultAssetDependency(assetType, std::format(",{}", assetName)))
|
||||
return nullptr;
|
||||
|
||||
++m_forced_load_depth;
|
||||
|
||||
result = m_creators->CreateAsset(assetType, assetName, *this);
|
||||
|
||||
assert(m_forced_load_depth > 0);
|
||||
m_forced_load_depth = std::min(m_forced_load_depth - 1u, 0u);
|
||||
}
|
||||
else
|
||||
result = m_creators->CreateAsset(assetType, assetName, *this);
|
||||
|
||||
if (result.HasTakenAction())
|
||||
{
|
||||
if (!result.HasFailed())
|
||||
return result.GetAssetInfo();
|
||||
|
||||
std::cerr << std::format("Could not load asset \"{}\" of type \"{}\"\n", assetName, *m_zone.m_pools->GetAssetTypeName(assetType));
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << std::format("Missing asset \"{}\" of type \"{}\"\n", assetName, *m_zone.m_pools->GetAssetTypeName(assetType));
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -65,31 +65,12 @@ public:
|
||||
|
||||
IndirectAssetReference LoadIndirectAssetReferenceGeneric(asset_type_t assetType, const std::string& assetName);
|
||||
|
||||
/**
|
||||
* \brief Loads an asset dependency like \c LoadDependency but guarantees that the returned asset is not a reference.
|
||||
* If normally a reference would be created, the actual asset is loaded but a reference is added to the zone.
|
||||
* \tparam AssetType The type of the asset
|
||||
* \param assetName The name of the asset
|
||||
* \return XAssetInfo of the asset that is guaranteed to not be a reference or \c nullptr
|
||||
*/
|
||||
template<typename AssetType> XAssetInfo<typename AssetType::Type>* ForceLoadDependency(const std::string& assetName)
|
||||
{
|
||||
static_assert(std::is_base_of_v<IAssetBase, AssetType>);
|
||||
|
||||
return static_cast<XAssetInfo<typename AssetType::Type>*>(ForceLoadDependencyGeneric(AssetType::EnumEntry, assetName));
|
||||
}
|
||||
|
||||
XAssetInfoGeneric* ForceLoadDependencyGeneric(asset_type_t assetType, const std::string& assetName);
|
||||
|
||||
private:
|
||||
[[nodiscard]] XAssetInfoGeneric* LoadDefaultAssetDependency(asset_type_t assetType, const std::string& assetName);
|
||||
|
||||
Zone& m_zone;
|
||||
std::unique_ptr<ZoneAssetPools> m_forced_asset_pools;
|
||||
const AssetCreatorCollection* m_creators;
|
||||
const IgnoredAssetLookup* m_ignored_asset_lookup;
|
||||
|
||||
unsigned m_forced_load_depth;
|
||||
};
|
||||
|
||||
#include "AssetCreatorCollection.h"
|
||||
|
@ -96,6 +96,7 @@ namespace
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderSound>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderSoundCurve>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderLoadedSound>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderClipMap>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderClipMapPvs>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderComWorld>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderGameWorldSp>(memory));
|
||||
|
@ -135,7 +135,8 @@ namespace
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderSound>(memory));
|
||||
collection.AddAssetCreator(CreateSoundCurveLoader(memory, searchPath));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderLoadedSound>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderClipMap>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderClipMapSp>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderClipMapMp>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderComWorld>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderGameWorldSp>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderGameWorldMp>(memory));
|
||||
|
@ -53,15 +53,15 @@ namespace
|
||||
case CommonStructuredDataTypeCategory::SHORT:
|
||||
return {DATA_SHORT, {0}};
|
||||
case CommonStructuredDataTypeCategory::STRING:
|
||||
return {DATA_STRING, {static_cast<unsigned>(inputType.m_info.string_length)}};
|
||||
return {DATA_STRING, {inputType.m_info.string_length}};
|
||||
case CommonStructuredDataTypeCategory::ENUM:
|
||||
return {DATA_ENUM, {static_cast<unsigned>(inputType.m_info.type_index)}};
|
||||
return {DATA_ENUM, {inputType.m_info.type_index}};
|
||||
case CommonStructuredDataTypeCategory::STRUCT:
|
||||
return {DATA_STRUCT, {static_cast<unsigned>(inputType.m_info.type_index)}};
|
||||
return {DATA_STRUCT, {inputType.m_info.type_index}};
|
||||
case CommonStructuredDataTypeCategory::INDEXED_ARRAY:
|
||||
return {DATA_INDEXED_ARRAY, {static_cast<unsigned>(inputType.m_info.type_index)}};
|
||||
return {DATA_INDEXED_ARRAY, {inputType.m_info.type_index}};
|
||||
case CommonStructuredDataTypeCategory::ENUM_ARRAY:
|
||||
return {DATA_ENUM_ARRAY, {static_cast<unsigned>(inputType.m_info.type_index)}};
|
||||
return {DATA_ENUM_ARRAY, {inputType.m_info.type_index}};
|
||||
case CommonStructuredDataTypeCategory::UNKNOWN:
|
||||
default:
|
||||
assert(false);
|
||||
@ -129,14 +129,14 @@ namespace
|
||||
{
|
||||
outputIndexedArray.arraySize = static_cast<int>(inputIndexedArray.m_element_count);
|
||||
outputIndexedArray.elementType = ConvertType(inputIndexedArray.m_array_type);
|
||||
outputIndexedArray.elementSize = utils::Align(inputIndexedArray.m_element_size_in_bits, 8uz) / 8uz;
|
||||
outputIndexedArray.elementSize = utils::Align(inputIndexedArray.m_element_size_in_bits, 8u) / 8u;
|
||||
}
|
||||
|
||||
void ConvertEnumedArray(const CommonStructuredDataEnumedArray& inputEnumedArray, StructuredDataEnumedArray& outputEnumedArray)
|
||||
{
|
||||
outputEnumedArray.enumIndex = static_cast<int>(inputEnumedArray.m_enum_index);
|
||||
outputEnumedArray.elementType = ConvertType(inputEnumedArray.m_array_type);
|
||||
outputEnumedArray.elementSize = utils::Align(inputEnumedArray.m_element_size_in_bits, 8uz) / 8uz;
|
||||
outputEnumedArray.elementSize = utils::Align(inputEnumedArray.m_element_size_in_bits, 8u) / 8u;
|
||||
}
|
||||
|
||||
void ConvertDef(const CommonStructuredDataDef& inputDef, StructuredDataDef& outputDef)
|
||||
|
@ -109,6 +109,7 @@ namespace
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderImage>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderSoundBank>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderSoundPatch>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderClipMap>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderClipMapPvs>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderComWorld>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderGameWorldSp>(memory));
|
||||
|
@ -404,6 +404,7 @@ namespace T6
|
||||
collection.AddAssetCreator(CreateImageLoader(memory, searchPath));
|
||||
collection.AddAssetCreator(CreateSoundBankLoader(memory, searchPath));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderSoundPatch>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderClipMap>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderClipMapPvs>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderComWorld>(memory));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderGameWorldSp>(memory));
|
||||
|
@ -262,7 +262,7 @@ namespace
|
||||
|
||||
for (const auto& attachmentName : valueArray)
|
||||
{
|
||||
auto* attachmentAssetInfo = m_context.ForceLoadDependency<AssetAttachment>(attachmentName);
|
||||
auto* attachmentAssetInfo = m_context.LoadDependency<AssetAttachment>(attachmentName);
|
||||
if (attachmentAssetInfo == nullptr)
|
||||
{
|
||||
std::cerr << std::format("Failed to load attachment asset \"{}\"\n", attachmentName);
|
||||
@ -314,7 +314,7 @@ namespace
|
||||
|
||||
for (const auto& attachmentUniqueName : valueArray)
|
||||
{
|
||||
auto* attachmentUniqueAssetInfo = m_context.ForceLoadDependency<AssetAttachmentUnique>(attachmentUniqueName);
|
||||
auto* attachmentUniqueAssetInfo = m_context.LoadDependency<AssetAttachmentUnique>(attachmentUniqueName);
|
||||
if (attachmentUniqueAssetInfo == nullptr)
|
||||
{
|
||||
std::cerr << std::format("Failed to load attachment unique asset \"{}\"\n", attachmentUniqueName);
|
||||
|
@ -131,7 +131,7 @@ public:
|
||||
sizeof(SoundAssetBankEntry),
|
||||
sizeof(SoundAssetBankChecksum),
|
||||
0x40,
|
||||
static_cast<unsigned>(m_entries.size()),
|
||||
m_entries.size(),
|
||||
0,
|
||||
0,
|
||||
m_total_size,
|
||||
@ -157,9 +157,9 @@ public:
|
||||
|
||||
SoundAssetBankEntry entry{
|
||||
sound.m_sound_id,
|
||||
static_cast<unsigned>(soundSize),
|
||||
static_cast<unsigned>(m_current_offset),
|
||||
static_cast<unsigned>(frameCount),
|
||||
soundSize,
|
||||
static_cast<size_t>(m_current_offset),
|
||||
frameCount,
|
||||
frameRateIndex,
|
||||
static_cast<unsigned char>(header.formatChunk.nChannels),
|
||||
sound.m_looping,
|
||||
@ -188,8 +188,8 @@ public:
|
||||
const auto frameRateIndex = INDEX_FOR_FRAMERATE[metaData.m_sample_rate];
|
||||
SoundAssetBankEntry entry{
|
||||
sound.m_sound_id,
|
||||
static_cast<unsigned>(soundSize),
|
||||
static_cast<unsigned>(m_current_offset),
|
||||
soundSize,
|
||||
static_cast<size_t>(m_current_offset),
|
||||
static_cast<unsigned>(metaData.m_total_samples),
|
||||
frameRateIndex,
|
||||
metaData.m_number_of_channels,
|
||||
|
@ -240,7 +240,7 @@ namespace sdd::struct_scope_sequences
|
||||
if (state->m_current_struct_is_root && state->m_current_struct->m_properties.empty())
|
||||
state->m_current_struct_padding_offset -= 64u;
|
||||
|
||||
state->m_current_struct->m_size_in_byte = utils::Align(state->m_current_struct_padding_offset, 8uz) / 8;
|
||||
state->m_current_struct->m_size_in_byte = utils::Align(state->m_current_struct_padding_offset, 8u) / 8;
|
||||
state->m_current_struct_padding_offset = 0u;
|
||||
state->m_current_struct_is_root = false;
|
||||
state->m_current_struct = nullptr;
|
||||
|
@ -74,7 +74,7 @@ class StructuredDataDefSizeCalculatorInternal
|
||||
|
||||
m_type_stack.emplace_back(CommonStructuredDataTypeCategory::STRUCT, index);
|
||||
|
||||
auto currentOffset = 0uz;
|
||||
auto currentOffset = 0u;
|
||||
for (auto& property : _struct.m_properties)
|
||||
{
|
||||
CalculateForType(property.m_type);
|
||||
@ -85,7 +85,7 @@ class StructuredDataDefSizeCalculatorInternal
|
||||
|
||||
currentOffset += property.m_type.GetSizeInBits(m_def);
|
||||
}
|
||||
currentOffset = utils::Align(currentOffset, 8uz);
|
||||
currentOffset = utils::Align(currentOffset, 8u);
|
||||
_struct.m_size_in_byte += currentOffset / 8;
|
||||
|
||||
m_struct_calculated[index] = true;
|
||||
|
@ -286,7 +286,7 @@ namespace
|
||||
|
||||
common.m_vertices.emplace_back(vertex);
|
||||
|
||||
XModelVertexBoneWeights vertexWeights{.weightOffset = static_cast<unsigned>(common.m_bone_weight_data.weights.size()), .weightCount = 0u};
|
||||
XModelVertexBoneWeights vertexWeights{common.m_bone_weight_data.weights.size(), 0u};
|
||||
for (auto i = 0u; i < std::extent_v<decltype(joints)>; i++)
|
||||
{
|
||||
if (std::abs(weights[i]) < std::numeric_limits<float>::epsilon())
|
||||
@ -315,12 +315,12 @@ namespace
|
||||
throw GltfLoadException("Requires primitives attribute POSITION");
|
||||
|
||||
AccessorsForVertex accessorsForVertex{
|
||||
.positionAccessor = *primitives.attributes.POSITION,
|
||||
.normalAccessor = primitives.attributes.NORMAL,
|
||||
.colorAccessor = primitives.attributes.COLOR_0,
|
||||
.uvAccessor = primitives.attributes.TEXCOORD_0,
|
||||
.jointsAccessor = primitives.attributes.JOINTS_0,
|
||||
.weightsAccessor = primitives.attributes.WEIGHTS_0,
|
||||
*primitives.attributes.POSITION,
|
||||
primitives.attributes.NORMAL,
|
||||
primitives.attributes.COLOR_0,
|
||||
primitives.attributes.TEXCOORD_0,
|
||||
primitives.attributes.JOINTS_0,
|
||||
primitives.attributes.WEIGHTS_0,
|
||||
};
|
||||
|
||||
const auto existingVertices = m_vertex_offset_for_accessors.find(accessorsForVertex);
|
||||
@ -328,7 +328,7 @@ namespace
|
||||
existingVertices == m_vertex_offset_for_accessors.end() ? CreateVertices(common, accessorsForVertex) : existingVertices->second;
|
||||
|
||||
// clang-format off
|
||||
const auto* indexAccessor = GetAccessorForIndex(
|
||||
auto* indexAccessor = GetAccessorForIndex(
|
||||
"INDICES",
|
||||
primitives.indices,
|
||||
{JsonAccessorType::SCALAR},
|
||||
@ -547,12 +547,15 @@ namespace
|
||||
if (!jRoot.nodes)
|
||||
return false;
|
||||
|
||||
if (!common.m_bones.empty())
|
||||
throw GltfLoadException("Only scenes with at most one skin are supported");
|
||||
|
||||
const auto rootNode = GetRootNodeForSkin(jRoot, skin).value_or(skin.joints[0]);
|
||||
const auto skinBoneOffset = common.m_bones.size();
|
||||
common.m_bones.resize(skinBoneOffset + skin.joints.size());
|
||||
|
||||
constexpr float defaultTranslation[3]{0.0f, 0.0f, 0.0f};
|
||||
constexpr XModelQuaternion defaultRotation{.x = 0.0f, .y = 0.0f, .z = 0.0f, .w = 1.0f};
|
||||
constexpr XModelQuaternion defaultRotation{0.0f, 0.0f, 0.0f, 1.0f};
|
||||
constexpr float defaultScale[3]{1.0f, 1.0f, 1.0f};
|
||||
|
||||
return ConvertJoint(jRoot, skin, common, skinBoneOffset, rootNode, std::nullopt, defaultTranslation, defaultRotation, defaultScale);
|
||||
@ -563,27 +566,13 @@ namespace
|
||||
if (!jRoot.meshes)
|
||||
return;
|
||||
|
||||
std::optional<unsigned> alreadyLoadedSkinIndex;
|
||||
|
||||
for (const auto& loadObject : m_load_objects)
|
||||
{
|
||||
if (loadObject.skinIndex && jRoot.skins)
|
||||
{
|
||||
if (alreadyLoadedSkinIndex)
|
||||
{
|
||||
if (*alreadyLoadedSkinIndex != *loadObject.skinIndex)
|
||||
throw GltfLoadException("Only scenes with at most one skin are supported");
|
||||
|
||||
// Do not load already loaded skin
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto& skin = jRoot.skins.value()[*loadObject.skinIndex];
|
||||
if (!ConvertSkin(jRoot, skin, common))
|
||||
return;
|
||||
|
||||
alreadyLoadedSkinIndex = *loadObject.skinIndex;
|
||||
}
|
||||
const auto& skin = jRoot.skins.value()[*loadObject.skinIndex];
|
||||
if (!ConvertSkin(jRoot, skin, common))
|
||||
return;
|
||||
}
|
||||
|
||||
const auto& mesh = jRoot.meshes.value()[loadObject.meshIndex];
|
||||
|
@ -48,12 +48,11 @@ bool DataUriBuffer::ReadDataFromUri(const std::string& uri)
|
||||
if (!IsDataUri(uri))
|
||||
return false;
|
||||
|
||||
const auto base64Data = &uri[URI_PREFIX_LENGTH];
|
||||
const auto base64DataLength = uri.size() - URI_PREFIX_LENGTH;
|
||||
m_data_size = base64::GetBase64DecodeOutputLength(base64Data, base64DataLength);
|
||||
m_data_size = base64::GetBase64DecodeOutputLength(base64DataLength);
|
||||
m_data = std::make_unique<uint8_t[]>(m_data_size);
|
||||
|
||||
m_data_size = base64::DecodeBase64(base64Data, base64DataLength, m_data.get(), m_data_size);
|
||||
m_data_size = base64::DecodeBase64(&uri[URI_PREFIX_LENGTH], base64DataLength, m_data.get(), m_data_size);
|
||||
|
||||
return m_data_size > 0;
|
||||
}
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include JSON_HEADER
|
||||
|
||||
#include "Asset/AssetRegistration.h"
|
||||
#include "ObjLoading.h"
|
||||
#include "Utils/QuatInt16.h"
|
||||
#include "Utils/StringUtils.h"
|
||||
#include "XModel/Gltf/GltfBinInput.h"
|
||||
@ -43,6 +44,7 @@
|
||||
#include <format>
|
||||
#include <iostream>
|
||||
#include <numeric>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
using namespace GAME;
|
||||
@ -144,17 +146,17 @@ namespace
|
||||
assert(common.m_vertex_bone_weights.size() == common.m_vertices.size());
|
||||
|
||||
XModelBone rootBone{
|
||||
.name = "root",
|
||||
.parentIndex = std::nullopt,
|
||||
.scale = {1.0f, 1.0f, 1.0f},
|
||||
.globalOffset = {0.0f, 0.0f, 0.0f},
|
||||
.localOffset = {0.0f, 0.0f, 0.0f},
|
||||
.globalRotation = {.x = 0.0f, .y = 0.0f, .z = 0.0f, .w = 1.0f},
|
||||
.localRotation = {.x = 0.0f, .y = 0.0f, .z = 0.0f, .w = 1.0f},
|
||||
"root",
|
||||
std::nullopt,
|
||||
{1.0f, 1.0f, 1.0f},
|
||||
{0.0f, 0.0f, 0.0f},
|
||||
{0.0f, 0.0f, 0.0f},
|
||||
{0.0f, 0.0f, 0.0f, 1.0f},
|
||||
{0.0f, 0.0f, 0.0f, 1.0f},
|
||||
};
|
||||
common.m_bones.emplace_back(rootBone);
|
||||
|
||||
XModelBoneWeight rootWeight{.boneIndex = 0, .weight = 1.0f};
|
||||
|
||||
XModelBoneWeight rootWeight{0, 1.0f};
|
||||
common.m_bone_weight_data.weights.emplace_back(rootWeight);
|
||||
|
||||
for (auto& vertexBoneWeights : common.m_vertex_bone_weights)
|
||||
@ -399,7 +401,7 @@ namespace
|
||||
}
|
||||
|
||||
static std::vector<std::optional<size_t>>
|
||||
GetRigidBoneIndicesForTris(const std::vector<size_t>& vertexIndices, const XSurface& surface, const XModelCommon& common)
|
||||
GetRigidBoneIndicesForTris(const std::vector<size_t>& vertexIndices, XSurface& surface, const XModelCommon& common)
|
||||
{
|
||||
std::vector<std::optional<size_t>> rigidBoneIndexForTri;
|
||||
rigidBoneIndexForTri.reserve(surface.triCount);
|
||||
@ -420,7 +422,7 @@ namespace
|
||||
return rigidBoneIndexForTri;
|
||||
}
|
||||
|
||||
static void ReorderRigidTrisByBoneIndex(const std::vector<size_t>& vertexIndices, const XSurface& surface, const XModelCommon& common)
|
||||
static void ReorderRigidTrisByBoneIndex(const std::vector<size_t>& vertexIndices, XSurface& surface, const XModelCommon& common)
|
||||
{
|
||||
const auto rigidBoneIndexForTri = GetRigidBoneIndicesForTris(vertexIndices, surface, common);
|
||||
|
||||
@ -454,17 +456,17 @@ namespace
|
||||
surface.partBits[partBitsIndex] |= 1 << shiftValue;
|
||||
}
|
||||
|
||||
void CreateVertListData(XSurface& surface, const std::vector<size_t>& xmodelToCommonVertexIndexLookup, const XModelCommon& common) const
|
||||
void CreateVertListData(XSurface& surface, const std::vector<size_t>& vertexIndices, const XModelCommon& common) const
|
||||
{
|
||||
ReorderRigidTrisByBoneIndex(xmodelToCommonVertexIndexLookup, surface, common);
|
||||
const auto rigidBoneIndexForTri = GetRigidBoneIndicesForTris(xmodelToCommonVertexIndexLookup, surface, common);
|
||||
ReorderRigidTrisByBoneIndex(vertexIndices, surface, common);
|
||||
const auto rigidBoneIndexForTri = GetRigidBoneIndicesForTris(vertexIndices, surface, common);
|
||||
|
||||
std::vector<XRigidVertList> vertLists;
|
||||
|
||||
auto currentVertexTail = 0u;
|
||||
auto currentTriTail = 0u;
|
||||
|
||||
const auto vertexCount = xmodelToCommonVertexIndexLookup.size();
|
||||
const auto vertexCount = vertexIndices.size();
|
||||
const auto triCount = static_cast<size_t>(surface.triCount);
|
||||
const auto boneCount = common.m_bones.size();
|
||||
for (auto boneIndex = 0u; boneIndex < boneCount; boneIndex++)
|
||||
@ -473,7 +475,7 @@ namespace
|
||||
boneVertList.boneOffset = static_cast<uint16_t>(boneIndex * sizeof(DObjSkelMat));
|
||||
|
||||
auto currentVertexHead = currentVertexTail;
|
||||
while (currentVertexHead < vertexCount && GetRigidBoneForVertex(xmodelToCommonVertexIndexLookup[currentVertexHead], common) == boneIndex)
|
||||
while (currentVertexHead < vertexCount && GetRigidBoneForVertex(currentVertexHead, common) == boneIndex)
|
||||
currentVertexHead++;
|
||||
|
||||
auto currentTriHead = currentTriTail;
|
||||
@ -510,7 +512,7 @@ namespace
|
||||
// TODO
|
||||
}
|
||||
|
||||
static void ReorderVerticesByWeightCount(std::vector<size_t>& vertexIndices, const XSurface& surface, const XModelCommon& common)
|
||||
static void ReorderVerticesByWeightCount(std::vector<size_t>& vertexIndices, XSurface& surface, const XModelCommon& common)
|
||||
{
|
||||
if (common.m_bone_weight_data.weights.empty())
|
||||
return;
|
||||
@ -539,21 +541,13 @@ namespace
|
||||
return false;
|
||||
});
|
||||
|
||||
std::vector<XSurfaceTri> preSortTris(surface.triCount);
|
||||
std::memcpy(preSortTris.data(), surface.triIndices, sizeof(XSurfaceTri) * surface.triCount);
|
||||
|
||||
std::vector<size_t> reverseLookup(reorderLookup.size());
|
||||
for (auto i = 0u; i < reverseLookup.size(); i++)
|
||||
reverseLookup[reorderLookup[i]] = i;
|
||||
|
||||
for (auto triIndex = 0u; triIndex < surface.triCount; triIndex++)
|
||||
{
|
||||
const auto& preSortTriIndices = preSortTris[triIndex];
|
||||
auto& triIndices = surface.triIndices[triIndex];
|
||||
|
||||
triIndices.i[0] = static_cast<uint16_t>(reverseLookup[preSortTriIndices.i[0]]);
|
||||
triIndices.i[1] = static_cast<uint16_t>(reverseLookup[preSortTriIndices.i[1]]);
|
||||
triIndices.i[2] = static_cast<uint16_t>(reverseLookup[preSortTriIndices.i[2]]);
|
||||
triIndices.i[0] = static_cast<uint16_t>(reorderLookup[triIndices.i[0]]);
|
||||
triIndices.i[1] = static_cast<uint16_t>(reorderLookup[triIndices.i[1]]);
|
||||
triIndices.i[2] = static_cast<uint16_t>(reorderLookup[triIndices.i[2]]);
|
||||
}
|
||||
|
||||
for (auto& entry : reorderLookup)
|
||||
@ -578,7 +572,6 @@ namespace
|
||||
surface.triCount = static_cast<uint16_t>(commonObject.m_faces.size());
|
||||
surface.triIndices = m_memory.Alloc<XSurfaceTri>(surface.triCount);
|
||||
|
||||
xmodelToCommonVertexIndexLookup.reserve(static_cast<size_t>(surface.triCount) * std::extent_v<decltype(XModelFace::vertexIndex)>);
|
||||
for (auto faceIndex = 0u; faceIndex < surface.triCount; faceIndex++)
|
||||
{
|
||||
const auto& face = commonObject.m_faces[faceIndex];
|
||||
@ -601,6 +594,8 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
ReorderVerticesByWeightCount(xmodelToCommonVertexIndexLookup, surface, common);
|
||||
|
||||
constexpr auto maxVertices = std::numeric_limits<decltype(XSurface::vertCount)>::max();
|
||||
if (vertexOffset + xmodelToCommonVertexIndexLookup.size() > maxVertices)
|
||||
{
|
||||
@ -608,8 +603,6 @@ namespace
|
||||
return false;
|
||||
}
|
||||
|
||||
ReorderVerticesByWeightCount(xmodelToCommonVertexIndexLookup, surface, common);
|
||||
|
||||
surface.baseVertIndex = static_cast<uint16_t>(vertexOffset);
|
||||
surface.vertCount = static_cast<uint16_t>(xmodelToCommonVertexIndexLookup.size());
|
||||
surface.verts0 = m_memory.Alloc<GfxPackedVertex>(surface.vertCount);
|
||||
|
@ -284,7 +284,7 @@ namespace
|
||||
const auto& vertList = surface.vertList[vertListIndex];
|
||||
const auto boneWeightOffset = weightOffset;
|
||||
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{static_cast<unsigned>(vertList.boneOffset / sizeof(DObjSkelMat)), 1.0f};
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{vertList.boneOffset / sizeof(DObjSkelMat), 1.0f};
|
||||
|
||||
for (auto vertListVertexOffset = 0u; vertListVertexOffset < vertList.vertCount; vertListVertexOffset++)
|
||||
{
|
||||
@ -301,7 +301,7 @@ namespace
|
||||
for (auto vertIndex = 0; vertIndex < surface.vertInfo.vertCount[0]; vertIndex++)
|
||||
{
|
||||
const auto boneWeightOffset = weightOffset;
|
||||
const unsigned boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
||||
const auto boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex0, 1.0f};
|
||||
|
||||
vertsBlendOffset += 1;
|
||||
@ -313,8 +313,8 @@ namespace
|
||||
for (auto vertIndex = 0; vertIndex < surface.vertInfo.vertCount[1]; vertIndex++)
|
||||
{
|
||||
const auto boneWeightOffset = weightOffset;
|
||||
const unsigned boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
||||
const unsigned boneIndex1 = surface.vertInfo.vertsBlend[vertsBlendOffset + 1] / sizeof(DObjSkelMat);
|
||||
const auto boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
||||
const auto boneIndex1 = surface.vertInfo.vertsBlend[vertsBlendOffset + 1] / sizeof(DObjSkelMat);
|
||||
const auto boneWeight1 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 2]);
|
||||
const auto boneWeight0 = 1.0f - boneWeight1;
|
||||
|
||||
@ -330,10 +330,10 @@ namespace
|
||||
for (auto vertIndex = 0; vertIndex < surface.vertInfo.vertCount[2]; vertIndex++)
|
||||
{
|
||||
const auto boneWeightOffset = weightOffset;
|
||||
const unsigned boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
||||
const unsigned boneIndex1 = surface.vertInfo.vertsBlend[vertsBlendOffset + 1] / sizeof(DObjSkelMat);
|
||||
const auto boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
||||
const auto boneIndex1 = surface.vertInfo.vertsBlend[vertsBlendOffset + 1] / sizeof(DObjSkelMat);
|
||||
const auto boneWeight1 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 2]);
|
||||
const unsigned boneIndex2 = surface.vertInfo.vertsBlend[vertsBlendOffset + 3] / sizeof(DObjSkelMat);
|
||||
const auto boneIndex2 = surface.vertInfo.vertsBlend[vertsBlendOffset + 3] / sizeof(DObjSkelMat);
|
||||
const auto boneWeight2 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 4]);
|
||||
const auto boneWeight0 = 1.0f - boneWeight1 - boneWeight2;
|
||||
|
||||
@ -350,12 +350,12 @@ namespace
|
||||
for (auto vertIndex = 0; vertIndex < surface.vertInfo.vertCount[3]; vertIndex++)
|
||||
{
|
||||
const auto boneWeightOffset = weightOffset;
|
||||
const unsigned boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
||||
const unsigned boneIndex1 = surface.vertInfo.vertsBlend[vertsBlendOffset + 1] / sizeof(DObjSkelMat);
|
||||
const auto boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
||||
const auto boneIndex1 = surface.vertInfo.vertsBlend[vertsBlendOffset + 1] / sizeof(DObjSkelMat);
|
||||
const auto boneWeight1 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 2]);
|
||||
const unsigned boneIndex2 = surface.vertInfo.vertsBlend[vertsBlendOffset + 3] / sizeof(DObjSkelMat);
|
||||
const auto boneIndex2 = surface.vertInfo.vertsBlend[vertsBlendOffset + 3] / sizeof(DObjSkelMat);
|
||||
const auto boneWeight2 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 4]);
|
||||
const unsigned boneIndex3 = surface.vertInfo.vertsBlend[vertsBlendOffset + 5] / sizeof(DObjSkelMat);
|
||||
const auto boneIndex3 = surface.vertInfo.vertsBlend[vertsBlendOffset + 5] / sizeof(DObjSkelMat);
|
||||
const auto boneWeight3 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 6]);
|
||||
const auto boneWeight0 = 1.0f - boneWeight1 - boneWeight2 - boneWeight3;
|
||||
|
||||
|
@ -34,7 +34,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const
|
||||
// DUMP_ASSET_POOL(AssetDumpersnd_alias_list_t, m_sound, ASSET_TYPE_SOUND)
|
||||
// DUMP_ASSET_POOL(AssetDumperSndCurve, m_sound_curve, ASSET_TYPE_SOUND_CURVE)
|
||||
DUMP_ASSET_POOL(AssetDumperLoadedSound, m_loaded_sound, ASSET_TYPE_LOADED_SOUND)
|
||||
// DUMP_ASSET_POOL(AssetDumperClipMap, m_clip_map, ASSET_TYPE_CLIPMAP_PVS)
|
||||
// DUMP_ASSET_POOL(AssetDumperclipMap_t, m_clip_map, ASSET_TYPE_CLIPMAP)
|
||||
// DUMP_ASSET_POOL(AssetDumperComWorld, m_com_world, ASSET_TYPE_COMWORLD)
|
||||
// DUMP_ASSET_POOL(AssetDumperGameWorldSp, m_game_world_sp, ASSET_TYPE_GAMEWORLD_SP)
|
||||
// DUMP_ASSET_POOL(AssetDumperGameWorldMp, m_game_world_mp, ASSET_TYPE_GAMEWORLD_MP)
|
||||
|
@ -37,22 +37,22 @@ CommonStructuredDataType AssetDumperStructuredDataDefSet::ConvertType(const Comm
|
||||
case DATA_ENUM:
|
||||
assert(!def->m_enums.empty());
|
||||
out.m_category = CommonStructuredDataTypeCategory::ENUM;
|
||||
out.m_info.type_index = std::max(std::min(static_cast<size_t>(in.u.enumIndex), def->m_enums.size() - 1uz), 0uz);
|
||||
out.m_info.type_index = std::max(std::min(static_cast<size_t>(in.u.enumIndex), def->m_enums.size() - 1u), 0u);
|
||||
break;
|
||||
case DATA_STRUCT:
|
||||
assert(!def->m_structs.empty());
|
||||
out.m_category = CommonStructuredDataTypeCategory::STRUCT;
|
||||
out.m_info.type_index = std::max(std::min(static_cast<size_t>(in.u.structIndex), def->m_structs.size() - 1uz), 0uz);
|
||||
out.m_info.type_index = std::max(std::min(static_cast<size_t>(in.u.structIndex), def->m_structs.size() - 1u), 0u);
|
||||
break;
|
||||
case DATA_INDEXED_ARRAY:
|
||||
assert(!def->m_indexed_arrays.empty());
|
||||
out.m_category = CommonStructuredDataTypeCategory::INDEXED_ARRAY;
|
||||
out.m_info.type_index = std::max(std::min(static_cast<size_t>(in.u.indexedArrayIndex), def->m_indexed_arrays.size() - 1uz), 0uz);
|
||||
out.m_info.type_index = std::max(std::min(static_cast<size_t>(in.u.indexedArrayIndex), def->m_indexed_arrays.size() - 1u), 0u);
|
||||
break;
|
||||
case DATA_ENUM_ARRAY:
|
||||
assert(!def->m_enumed_arrays.empty());
|
||||
out.m_category = CommonStructuredDataTypeCategory::ENUM_ARRAY;
|
||||
out.m_info.type_index = std::max(std::min(static_cast<size_t>(in.u.enumedArrayIndex), def->m_enumed_arrays.size() - 1uz), 0uz);
|
||||
out.m_info.type_index = std::max(std::min(static_cast<size_t>(in.u.enumedArrayIndex), def->m_enumed_arrays.size() - 1u), 0u);
|
||||
break;
|
||||
case DATA_COUNT:
|
||||
default:
|
||||
@ -138,7 +138,7 @@ void AssetDumperStructuredDataDefSet::ConvertEnumedArray(const CommonStructuredD
|
||||
assert(!def->m_enums.empty());
|
||||
out->m_element_size_in_bits = in->elementType.type == DATA_BOOL ? 1 : in->elementSize * 8;
|
||||
out->m_array_type = ConvertType(def, in->elementType);
|
||||
out->m_enum_index = std::max(std::min(static_cast<size_t>(in->enumIndex), def->m_enums.size() - 1uz), 0uz);
|
||||
out->m_enum_index = std::max(std::min(static_cast<size_t>(in->enumIndex), def->m_enums.size() - 1u), 0u);
|
||||
|
||||
if (def->m_enums.empty())
|
||||
{
|
||||
|
@ -267,7 +267,7 @@ namespace
|
||||
const auto& vertList = surface.vertList[vertListIndex];
|
||||
const auto boneWeightOffset = weightOffset;
|
||||
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{static_cast<unsigned>(vertList.boneOffset / sizeof(DObjSkelMat)), 1.0f};
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{vertList.boneOffset / sizeof(DObjSkelMat), 1.0f};
|
||||
|
||||
for (auto vertListVertexOffset = 0u; vertListVertexOffset < vertList.vertCount; vertListVertexOffset++)
|
||||
{
|
||||
@ -284,7 +284,7 @@ namespace
|
||||
for (auto vertIndex = 0; vertIndex < surface.vertInfo.vertCount[0]; vertIndex++)
|
||||
{
|
||||
const auto boneWeightOffset = weightOffset;
|
||||
const unsigned boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
||||
const auto boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex0, 1.0f};
|
||||
|
||||
vertsBlendOffset += 1;
|
||||
@ -296,8 +296,8 @@ namespace
|
||||
for (auto vertIndex = 0; vertIndex < surface.vertInfo.vertCount[1]; vertIndex++)
|
||||
{
|
||||
const auto boneWeightOffset = weightOffset;
|
||||
const unsigned boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
||||
const unsigned boneIndex1 = surface.vertInfo.vertsBlend[vertsBlendOffset + 1] / sizeof(DObjSkelMat);
|
||||
const auto boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
||||
const auto boneIndex1 = surface.vertInfo.vertsBlend[vertsBlendOffset + 1] / sizeof(DObjSkelMat);
|
||||
const auto boneWeight1 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 2]);
|
||||
const auto boneWeight0 = 1.0f - boneWeight1;
|
||||
|
||||
@ -313,10 +313,10 @@ namespace
|
||||
for (auto vertIndex = 0; vertIndex < surface.vertInfo.vertCount[2]; vertIndex++)
|
||||
{
|
||||
const auto boneWeightOffset = weightOffset;
|
||||
const unsigned boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
||||
const unsigned boneIndex1 = surface.vertInfo.vertsBlend[vertsBlendOffset + 1] / sizeof(DObjSkelMat);
|
||||
const auto boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
||||
const auto boneIndex1 = surface.vertInfo.vertsBlend[vertsBlendOffset + 1] / sizeof(DObjSkelMat);
|
||||
const auto boneWeight1 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 2]);
|
||||
const unsigned boneIndex2 = surface.vertInfo.vertsBlend[vertsBlendOffset + 3] / sizeof(DObjSkelMat);
|
||||
const auto boneIndex2 = surface.vertInfo.vertsBlend[vertsBlendOffset + 3] / sizeof(DObjSkelMat);
|
||||
const auto boneWeight2 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 4]);
|
||||
const auto boneWeight0 = 1.0f - boneWeight1 - boneWeight2;
|
||||
|
||||
@ -333,12 +333,12 @@ namespace
|
||||
for (auto vertIndex = 0; vertIndex < surface.vertInfo.vertCount[3]; vertIndex++)
|
||||
{
|
||||
const auto boneWeightOffset = weightOffset;
|
||||
const unsigned boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
||||
const unsigned boneIndex1 = surface.vertInfo.vertsBlend[vertsBlendOffset + 1] / sizeof(DObjSkelMat);
|
||||
const auto boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
||||
const auto boneIndex1 = surface.vertInfo.vertsBlend[vertsBlendOffset + 1] / sizeof(DObjSkelMat);
|
||||
const auto boneWeight1 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 2]);
|
||||
const unsigned boneIndex2 = surface.vertInfo.vertsBlend[vertsBlendOffset + 3] / sizeof(DObjSkelMat);
|
||||
const auto boneIndex2 = surface.vertInfo.vertsBlend[vertsBlendOffset + 3] / sizeof(DObjSkelMat);
|
||||
const auto boneWeight2 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 4]);
|
||||
const unsigned boneIndex3 = surface.vertInfo.vertsBlend[vertsBlendOffset + 5] / sizeof(DObjSkelMat);
|
||||
const auto boneIndex3 = surface.vertInfo.vertsBlend[vertsBlendOffset + 5] / sizeof(DObjSkelMat);
|
||||
const auto boneWeight3 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 6]);
|
||||
const auto boneWeight0 = 1.0f - boneWeight1 - boneWeight2 - boneWeight3;
|
||||
|
||||
|
@ -50,7 +50,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const
|
||||
// DUMP_ASSET_POOL(AssetDumpersnd_alias_list_t, m_sound, ASSET_TYPE_SOUND)
|
||||
DUMP_ASSET_POOL(AssetDumperSndCurve, m_sound_curve, ASSET_TYPE_SOUND_CURVE)
|
||||
DUMP_ASSET_POOL(AssetDumperLoadedSound, m_loaded_sound, ASSET_TYPE_LOADED_SOUND)
|
||||
// DUMP_ASSET_POOL(AssetDumperClipMap, m_clip_map, ASSET_TYPE_CLIPMAP_MP)
|
||||
// DUMP_ASSET_POOL(AssetDumperclipMap_t, m_clip_map, ASSET_TYPE_CLIPMAP_MP)
|
||||
// DUMP_ASSET_POOL(AssetDumperComWorld, m_com_world, ASSET_TYPE_COMWORLD)
|
||||
// DUMP_ASSET_POOL(AssetDumperGameWorldSp, m_game_world_sp, ASSET_TYPE_GAMEWORLD_SP)
|
||||
// DUMP_ASSET_POOL(AssetDumperGameWorldMp, m_game_world_mp, ASSET_TYPE_GAMEWORLD_MP)
|
||||
|
@ -35,7 +35,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const
|
||||
DUMP_ASSET_POOL(AssetDumperGfxImage, m_image, ASSET_TYPE_IMAGE)
|
||||
// DUMP_ASSET_POOL(AssetDumperSndBank, m_sound_bank, ASSET_TYPE_SOUND)
|
||||
// DUMP_ASSET_POOL(AssetDumperSndPatch, m_sound_patch, ASSET_TYPE_SOUND_PATCH)
|
||||
// DUMP_ASSET_POOL(AssetDumperClipMap, m_clip_map, ASSET_TYPE_CLIPMAP_PVS)
|
||||
// DUMP_ASSET_POOL(AssetDumperClipMap, m_clip_map, ASSET_TYPE_CLIPMAP)
|
||||
// DUMP_ASSET_POOL(AssetDumperComWorld, m_com_world, ASSET_TYPE_COMWORLD)
|
||||
// DUMP_ASSET_POOL(AssetDumperGameWorldSp, m_game_world_sp, ASSET_TYPE_GAMEWORLD_SP)
|
||||
// DUMP_ASSET_POOL(AssetDumperGameWorldMp, m_game_world_mp, ASSET_TYPE_GAMEWORLD_MP)
|
||||
|
@ -1,23 +0,0 @@
|
||||
#include "AssetDumperMapEnts.h"
|
||||
|
||||
#include <format>
|
||||
|
||||
using namespace T6;
|
||||
|
||||
bool AssetDumperMapEnts::ShouldDump(XAssetInfo<MapEnts>* asset)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void AssetDumperMapEnts::DumpAsset(AssetDumpingContext& context, XAssetInfo<MapEnts>* asset)
|
||||
{
|
||||
const auto* mapEnts = asset->Asset();
|
||||
|
||||
const auto mapEntsFile = context.OpenAssetFile(std::format("{}.ents", mapEnts->name));
|
||||
|
||||
if (!mapEntsFile)
|
||||
return;
|
||||
|
||||
auto& stream = *mapEntsFile;
|
||||
stream.write(mapEnts->entityString, mapEnts->numEntityChars - 1);
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Game/T6/T6.h"
|
||||
|
||||
namespace T6
|
||||
{
|
||||
class AssetDumperMapEnts final : public AbstractAssetDumper<MapEnts>
|
||||
{
|
||||
protected:
|
||||
bool ShouldDump(XAssetInfo<MapEnts>* asset) override;
|
||||
void DumpAsset(AssetDumpingContext& context, XAssetInfo<MapEnts>* asset) override;
|
||||
};
|
||||
} // namespace T6
|
@ -110,7 +110,7 @@ namespace
|
||||
"devraw/",
|
||||
};
|
||||
|
||||
constexpr unsigned FRAME_RATE_FOR_INDEX[]{
|
||||
constexpr size_t FRAME_RATE_FOR_INDEX[]{
|
||||
8000,
|
||||
12000,
|
||||
16000,
|
||||
|
@ -4,7 +4,6 @@
|
||||
#include "AssetDumpers/AssetDumperGfxImage.h"
|
||||
#include "AssetDumpers/AssetDumperLeaderboardDef.h"
|
||||
#include "AssetDumpers/AssetDumperLocalizeEntry.h"
|
||||
#include "AssetDumpers/AssetDumperMapEnts.h"
|
||||
#include "AssetDumpers/AssetDumperMaterial.h"
|
||||
#include "AssetDumpers/AssetDumperPhysConstraints.h"
|
||||
#include "AssetDumpers/AssetDumperPhysPreset.h"
|
||||
@ -50,11 +49,11 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const
|
||||
DUMP_ASSET_POOL(AssetDumperGfxImage, m_image, ASSET_TYPE_IMAGE)
|
||||
DUMP_ASSET_POOL(AssetDumperSndBank, m_sound_bank, ASSET_TYPE_SOUND)
|
||||
// DUMP_ASSET_POOL(AssetDumperSndPatch, m_sound_patch, ASSET_TYPE_SOUND_PATCH)
|
||||
// DUMP_ASSET_POOL(AssetDumperClipMap, m_clip_map, ASSET_TYPE_CLIPMAP_PVS)
|
||||
// DUMP_ASSET_POOL(AssetDumperClipMap, m_clip_map, ASSET_TYPE_CLIPMAP)
|
||||
// DUMP_ASSET_POOL(AssetDumperComWorld, m_com_world, ASSET_TYPE_COMWORLD)
|
||||
// DUMP_ASSET_POOL(AssetDumperGameWorldSp, m_game_world_sp, ASSET_TYPE_GAMEWORLD_SP)
|
||||
// DUMP_ASSET_POOL(AssetDumperGameWorldMp, m_game_world_mp, ASSET_TYPE_GAMEWORLD_MP)
|
||||
DUMP_ASSET_POOL(AssetDumperMapEnts, m_map_ents, ASSET_TYPE_MAP_ENTS)
|
||||
// DUMP_ASSET_POOL(AssetDumperMapEnts, m_map_ents, ASSET_TYPE_MAP_ENTS)
|
||||
// DUMP_ASSET_POOL(AssetDumperGfxWorld, m_gfx_world, ASSET_TYPE_GFXWORLD)
|
||||
// DUMP_ASSET_POOL(AssetDumperGfxLightDef, m_gfx_light_def, ASSET_TYPE_LIGHT_DEF)
|
||||
// DUMP_ASSET_POOL(AssetDumperFont, m_font, ASSET_TYPE_FONT)
|
||||
|
@ -27,7 +27,7 @@ void WavWriter::WritePcmHeader(const WavMetaData& metaData, const size_t dataLen
|
||||
};
|
||||
m_stream.write(reinterpret_cast<const char*>(&formatChunk), sizeof(formatChunk));
|
||||
|
||||
const WavChunkHeader dataChunkHeader{WAV_CHUNK_ID_DATA, static_cast<unsigned>(dataLen)};
|
||||
const WavChunkHeader dataChunkHeader{WAV_CHUNK_ID_DATA, dataLen};
|
||||
m_stream.write(reinterpret_cast<const char*>(&dataChunkHeader), sizeof(dataChunkHeader));
|
||||
}
|
||||
|
||||
|
@ -139,7 +139,7 @@ void StructuredDataDefDumper::DumpType(const CommonStructuredDataDef& def,
|
||||
|
||||
void StructuredDataDefDumper::DumpProperty(const CommonStructuredDataDef& def,
|
||||
const CommonStructuredDataStructProperty& property,
|
||||
size_t& currentOffsetInBit) const
|
||||
unsigned& currentOffsetInBit) const
|
||||
{
|
||||
std::string typeName;
|
||||
std::vector<std::string> arraySpecifiers;
|
||||
@ -205,11 +205,11 @@ void StructuredDataDefDumper::DumpStruct(const CommonStructuredDataDef& def, con
|
||||
IncIndent();
|
||||
|
||||
auto currentOffsetInBit =
|
||||
def.m_root_type.m_category == CommonStructuredDataTypeCategory::STRUCT && def.m_root_type.m_info.type_index == structIndex ? 64uz : 0uz;
|
||||
def.m_root_type.m_category == CommonStructuredDataTypeCategory::STRUCT && def.m_root_type.m_info.type_index == structIndex ? 64u : 0u;
|
||||
for (const auto& property : _struct.m_properties)
|
||||
DumpProperty(def, property, currentOffsetInBit);
|
||||
|
||||
currentOffsetInBit = utils::Align(currentOffsetInBit, 8uz);
|
||||
currentOffsetInBit = utils::Align(currentOffsetInBit, 8u);
|
||||
if ((currentOffsetInBit / 8) < _struct.m_size_in_byte)
|
||||
{
|
||||
Indent();
|
||||
|
@ -17,7 +17,7 @@ class StructuredDataDefDumper : AbstractTextDumper
|
||||
|
||||
void DumpEnum(const CommonStructuredDataEnum& _enum);
|
||||
void DumpType(const CommonStructuredDataDef& def, CommonStructuredDataType type, std::string& typeName, std::vector<std::string>& arraySpecifiers) const;
|
||||
void DumpProperty(const CommonStructuredDataDef& def, const CommonStructuredDataStructProperty& property, size_t& currentOffsetInBit) const;
|
||||
void DumpProperty(const CommonStructuredDataDef& def, const CommonStructuredDataStructProperty& property, unsigned& currentOffsetInBit) const;
|
||||
void DumpStruct(const CommonStructuredDataDef& def, const CommonStructuredDataStruct& _struct, size_t structIndex);
|
||||
|
||||
public:
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include <Eigen>
|
||||
#pragma warning(pop)
|
||||
|
||||
#include <algorithm>
|
||||
#include <format>
|
||||
|
||||
using namespace gltf;
|
||||
@ -42,13 +41,13 @@ namespace
|
||||
|
||||
CreateJsonAsset(gltf.asset);
|
||||
CreateSkeletonNodes(gltf, xmodel);
|
||||
CreateMeshNodes(gltf, xmodel);
|
||||
CreateMeshNode(gltf, xmodel);
|
||||
CreateRootNode(gltf, xmodel);
|
||||
CreateMaterials(gltf, xmodel);
|
||||
CreateBufferViews(gltf, xmodel);
|
||||
CreateAccessors(gltf, xmodel);
|
||||
CreateSkin(gltf, xmodel);
|
||||
CreateMeshes(gltf, xmodel);
|
||||
CreateMesh(gltf, xmodel);
|
||||
CreateScene(gltf, xmodel);
|
||||
FillBufferData(gltf, xmodel, bufferData);
|
||||
CreateBuffer(gltf, xmodel, bufferData);
|
||||
@ -69,44 +68,39 @@ namespace
|
||||
asset.generator = GLTF_GENERATOR;
|
||||
}
|
||||
|
||||
void CreateMeshNodes(JsonRoot& gltf, const XModelCommon& xmodel)
|
||||
void CreateMeshNode(JsonRoot& gltf, const XModelCommon& xmodel)
|
||||
{
|
||||
JsonNode meshNode;
|
||||
|
||||
if (!xmodel.m_name.empty())
|
||||
meshNode.name = xmodel.m_name;
|
||||
|
||||
// We only have one mesh
|
||||
meshNode.mesh = 0u;
|
||||
|
||||
// Only add skin if the model has bones
|
||||
if (!xmodel.m_bones.empty())
|
||||
{
|
||||
// We only have one skin
|
||||
meshNode.skin = 0u;
|
||||
}
|
||||
|
||||
if (!gltf.nodes.has_value())
|
||||
gltf.nodes.emplace();
|
||||
|
||||
m_first_mesh_node = gltf.nodes->size();
|
||||
m_mesh_node = gltf.nodes->size();
|
||||
|
||||
auto meshIndex = 0u;
|
||||
for (const auto& object : xmodel.m_objects)
|
||||
{
|
||||
JsonNode meshNode;
|
||||
if (xmodel.m_bones.empty())
|
||||
m_root_node = m_mesh_node;
|
||||
|
||||
if (!object.name.empty())
|
||||
meshNode.name = object.name;
|
||||
|
||||
meshNode.mesh = meshIndex++;
|
||||
|
||||
// Only add skin if the model has bones
|
||||
if (!xmodel.m_bones.empty())
|
||||
{
|
||||
// We only have one skin
|
||||
meshNode.skin = 0u;
|
||||
}
|
||||
|
||||
gltf.nodes->emplace_back(std::move(meshNode));
|
||||
}
|
||||
|
||||
// If we only have one mesh and no bones we don't need a dedicated root node
|
||||
if (xmodel.m_bones.empty() && xmodel.m_objects.size() == 1)
|
||||
m_root_node = m_first_mesh_node;
|
||||
gltf.nodes->emplace_back(std::move(meshNode));
|
||||
}
|
||||
|
||||
void CreateRootNode(JsonRoot& gltf, const XModelCommon& xmodel)
|
||||
{
|
||||
JsonNode rootNode;
|
||||
|
||||
// If we have at most one mesh and no bones we don't need a dedicated root node
|
||||
if (xmodel.m_bones.empty() && xmodel.m_objects.size() <= 1)
|
||||
if (xmodel.m_bones.empty())
|
||||
return;
|
||||
|
||||
if (!xmodel.m_name.empty())
|
||||
@ -116,31 +110,29 @@ namespace
|
||||
gltf.nodes.emplace();
|
||||
|
||||
rootNode.children.emplace();
|
||||
|
||||
const auto meshCount = xmodel.m_objects.size();
|
||||
for (auto meshIndex = 0u; meshIndex < meshCount; meshIndex++)
|
||||
rootNode.children->push_back(m_first_mesh_node + meshIndex);
|
||||
|
||||
rootNode.children->push_back(m_mesh_node);
|
||||
rootNode.children->push_back(m_first_bone_node);
|
||||
|
||||
m_root_node = gltf.nodes->size();
|
||||
gltf.nodes->emplace_back(std::move(rootNode));
|
||||
}
|
||||
|
||||
void CreateMeshes(JsonRoot& gltf, const XModelCommon& xmodel)
|
||||
void CreateMesh(JsonRoot& gltf, const XModelCommon& xmodel)
|
||||
{
|
||||
if (!gltf.meshes.has_value())
|
||||
gltf.meshes.emplace();
|
||||
|
||||
JsonMesh mesh;
|
||||
|
||||
const auto hasBoneWeightData = !xmodel.m_bone_weight_data.weights.empty();
|
||||
|
||||
auto objectIndex = 0u;
|
||||
for (const auto& object : xmodel.m_objects)
|
||||
{
|
||||
JsonMesh mesh;
|
||||
JsonMeshPrimitives primitives;
|
||||
|
||||
primitives.material = object.materialIndex;
|
||||
if (object.materialIndex >= 0)
|
||||
primitives.material = static_cast<unsigned>(object.materialIndex);
|
||||
|
||||
primitives.attributes.POSITION = m_position_accessor;
|
||||
primitives.attributes.NORMAL = m_normal_accessor;
|
||||
@ -157,8 +149,9 @@ namespace
|
||||
|
||||
mesh.primitives.emplace_back(primitives);
|
||||
objectIndex++;
|
||||
gltf.meshes->emplace_back(std::move(mesh));
|
||||
}
|
||||
|
||||
gltf.meshes->emplace_back(std::move(mesh));
|
||||
}
|
||||
|
||||
static void CreateMaterials(JsonRoot& gltf, const XModelCommon& xmodel)
|
||||
@ -473,12 +466,18 @@ namespace
|
||||
vertex->coordinates[1] = commonVertex.coordinates[2];
|
||||
vertex->coordinates[2] = -commonVertex.coordinates[1];
|
||||
|
||||
minPosition[0] = std::min(minPosition[0], vertex->coordinates[0]);
|
||||
minPosition[1] = std::min(minPosition[1], vertex->coordinates[1]);
|
||||
minPosition[2] = std::min(minPosition[2], vertex->coordinates[2]);
|
||||
maxPosition[0] = std::max(maxPosition[0], vertex->coordinates[0]);
|
||||
maxPosition[1] = std::max(maxPosition[1], vertex->coordinates[1]);
|
||||
maxPosition[2] = std::max(maxPosition[2], vertex->coordinates[2]);
|
||||
if (minPosition[0] > vertex->coordinates[0])
|
||||
minPosition[0] = vertex->coordinates[0];
|
||||
if (minPosition[1] > vertex->coordinates[1])
|
||||
minPosition[1] = vertex->coordinates[1];
|
||||
if (minPosition[2] > vertex->coordinates[2])
|
||||
minPosition[2] = vertex->coordinates[2];
|
||||
if (maxPosition[0] < vertex->coordinates[0])
|
||||
maxPosition[0] = vertex->coordinates[0];
|
||||
if (maxPosition[1] < vertex->coordinates[1])
|
||||
maxPosition[1] = vertex->coordinates[1];
|
||||
if (maxPosition[2] < vertex->coordinates[2])
|
||||
maxPosition[2] = vertex->coordinates[2];
|
||||
|
||||
vertex->normal[0] = commonVertex.normal[0];
|
||||
vertex->normal[1] = commonVertex.normal[2];
|
||||
@ -500,7 +499,7 @@ namespace
|
||||
{
|
||||
assert(xmodel.m_vertex_bone_weights.size() == xmodel.m_vertices.size());
|
||||
|
||||
auto* joints = &bufferData[currentBufferOffset];
|
||||
auto* joints = reinterpret_cast<uint8_t*>(&bufferData[currentBufferOffset]);
|
||||
auto* weights = reinterpret_cast<float*>(&bufferData[currentBufferOffset + sizeof(uint8_t) * 4u * xmodel.m_vertex_bone_weights.size()]);
|
||||
for (const auto& commonVertexWeights : xmodel.m_vertex_bone_weights)
|
||||
{
|
||||
@ -611,7 +610,7 @@ namespace
|
||||
gltf.buffers->emplace_back(std::move(jsonBuffer));
|
||||
}
|
||||
|
||||
unsigned m_first_mesh_node = 0u;
|
||||
unsigned m_mesh_node = 0u;
|
||||
unsigned m_root_node = 0u;
|
||||
unsigned m_first_bone_node = 0u;
|
||||
unsigned m_position_accessor = 0u;
|
||||
|
@ -32,9 +32,7 @@
|
||||
#include <cassert>
|
||||
#include <format>
|
||||
|
||||
using namespace GAME;
|
||||
|
||||
namespace
|
||||
namespace GAME
|
||||
{
|
||||
std::string GetFileNameForLod(const std::string& modelName, const unsigned lod, const std::string& extension)
|
||||
{
|
||||
@ -225,10 +223,10 @@ namespace
|
||||
bone.globalOffset[1] = baseMat.trans.y;
|
||||
bone.globalOffset[2] = baseMat.trans.z;
|
||||
bone.globalRotation = {
|
||||
.x = baseMat.quat.x,
|
||||
.y = baseMat.quat.y,
|
||||
.z = baseMat.quat.z,
|
||||
.w = baseMat.quat.w,
|
||||
baseMat.quat.x,
|
||||
baseMat.quat.y,
|
||||
baseMat.quat.z,
|
||||
baseMat.quat.w,
|
||||
};
|
||||
|
||||
if (boneNum < model->numRootBones)
|
||||
@ -236,7 +234,7 @@ namespace
|
||||
bone.localOffset[0] = 0;
|
||||
bone.localOffset[1] = 0;
|
||||
bone.localOffset[2] = 0;
|
||||
bone.localRotation = {.x = 0, .y = 0, .z = 0, .w = 1};
|
||||
bone.localRotation = {0, 0, 0, 1};
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -247,10 +245,10 @@ namespace
|
||||
|
||||
const auto& quat = model->quats[boneNum - model->numRootBones];
|
||||
bone.localRotation = {
|
||||
.x = QuatInt16::ToFloat(quat.v[0]),
|
||||
.y = QuatInt16::ToFloat(quat.v[1]),
|
||||
.z = QuatInt16::ToFloat(quat.v[2]),
|
||||
.w = QuatInt16::ToFloat(quat.v[3]),
|
||||
QuatInt16::ToFloat(quat.v[0]),
|
||||
QuatInt16::ToFloat(quat.v[1]),
|
||||
QuatInt16::ToFloat(quat.v[2]),
|
||||
QuatInt16::ToFloat(quat.v[3]),
|
||||
};
|
||||
}
|
||||
|
||||
@ -392,9 +390,8 @@ namespace
|
||||
{
|
||||
const auto& vertList = surface.vertList[vertListIndex];
|
||||
const auto boneWeightOffset = weightOffset;
|
||||
|
||||
weightCollection.weights[weightOffset++] =
|
||||
XModelBoneWeight{.boneIndex = static_cast<unsigned>(vertList.boneOffset / sizeof(DObjSkelMat)), .weight = 1.0f};
|
||||
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{vertList.boneOffset / sizeof(DObjSkelMat), 1.0f};
|
||||
|
||||
for (auto vertListVertexOffset = 0u; vertListVertexOffset < vertList.vertCount; vertListVertexOffset++)
|
||||
{
|
||||
@ -411,8 +408,8 @@ namespace
|
||||
for (auto vertIndex = 0; vertIndex < surface.vertInfo.vertCount[0]; vertIndex++)
|
||||
{
|
||||
const auto boneWeightOffset = weightOffset;
|
||||
const unsigned boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{.boneIndex = boneIndex0, .weight = 1.0f};
|
||||
const auto boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex0, 1.0f};
|
||||
|
||||
vertsBlendOffset += 1;
|
||||
|
||||
@ -423,13 +420,13 @@ namespace
|
||||
for (auto vertIndex = 0; vertIndex < surface.vertInfo.vertCount[1]; vertIndex++)
|
||||
{
|
||||
const auto boneWeightOffset = weightOffset;
|
||||
const unsigned boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
||||
const unsigned boneIndex1 = surface.vertInfo.vertsBlend[vertsBlendOffset + 1] / sizeof(DObjSkelMat);
|
||||
const auto boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
||||
const auto boneIndex1 = surface.vertInfo.vertsBlend[vertsBlendOffset + 1] / sizeof(DObjSkelMat);
|
||||
const auto boneWeight1 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 2]);
|
||||
const auto boneWeight0 = 1.0f - boneWeight1;
|
||||
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{.boneIndex = boneIndex0, .weight = boneWeight0};
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{.boneIndex = boneIndex1, .weight = boneWeight1};
|
||||
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex0, boneWeight0};
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex1, boneWeight1};
|
||||
|
||||
vertsBlendOffset += 3;
|
||||
|
||||
@ -440,16 +437,16 @@ namespace
|
||||
for (auto vertIndex = 0; vertIndex < surface.vertInfo.vertCount[2]; vertIndex++)
|
||||
{
|
||||
const auto boneWeightOffset = weightOffset;
|
||||
const unsigned boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
||||
const unsigned boneIndex1 = surface.vertInfo.vertsBlend[vertsBlendOffset + 1] / sizeof(DObjSkelMat);
|
||||
const auto boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
||||
const auto boneIndex1 = surface.vertInfo.vertsBlend[vertsBlendOffset + 1] / sizeof(DObjSkelMat);
|
||||
const auto boneWeight1 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 2]);
|
||||
const unsigned boneIndex2 = surface.vertInfo.vertsBlend[vertsBlendOffset + 3] / sizeof(DObjSkelMat);
|
||||
const auto boneIndex2 = surface.vertInfo.vertsBlend[vertsBlendOffset + 3] / sizeof(DObjSkelMat);
|
||||
const auto boneWeight2 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 4]);
|
||||
const auto boneWeight0 = 1.0f - boneWeight1 - boneWeight2;
|
||||
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{.boneIndex = boneIndex0, .weight = boneWeight0};
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{.boneIndex = boneIndex1, .weight = boneWeight1};
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{.boneIndex = boneIndex2, .weight = boneWeight2};
|
||||
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex0, boneWeight0};
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex1, boneWeight1};
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex2, boneWeight2};
|
||||
|
||||
vertsBlendOffset += 5;
|
||||
|
||||
@ -460,19 +457,19 @@ namespace
|
||||
for (auto vertIndex = 0; vertIndex < surface.vertInfo.vertCount[3]; vertIndex++)
|
||||
{
|
||||
const auto boneWeightOffset = weightOffset;
|
||||
const unsigned boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
||||
const unsigned boneIndex1 = surface.vertInfo.vertsBlend[vertsBlendOffset + 1] / sizeof(DObjSkelMat);
|
||||
const auto boneIndex0 = surface.vertInfo.vertsBlend[vertsBlendOffset + 0] / sizeof(DObjSkelMat);
|
||||
const auto boneIndex1 = surface.vertInfo.vertsBlend[vertsBlendOffset + 1] / sizeof(DObjSkelMat);
|
||||
const auto boneWeight1 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 2]);
|
||||
const unsigned boneIndex2 = surface.vertInfo.vertsBlend[vertsBlendOffset + 3] / sizeof(DObjSkelMat);
|
||||
const auto boneIndex2 = surface.vertInfo.vertsBlend[vertsBlendOffset + 3] / sizeof(DObjSkelMat);
|
||||
const auto boneWeight2 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 4]);
|
||||
const unsigned boneIndex3 = surface.vertInfo.vertsBlend[vertsBlendOffset + 5] / sizeof(DObjSkelMat);
|
||||
const auto boneIndex3 = surface.vertInfo.vertsBlend[vertsBlendOffset + 5] / sizeof(DObjSkelMat);
|
||||
const auto boneWeight3 = BoneWeight16(surface.vertInfo.vertsBlend[vertsBlendOffset + 6]);
|
||||
const auto boneWeight0 = 1.0f - boneWeight1 - boneWeight2 - boneWeight3;
|
||||
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{.boneIndex = boneIndex0, .weight = boneWeight0};
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{.boneIndex = boneIndex1, .weight = boneWeight1};
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{.boneIndex = boneIndex2, .weight = boneWeight2};
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{.boneIndex = boneIndex3, .weight = boneWeight3};
|
||||
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex0, boneWeight0};
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex1, boneWeight1};
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex2, boneWeight2};
|
||||
weightCollection.weights[weightOffset++] = XModelBoneWeight{boneIndex3, boneWeight3};
|
||||
|
||||
vertsBlendOffset += 7;
|
||||
|
||||
@ -570,7 +567,7 @@ namespace
|
||||
void DumpXModelExportLod(const XModelCommon& common, const AssetDumpingContext& context, const XAssetInfo<XModel>* asset, const unsigned lod)
|
||||
{
|
||||
const auto* model = asset->Asset();
|
||||
const auto assetFile = context.OpenAssetFile(GetFileNameForLod(model->name, lod, ".xmodel_export"));
|
||||
const auto assetFile = context.OpenAssetFile(GetFileNameForLod(model->name, lod, ".XMODEL_EXPORT"));
|
||||
|
||||
if (!assetFile)
|
||||
return;
|
||||
@ -665,13 +662,13 @@ namespace
|
||||
switch (ObjWriting::Configuration.ModelOutputFormat)
|
||||
{
|
||||
case ObjWriting::Configuration_t::ModelOutputFormat_e::XMODEL_EXPORT:
|
||||
return ".xmodel_export";
|
||||
return ".XMODEL_EXPORT";
|
||||
case ObjWriting::Configuration_t::ModelOutputFormat_e::OBJ:
|
||||
return ".obj";
|
||||
return ".OBJ";
|
||||
case ObjWriting::Configuration_t::ModelOutputFormat_e::GLTF:
|
||||
return ".gltf";
|
||||
return ".GLTF";
|
||||
case ObjWriting::Configuration_t::ModelOutputFormat_e::GLB:
|
||||
return ".glb";
|
||||
return ".GLB";
|
||||
default:
|
||||
assert(false);
|
||||
return "";
|
||||
@ -727,10 +724,7 @@ namespace
|
||||
const JsonDumper dumper(context, *assetFile);
|
||||
dumper.Dump(asset->Asset());
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace GAME
|
||||
{
|
||||
void DumpXModel(AssetDumpingContext& context, XAssetInfo<XModel>* asset)
|
||||
{
|
||||
DumpXModelJson(context, asset);
|
||||
|
@ -1,11 +1,11 @@
|
||||
#include "AbstractDirectiveStreamProxy.h"
|
||||
|
||||
TokenPos AbstractDirectiveStreamProxy::CreatePos(const ParserLine& line, const size_t position)
|
||||
TokenPos AbstractDirectiveStreamProxy::CreatePos(const ParserLine& line, const unsigned position)
|
||||
{
|
||||
return TokenPos(*line.m_filename, line.m_line_number, static_cast<int>(position + 1));
|
||||
}
|
||||
|
||||
bool AbstractDirectiveStreamProxy::SkipWhitespace(const ParserLine& line, size_t& position)
|
||||
bool AbstractDirectiveStreamProxy::SkipWhitespace(const ParserLine& line, unsigned& position)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
@ -21,7 +21,7 @@ bool AbstractDirectiveStreamProxy::SkipWhitespace(const ParserLine& line, size_t
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AbstractDirectiveStreamProxy::ExtractInteger(const ParserLine& line, size_t& position, int& value)
|
||||
bool AbstractDirectiveStreamProxy::ExtractInteger(const ParserLine& line, unsigned& position, int& value)
|
||||
{
|
||||
if (position >= line.m_line.size())
|
||||
return false;
|
||||
@ -40,7 +40,7 @@ bool AbstractDirectiveStreamProxy::ExtractInteger(const ParserLine& line, size_t
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AbstractDirectiveStreamProxy::ExtractIdentifier(const ParserLine& line, size_t& position)
|
||||
bool AbstractDirectiveStreamProxy::ExtractIdentifier(const ParserLine& line, unsigned& position)
|
||||
{
|
||||
auto firstChar = true;
|
||||
while (true)
|
||||
@ -60,7 +60,7 @@ bool AbstractDirectiveStreamProxy::ExtractIdentifier(const ParserLine& line, siz
|
||||
}
|
||||
}
|
||||
|
||||
bool AbstractDirectiveStreamProxy::MatchCharacter(const ParserLine& line, size_t& position, char c)
|
||||
bool AbstractDirectiveStreamProxy::MatchCharacter(const ParserLine& line, unsigned& position, char c)
|
||||
{
|
||||
if (position < line.m_line.size() && line.m_line[position] == c)
|
||||
{
|
||||
@ -71,12 +71,12 @@ bool AbstractDirectiveStreamProxy::MatchCharacter(const ParserLine& line, size_t
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AbstractDirectiveStreamProxy::MatchNextCharacter(const ParserLine& line, size_t& position, char c)
|
||||
bool AbstractDirectiveStreamProxy::MatchNextCharacter(const ParserLine& line, unsigned& position, char c)
|
||||
{
|
||||
return SkipWhitespace(line, position) && MatchCharacter(line, position, c);
|
||||
}
|
||||
|
||||
bool AbstractDirectiveStreamProxy::MatchString(const ParserLine& line, size_t& position, const char* str, size_t len)
|
||||
bool AbstractDirectiveStreamProxy::MatchString(const ParserLine& line, unsigned& position, const char* str, unsigned len)
|
||||
{
|
||||
if (line.m_line.compare(position, len, str) == 0)
|
||||
{
|
||||
@ -87,12 +87,12 @@ bool AbstractDirectiveStreamProxy::MatchString(const ParserLine& line, size_t& p
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AbstractDirectiveStreamProxy::MatchNextString(const ParserLine& line, size_t& position, const char* str, size_t len)
|
||||
bool AbstractDirectiveStreamProxy::MatchNextString(const ParserLine& line, unsigned& position, const char* str, unsigned len)
|
||||
{
|
||||
return SkipWhitespace(line, position) && MatchString(line, position, str, len);
|
||||
}
|
||||
|
||||
bool AbstractDirectiveStreamProxy::FindDirective(const ParserLine& line, size_t& directiveStartPosition, size_t& directiveEndPos)
|
||||
bool AbstractDirectiveStreamProxy::FindDirective(const ParserLine& line, unsigned& directiveStartPosition, unsigned& directiveEndPos)
|
||||
{
|
||||
directiveStartPosition = 0;
|
||||
for (; directiveStartPosition < line.m_line.size(); directiveStartPosition++)
|
||||
|
@ -3,22 +3,20 @@
|
||||
#include "Parsing/IParserLineStream.h"
|
||||
#include "Parsing/TokenPos.h"
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
class AbstractDirectiveStreamProxy : public IParserLineStream
|
||||
{
|
||||
protected:
|
||||
AbstractDirectiveStreamProxy() = default;
|
||||
|
||||
static TokenPos CreatePos(const ParserLine& line, size_t position);
|
||||
static TokenPos CreatePos(const ParserLine& line, unsigned position);
|
||||
|
||||
static bool SkipWhitespace(const ParserLine& line, size_t& position);
|
||||
static bool ExtractInteger(const ParserLine& line, size_t& position, int& value);
|
||||
static bool ExtractIdentifier(const ParserLine& line, size_t& position);
|
||||
static bool MatchCharacter(const ParserLine& line, size_t& position, char c);
|
||||
static bool MatchNextCharacter(const ParserLine& line, size_t& position, char c);
|
||||
static bool MatchString(const ParserLine& line, size_t& position, const char* str, size_t len);
|
||||
static bool MatchNextString(const ParserLine& line, size_t& position, const char* str, size_t len);
|
||||
static bool SkipWhitespace(const ParserLine& line, unsigned& position);
|
||||
static bool ExtractInteger(const ParserLine& line, unsigned& position, int& value);
|
||||
static bool ExtractIdentifier(const ParserLine& line, unsigned& position);
|
||||
static bool MatchCharacter(const ParserLine& line, unsigned& position, char c);
|
||||
static bool MatchNextCharacter(const ParserLine& line, unsigned& position, char c);
|
||||
static bool MatchString(const ParserLine& line, unsigned& position, const char* str, unsigned len);
|
||||
static bool MatchNextString(const ParserLine& line, unsigned& position, const char* str, unsigned len);
|
||||
|
||||
static bool FindDirective(const ParserLine& line, size_t& directiveStartPosition, size_t& directiveEndPos);
|
||||
static bool FindDirective(const ParserLine& line, unsigned& directiveStartPosition, unsigned& directiveEndPos);
|
||||
};
|
||||
|
@ -14,12 +14,12 @@
|
||||
|
||||
namespace
|
||||
{
|
||||
bool IsStringizeParameterForwardLookup(const std::string& value, size_t pos)
|
||||
bool IsStringizeParameterForwardLookup(const std::string& value, unsigned pos)
|
||||
{
|
||||
return pos + 1 && (isalpha(value[pos + 1]) || value[pos + 1] == '_');
|
||||
}
|
||||
|
||||
bool IsTokenPastingOperatorForwardLookup(const std::string& value, size_t pos)
|
||||
bool IsTokenPastingOperatorForwardLookup(const std::string& value, unsigned pos)
|
||||
{
|
||||
return pos + 1 < value.size() && value[pos + 1] == '#';
|
||||
}
|
||||
@ -32,7 +32,7 @@ DefinesStreamProxy::DefineParameterPosition::DefineParameterPosition()
|
||||
{
|
||||
}
|
||||
|
||||
DefinesStreamProxy::DefineParameterPosition::DefineParameterPosition(const unsigned index, const size_t position, const bool stringize)
|
||||
DefinesStreamProxy::DefineParameterPosition::DefineParameterPosition(const unsigned index, const unsigned position, const bool stringize)
|
||||
: m_parameter_index(index),
|
||||
m_parameter_position(position),
|
||||
m_stringize(stringize)
|
||||
@ -175,7 +175,7 @@ int DefinesStreamProxy::GetLineEndEscapePos(const ParserLine& line)
|
||||
return -1;
|
||||
}
|
||||
|
||||
void DefinesStreamProxy::ContinueDefine(const ParserLine& line, const size_t currentPos)
|
||||
void DefinesStreamProxy::ContinueDefine(const ParserLine& line, const unsigned currentPos)
|
||||
{
|
||||
const auto lineEndEscapePos = GetLineEndEscapePos(line);
|
||||
if (lineEndEscapePos < 0)
|
||||
@ -204,7 +204,7 @@ void DefinesStreamProxy::ContinueDefine(const ParserLine& line, const size_t cur
|
||||
}
|
||||
}
|
||||
|
||||
void DefinesStreamProxy::ContinueParameters(const ParserLine& line, size_t& currentPos)
|
||||
void DefinesStreamProxy::ContinueParameters(const ParserLine& line, unsigned& currentPos)
|
||||
{
|
||||
const auto lineEndEscapePos = GetLineEndEscapePos(line);
|
||||
while (true)
|
||||
@ -241,7 +241,7 @@ void DefinesStreamProxy::ContinueParameters(const ParserLine& line, size_t& curr
|
||||
}
|
||||
}
|
||||
|
||||
void DefinesStreamProxy::MatchDefineParameters(const ParserLine& line, size_t& currentPos)
|
||||
void DefinesStreamProxy::MatchDefineParameters(const ParserLine& line, unsigned& currentPos)
|
||||
{
|
||||
m_current_define_parameters = std::vector<std::string>();
|
||||
if (line.m_line[currentPos] != '(')
|
||||
@ -253,7 +253,7 @@ void DefinesStreamProxy::MatchDefineParameters(const ParserLine& line, size_t& c
|
||||
ContinueParameters(line, currentPos);
|
||||
}
|
||||
|
||||
bool DefinesStreamProxy::MatchDefineDirective(const ParserLine& line, const size_t directiveStartPosition, const size_t directiveEndPosition)
|
||||
bool DefinesStreamProxy::MatchDefineDirective(const ParserLine& line, const unsigned directiveStartPosition, const unsigned directiveEndPosition)
|
||||
{
|
||||
auto currentPos = directiveStartPosition;
|
||||
|
||||
@ -284,7 +284,7 @@ bool DefinesStreamProxy::MatchDefineDirective(const ParserLine& line, const size
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DefinesStreamProxy::MatchUndefDirective(const ParserLine& line, const size_t directiveStartPosition, const size_t directiveEndPosition)
|
||||
bool DefinesStreamProxy::MatchUndefDirective(const ParserLine& line, const unsigned directiveStartPosition, const unsigned directiveEndPosition)
|
||||
{
|
||||
auto currentPos = directiveStartPosition;
|
||||
|
||||
@ -323,7 +323,7 @@ std::unique_ptr<ISimpleExpression> DefinesStreamProxy::ParseExpression(std::shar
|
||||
return expressionInterpreter.Evaluate();
|
||||
}
|
||||
|
||||
bool DefinesStreamProxy::MatchIfDirective(const ParserLine& line, const size_t directiveStartPosition, const size_t directiveEndPosition)
|
||||
bool DefinesStreamProxy::MatchIfDirective(const ParserLine& line, const unsigned directiveStartPosition, const unsigned directiveEndPosition)
|
||||
{
|
||||
auto currentPos = directiveStartPosition;
|
||||
|
||||
@ -356,7 +356,7 @@ bool DefinesStreamProxy::MatchIfDirective(const ParserLine& line, const size_t d
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DefinesStreamProxy::MatchElIfDirective(const ParserLine& line, const size_t directiveStartPosition, const size_t directiveEndPosition)
|
||||
bool DefinesStreamProxy::MatchElIfDirective(const ParserLine& line, const unsigned directiveStartPosition, const unsigned directiveEndPosition)
|
||||
{
|
||||
auto currentPos = directiveStartPosition;
|
||||
|
||||
@ -398,7 +398,7 @@ bool DefinesStreamProxy::MatchElIfDirective(const ParserLine& line, const size_t
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DefinesStreamProxy::MatchIfdefDirective(const ParserLine& line, const size_t directiveStartPosition, const size_t directiveEndPosition)
|
||||
bool DefinesStreamProxy::MatchIfdefDirective(const ParserLine& line, const unsigned directiveStartPosition, const unsigned directiveEndPosition)
|
||||
{
|
||||
auto currentPos = directiveStartPosition;
|
||||
|
||||
@ -439,7 +439,7 @@ bool DefinesStreamProxy::MatchIfdefDirective(const ParserLine& line, const size_
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DefinesStreamProxy::MatchElseDirective(const ParserLine& line, const size_t directiveStartPosition, const size_t directiveEndPosition)
|
||||
bool DefinesStreamProxy::MatchElseDirective(const ParserLine& line, const unsigned directiveStartPosition, const unsigned directiveEndPosition)
|
||||
{
|
||||
auto currentPos = directiveStartPosition;
|
||||
|
||||
@ -460,7 +460,7 @@ bool DefinesStreamProxy::MatchElseDirective(const ParserLine& line, const size_t
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DefinesStreamProxy::MatchEndifDirective(const ParserLine& line, const size_t directiveStartPosition, const size_t directiveEndPosition)
|
||||
bool DefinesStreamProxy::MatchEndifDirective(const ParserLine& line, const unsigned directiveStartPosition, const unsigned directiveEndPosition)
|
||||
{
|
||||
auto currentPos = directiveStartPosition;
|
||||
|
||||
@ -486,8 +486,8 @@ bool DefinesStreamProxy::MatchEndifDirective(const ParserLine& line, const size_
|
||||
|
||||
bool DefinesStreamProxy::MatchDirectives(ParserLine& line)
|
||||
{
|
||||
size_t directiveStartPos;
|
||||
size_t directiveEndPos;
|
||||
unsigned directiveStartPos;
|
||||
unsigned directiveEndPos;
|
||||
|
||||
if (!FindDirective(line, directiveStartPos, directiveEndPos))
|
||||
return false;
|
||||
@ -537,9 +537,9 @@ void DefinesStreamProxy::ExtractParametersFromMacroUsage(
|
||||
ContinueMacroParameters(line, linePos, state, input, inputPos);
|
||||
}
|
||||
|
||||
bool DefinesStreamProxy::MatchDefinedExpression(const ParserLine& line, size_t& pos, std::string& definitionName)
|
||||
bool DefinesStreamProxy::MatchDefinedExpression(const ParserLine& line, unsigned& pos, std::string& definitionName)
|
||||
{
|
||||
auto currentPos = pos;
|
||||
unsigned currentPos = pos;
|
||||
|
||||
if (!MatchNextCharacter(line, currentPos, '('))
|
||||
return false;
|
||||
@ -559,7 +559,7 @@ bool DefinesStreamProxy::MatchDefinedExpression(const ParserLine& line, size_t&
|
||||
|
||||
void DefinesStreamProxy::ExpandDefinedExpressions(ParserLine& line) const
|
||||
{
|
||||
auto currentPos = 0uz;
|
||||
auto currentPos = 0u;
|
||||
|
||||
while (true)
|
||||
{
|
||||
@ -1094,7 +1094,7 @@ ParserLine DefinesStreamProxy::NextLine()
|
||||
{
|
||||
if (m_in_define)
|
||||
{
|
||||
auto currentPos = 0uz;
|
||||
unsigned currentPos = 0u;
|
||||
|
||||
if (m_parameter_state != ParameterState::NOT_IN_PARAMETERS)
|
||||
{
|
||||
|
@ -4,7 +4,6 @@
|
||||
#include "Parsing/IParserLineStream.h"
|
||||
#include "Parsing/Simple/Expression/ISimpleExpression.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <sstream>
|
||||
@ -30,11 +29,11 @@ public:
|
||||
{
|
||||
public:
|
||||
unsigned m_parameter_index;
|
||||
size_t m_parameter_position;
|
||||
unsigned m_parameter_position;
|
||||
bool m_stringize;
|
||||
|
||||
DefineParameterPosition();
|
||||
DefineParameterPosition(unsigned index, size_t position, bool stringize);
|
||||
DefineParameterPosition(unsigned index, unsigned position, bool stringize);
|
||||
};
|
||||
|
||||
class Define
|
||||
@ -97,22 +96,22 @@ private:
|
||||
MacroParameterState m_multi_line_macro_parameters;
|
||||
|
||||
static int GetLineEndEscapePos(const ParserLine& line);
|
||||
void MatchDefineParameters(const ParserLine& line, size_t& currentPos);
|
||||
void ContinueDefine(const ParserLine& line, size_t currentPos);
|
||||
void ContinueParameters(const ParserLine& line, size_t& currentPos);
|
||||
_NODISCARD bool MatchDefineDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition);
|
||||
_NODISCARD bool MatchUndefDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition);
|
||||
_NODISCARD bool MatchIfDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition);
|
||||
_NODISCARD bool MatchElIfDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition);
|
||||
_NODISCARD bool MatchIfdefDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition);
|
||||
_NODISCARD bool MatchElseDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition);
|
||||
_NODISCARD bool MatchEndifDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition);
|
||||
void MatchDefineParameters(const ParserLine& line, unsigned& currentPos);
|
||||
void ContinueDefine(const ParserLine& line, unsigned currentPos);
|
||||
void ContinueParameters(const ParserLine& line, unsigned& currentPos);
|
||||
_NODISCARD bool MatchDefineDirective(const ParserLine& line, unsigned directiveStartPosition, unsigned directiveEndPosition);
|
||||
_NODISCARD bool MatchUndefDirective(const ParserLine& line, unsigned directiveStartPosition, unsigned directiveEndPosition);
|
||||
_NODISCARD bool MatchIfDirective(const ParserLine& line, unsigned directiveStartPosition, unsigned directiveEndPosition);
|
||||
_NODISCARD bool MatchElIfDirective(const ParserLine& line, unsigned directiveStartPosition, unsigned directiveEndPosition);
|
||||
_NODISCARD bool MatchIfdefDirective(const ParserLine& line, unsigned directiveStartPosition, unsigned directiveEndPosition);
|
||||
_NODISCARD bool MatchElseDirective(const ParserLine& line, unsigned directiveStartPosition, unsigned directiveEndPosition);
|
||||
_NODISCARD bool MatchEndifDirective(const ParserLine& line, unsigned directiveStartPosition, unsigned directiveEndPosition);
|
||||
_NODISCARD bool MatchDirectives(ParserLine& line);
|
||||
|
||||
void ExtractParametersFromMacroUsage(const ParserLine& line, unsigned& linePos, MacroParameterState& state, const std::string& input, unsigned& inputPos);
|
||||
bool FindMacroForIdentifier(const std::string& input, unsigned wordStart, unsigned wordEnd, const Define*& value) const;
|
||||
|
||||
static bool MatchDefinedExpression(const ParserLine& line, size_t& pos, std::string& definitionName);
|
||||
static bool MatchDefinedExpression(const ParserLine& line, unsigned& pos, std::string& definitionName);
|
||||
void ExpandDefinedExpressions(ParserLine& line) const;
|
||||
|
||||
bool FindNextMacro(const std::string& input, unsigned& inputPos, unsigned& defineStart, const DefinesStreamProxy::Define*& define);
|
||||
|
@ -13,9 +13,9 @@ IncludingStreamProxy::IncludingStreamProxy(IParserLineStream* stream)
|
||||
}
|
||||
|
||||
bool IncludingStreamProxy::ExtractIncludeFilename(const ParserLine& line,
|
||||
const size_t includeDirectivePosition,
|
||||
size_t& filenameStartPosition,
|
||||
size_t& filenameEndPosition)
|
||||
const unsigned includeDirectivePosition,
|
||||
unsigned& filenameStartPosition,
|
||||
unsigned& filenameEndPosition)
|
||||
{
|
||||
auto currentPos = includeDirectivePosition;
|
||||
bool isDoubleQuotes;
|
||||
@ -60,7 +60,7 @@ bool IncludingStreamProxy::ExtractIncludeFilename(const ParserLine& line,
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IncludingStreamProxy::MatchIncludeDirective(const ParserLine& line, const size_t directiveStartPos, const size_t directiveEndPos) const
|
||||
bool IncludingStreamProxy::MatchIncludeDirective(const ParserLine& line, const unsigned directiveStartPos, const unsigned directiveEndPos) const
|
||||
{
|
||||
auto currentPos = directiveStartPos;
|
||||
|
||||
@ -70,7 +70,7 @@ bool IncludingStreamProxy::MatchIncludeDirective(const ParserLine& line, const s
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t filenameStart, filenameEnd;
|
||||
unsigned filenameStart, filenameEnd;
|
||||
|
||||
if (!ExtractIncludeFilename(line, currentPos, filenameStart, filenameEnd))
|
||||
throw ParsingException(TokenPos(*line.m_filename, line.m_line_number, static_cast<int>(currentPos)), INCLUDE_QUOTES_ERROR);
|
||||
@ -86,7 +86,7 @@ bool IncludingStreamProxy::MatchIncludeDirective(const ParserLine& line, const s
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IncludingStreamProxy::MatchPragmaOnceDirective(const ParserLine& line, const size_t directiveStartPos, const size_t directiveEndPos)
|
||||
bool IncludingStreamProxy::MatchPragmaOnceDirective(const ParserLine& line, const unsigned directiveStartPos, const unsigned directiveEndPos)
|
||||
{
|
||||
auto currentPos = directiveStartPos;
|
||||
|
||||
@ -116,7 +116,7 @@ bool IncludingStreamProxy::MatchPragmaOnceDirective(const ParserLine& line, cons
|
||||
|
||||
bool IncludingStreamProxy::MatchDirectives(const ParserLine& line)
|
||||
{
|
||||
size_t directiveStartPos, directiveEndPos;
|
||||
unsigned directiveStartPos, directiveEndPos;
|
||||
|
||||
if (!FindDirective(line, directiveStartPos, directiveEndPos))
|
||||
return false;
|
||||
|
@ -16,9 +16,9 @@ class IncludingStreamProxy final : public AbstractDirectiveStreamProxy
|
||||
std::set<std::string> m_included_files;
|
||||
|
||||
_NODISCARD static bool
|
||||
ExtractIncludeFilename(const ParserLine& line, size_t includeDirectivePosition, size_t& filenameStartPosition, size_t& filenameEndPosition);
|
||||
_NODISCARD bool MatchIncludeDirective(const ParserLine& line, size_t directiveStartPos, size_t directiveEndPos) const;
|
||||
_NODISCARD bool MatchPragmaOnceDirective(const ParserLine& line, size_t directiveStartPos, size_t directiveEndPos);
|
||||
ExtractIncludeFilename(const ParserLine& line, unsigned includeDirectivePosition, unsigned& filenameStartPosition, unsigned& filenameEndPosition);
|
||||
_NODISCARD bool MatchIncludeDirective(const ParserLine& line, unsigned directiveStartPos, unsigned directiveEndPos) const;
|
||||
_NODISCARD bool MatchPragmaOnceDirective(const ParserLine& line, unsigned directiveStartPos, unsigned directiveEndPos);
|
||||
_NODISCARD bool MatchDirectives(const ParserLine& line);
|
||||
|
||||
public:
|
||||
|
@ -7,7 +7,7 @@ PackDefinitionStreamProxy::PackDefinitionStreamProxy(IParserLineStream* stream)
|
||||
{
|
||||
}
|
||||
|
||||
bool PackDefinitionStreamProxy::MatchPackDirective(const ParserLine& line, const size_t directiveStartPosition, const size_t directiveEndPosition)
|
||||
bool PackDefinitionStreamProxy::MatchPackDirective(const ParserLine& line, const unsigned directiveStartPosition, const unsigned directiveEndPosition)
|
||||
{
|
||||
auto packValue = 0;
|
||||
auto currentPosition = directiveStartPosition;
|
||||
@ -60,7 +60,7 @@ bool PackDefinitionStreamProxy::MatchPackDirective(const ParserLine& line, const
|
||||
|
||||
bool PackDefinitionStreamProxy::MatchDirectives(const ParserLine& line)
|
||||
{
|
||||
size_t directiveStartPos, directiveEndPos;
|
||||
unsigned directiveStartPos, directiveEndPos;
|
||||
|
||||
if (!FindDirective(line, directiveStartPos, directiveEndPos))
|
||||
return false;
|
||||
|
@ -21,7 +21,7 @@ private:
|
||||
IParserLineStream* const m_stream;
|
||||
std::stack<int> m_current_pack;
|
||||
|
||||
_NODISCARD bool MatchPackDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition);
|
||||
_NODISCARD bool MatchPackDirective(const ParserLine& line, unsigned directiveStartPosition, unsigned directiveEndPosition);
|
||||
_NODISCARD bool MatchDirectives(const ParserLine& line);
|
||||
|
||||
public:
|
||||
|
@ -15,7 +15,7 @@ void SetDefineStreamProxy::SetDefinesProxy(DefinesStreamProxy* definesProxy)
|
||||
m_defines_proxy = definesProxy;
|
||||
}
|
||||
|
||||
bool SetDefineStreamProxy::MatchSetDirective(const ParserLine& line, const size_t directiveStartPosition, const size_t directiveEndPosition) const
|
||||
bool SetDefineStreamProxy::MatchSetDirective(const ParserLine& line, const unsigned directiveStartPosition, const unsigned directiveEndPosition) const
|
||||
{
|
||||
auto currentPosition = directiveStartPosition;
|
||||
|
||||
@ -59,7 +59,7 @@ bool SetDefineStreamProxy::MatchSetDirective(const ParserLine& line, const size_
|
||||
|
||||
bool SetDefineStreamProxy::MatchDirectives(const ParserLine& line) const
|
||||
{
|
||||
size_t directiveStartPos, directiveEndPos;
|
||||
unsigned directiveStartPos, directiveEndPos;
|
||||
|
||||
if (!FindDirective(line, directiveStartPos, directiveEndPos))
|
||||
return false;
|
||||
|
@ -22,7 +22,7 @@ namespace templating
|
||||
private:
|
||||
static constexpr const char* SET_DIRECTIVE = "set";
|
||||
|
||||
_NODISCARD bool MatchSetDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition) const;
|
||||
_NODISCARD bool MatchSetDirective(const ParserLine& line, unsigned directiveStartPosition, unsigned directiveEndPosition) const;
|
||||
_NODISCARD bool MatchDirectives(const ParserLine& line) const;
|
||||
|
||||
IParserLineStream* const m_stream;
|
||||
|
@ -18,7 +18,7 @@ void TemplatingStreamProxy::SetDefinesProxy(DefinesStreamProxy* definesProxy)
|
||||
m_defines_proxy = definesProxy;
|
||||
}
|
||||
|
||||
bool TemplatingStreamProxy::MatchSwitchDirective(const ParserLine& line, const size_t directiveStartPosition, const size_t directiveEndPosition) const
|
||||
bool TemplatingStreamProxy::MatchSwitchDirective(const ParserLine& line, const unsigned directiveStartPosition, const unsigned directiveEndPosition) const
|
||||
{
|
||||
auto currentPosition = directiveStartPosition;
|
||||
|
||||
@ -43,7 +43,7 @@ bool TemplatingStreamProxy::MatchSwitchDirective(const ParserLine& line, const s
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TemplatingStreamProxy::MatchOptionsDirective(const ParserLine& line, const size_t directiveStartPosition, const size_t directiveEndPosition) const
|
||||
bool TemplatingStreamProxy::MatchOptionsDirective(const ParserLine& line, const unsigned directiveStartPosition, const unsigned directiveEndPosition) const
|
||||
{
|
||||
auto currentPosition = directiveStartPosition;
|
||||
|
||||
@ -93,7 +93,7 @@ bool TemplatingStreamProxy::MatchOptionsDirective(const ParserLine& line, const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TemplatingStreamProxy::MatchFilenameDirective(const ParserLine& line, const size_t directiveStartPosition, const size_t directiveEndPosition) const
|
||||
bool TemplatingStreamProxy::MatchFilenameDirective(const ParserLine& line, const unsigned directiveStartPosition, const unsigned directiveEndPosition) const
|
||||
{
|
||||
auto currentPosition = directiveStartPosition;
|
||||
|
||||
@ -128,7 +128,7 @@ bool TemplatingStreamProxy::MatchFilenameDirective(const ParserLine& line, const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TemplatingStreamProxy::MatchSkipDirective(const ParserLine& line, const size_t directiveStartPosition, const size_t directiveEndPosition) const
|
||||
bool TemplatingStreamProxy::MatchSkipDirective(const ParserLine& line, const unsigned directiveStartPosition, const unsigned directiveEndPosition) const
|
||||
{
|
||||
auto currentPosition = directiveStartPosition;
|
||||
|
||||
@ -146,7 +146,7 @@ bool TemplatingStreamProxy::MatchSkipDirective(const ParserLine& line, const siz
|
||||
|
||||
bool TemplatingStreamProxy::MatchDirectives(const ParserLine& line) const
|
||||
{
|
||||
size_t directiveStartPos, directiveEndPos;
|
||||
unsigned directiveStartPos, directiveEndPos;
|
||||
|
||||
if (!FindDirective(line, directiveStartPos, directiveEndPos))
|
||||
return false;
|
||||
|
@ -43,10 +43,10 @@ namespace templating
|
||||
static constexpr const char* FILENAME_DIRECTIVE = "filename";
|
||||
static constexpr const char* SKIP_DIRECTIVE = "skip";
|
||||
|
||||
_NODISCARD bool MatchSwitchDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition) const;
|
||||
_NODISCARD bool MatchOptionsDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition) const;
|
||||
_NODISCARD bool MatchFilenameDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition) const;
|
||||
_NODISCARD bool MatchSkipDirective(const ParserLine& line, size_t directiveStartPosition, size_t directiveEndPosition) const;
|
||||
_NODISCARD bool MatchSwitchDirective(const ParserLine& line, unsigned directiveStartPosition, unsigned directiveEndPosition) const;
|
||||
_NODISCARD bool MatchOptionsDirective(const ParserLine& line, unsigned directiveStartPosition, unsigned directiveEndPosition) const;
|
||||
_NODISCARD bool MatchFilenameDirective(const ParserLine& line, unsigned directiveStartPosition, unsigned directiveEndPosition) const;
|
||||
_NODISCARD bool MatchSkipDirective(const ParserLine& line, unsigned directiveStartPosition, unsigned directiveEndPosition) const;
|
||||
_NODISCARD bool MatchDirectives(const ParserLine& line) const;
|
||||
|
||||
IParserLineStream* const m_stream;
|
||||
|
@ -25,23 +25,6 @@ bool UnlinkerPaths::LoadUserPaths(const UnlinkerArgs& args)
|
||||
auto searchPathName = absolutePath.string();
|
||||
m_user_paths.CommitSearchPath(std::make_unique<SearchPathFilesystem>(searchPathName));
|
||||
m_specified_user_paths.emplace(std::move(searchPathName));
|
||||
|
||||
std::filesystem::directory_iterator iterator(absolutePath);
|
||||
const auto end = fs::end(iterator);
|
||||
for (auto i = fs::begin(iterator); i != end; ++i)
|
||||
{
|
||||
if (!i->is_regular_file())
|
||||
continue;
|
||||
|
||||
auto extension = i->path().extension().string();
|
||||
utils::MakeStringLowerCase(extension);
|
||||
if (extension == ".iwd")
|
||||
{
|
||||
auto iwd = iwd::LoadFromFile(i->path().string());
|
||||
if (iwd)
|
||||
m_user_paths.CommitSearchPath(std::move(iwd));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << std::format("{} SearchPaths{}\n", m_specified_user_paths.size(), !m_specified_user_paths.empty() ? ":" : "");
|
||||
|
@ -2,6 +2,6 @@
|
||||
|
||||
int main(const int argc, const char** argv)
|
||||
{
|
||||
auto zoneCodeGenerator = ZoneCodeGenerator::Create();
|
||||
return zoneCodeGenerator->Run(argc, argv);
|
||||
const ZoneCodeGenerator zoneCodeGenerator;
|
||||
return zoneCodeGenerator.Run(argc, argv);
|
||||
}
|
||||
|
@ -2,35 +2,32 @@
|
||||
|
||||
#include "Domain/Information/MemberInformation.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class MemberComputations
|
||||
{
|
||||
const MemberInformation* const m_info;
|
||||
|
||||
public:
|
||||
explicit MemberComputations(const MemberInformation* member);
|
||||
|
||||
[[nodiscard]] bool ShouldIgnore() const;
|
||||
[[nodiscard]] bool ContainsNonEmbeddedReference() const;
|
||||
[[nodiscard]] bool ContainsSinglePointerReference() const;
|
||||
[[nodiscard]] bool ContainsArrayPointerReference() const;
|
||||
[[nodiscard]] bool ContainsPointerArrayReference() const;
|
||||
[[nodiscard]] bool ContainsArrayReference() const;
|
||||
[[nodiscard]] const IEvaluation* GetArrayPointerCountEvaluation() const;
|
||||
[[nodiscard]] bool IsArray() const;
|
||||
[[nodiscard]] std::vector<int> GetArraySizes() const;
|
||||
[[nodiscard]] int GetArrayDimension() const;
|
||||
[[nodiscard]] bool IsPointerToArray() const;
|
||||
[[nodiscard]] std::vector<int> GetPointerToArraySizes() const;
|
||||
[[nodiscard]] int GetPointerDepth() const;
|
||||
[[nodiscard]] bool IsNotInDefaultNormalBlock() const;
|
||||
[[nodiscard]] bool IsInTempBlock() const;
|
||||
[[nodiscard]] bool IsInRuntimeBlock() const;
|
||||
[[nodiscard]] bool IsFirstMember() const;
|
||||
[[nodiscard]] bool IsLastMember() const;
|
||||
[[nodiscard]] bool HasDynamicArraySize() const;
|
||||
[[nodiscard]] bool IsDynamicMember() const;
|
||||
[[nodiscard]] bool IsAfterPartialLoad() const;
|
||||
|
||||
private:
|
||||
const MemberInformation* const m_info;
|
||||
_NODISCARD bool ShouldIgnore() const;
|
||||
_NODISCARD bool ContainsNonEmbeddedReference() const;
|
||||
_NODISCARD bool ContainsSinglePointerReference() const;
|
||||
_NODISCARD bool ContainsArrayPointerReference() const;
|
||||
_NODISCARD bool ContainsPointerArrayReference() const;
|
||||
_NODISCARD bool ContainsArrayReference() const;
|
||||
_NODISCARD const IEvaluation* GetArrayPointerCountEvaluation() const;
|
||||
_NODISCARD bool IsArray() const;
|
||||
_NODISCARD std::vector<int> GetArraySizes() const;
|
||||
_NODISCARD int GetArrayDimension() const;
|
||||
_NODISCARD bool IsPointerToArray() const;
|
||||
_NODISCARD std::vector<int> GetPointerToArraySizes() const;
|
||||
_NODISCARD int GetPointerDepth() const;
|
||||
_NODISCARD bool IsNotInDefaultNormalBlock() const;
|
||||
_NODISCARD bool IsInTempBlock() const;
|
||||
_NODISCARD bool IsInRuntimeBlock() const;
|
||||
_NODISCARD bool IsFirstMember() const;
|
||||
_NODISCARD bool IsLastMember() const;
|
||||
_NODISCARD bool HasDynamicArraySize() const;
|
||||
_NODISCARD bool IsDynamicMember() const;
|
||||
_NODISCARD bool IsAfterPartialLoad() const;
|
||||
};
|
||||
|
@ -2,36 +2,34 @@
|
||||
|
||||
#include "Domain/Evaluation/IEvaluation.h"
|
||||
#include "Domain/Information/MemberInformation.h"
|
||||
|
||||
#include <vector>
|
||||
#include "Utils/ClassUtils.h"
|
||||
|
||||
class DeclarationModifierComputations
|
||||
{
|
||||
public:
|
||||
explicit DeclarationModifierComputations(const MemberInformation* member);
|
||||
|
||||
[[nodiscard]] DeclarationModifier* GetDeclarationModifier() const;
|
||||
[[nodiscard]] DeclarationModifier* GetNextDeclarationModifier() const;
|
||||
[[nodiscard]] std::vector<DeclarationModifier*> GetFollowingDeclarationModifiers() const;
|
||||
[[nodiscard]] std::vector<int> GetArrayIndices() const;
|
||||
[[nodiscard]] bool IsArray() const;
|
||||
[[nodiscard]] int GetArraySize() const;
|
||||
[[nodiscard]] bool HasDynamicArrayCount() const;
|
||||
[[nodiscard]] const IEvaluation* GetDynamicArrayCountEvaluation() const;
|
||||
[[nodiscard]] std::vector<DeclarationModifierComputations> GetArrayEntries() const;
|
||||
[[nodiscard]] bool IsSinglePointer() const;
|
||||
[[nodiscard]] bool IsArrayPointer() const;
|
||||
[[nodiscard]] const IEvaluation* GetArrayPointerCountEvaluation() const;
|
||||
[[nodiscard]] bool IsPointerArray() const;
|
||||
[[nodiscard]] const IEvaluation* GetPointerArrayCountEvaluation() const;
|
||||
[[nodiscard]] bool IsDynamicArray() const;
|
||||
[[nodiscard]] const IEvaluation* GetDynamicArraySizeEvaluation() const;
|
||||
[[nodiscard]] unsigned GetAlignment() const;
|
||||
|
||||
private:
|
||||
DeclarationModifierComputations(const MemberInformation* member, std::vector<int> modifierIndices);
|
||||
|
||||
const MemberInformation* const m_information;
|
||||
std::vector<int> m_modifier_indices;
|
||||
int m_combined_index;
|
||||
|
||||
DeclarationModifierComputations(const MemberInformation* member, std::vector<int> modifierIndices);
|
||||
|
||||
public:
|
||||
explicit DeclarationModifierComputations(const MemberInformation* member);
|
||||
|
||||
_NODISCARD DeclarationModifier* GetDeclarationModifier() const;
|
||||
_NODISCARD DeclarationModifier* GetNextDeclarationModifier() const;
|
||||
_NODISCARD std::vector<DeclarationModifier*> GetFollowingDeclarationModifiers() const;
|
||||
_NODISCARD std::vector<int> GetArrayIndices() const;
|
||||
_NODISCARD bool IsArray() const;
|
||||
_NODISCARD int GetArraySize() const;
|
||||
_NODISCARD bool HasDynamicArrayCount() const;
|
||||
_NODISCARD const IEvaluation* GetDynamicArrayCountEvaluation() const;
|
||||
_NODISCARD std::vector<DeclarationModifierComputations> GetArrayEntries() const;
|
||||
_NODISCARD bool IsSinglePointer() const;
|
||||
_NODISCARD bool IsArrayPointer() const;
|
||||
_NODISCARD const IEvaluation* GetArrayPointerCountEvaluation() const;
|
||||
_NODISCARD bool IsPointerArray() const;
|
||||
_NODISCARD const IEvaluation* GetPointerArrayCountEvaluation() const;
|
||||
_NODISCARD bool IsDynamicArray() const;
|
||||
_NODISCARD const IEvaluation* GetDynamicArraySizeEvaluation() const;
|
||||
_NODISCARD unsigned GetAlignment() const;
|
||||
};
|
||||
|
@ -4,13 +4,12 @@
|
||||
|
||||
class StructureComputations
|
||||
{
|
||||
const StructureInformation* const m_info;
|
||||
|
||||
public:
|
||||
explicit StructureComputations(const StructureInformation* structure);
|
||||
|
||||
[[nodiscard]] bool IsAsset() const;
|
||||
[[nodiscard]] MemberInformation* GetDynamicMember() const;
|
||||
[[nodiscard]] std::vector<MemberInformation*> GetUsedMembers() const;
|
||||
|
||||
private:
|
||||
const StructureInformation* m_info;
|
||||
_NODISCARD bool IsAsset() const;
|
||||
_NODISCARD MemberInformation* GetDynamicMember() const;
|
||||
_NODISCARD std::vector<MemberInformation*> GetUsedMembers() const;
|
||||
};
|
||||
|
@ -2,16 +2,13 @@
|
||||
|
||||
#include "DeclarationModifier.h"
|
||||
#include "Domain/Evaluation/IEvaluation.h"
|
||||
#include "Utils/ClassUtils.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
class ArrayDeclarationModifier final : public DeclarationModifier
|
||||
{
|
||||
public:
|
||||
explicit ArrayDeclarationModifier(int size);
|
||||
|
||||
[[nodiscard]] DeclarationModifierType GetType() const override;
|
||||
|
||||
int m_size;
|
||||
|
||||
/**
|
||||
@ -23,4 +20,8 @@ public:
|
||||
* \brief The array has a size that is given by \c m_size but only a certain dynamic amount is handled by generated count.
|
||||
*/
|
||||
std::unique_ptr<IEvaluation> m_dynamic_count_evaluation;
|
||||
|
||||
explicit ArrayDeclarationModifier(int size);
|
||||
|
||||
_NODISCARD DeclarationModifierType GetType() const override;
|
||||
};
|
||||
|
@ -4,6 +4,17 @@
|
||||
class BaseTypeDefinition final : public DataDefinition
|
||||
{
|
||||
public:
|
||||
const unsigned m_size;
|
||||
|
||||
private:
|
||||
BaseTypeDefinition(std::string name, unsigned size);
|
||||
|
||||
public:
|
||||
_NODISCARD DataDefinitionType GetType() const override;
|
||||
_NODISCARD unsigned GetAlignment() const override;
|
||||
_NODISCARD bool GetForceAlignment() const override;
|
||||
_NODISCARD unsigned GetSize() const override;
|
||||
|
||||
static const BaseTypeDefinition* const FLOAT;
|
||||
static const BaseTypeDefinition* const DOUBLE;
|
||||
static const BaseTypeDefinition* const BOOL;
|
||||
@ -21,14 +32,4 @@ public:
|
||||
|
||||
static const BaseTypeDefinition* const ALL_BASE_TYPES[];
|
||||
static const size_t ALL_BASE_TYPES_COUNT;
|
||||
|
||||
[[nodiscard]] DataDefinitionType GetType() const override;
|
||||
[[nodiscard]] unsigned GetAlignment() const override;
|
||||
[[nodiscard]] bool GetForceAlignment() const override;
|
||||
[[nodiscard]] unsigned GetSize() const override;
|
||||
|
||||
const unsigned m_size;
|
||||
|
||||
private:
|
||||
BaseTypeDefinition(std::string name, unsigned size);
|
||||
};
|
||||
|
@ -25,13 +25,13 @@ public:
|
||||
DataDefinition& operator=(const DataDefinition& other) = default;
|
||||
DataDefinition& operator=(DataDefinition&& other) noexcept = default;
|
||||
|
||||
[[nodiscard]] virtual DataDefinitionType GetType() const = 0;
|
||||
[[nodiscard]] virtual unsigned GetAlignment() const = 0;
|
||||
[[nodiscard]] virtual bool GetForceAlignment() const = 0;
|
||||
[[nodiscard]] virtual unsigned GetSize() const = 0;
|
||||
|
||||
[[nodiscard]] std::string GetFullName() const;
|
||||
|
||||
std::string m_namespace;
|
||||
std::string m_name;
|
||||
|
||||
_NODISCARD virtual DataDefinitionType GetType() const = 0;
|
||||
_NODISCARD virtual unsigned GetAlignment() const = 0;
|
||||
_NODISCARD virtual bool GetForceAlignment() const = 0;
|
||||
_NODISCARD virtual unsigned GetSize() const = 0;
|
||||
|
||||
_NODISCARD std::string GetFullName() const;
|
||||
};
|
||||
|
@ -18,5 +18,5 @@ public:
|
||||
DeclarationModifier& operator=(const DeclarationModifier& other) = default;
|
||||
DeclarationModifier& operator=(DeclarationModifier&& other) noexcept = default;
|
||||
|
||||
[[nodiscard]] virtual DeclarationModifierType GetType() const = 0;
|
||||
_NODISCARD virtual DeclarationModifierType GetType() const = 0;
|
||||
};
|
||||
|
@ -14,6 +14,26 @@ DefinitionWithMembers::DefinitionWithMembers(std::string _namespace, std::string
|
||||
{
|
||||
}
|
||||
|
||||
// void DefinitionWithMembers::CalculateAlignment()
|
||||
//{
|
||||
// if (m_has_alignment_override)
|
||||
// {
|
||||
// m_flags |= FLAG_ALIGNMENT_FORCED;
|
||||
// m_alignment = m_alignment_override;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// m_alignment = 0;
|
||||
// for (const auto& member : m_members)
|
||||
// {
|
||||
// const auto memberAlignment = member->GetAlignment();
|
||||
// if (memberAlignment > m_alignment)
|
||||
// m_alignment = memberAlignment;
|
||||
// }
|
||||
// }
|
||||
// m_flags |= FLAG_ALIGNMENT_CALCULATED;
|
||||
// }
|
||||
|
||||
unsigned DefinitionWithMembers::GetAlignment() const
|
||||
{
|
||||
assert(m_flags & FLAG_FIELDS_CALCULATED);
|
||||
|
@ -13,12 +13,6 @@ public:
|
||||
static constexpr int FLAG_FIELDS_CALCULATING = 1 << 1;
|
||||
static constexpr int FLAG_ALIGNMENT_FORCED = 1 << 2;
|
||||
|
||||
DefinitionWithMembers(std::string _namespace, std::string name, unsigned pack);
|
||||
|
||||
[[nodiscard]] unsigned GetAlignment() const override;
|
||||
[[nodiscard]] bool GetForceAlignment() const override;
|
||||
[[nodiscard]] unsigned GetSize() const override;
|
||||
|
||||
unsigned m_flags;
|
||||
unsigned m_size;
|
||||
unsigned m_alignment;
|
||||
@ -30,4 +24,10 @@ public:
|
||||
unsigned m_alignment_override;
|
||||
|
||||
std::vector<std::shared_ptr<Variable>> m_members;
|
||||
|
||||
DefinitionWithMembers(std::string _namespace, std::string name, unsigned pack);
|
||||
|
||||
_NODISCARD unsigned GetAlignment() const override;
|
||||
_NODISCARD bool GetForceAlignment() const override;
|
||||
_NODISCARD unsigned GetSize() const override;
|
||||
};
|
||||
|
@ -10,15 +10,15 @@
|
||||
class EnumDefinition final : public DataDefinition
|
||||
{
|
||||
public:
|
||||
EnumDefinition(std::string _namespace, std::string name, const BaseTypeDefinition* parentType);
|
||||
|
||||
[[nodiscard]] DataDefinitionType GetType() const override;
|
||||
[[nodiscard]] unsigned GetAlignment() const override;
|
||||
[[nodiscard]] bool GetForceAlignment() const override;
|
||||
[[nodiscard]] unsigned GetSize() const override;
|
||||
|
||||
void AddEnumMember(EnumMember enumMember);
|
||||
|
||||
const BaseTypeDefinition* m_parent_type;
|
||||
std::vector<std::unique_ptr<EnumMember>> m_members;
|
||||
|
||||
EnumDefinition(std::string _namespace, std::string name, const BaseTypeDefinition* parentType);
|
||||
|
||||
_NODISCARD DataDefinitionType GetType() const override;
|
||||
_NODISCARD unsigned GetAlignment() const override;
|
||||
_NODISCARD bool GetForceAlignment() const override;
|
||||
_NODISCARD unsigned GetSize() const override;
|
||||
|
||||
void AddEnumMember(EnumMember enumMember);
|
||||
};
|
||||
|
@ -5,9 +5,9 @@
|
||||
class EnumMember
|
||||
{
|
||||
public:
|
||||
EnumMember();
|
||||
EnumMember(std::string name, int value);
|
||||
|
||||
std::string m_name;
|
||||
int m_value;
|
||||
|
||||
EnumMember();
|
||||
EnumMember(std::string name, int value);
|
||||
};
|
||||
|
@ -5,13 +5,13 @@
|
||||
class ForwardDeclaration final : public DataDefinition
|
||||
{
|
||||
public:
|
||||
ForwardDeclaration(std::string _namespace, std::string name, DataDefinitionType type);
|
||||
|
||||
[[nodiscard]] DataDefinitionType GetType() const override;
|
||||
[[nodiscard]] unsigned GetAlignment() const override;
|
||||
[[nodiscard]] bool GetForceAlignment() const override;
|
||||
[[nodiscard]] unsigned GetSize() const override;
|
||||
|
||||
const DataDefinitionType m_forwarded_type;
|
||||
const DataDefinition* m_definition;
|
||||
|
||||
ForwardDeclaration(std::string _namespace, std::string name, DataDefinitionType type);
|
||||
|
||||
_NODISCARD DataDefinitionType GetType() const override;
|
||||
_NODISCARD unsigned GetAlignment() const override;
|
||||
_NODISCARD bool GetForceAlignment() const override;
|
||||
_NODISCARD unsigned GetSize() const override;
|
||||
};
|
||||
|
@ -8,19 +8,19 @@
|
||||
|
||||
class PointerDeclarationModifier final : public DeclarationModifier
|
||||
{
|
||||
static const IEvaluation* const DEFAULT_COUNT;
|
||||
|
||||
static bool EvaluationIsArray(const IEvaluation* evaluation);
|
||||
|
||||
public:
|
||||
[[nodiscard]] DeclarationModifierType GetType() const override;
|
||||
[[nodiscard]] const IEvaluation* GetCountEvaluation() const;
|
||||
[[nodiscard]] const IEvaluation* GetCountEvaluationForArrayIndex(int index);
|
||||
|
||||
[[nodiscard]] bool CountEvaluationIsArray() const;
|
||||
[[nodiscard]] bool CountEvaluationIsArray(int index) const;
|
||||
[[nodiscard]] bool AnyCountEvaluationIsArray() const;
|
||||
|
||||
std::unique_ptr<IEvaluation> m_count_evaluation;
|
||||
std::vector<std::unique_ptr<IEvaluation>> m_count_evaluation_by_array_index;
|
||||
|
||||
private:
|
||||
static const IEvaluation* const DEFAULT_COUNT;
|
||||
static bool EvaluationIsArray(const IEvaluation* evaluation);
|
||||
_NODISCARD DeclarationModifierType GetType() const override;
|
||||
_NODISCARD const IEvaluation* GetCountEvaluation() const;
|
||||
_NODISCARD const IEvaluation* GetCountEvaluationForArrayIndex(int index);
|
||||
|
||||
_NODISCARD bool CountEvaluationIsArray() const;
|
||||
_NODISCARD bool CountEvaluationIsArray(int index) const;
|
||||
_NODISCARD bool AnyCountEvaluationIsArray() const;
|
||||
};
|
||||
|
@ -7,5 +7,5 @@ class StructDefinition final : public DefinitionWithMembers
|
||||
public:
|
||||
StructDefinition(std::string _namespace, std::string name, int pack);
|
||||
|
||||
[[nodiscard]] DataDefinitionType GetType() const override;
|
||||
_NODISCARD DataDefinitionType GetType() const override;
|
||||
};
|
||||
|
@ -13,21 +13,21 @@ public:
|
||||
static constexpr int FLAG_FIELDS_CALCULATED = 1 << 0;
|
||||
static constexpr int FLAG_ALIGNMENT_FORCED = 1 << 1;
|
||||
|
||||
unsigned m_flags;
|
||||
unsigned m_size;
|
||||
unsigned m_alignment;
|
||||
|
||||
explicit TypeDeclaration(const DataDefinition* type);
|
||||
|
||||
[[nodiscard]] unsigned GetSize() const;
|
||||
[[nodiscard]] unsigned GetAlignment() const;
|
||||
[[nodiscard]] bool GetForceAlignment() const;
|
||||
|
||||
std::vector<std::unique_ptr<DeclarationModifier>> m_declaration_modifiers;
|
||||
|
||||
bool m_is_const;
|
||||
bool m_has_custom_bit_size;
|
||||
|
||||
const DataDefinition* m_type;
|
||||
unsigned m_custom_bit_size;
|
||||
|
||||
unsigned m_flags;
|
||||
unsigned m_size;
|
||||
unsigned m_alignment;
|
||||
std::vector<std::unique_ptr<DeclarationModifier>> m_declaration_modifiers;
|
||||
|
||||
_NODISCARD unsigned GetSize() const;
|
||||
_NODISCARD unsigned GetAlignment() const;
|
||||
_NODISCARD bool GetForceAlignment() const;
|
||||
};
|
||||
|
@ -6,14 +6,14 @@
|
||||
class TypedefDefinition final : public DataDefinition
|
||||
{
|
||||
public:
|
||||
TypedefDefinition(std::string _namespace, std::string name, std::unique_ptr<TypeDeclaration> typeDeclaration);
|
||||
|
||||
[[nodiscard]] DataDefinitionType GetType() const override;
|
||||
[[nodiscard]] unsigned GetAlignment() const override;
|
||||
[[nodiscard]] bool GetForceAlignment() const override;
|
||||
[[nodiscard]] unsigned GetSize() const override;
|
||||
|
||||
bool m_has_alignment_override;
|
||||
unsigned m_alignment_override;
|
||||
std::unique_ptr<TypeDeclaration> m_type_declaration;
|
||||
|
||||
TypedefDefinition(std::string _namespace, std::string name, std::unique_ptr<TypeDeclaration> typeDeclaration);
|
||||
|
||||
_NODISCARD DataDefinitionType GetType() const override;
|
||||
_NODISCARD unsigned GetAlignment() const override;
|
||||
_NODISCARD bool GetForceAlignment() const override;
|
||||
_NODISCARD unsigned GetSize() const override;
|
||||
};
|
||||
|
@ -4,8 +4,11 @@
|
||||
|
||||
class UnionDefinition final : public DefinitionWithMembers
|
||||
{
|
||||
// protected:
|
||||
// void CalculateSize() override;
|
||||
|
||||
public:
|
||||
UnionDefinition(std::string _namespace, std::string name, int pack);
|
||||
|
||||
[[nodiscard]] DataDefinitionType GetType() const override;
|
||||
_NODISCARD DataDefinitionType GetType() const override;
|
||||
};
|
||||
|
@ -9,14 +9,14 @@
|
||||
class Variable
|
||||
{
|
||||
public:
|
||||
Variable(std::string name, std::unique_ptr<TypeDeclaration> typeDeclaration);
|
||||
|
||||
[[nodiscard]] unsigned GetAlignment() const;
|
||||
[[nodiscard]] bool GetForceAlignment() const;
|
||||
|
||||
std::string m_name;
|
||||
bool m_has_alignment_override;
|
||||
unsigned m_alignment_override;
|
||||
unsigned m_offset;
|
||||
std::unique_ptr<TypeDeclaration> m_type_declaration;
|
||||
|
||||
Variable(std::string name, std::unique_ptr<TypeDeclaration> typeDeclaration);
|
||||
|
||||
_NODISCARD unsigned GetAlignment() const;
|
||||
_NODISCARD bool GetForceAlignment() const;
|
||||
};
|
||||
|
@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Utils/ClassUtils.h"
|
||||
|
||||
enum class EvaluationType
|
||||
{
|
||||
OPERAND_DYNAMIC,
|
||||
@ -18,7 +20,7 @@ public:
|
||||
IEvaluation& operator=(const IEvaluation& other) = default;
|
||||
IEvaluation& operator=(IEvaluation&& other) noexcept = default;
|
||||
|
||||
[[nodiscard]] virtual EvaluationType GetType() const = 0;
|
||||
[[nodiscard]] virtual bool IsStatic() const = 0;
|
||||
[[nodiscard]] virtual int EvaluateNumeric() const = 0;
|
||||
_NODISCARD virtual EvaluationType GetType() const = 0;
|
||||
_NODISCARD virtual bool IsStatic() const = 0;
|
||||
_NODISCARD virtual int EvaluateNumeric() const = 0;
|
||||
};
|
||||
|
@ -9,16 +9,16 @@
|
||||
class OperandDynamic final : public IEvaluation
|
||||
{
|
||||
public:
|
||||
StructureInformation* const m_structure;
|
||||
std::vector<MemberInformation*> m_referenced_member_chain;
|
||||
std::vector<std::unique_ptr<IEvaluation>> m_array_indices;
|
||||
|
||||
explicit OperandDynamic(StructureInformation* structure);
|
||||
OperandDynamic(StructureInformation* structure,
|
||||
std::vector<MemberInformation*> referencedMemberChain,
|
||||
std::vector<std::unique_ptr<IEvaluation>> arrayIndices);
|
||||
|
||||
[[nodiscard]] EvaluationType GetType() const override;
|
||||
[[nodiscard]] bool IsStatic() const override;
|
||||
[[nodiscard]] int EvaluateNumeric() const override;
|
||||
|
||||
StructureInformation* const m_structure;
|
||||
std::vector<MemberInformation*> m_referenced_member_chain;
|
||||
std::vector<std::unique_ptr<IEvaluation>> m_array_indices;
|
||||
_NODISCARD EvaluationType GetType() const override;
|
||||
_NODISCARD bool IsStatic() const override;
|
||||
_NODISCARD int EvaluateNumeric() const override;
|
||||
};
|
||||
|
@ -6,13 +6,13 @@
|
||||
class OperandStatic final : public IEvaluation
|
||||
{
|
||||
public:
|
||||
const int m_value;
|
||||
EnumMember* const m_enum_member;
|
||||
|
||||
explicit OperandStatic(int value);
|
||||
explicit OperandStatic(EnumMember* enumMember);
|
||||
|
||||
[[nodiscard]] EvaluationType GetType() const override;
|
||||
[[nodiscard]] bool IsStatic() const override;
|
||||
[[nodiscard]] int EvaluateNumeric() const override;
|
||||
|
||||
const int m_value;
|
||||
EnumMember* const m_enum_member;
|
||||
_NODISCARD EvaluationType GetType() const override;
|
||||
_NODISCARD bool IsStatic() const override;
|
||||
_NODISCARD int EvaluateNumeric() const override;
|
||||
};
|
||||
|
@ -9,17 +9,17 @@
|
||||
class Operation final : public IEvaluation
|
||||
{
|
||||
public:
|
||||
explicit Operation(const OperationType* type);
|
||||
Operation(const OperationType* type, std::unique_ptr<IEvaluation> operand1, std::unique_ptr<IEvaluation> operand2);
|
||||
|
||||
[[nodiscard]] EvaluationType GetType() const override;
|
||||
[[nodiscard]] bool IsStatic() const override;
|
||||
[[nodiscard]] int EvaluateNumeric() const override;
|
||||
|
||||
[[nodiscard]] bool Operand1NeedsParenthesis() const;
|
||||
[[nodiscard]] bool Operand2NeedsParenthesis() const;
|
||||
|
||||
const OperationType* const m_operation_type;
|
||||
std::unique_ptr<IEvaluation> m_operand1;
|
||||
std::unique_ptr<IEvaluation> m_operand2;
|
||||
|
||||
explicit Operation(const OperationType* type);
|
||||
Operation(const OperationType* type, std::unique_ptr<IEvaluation> operand1, std::unique_ptr<IEvaluation> operand2);
|
||||
|
||||
_NODISCARD EvaluationType GetType() const override;
|
||||
_NODISCARD bool IsStatic() const override;
|
||||
_NODISCARD int EvaluateNumeric() const override;
|
||||
|
||||
_NODISCARD bool Operand1NeedsParenthesis() const;
|
||||
_NODISCARD bool Operand2NeedsParenthesis() const;
|
||||
};
|
||||
|
@ -20,6 +20,14 @@ enum class OperationPrecedence
|
||||
|
||||
class OperationType
|
||||
{
|
||||
public:
|
||||
std::string m_syntax;
|
||||
OperationPrecedence m_precedence;
|
||||
std::function<int(int operand1, int operand2)> m_evaluation_function;
|
||||
|
||||
private:
|
||||
OperationType(std::string syntax, OperationPrecedence precedence, std::function<int(int, int)> evaluationFunction);
|
||||
|
||||
public:
|
||||
static const OperationType* const OPERATION_ADD;
|
||||
static const OperationType* const OPERATION_SUBTRACT;
|
||||
@ -41,11 +49,4 @@ public:
|
||||
static const OperationType* const OPERATION_OR;
|
||||
|
||||
static const OperationType* const ALL_OPERATION_TYPES[];
|
||||
|
||||
std::string m_syntax;
|
||||
OperationPrecedence m_precedence;
|
||||
std::function<int(int operand1, int operand2)> m_evaluation_function;
|
||||
|
||||
private:
|
||||
OperationType(std::string syntax, OperationPrecedence precedence, std::function<int(int, int)> evaluationFunction);
|
||||
};
|
||||
|
@ -8,8 +8,8 @@
|
||||
class CustomAction
|
||||
{
|
||||
public:
|
||||
CustomAction(std::string actionName, std::vector<DataDefinition*> parameterTypes);
|
||||
|
||||
std::string m_action_name;
|
||||
std::vector<DataDefinition*> m_parameter_types;
|
||||
|
||||
CustomAction(std::string actionName, std::vector<DataDefinition*> parameterTypes);
|
||||
};
|
||||
|
@ -13,10 +13,10 @@ enum class FastFileBlockType
|
||||
class FastFileBlock
|
||||
{
|
||||
public:
|
||||
FastFileBlock(std::string name, unsigned index, FastFileBlockType type, bool isDefault);
|
||||
|
||||
std::string m_name;
|
||||
unsigned m_index;
|
||||
FastFileBlockType m_type;
|
||||
bool m_is_default;
|
||||
|
||||
FastFileBlock(std::string name, unsigned index, FastFileBlockType type, bool isDefault);
|
||||
};
|
||||
|
@ -12,8 +12,6 @@ class StructureInformation;
|
||||
class MemberInformation
|
||||
{
|
||||
public:
|
||||
MemberInformation(StructureInformation* parent, StructureInformation* type, Variable* member);
|
||||
|
||||
StructureInformation* m_parent;
|
||||
StructureInformation* m_type;
|
||||
Variable* m_member;
|
||||
@ -26,4 +24,6 @@ public:
|
||||
std::unique_ptr<CustomAction> m_post_load_action;
|
||||
const FastFileBlock* m_fast_file_block;
|
||||
const EnumMember* m_asset_ref;
|
||||
|
||||
MemberInformation(StructureInformation* parent, StructureInformation* type, Variable* member);
|
||||
};
|
||||
|
@ -5,17 +5,13 @@
|
||||
#include "Domain/Extension/CustomAction.h"
|
||||
#include "Domain/FastFile/FastFileBlock.h"
|
||||
#include "MemberInformation.h"
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include "Utils/ClassUtils.h"
|
||||
|
||||
class MemberInformation;
|
||||
|
||||
class StructureInformation
|
||||
{
|
||||
public:
|
||||
explicit StructureInformation(DefinitionWithMembers* definition);
|
||||
|
||||
DefinitionWithMembers* const m_definition;
|
||||
EnumMember* m_asset_enum_entry;
|
||||
|
||||
@ -35,4 +31,6 @@ public:
|
||||
std::unique_ptr<CustomAction> m_post_load_action;
|
||||
const FastFileBlock* m_block;
|
||||
std::vector<MemberInformation*> m_name_chain;
|
||||
|
||||
explicit StructureInformation(DefinitionWithMembers* definition);
|
||||
};
|
||||
|
@ -3,24 +3,21 @@
|
||||
#include "ICodeTemplate.h"
|
||||
#include "ZoneCodeGeneratorArguments.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
class CodeGenerator
|
||||
{
|
||||
public:
|
||||
explicit CodeGenerator(const ZoneCodeGeneratorArguments* args);
|
||||
const ZoneCodeGeneratorArguments* m_args;
|
||||
|
||||
bool GenerateCode(IDataRepository* repository);
|
||||
std::unordered_map<std::string, std::unique_ptr<ICodeTemplate>> m_template_mapping;
|
||||
|
||||
private:
|
||||
void SetupTemplates();
|
||||
|
||||
bool GenerateCodeForTemplate(RenderingContext* context, ICodeTemplate* codeTemplate) const;
|
||||
static bool GetAssetWithName(IDataRepository* repository, const std::string& name, StructureInformation*& asset);
|
||||
|
||||
const ZoneCodeGeneratorArguments* m_args;
|
||||
public:
|
||||
explicit CodeGenerator(const ZoneCodeGeneratorArguments* args);
|
||||
|
||||
std::unordered_map<std::string, std::unique_ptr<ICodeTemplate>> m_template_mapping;
|
||||
bool GenerateCode(IDataRepository* repository);
|
||||
};
|
||||
|
@ -10,8 +10,6 @@
|
||||
class RenderingUsedType
|
||||
{
|
||||
public:
|
||||
RenderingUsedType(const DataDefinition* type, StructureInformation* info);
|
||||
|
||||
bool m_members_loaded;
|
||||
const DataDefinition* m_type;
|
||||
StructureInformation* m_info;
|
||||
@ -22,13 +20,25 @@ public:
|
||||
bool m_array_reference_exists;
|
||||
bool m_pointer_array_reference_exists;
|
||||
bool m_pointer_array_reference_is_reusable;
|
||||
|
||||
RenderingUsedType(const DataDefinition* type, StructureInformation* info);
|
||||
};
|
||||
|
||||
class RenderingContext
|
||||
{
|
||||
public:
|
||||
static std::unique_ptr<RenderingContext> BuildContext(const IDataRepository* repository, StructureInformation* asset);
|
||||
std::unordered_map<const DataDefinition*, std::unique_ptr<RenderingUsedType>> m_used_types_lookup;
|
||||
|
||||
RenderingContext(std::string game, std::vector<const FastFileBlock*> fastFileBlocks);
|
||||
|
||||
RenderingUsedType* AddUsedType(std::unique_ptr<RenderingUsedType> usedType);
|
||||
RenderingUsedType* GetBaseType(const IDataRepository* repository, MemberComputations* computations, RenderingUsedType* usedType);
|
||||
void AddMembersToContext(const IDataRepository* repository, StructureInformation* info);
|
||||
void ScanUsedTypeIfNeeded(const IDataRepository* repository, MemberComputations* computations, RenderingUsedType* usedType);
|
||||
void MakeAsset(const IDataRepository* repository, StructureInformation* asset);
|
||||
void CreateUsedTypeCollections();
|
||||
bool UsedTypeHasActions(const RenderingUsedType* usedType) const;
|
||||
|
||||
public:
|
||||
std::string m_game;
|
||||
std::vector<const FastFileBlock*> m_blocks;
|
||||
|
||||
@ -42,16 +52,5 @@ public:
|
||||
const FastFileBlock* m_default_normal_block;
|
||||
const FastFileBlock* m_default_temp_block;
|
||||
|
||||
private:
|
||||
RenderingContext(std::string game, std::vector<const FastFileBlock*> fastFileBlocks);
|
||||
|
||||
RenderingUsedType* AddUsedType(std::unique_ptr<RenderingUsedType> usedType);
|
||||
RenderingUsedType* GetBaseType(const IDataRepository* repository, MemberComputations* computations, RenderingUsedType* usedType);
|
||||
void AddMembersToContext(const IDataRepository* repository, StructureInformation* info);
|
||||
void ScanUsedTypeIfNeeded(const IDataRepository* repository, MemberComputations* computations, RenderingUsedType* usedType);
|
||||
void MakeAsset(const IDataRepository* repository, StructureInformation* asset);
|
||||
void CreateUsedTypeCollections();
|
||||
bool UsedTypeHasActions(const RenderingUsedType* usedType) const;
|
||||
|
||||
std::unordered_map<const DataDefinition*, std::unique_ptr<RenderingUsedType>> m_used_types_lookup;
|
||||
static std::unique_ptr<RenderingContext> BuildContext(const IDataRepository* repository, StructureInformation* asset);
|
||||
};
|
||||
|
@ -6,75 +6,69 @@
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
namespace
|
||||
class AssetStructTestsTemplate::Internal final : BaseTemplate
|
||||
{
|
||||
static constexpr int TAG_SOURCE = 1;
|
||||
|
||||
class Template final : BaseTemplate
|
||||
void TestMethod(StructureInformation* structure)
|
||||
{
|
||||
public:
|
||||
Template(std::ostream& stream, RenderingContext* context)
|
||||
: BaseTemplate(stream, context)
|
||||
{
|
||||
}
|
||||
LINE("TEST_CASE(\"" << m_env.m_game << "::" << m_env.m_asset->m_definition->GetFullName() << ": Tests for " << structure->m_definition->GetFullName()
|
||||
<< "\", \"[assetstruct]\")")
|
||||
LINE("{")
|
||||
m_intendation++;
|
||||
|
||||
void Source()
|
||||
for (const auto& member : structure->m_ordered_members)
|
||||
{
|
||||
LINE("// ====================================================================")
|
||||
LINE("// This file has been generated by ZoneCodeGenerator.")
|
||||
LINE("// Do not modify.")
|
||||
LINE("// Any changes will be discarded when regenerating.")
|
||||
LINE("// ====================================================================")
|
||||
LINE("")
|
||||
LINE("#include <catch2/catch_test_macros.hpp>")
|
||||
LINE("#include <catch2/generators/catch_generators.hpp>")
|
||||
LINE("#include <cstddef>")
|
||||
LINE("#include \"Game/" << m_env.m_game << "/" << m_env.m_game << ".h\"")
|
||||
LINE("")
|
||||
LINE("using namespace " << m_env.m_game << ";")
|
||||
LINE("")
|
||||
LINE("namespace game::" << m_env.m_game << "::xassets::asset_" << Lower(m_env.m_asset->m_definition->m_name))
|
||||
LINE("{")
|
||||
m_intendation++;
|
||||
|
||||
TestMethod(m_env.m_asset);
|
||||
for (auto* structure : m_env.m_used_structures)
|
||||
if (!member->m_member->m_name.empty() && !member->m_member->m_type_declaration->m_has_custom_bit_size)
|
||||
{
|
||||
StructureComputations computations(structure->m_info);
|
||||
if (!structure->m_info->m_definition->m_anonymous && !computations.IsAsset())
|
||||
TestMethod(structure->m_info);
|
||||
LINE("REQUIRE(offsetof(" << structure->m_definition->GetFullName() << ", " << member->m_member->m_name << ") == " << member->m_member->m_offset
|
||||
<< ");")
|
||||
}
|
||||
|
||||
m_intendation--;
|
||||
LINE("}")
|
||||
}
|
||||
|
||||
private:
|
||||
void TestMethod(StructureInformation* structure)
|
||||
LINE("")
|
||||
|
||||
LINE("REQUIRE(" << structure->m_definition->GetSize() << "u == sizeof(" << structure->m_definition->GetFullName() << "));")
|
||||
LINE("REQUIRE(" << structure->m_definition->GetAlignment() << "u == alignof(" << structure->m_definition->GetFullName() << "));")
|
||||
m_intendation--;
|
||||
LINE("}")
|
||||
}
|
||||
|
||||
public:
|
||||
Internal(std::ostream& stream, RenderingContext* context)
|
||||
: BaseTemplate(stream, context)
|
||||
{
|
||||
}
|
||||
|
||||
void Source()
|
||||
{
|
||||
LINE("// ====================================================================")
|
||||
LINE("// This file has been generated by ZoneCodeGenerator.")
|
||||
LINE("// Do not modify.")
|
||||
LINE("// Any changes will be discarded when regenerating.")
|
||||
LINE("// ====================================================================")
|
||||
LINE("")
|
||||
LINE("#include <catch2/catch_test_macros.hpp>")
|
||||
LINE("#include <catch2/generators/catch_generators.hpp>")
|
||||
LINE("#include <cstddef>")
|
||||
LINE("#include \"Game/" << m_env.m_game << "/" << m_env.m_game << ".h\"")
|
||||
LINE("")
|
||||
LINE("using namespace " << m_env.m_game << ";")
|
||||
LINE("")
|
||||
LINE("namespace game::" << m_env.m_game << "::xassets::asset_" << Lower(m_env.m_asset->m_definition->m_name))
|
||||
LINE("{")
|
||||
m_intendation++;
|
||||
|
||||
TestMethod(m_env.m_asset);
|
||||
for (auto* structure : m_env.m_used_structures)
|
||||
{
|
||||
LINE("TEST_CASE(\"" << m_env.m_game << "::" << m_env.m_asset->m_definition->GetFullName() << ": Tests for "
|
||||
<< structure->m_definition->GetFullName() << "\", \"[assetstruct]\")")
|
||||
LINE("{")
|
||||
m_intendation++;
|
||||
|
||||
for (const auto& member : structure->m_ordered_members)
|
||||
{
|
||||
if (!member->m_member->m_name.empty() && !member->m_member->m_type_declaration->m_has_custom_bit_size)
|
||||
{
|
||||
LINE("REQUIRE(offsetof(" << structure->m_definition->GetFullName() << ", " << member->m_member->m_name
|
||||
<< ") == " << member->m_member->m_offset << ");")
|
||||
}
|
||||
}
|
||||
|
||||
LINE("")
|
||||
|
||||
LINE("REQUIRE(" << structure->m_definition->GetSize() << "u == sizeof(" << structure->m_definition->GetFullName() << "));")
|
||||
LINE("REQUIRE(" << structure->m_definition->GetAlignment() << "u == alignof(" << structure->m_definition->GetFullName() << "));")
|
||||
m_intendation--;
|
||||
LINE("}")
|
||||
StructureComputations computations(structure->m_info);
|
||||
if (!structure->m_info->m_definition->m_anonymous && !computations.IsAsset())
|
||||
TestMethod(structure->m_info);
|
||||
}
|
||||
};
|
||||
} // namespace
|
||||
|
||||
m_intendation--;
|
||||
LINE("}")
|
||||
}
|
||||
};
|
||||
|
||||
std::vector<CodeTemplateFile> AssetStructTestsTemplate::GetFilesToRender(RenderingContext* context)
|
||||
{
|
||||
@ -95,10 +89,10 @@ std::vector<CodeTemplateFile> AssetStructTestsTemplate::GetFilesToRender(Renderi
|
||||
|
||||
void AssetStructTestsTemplate::RenderFile(std::ostream& stream, const int fileTag, RenderingContext* context)
|
||||
{
|
||||
Template t(stream, context);
|
||||
Internal internal(stream, context);
|
||||
|
||||
if (fileTag == TAG_SOURCE)
|
||||
t.Source();
|
||||
internal.Source();
|
||||
else
|
||||
std::cout << "Invalid tag in AssetStructTestsTemplate\n";
|
||||
}
|
||||
|
@ -3,6 +3,10 @@
|
||||
|
||||
class AssetStructTestsTemplate final : public ICodeTemplate
|
||||
{
|
||||
static constexpr int TAG_SOURCE = 1;
|
||||
|
||||
class Internal;
|
||||
|
||||
public:
|
||||
std::vector<CodeTemplateFile> GetFilesToRender(RenderingContext* context) override;
|
||||
void RenderFile(std::ostream& stream, int fileTag, RenderingContext* context) override;
|
||||
|
@ -15,10 +15,27 @@ class BaseTemplate
|
||||
protected:
|
||||
static constexpr const char* INTENDATION = " ";
|
||||
|
||||
std::ostream& m_out;
|
||||
RenderingContext& m_env;
|
||||
unsigned m_intendation;
|
||||
|
||||
BaseTemplate(std::ostream& stream, RenderingContext* context);
|
||||
|
||||
void DoIntendation() const;
|
||||
|
||||
private:
|
||||
static void MakeSafeTypeNameInternal(const DataDefinition* def, std::ostringstream& str);
|
||||
static void MakeTypeVarNameInternal(const DataDefinition* def, std::ostringstream& str);
|
||||
static void MakeTypeWrittenVarNameInternal(const DataDefinition* def, std::ostringstream& str);
|
||||
static void MakeTypePtrVarNameInternal(const DataDefinition* def, std::ostringstream& str);
|
||||
static void MakeTypeWrittenPtrVarNameInternal(const DataDefinition* def, std::ostringstream& str);
|
||||
static void MakeArrayIndicesInternal(const DeclarationModifierComputations& modifierComputations, std::ostringstream& str);
|
||||
static void MakeOperandStatic(const OperandStatic* op, std::ostringstream& str);
|
||||
static void MakeOperandDynamic(const OperandDynamic* op, std::ostringstream& str);
|
||||
static void MakeOperation(const Operation* operation, std::ostringstream& str);
|
||||
static void MakeEvaluationInternal(const IEvaluation* evaluation, std::ostringstream& str);
|
||||
|
||||
protected:
|
||||
static std::string Upper(std::string str);
|
||||
static std::string Lower(std::string str);
|
||||
static std::string MakeTypeVarName(const DataDefinition* def);
|
||||
@ -38,22 +55,6 @@ protected:
|
||||
static std::string MakeCustomActionCall(CustomAction* action);
|
||||
static std::string MakeArrayCount(const ArrayDeclarationModifier* arrayModifier);
|
||||
static std::string MakeEvaluation(const IEvaluation* evaluation);
|
||||
|
||||
std::ostream& m_out;
|
||||
RenderingContext& m_env;
|
||||
unsigned m_intendation;
|
||||
|
||||
private:
|
||||
static void MakeSafeTypeNameInternal(const DataDefinition* def, std::ostringstream& str);
|
||||
static void MakeTypeVarNameInternal(const DataDefinition* def, std::ostringstream& str);
|
||||
static void MakeTypeWrittenVarNameInternal(const DataDefinition* def, std::ostringstream& str);
|
||||
static void MakeTypePtrVarNameInternal(const DataDefinition* def, std::ostringstream& str);
|
||||
static void MakeTypeWrittenPtrVarNameInternal(const DataDefinition* def, std::ostringstream& str);
|
||||
static void MakeArrayIndicesInternal(const DeclarationModifierComputations& modifierComputations, std::ostringstream& str);
|
||||
static void MakeOperandStatic(const OperandStatic* op, std::ostringstream& str);
|
||||
static void MakeOperandDynamic(const OperandDynamic* op, std::ostringstream& str);
|
||||
static void MakeOperation(const Operation* operation, std::ostringstream& str);
|
||||
static void MakeEvaluationInternal(const IEvaluation* evaluation, std::ostringstream& str);
|
||||
};
|
||||
|
||||
#define LINE(x) \
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -3,6 +3,11 @@
|
||||
|
||||
class ZoneLoadTemplate final : public ICodeTemplate
|
||||
{
|
||||
static constexpr int TAG_HEADER = 1;
|
||||
static constexpr int TAG_SOURCE = 2;
|
||||
|
||||
class Internal;
|
||||
|
||||
public:
|
||||
std::vector<CodeTemplateFile> GetFilesToRender(RenderingContext* context) override;
|
||||
void RenderFile(std::ostream& stream, int fileTag, RenderingContext* context) override;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -3,6 +3,11 @@
|
||||
|
||||
class ZoneMarkTemplate final : public ICodeTemplate
|
||||
{
|
||||
static constexpr int TAG_HEADER = 1;
|
||||
static constexpr int TAG_SOURCE = 2;
|
||||
|
||||
class Internal;
|
||||
|
||||
public:
|
||||
std::vector<CodeTemplateFile> GetFilesToRender(RenderingContext* context) override;
|
||||
void RenderFile(std::ostream& stream, int fileTag, RenderingContext* context) override;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -3,6 +3,11 @@
|
||||
|
||||
class ZoneWriteTemplate final : public ICodeTemplate
|
||||
{
|
||||
static constexpr int TAG_HEADER = 1;
|
||||
static constexpr int TAG_SOURCE = 2;
|
||||
|
||||
class Internal;
|
||||
|
||||
public:
|
||||
std::vector<CodeTemplateFile> GetFilesToRender(RenderingContext* context) override;
|
||||
void RenderFile(std::ostream& stream, int fileTag, RenderingContext* context) override;
|
||||
|
@ -17,12 +17,6 @@
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
|
||||
namespace
|
||||
{
|
||||
static constexpr const char* ZONE_CODE_GENERATOR_DEFINE_NAME = "__zonecodegenerator";
|
||||
static constexpr const char* ZONE_CODE_GENERATOR_DEFINE_VALUE = "1";
|
||||
} // namespace
|
||||
|
||||
CommandsFileReader::CommandsFileReader(const ZoneCodeGeneratorArguments* args, std::string filename)
|
||||
: m_args(args),
|
||||
m_filename(std::move(filename)),
|
||||
@ -36,7 +30,7 @@ bool CommandsFileReader::OpenBaseStream()
|
||||
auto stream = std::make_unique<ParserFilesystemStream>(m_filename);
|
||||
if (!stream->IsOpen())
|
||||
{
|
||||
std::cerr << "Could not open commands file\n";
|
||||
std::cout << "Could not open commands file\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -74,7 +68,7 @@ bool CommandsFileReader::ReadCommandsFile(IDataRepository* repository)
|
||||
{
|
||||
if (m_args->m_verbose)
|
||||
{
|
||||
std::cout << std::format("Reading commands file: {}\n", m_filename);
|
||||
std::cout << "Reading commands file: " << m_filename << "\n";
|
||||
}
|
||||
|
||||
if (!OpenBaseStream())
|
||||
@ -90,7 +84,9 @@ bool CommandsFileReader::ReadCommandsFile(IDataRepository* repository)
|
||||
const auto end = std::chrono::steady_clock::now();
|
||||
|
||||
if (m_args->m_verbose)
|
||||
std::cout << std::format("Processing commands took {}ms\n", std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count());
|
||||
{
|
||||
std::cout << "Processing commands took " << std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() << "ms\n";
|
||||
}
|
||||
|
||||
if (!result)
|
||||
return false;
|
||||
|
@ -9,15 +9,8 @@
|
||||
|
||||
class CommandsFileReader
|
||||
{
|
||||
public:
|
||||
CommandsFileReader(const ZoneCodeGeneratorArguments* args, std::string filename);
|
||||
|
||||
bool ReadCommandsFile(IDataRepository* repository);
|
||||
|
||||
private:
|
||||
bool OpenBaseStream();
|
||||
void SetupStreamProxies();
|
||||
void SetupPostProcessors();
|
||||
static constexpr const char* ZONE_CODE_GENERATOR_DEFINE_NAME = "__zonecodegenerator";
|
||||
static constexpr const char* ZONE_CODE_GENERATOR_DEFINE_VALUE = "1";
|
||||
|
||||
const ZoneCodeGeneratorArguments* m_args;
|
||||
std::string m_filename;
|
||||
@ -26,4 +19,13 @@ private:
|
||||
IParserLineStream* m_stream;
|
||||
|
||||
std::vector<std::unique_ptr<IPostProcessor>> m_post_processors;
|
||||
|
||||
bool OpenBaseStream();
|
||||
void SetupStreamProxies();
|
||||
void SetupPostProcessors();
|
||||
|
||||
public:
|
||||
explicit CommandsFileReader(const ZoneCodeGeneratorArguments* args, std::string filename);
|
||||
|
||||
bool ReadCommandsFile(IDataRepository* repository);
|
||||
};
|
||||
|
@ -5,9 +5,9 @@
|
||||
|
||||
class CommandsLexer final : public AbstractLexer<CommandsParserValue>
|
||||
{
|
||||
public:
|
||||
explicit CommandsLexer(IParserLineStream* stream);
|
||||
|
||||
protected:
|
||||
CommandsParserValue GetNextToken() override;
|
||||
|
||||
public:
|
||||
explicit CommandsLexer(IParserLineStream* stream);
|
||||
};
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user