mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-18 00:32:11 +01:00
Add WUFFS_BASE__HAVE_UNIQUE_PTR macro
This commit is contained in:
1 parent
2dfeee722c
commit
69e32e8579
4 files changed
+38
-36
No files matched your search
@@ -33,8 +33,9 @@
|
||||
|
||||
// Note that Clang also defines __GNUC__.
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus >= 201103L
|
||||
#if (__cplusplus >= 201103L) || defined(_MSC_VER)
|
||||
#include <memory>
|
||||
#define WUFFS_BASE__HAVE_UNIQUE_PTR
|
||||
#elif defined(__GNUC__)
|
||||
#warning "Wuffs' C++ code expects -std=c++11 or later"
|
||||
#elif defined(_MSC_VER)
|
||||
|
||||
@@ -439,7 +439,7 @@ func insertInterfaceDeclarations(buf *buffer) error {
|
||||
buf.writes(" } private_impl;\n\n")
|
||||
|
||||
buf.writes("#ifdef __cplusplus\n")
|
||||
buf.writes("#if (__cplusplus >= 201103L)\n")
|
||||
buf.writes("#if defined(WUFFS_BASE__HAVE_UNIQUE_PTR)\n")
|
||||
buf.printf(" using unique_ptr = std::unique_ptr<wuffs_base__%s, decltype(&free)>;\n", n)
|
||||
buf.writes("#endif\n\n")
|
||||
|
||||
@@ -1215,7 +1215,7 @@ func (g *gen) writeCppMethods(b *buffer, n *a.Struct) error {
|
||||
fullStructName := g.pkgPrefix + structName + "__struct"
|
||||
b.writes("#ifdef __cplusplus\n")
|
||||
|
||||
b.writes("#if (__cplusplus >= 201103L)\n")
|
||||
b.writes("#if defined(WUFFS_BASE__HAVE_UNIQUE_PTR)\n")
|
||||
b.printf("using unique_ptr = std::unique_ptr<%s%s, decltype(&free)>;\n\n", g.pkgPrefix, structName)
|
||||
b.writes("// On failure, the alloc_etc functions return nullptr. They don't throw.\n\n")
|
||||
b.writes("static inline unique_ptr\n")
|
||||
@@ -1231,7 +1231,7 @@ func (g *gen) writeCppMethods(b *buffer, n *a.Struct) error {
|
||||
iName, g.pkgPrefix, structName, iName)
|
||||
b.printf("}\n")
|
||||
}
|
||||
b.writes("#endif // (__cplusplus >= 201103L)\n\n")
|
||||
b.writes("#endif // defined(WUFFS_BASE__HAVE_UNIQUE_PTR)\n\n")
|
||||
|
||||
b.writes("#if (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)\n")
|
||||
b.writes("// Disallow constructing or copying an object via standard C++ mechanisms,\n")
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package data
|
||||
|
||||
const BaseAllImplC = "" +
|
||||
"#ifndef WUFFS_INCLUDE_GUARD__BASE\n#define WUFFS_INCLUDE_GUARD__BASE\n\n#if defined(WUFFS_IMPLEMENTATION) && !defined(WUFFS_CONFIG__MODULES)\n#define WUFFS_CONFIG__MODULES\n#define WUFFS_CONFIG__MODULE__BASE\n#endif\n\n// !! WUFFS MONOLITHIC RELEASE DISCARDS EVERYTHING ABOVE.\n\n// !! INSERT base/copyright\n\n#include <stdbool.h>\n#include <stdint.h>\n#include <stdlib.h>\n#include <string.h>\n\n// Note that Clang also defines __GNUC__.\n#ifdef __cplusplus\n#if __cplusplus >= 201103L\n#include <memory>\n#elif defined(__GNUC__)\n#warning \"Wuffs' C++ code expects -std=c++11 or later\"\n#elif defined(_MSC_VER)\n#pragma message(\"Wuffs' C++ code expects C++11 or later\")\n#endif\n\nextern \"C\" {\n#endif\n\n// !! INSERT base/all-public.h.\n\n// !! INSERT InterfaceDeclarations.\n\n" +
|
||||
"#ifndef WUFFS_INCLUDE_GUARD__BASE\n#define WUFFS_INCLUDE_GUARD__BASE\n\n#if defined(WUFFS_IMPLEMENTATION) && !defined(WUFFS_CONFIG__MODULES)\n#define WUFFS_CONFIG__MODULES\n#define WUFFS_CONFIG__MODULE__BASE\n#endif\n\n// !! WUFFS MONOLITHIC RELEASE DISCARDS EVERYTHING ABOVE.\n\n// !! INSERT base/copyright\n\n#include <stdbool.h>\n#include <stdint.h>\n#include <stdlib.h>\n#include <string.h>\n\n// Note that Clang also defines __GNUC__.\n#ifdef __cplusplus\n#if (__cplusplus >= 201103L) || defined(_MSC_VER)\n#include <memory>\n#define WUFFS_BASE__HAVE_UNIQUE_PTR\n#elif defined(__GNUC__)\n#warning \"Wuffs' C++ code expects -std=c++11 or later\"\n#elif defined(_MSC_VER)\n#pragma message(\"Wuffs' C++ code expects C++11 or later\")\n#endif\n\nextern \"C\" {\n#endif\n\n// !! INSERT base/all-public.h.\n\n// !! INSERT InterfaceDeclarations.\n\n" +
|
||||
"" +
|
||||
"// ----------------\n\n#ifdef __cplusplus\n} // extern \"C\"\n#endif\n\n// WUFFS C HEADER ENDS HERE.\n#ifdef WUFFS_IMPLEMENTATION\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n// !! INSERT base/all-private.h.\n\n" +
|
||||
"" +
|
||||
|
||||
@@ -37,8 +37,9 @@
|
||||
|
||||
// Note that Clang also defines __GNUC__.
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus >= 201103L
|
||||
#if (__cplusplus >= 201103L) || defined(_MSC_VER)
|
||||
#include <memory>
|
||||
#define WUFFS_BASE__HAVE_UNIQUE_PTR
|
||||
#elif defined(__GNUC__)
|
||||
#warning "Wuffs' C++ code expects -std=c++11 or later"
|
||||
#elif defined(_MSC_VER)
|
||||
@@ -5250,7 +5251,7 @@ struct wuffs_base__hasher_u32__struct {
|
||||
} private_impl;
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if (__cplusplus >= 201103L)
|
||||
#if defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
|
||||
using unique_ptr = std::unique_ptr<wuffs_base__hasher_u32, decltype(&free)>;
|
||||
#endif
|
||||
|
||||
@@ -5401,7 +5402,7 @@ struct wuffs_base__image_decoder__struct {
|
||||
} private_impl;
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if (__cplusplus >= 201103L)
|
||||
#if defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
|
||||
using unique_ptr = std::unique_ptr<wuffs_base__image_decoder, decltype(&free)>;
|
||||
#endif
|
||||
|
||||
@@ -5542,7 +5543,7 @@ struct wuffs_base__io_transformer__struct {
|
||||
} private_impl;
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if (__cplusplus >= 201103L)
|
||||
#if defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
|
||||
using unique_ptr = std::unique_ptr<wuffs_base__io_transformer, decltype(&free)>;
|
||||
#endif
|
||||
|
||||
@@ -5620,7 +5621,7 @@ struct wuffs_base__token_decoder__struct {
|
||||
} private_impl;
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if (__cplusplus >= 201103L)
|
||||
#if defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
|
||||
using unique_ptr = std::unique_ptr<wuffs_base__token_decoder, decltype(&free)>;
|
||||
#endif
|
||||
|
||||
@@ -5756,7 +5757,7 @@ struct wuffs_adler32__hasher__struct {
|
||||
} private_impl;
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if (__cplusplus >= 201103L)
|
||||
#if defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
|
||||
using unique_ptr = std::unique_ptr<wuffs_adler32__hasher, decltype(&free)>;
|
||||
|
||||
// On failure, the alloc_etc functions return nullptr. They don't throw.
|
||||
@@ -5771,7 +5772,7 @@ struct wuffs_adler32__hasher__struct {
|
||||
return wuffs_base__hasher_u32::unique_ptr(
|
||||
wuffs_adler32__hasher__alloc_as__wuffs_base__hasher_u32(), &free);
|
||||
}
|
||||
#endif // (__cplusplus >= 201103L)
|
||||
#endif // defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
|
||||
|
||||
#if (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)
|
||||
// Disallow constructing or copying an object via standard C++ mechanisms,
|
||||
@@ -6038,7 +6039,7 @@ struct wuffs_bmp__decoder__struct {
|
||||
} private_data;
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if (__cplusplus >= 201103L)
|
||||
#if defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
|
||||
using unique_ptr = std::unique_ptr<wuffs_bmp__decoder, decltype(&free)>;
|
||||
|
||||
// On failure, the alloc_etc functions return nullptr. They don't throw.
|
||||
@@ -6053,7 +6054,7 @@ struct wuffs_bmp__decoder__struct {
|
||||
return wuffs_base__image_decoder::unique_ptr(
|
||||
wuffs_bmp__decoder__alloc_as__wuffs_base__image_decoder(), &free);
|
||||
}
|
||||
#endif // (__cplusplus >= 201103L)
|
||||
#endif // defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
|
||||
|
||||
#if (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)
|
||||
// Disallow constructing or copying an object via standard C++ mechanisms,
|
||||
@@ -6320,7 +6321,7 @@ struct wuffs_cbor__decoder__struct {
|
||||
} private_data;
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if (__cplusplus >= 201103L)
|
||||
#if defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
|
||||
using unique_ptr = std::unique_ptr<wuffs_cbor__decoder, decltype(&free)>;
|
||||
|
||||
// On failure, the alloc_etc functions return nullptr. They don't throw.
|
||||
@@ -6335,7 +6336,7 @@ struct wuffs_cbor__decoder__struct {
|
||||
return wuffs_base__token_decoder::unique_ptr(
|
||||
wuffs_cbor__decoder__alloc_as__wuffs_base__token_decoder(), &free);
|
||||
}
|
||||
#endif // (__cplusplus >= 201103L)
|
||||
#endif // defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
|
||||
|
||||
#if (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)
|
||||
// Disallow constructing or copying an object via standard C++ mechanisms,
|
||||
@@ -6506,7 +6507,7 @@ struct wuffs_crc32__ieee_hasher__struct {
|
||||
} private_impl;
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if (__cplusplus >= 201103L)
|
||||
#if defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
|
||||
using unique_ptr = std::unique_ptr<wuffs_crc32__ieee_hasher, decltype(&free)>;
|
||||
|
||||
// On failure, the alloc_etc functions return nullptr. They don't throw.
|
||||
@@ -6521,7 +6522,7 @@ struct wuffs_crc32__ieee_hasher__struct {
|
||||
return wuffs_base__hasher_u32::unique_ptr(
|
||||
wuffs_crc32__ieee_hasher__alloc_as__wuffs_base__hasher_u32(), &free);
|
||||
}
|
||||
#endif // (__cplusplus >= 201103L)
|
||||
#endif // defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
|
||||
|
||||
#if (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)
|
||||
// Disallow constructing or copying an object via standard C++ mechanisms,
|
||||
@@ -6760,7 +6761,7 @@ struct wuffs_deflate__decoder__struct {
|
||||
} private_data;
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if (__cplusplus >= 201103L)
|
||||
#if defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
|
||||
using unique_ptr = std::unique_ptr<wuffs_deflate__decoder, decltype(&free)>;
|
||||
|
||||
// On failure, the alloc_etc functions return nullptr. They don't throw.
|
||||
@@ -6775,7 +6776,7 @@ struct wuffs_deflate__decoder__struct {
|
||||
return wuffs_base__io_transformer::unique_ptr(
|
||||
wuffs_deflate__decoder__alloc_as__wuffs_base__io_transformer(), &free);
|
||||
}
|
||||
#endif // (__cplusplus >= 201103L)
|
||||
#endif // defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
|
||||
|
||||
#if (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)
|
||||
// Disallow constructing or copying an object via standard C++ mechanisms,
|
||||
@@ -6988,7 +6989,7 @@ struct wuffs_lzw__decoder__struct {
|
||||
} private_data;
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if (__cplusplus >= 201103L)
|
||||
#if defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
|
||||
using unique_ptr = std::unique_ptr<wuffs_lzw__decoder, decltype(&free)>;
|
||||
|
||||
// On failure, the alloc_etc functions return nullptr. They don't throw.
|
||||
@@ -7003,7 +7004,7 @@ struct wuffs_lzw__decoder__struct {
|
||||
return wuffs_base__io_transformer::unique_ptr(
|
||||
wuffs_lzw__decoder__alloc_as__wuffs_base__io_transformer(), &free);
|
||||
}
|
||||
#endif // (__cplusplus >= 201103L)
|
||||
#endif // defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
|
||||
|
||||
#if (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)
|
||||
// Disallow constructing or copying an object via standard C++ mechanisms,
|
||||
@@ -7364,7 +7365,7 @@ struct wuffs_gif__decoder__struct {
|
||||
} private_data;
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if (__cplusplus >= 201103L)
|
||||
#if defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
|
||||
using unique_ptr = std::unique_ptr<wuffs_gif__decoder, decltype(&free)>;
|
||||
|
||||
// On failure, the alloc_etc functions return nullptr. They don't throw.
|
||||
@@ -7379,7 +7380,7 @@ struct wuffs_gif__decoder__struct {
|
||||
return wuffs_base__image_decoder::unique_ptr(
|
||||
wuffs_gif__decoder__alloc_as__wuffs_base__image_decoder(), &free);
|
||||
}
|
||||
#endif // (__cplusplus >= 201103L)
|
||||
#endif // defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
|
||||
|
||||
#if (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)
|
||||
// Disallow constructing or copying an object via standard C++ mechanisms,
|
||||
@@ -7632,7 +7633,7 @@ struct wuffs_gzip__decoder__struct {
|
||||
} private_data;
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if (__cplusplus >= 201103L)
|
||||
#if defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
|
||||
using unique_ptr = std::unique_ptr<wuffs_gzip__decoder, decltype(&free)>;
|
||||
|
||||
// On failure, the alloc_etc functions return nullptr. They don't throw.
|
||||
@@ -7647,7 +7648,7 @@ struct wuffs_gzip__decoder__struct {
|
||||
return wuffs_base__io_transformer::unique_ptr(
|
||||
wuffs_gzip__decoder__alloc_as__wuffs_base__io_transformer(), &free);
|
||||
}
|
||||
#endif // (__cplusplus >= 201103L)
|
||||
#endif // defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
|
||||
|
||||
#if (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)
|
||||
// Disallow constructing or copying an object via standard C++ mechanisms,
|
||||
@@ -7901,7 +7902,7 @@ struct wuffs_json__decoder__struct {
|
||||
} private_data;
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if (__cplusplus >= 201103L)
|
||||
#if defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
|
||||
using unique_ptr = std::unique_ptr<wuffs_json__decoder, decltype(&free)>;
|
||||
|
||||
// On failure, the alloc_etc functions return nullptr. They don't throw.
|
||||
@@ -7916,7 +7917,7 @@ struct wuffs_json__decoder__struct {
|
||||
return wuffs_base__token_decoder::unique_ptr(
|
||||
wuffs_json__decoder__alloc_as__wuffs_base__token_decoder(), &free);
|
||||
}
|
||||
#endif // (__cplusplus >= 201103L)
|
||||
#endif // defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
|
||||
|
||||
#if (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)
|
||||
// Disallow constructing or copying an object via standard C++ mechanisms,
|
||||
@@ -8159,7 +8160,7 @@ struct wuffs_nie__decoder__struct {
|
||||
} private_data;
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if (__cplusplus >= 201103L)
|
||||
#if defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
|
||||
using unique_ptr = std::unique_ptr<wuffs_nie__decoder, decltype(&free)>;
|
||||
|
||||
// On failure, the alloc_etc functions return nullptr. They don't throw.
|
||||
@@ -8174,7 +8175,7 @@ struct wuffs_nie__decoder__struct {
|
||||
return wuffs_base__image_decoder::unique_ptr(
|
||||
wuffs_nie__decoder__alloc_as__wuffs_base__image_decoder(), &free);
|
||||
}
|
||||
#endif // (__cplusplus >= 201103L)
|
||||
#endif // defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
|
||||
|
||||
#if (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)
|
||||
// Disallow constructing or copying an object via standard C++ mechanisms,
|
||||
@@ -8442,7 +8443,7 @@ struct wuffs_zlib__decoder__struct {
|
||||
} private_data;
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if (__cplusplus >= 201103L)
|
||||
#if defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
|
||||
using unique_ptr = std::unique_ptr<wuffs_zlib__decoder, decltype(&free)>;
|
||||
|
||||
// On failure, the alloc_etc functions return nullptr. They don't throw.
|
||||
@@ -8457,7 +8458,7 @@ struct wuffs_zlib__decoder__struct {
|
||||
return wuffs_base__io_transformer::unique_ptr(
|
||||
wuffs_zlib__decoder__alloc_as__wuffs_base__io_transformer(), &free);
|
||||
}
|
||||
#endif // (__cplusplus >= 201103L)
|
||||
#endif // defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
|
||||
|
||||
#if (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)
|
||||
// Disallow constructing or copying an object via standard C++ mechanisms,
|
||||
@@ -8774,7 +8775,7 @@ struct wuffs_png__decoder__struct {
|
||||
} private_data;
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if (__cplusplus >= 201103L)
|
||||
#if defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
|
||||
using unique_ptr = std::unique_ptr<wuffs_png__decoder, decltype(&free)>;
|
||||
|
||||
// On failure, the alloc_etc functions return nullptr. They don't throw.
|
||||
@@ -8789,7 +8790,7 @@ struct wuffs_png__decoder__struct {
|
||||
return wuffs_base__image_decoder::unique_ptr(
|
||||
wuffs_png__decoder__alloc_as__wuffs_base__image_decoder(), &free);
|
||||
}
|
||||
#endif // (__cplusplus >= 201103L)
|
||||
#endif // defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
|
||||
|
||||
#if (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)
|
||||
// Disallow constructing or copying an object via standard C++ mechanisms,
|
||||
@@ -9095,7 +9096,7 @@ struct wuffs_wbmp__decoder__struct {
|
||||
} private_data;
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if (__cplusplus >= 201103L)
|
||||
#if defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
|
||||
using unique_ptr = std::unique_ptr<wuffs_wbmp__decoder, decltype(&free)>;
|
||||
|
||||
// On failure, the alloc_etc functions return nullptr. They don't throw.
|
||||
@@ -9110,7 +9111,7 @@ struct wuffs_wbmp__decoder__struct {
|
||||
return wuffs_base__image_decoder::unique_ptr(
|
||||
wuffs_wbmp__decoder__alloc_as__wuffs_base__image_decoder(), &free);
|
||||
}
|
||||
#endif // (__cplusplus >= 201103L)
|
||||
#endif // defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
|
||||
|
||||
#if (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)
|
||||
// Disallow constructing or copying an object via standard C++ mechanisms,
|
||||
|
||||
Reference in new issue
Block a user