Skip to content

Commit

Permalink
Fix: Don't shadow any class members in parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
spnda committed Apr 27, 2024
1 parent c9bd625 commit e70088f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 30 deletions.
40 changes: 20 additions & 20 deletions src/fastgltf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3910,33 +3910,33 @@ fg::Parser& fg::Parser::operator=(Parser&& other) noexcept {

fg::Parser::~Parser() = default;

fg::Expected<fg::Asset> fg::Parser::loadGltf(GltfDataBuffer* buffer, fs::path directory, Options options, Category categories) {
fg::Expected<fg::Asset> fg::Parser::loadGltf(GltfDataBuffer* buffer, fs::path _directory, Options _options, Category categories) {
auto type = fastgltf::determineGltfFileType(buffer);

if (type == fastgltf::GltfType::glTF) {
return loadGltfJson(buffer, std::move(directory), options, categories);
return loadGltfJson(buffer, std::move(_directory), _options, categories);
}

if (type == fastgltf::GltfType::GLB) {
return loadGltfBinary(buffer, std::move(directory), options, categories);
return loadGltfBinary(buffer, std::move(_directory), _options, categories);
}

return Error::InvalidFileData;
}

fg::Expected<fg::Asset> fg::Parser::loadGltfJson(GltfDataBuffer* buffer, fs::path directory, Options options, Category categories) {
fg::Expected<fg::Asset> fg::Parser::loadGltfJson(GltfDataBuffer* buffer, fs::path _directory, Options _options, Category categories) {
using namespace simdjson;

options = _options;
directory = std::move(_directory);

#if !defined(__ANDROID__)
// If we never have to load the files ourselves, we're fine with the directory being invalid/blank.
if (std::error_code ec; hasBit(options, Options::LoadExternalBuffers) && (!fs::is_directory(directory, ec) || ec)) {
if (std::error_code ec; hasBit(_options, Options::LoadExternalBuffers) && (!fs::is_directory(directory, ec) || ec)) {
return Error::InvalidPath;
}
#endif

this->options = options;
this->directory = std::move(directory);

// If we own the allocation of the JSON data, we'll try to minify the JSON, which, in most cases,
// will speed up the parsing by a small amount.
std::size_t jsonLength = buffer->getBufferSize();
Expand All @@ -3959,17 +3959,17 @@ fg::Expected<fg::Asset> fg::Parser::loadGltfJson(GltfDataBuffer* buffer, fs::pat
return parse(root, categories);
}

fg::Expected<fg::Asset> fg::Parser::loadGltfBinary(GltfDataBuffer* buffer, fs::path directory, Options options, Category categories) {
fg::Expected<fg::Asset> fg::Parser::loadGltfBinary(GltfDataBuffer* buffer, fs::path _directory, Options _options, Category categories) {
using namespace simdjson;

options = _options;
directory = std::move(_directory);

// If we never have to load the files ourselves, we're fine with the directory being invalid/blank.
if (std::error_code ec; hasBit(options, Options::LoadExternalBuffers) && (!fs::is_directory(directory, ec) || ec)) {
return Error::InvalidPath;
}

this->options = options;
this->directory = std::move(directory);

std::size_t offset = 0UL;
auto read = [&buffer, &offset](void* dst, std::size_t size) mutable {
std::memcpy(dst, buffer->bufferPointer + offset, size);
Expand Down Expand Up @@ -5422,10 +5422,10 @@ std::string fg::Exporter::writeJson(const fastgltf::Asset &asset) {
return outputString;
}

fg::Expected<fg::ExportResult<std::string>> fg::Exporter::writeGltfJson(const Asset& asset, ExportOptions nOptions) {
fg::Expected<fg::ExportResult<std::string>> fg::Exporter::writeGltfJson(const Asset& asset, ExportOptions _options) {
bufferPaths.clear();
imagePaths.clear();
options = nOptions;
options = _options;
exportingBinary = false;

if (hasBit(options, ExportOptions::ValidateAsset)) {
Expand All @@ -5448,10 +5448,10 @@ fg::Expected<fg::ExportResult<std::string>> fg::Exporter::writeGltfJson(const As
return std::move(result);
}

fg::Expected<fg::ExportResult<std::vector<std::byte>>> fg::Exporter::writeGltfBinary(const Asset& asset, ExportOptions nOptions) {
fg::Expected<fg::ExportResult<std::vector<std::byte>>> fg::Exporter::writeGltfBinary(const Asset& asset, ExportOptions _options) {
bufferPaths.clear();
imagePaths.clear();
options = nOptions;
options = _options;
exportingBinary = true;

options &= (~ExportOptions::PrettyPrintJson);
Expand Down Expand Up @@ -5609,15 +5609,15 @@ namespace fastgltf {
}
} // namespace fastgltf

fg::Error fg::FileExporter::writeGltfJson(const Asset& asset, fs::path target, ExportOptions options) {
fg::Error fg::FileExporter::writeGltfJson(const Asset& asset, fs::path target, ExportOptions _options) {
if (std::error_code ec; !fs::exists(target.parent_path(), ec) || ec) {
fs::create_directory(target.parent_path(), ec);
if (ec) {
return Error::InvalidPath;
}
}

auto expected = Exporter::writeGltfJson(asset, options);
auto expected = Exporter::writeGltfJson(asset, _options);

if (!expected) {
return expected.error();
Expand All @@ -5638,15 +5638,15 @@ fg::Error fg::FileExporter::writeGltfJson(const Asset& asset, fs::path target, E
return Error::None;
}

fg::Error fg::FileExporter::writeGltfBinary(const Asset& asset, fs::path target, ExportOptions options) {
fg::Error fg::FileExporter::writeGltfBinary(const Asset& asset, fs::path target, ExportOptions _options) {
if (std::error_code ec; !fs::exists(target.parent_path(), ec) || ec) {
fs::create_directory(target.parent_path(), ec);
if (ec) {
return Error::InvalidPath;
}
}

auto expected = Exporter::writeGltfBinary(asset, options);
auto expected = Exporter::writeGltfBinary(asset, _options);

if (!expected) {
return expected.error();
Expand Down
12 changes: 6 additions & 6 deletions tests/benchmarks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <catch2/benchmark/catch_benchmark.hpp>
#include <catch2/catch_test_macros.hpp>

#include "simdjson.h"
#include <simdjson.h>

#include <fastgltf/core.hpp>
#include <fastgltf/base64.hpp>
Expand Down Expand Up @@ -32,8 +32,8 @@ bool tinygltf_FileExistsFunction([[maybe_unused]] const std::string& filename, [
return true;
}

std::string tinygltf_ExpandFilePathFunction(const std::string& path, [[maybe_unused]] void* user) {
return path;
std::string tinygltf_ExpandFilePathFunction(const std::string& filePath, [[maybe_unused]] void* user) {
return filePath;
}

bool tinygltf_ReadWholeFileFunction(std::vector<unsigned char>* data, std::string*, const std::string&, void*) {
Expand Down Expand Up @@ -76,10 +76,10 @@ void setTinyGLTFCallbacks(tinygltf::TinyGLTF& gltf) {
#include <assimp/Base64.hpp>
#endif

fastgltf::StaticVector<std::uint8_t> readFileAsBytes(const std::filesystem::path& path) {
std::ifstream file(path, std::ios::ate | std::ios::binary);
fastgltf::StaticVector<std::uint8_t> readFileAsBytes(const std::filesystem::path& filePath) {
std::ifstream file(filePath, std::ios::ate | std::ios::binary);
if (!file.is_open())
throw std::runtime_error(std::string { "Failed to open file: " } + path.string());
throw std::runtime_error(std::string { "Failed to open file: " } + filePath.string());

auto fileSize = file.tellg();
fastgltf::StaticVector<std::uint8_t> bytes(static_cast<std::size_t>(fileSize) + fastgltf::getGltfBufferPadding());
Expand Down
8 changes: 4 additions & 4 deletions tests/uri_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ TEST_CASE("Test basic URIs", "[uri-tests]") {
REQUIRE(uri1.scheme().empty());
REQUIRE(uri1.path().empty());

std::string_view path = "path/somewhere.xyz";
std::string_view relpath = "path/somewhere.xyz";
SECTION("Basic local path") {
const fastgltf::URI uri2(path);
const fastgltf::URI uri2(relpath);
REQUIRE(uri2.scheme().empty());
REQUIRE(uri2.path() == path);
REQUIRE(uri2.path() == relpath);
REQUIRE(uri2.isLocalPath());
REQUIRE(uri2.fspath() == path);
REQUIRE(uri2.fspath() == relpath);
}

std::string_view abspath = "/path/somewhere.xyz";
Expand Down

0 comments on commit e70088f

Please sign in to comment.