mirror of
https://github.com/syoyo/tinygltf.git
synced 2026-06-11 20:53:50 +00:00
Compare commits
2 Commits
copilot/su
...
copilot/su
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
946c5a2d9b | ||
|
|
0e370ef62f |
@@ -2908,22 +2908,6 @@ static int tg3__parse_audio_emitter(tg3__parse_ctx *ctx, const tg3__json &o,
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* ======================================================================
|
||||
* Internal: Portable variadic-comma helper
|
||||
*
|
||||
* TG3__COMMA_VA_ARGS(__VA_ARGS__) expands to , __VA_ARGS__ when the
|
||||
* argument list is non-empty, and to nothing when it is empty.
|
||||
*
|
||||
* - C++20 and later: uses the standard __VA_OPT__(,) token.
|
||||
* - C++17 and earlier: falls back to the widely-supported GNU/MSVC
|
||||
* ##__VA_ARGS__ extension.
|
||||
* ====================================================================== */
|
||||
#if __cplusplus >= 202002L
|
||||
# define TG3__COMMA_VA_ARGS(...) __VA_OPT__(,) __VA_ARGS__
|
||||
#else
|
||||
# define TG3__COMMA_VA_ARGS(...) , ##__VA_ARGS__
|
||||
#endif
|
||||
|
||||
/* ======================================================================
|
||||
* Internal: Array Parse Macro
|
||||
* ====================================================================== */
|
||||
@@ -2939,7 +2923,7 @@ static int tg3__parse_audio_emitter(tg3__parse_ctx *ctx, const tg3__json &o,
|
||||
if (_items) { \
|
||||
uint32_t _i = 0; \
|
||||
for (auto _it = _arr_it->begin(); _it != _arr_it->end(); ++_it, ++_i) { \
|
||||
parse_fn((ctx), *_it, &_items[_i] TG3__COMMA_VA_ARGS(__VA_ARGS__)); \
|
||||
parse_fn((ctx), *_it, &_items[_i], ##__VA_ARGS__); \
|
||||
} \
|
||||
(model_field) = _items; \
|
||||
(count_field) = _count; \
|
||||
@@ -4110,7 +4094,7 @@ static tg3__json tg3__serialize_model(const tg3_model *model, int wd,
|
||||
if ((arr) && (cnt) > 0) { \
|
||||
tg3__json jarr; jarr.set_array(); \
|
||||
for (uint32_t _i = 0; _i < (cnt); ++_i) { \
|
||||
jarr.push_back(fn(&(arr)[_i] TG3__COMMA_VA_ARGS(__VA_ARGS__))); \
|
||||
jarr.push_back(fn(&(arr)[_i], ##__VA_ARGS__)); \
|
||||
} \
|
||||
root[key] = static_cast<tg3__json&&>(jarr); \
|
||||
}
|
||||
@@ -4325,7 +4309,7 @@ struct tg3_writer {
|
||||
TINYGLTF3_API tg3_writer *tg3_writer_create(
|
||||
tg3_write_chunk_fn chunk_fn, void *user_data,
|
||||
const tg3_write_options *options) {
|
||||
tg3_writer *w = (tg3_writer *)calloc(1, sizeof(tg3_writer));
|
||||
tg3_writer *w = new (std::nothrow) tg3_writer();
|
||||
if (!w) return NULL;
|
||||
w->chunk_fn = chunk_fn;
|
||||
w->user_data = user_data;
|
||||
@@ -4351,7 +4335,7 @@ TINYGLTF3_API tg3_error_code tg3_writer_begin(tg3_writer *w, const tg3_asset *as
|
||||
w->root[json_key] = static_cast<tg3__json&&>(arr); \
|
||||
} \
|
||||
w->root[json_key].push_back( \
|
||||
serialize_fn(item, w->options.serialize_defaults TG3__COMMA_VA_ARGS(__VA_ARGS__))); \
|
||||
serialize_fn(item, w->options.serialize_defaults, ##__VA_ARGS__)); \
|
||||
return TG3_OK; \
|
||||
}
|
||||
|
||||
@@ -4401,10 +4385,7 @@ TINYGLTF3_API tg3_error_code tg3_writer_end(tg3_writer *w) {
|
||||
}
|
||||
|
||||
TINYGLTF3_API void tg3_writer_destroy(tg3_writer *w) {
|
||||
if (w) {
|
||||
w->root.~tinygltf_json();
|
||||
free(w);
|
||||
}
|
||||
delete w;
|
||||
}
|
||||
|
||||
#endif /* TINYGLTF3_IMPLEMENTATION */
|
||||
|
||||
Reference in New Issue
Block a user