diff --git a/cmd/wuffs-c/internal/cgen/cgen.go b/cmd/wuffs-c/internal/cgen/cgen.go index 8b76b16e..def9a777 100644 --- a/cmd/wuffs-c/internal/cgen/cgen.go +++ b/cmd/wuffs-c/internal/cgen/cgen.go @@ -476,14 +476,15 @@ func (g *gen) genHeader(b *buffer) error { b.writes("// These structs' fields, and the sizeof them, are private implementation\n") b.writes("// details that aren't guaranteed to be stable across Wuffs versions.\n") b.writes("//\n") - b.writes("// See https://en.wikipedia.org/wiki/Opaque_pointer#C\n") - b.writex(wiStart) + b.writes("// See https://en.wikipedia.org/wiki/Opaque_pointer#C\n\n") + b.writes("#if defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)\n\n") + for _, n := range g.structList { if err := g.writeStruct(b, n); err != nil { return err } } - b.writex(wiEnd) + b.writes("#endif // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)\n") b.writes("\n#ifdef __cplusplus\n} // extern \"C\"\n#endif\n\n") return nil @@ -700,16 +701,14 @@ func (g *gen) writeConstList(b *buffer, n *a.Expr) error { return nil } -func (g *gen) writeStruct(b *buffer, n *a.Struct) error { - structName := n.QID().Str(g.tm) - b.printf("struct %s%s__struct {\n", g.pkgPrefix, structName) +func (g *gen) writeStructPrivateImpl(b *buffer, n *a.Struct) error { b.writes("// Do not access the private_impl's fields directly. There is no API/ABI\n") b.writes("// compatibility or safety guarantee if you do so. Instead, use the\n") - b.printf("// %s%s__etc functions.\n", g.pkgPrefix, structName) + b.writes("// wuffs_foo__bar__baz functions.\n") b.writes("//\n") - b.writes("// In C++, these fields would be \"private\", but C does not support that.\n") - b.writes("//\n") - b.writes("// It is a struct, not a struct*, so that it can be stack allocated.\n") + b.writes("// It is a struct, not a struct*, so that the outermost wuffs_foo__bar\n") + b.writes("// struct can be stack allocated when WUFFS_IMPLEMENTATION is defined.\n") + b.writes("struct {\n") if n.Classy() { b.writes("uint32_t magic;\n") @@ -756,6 +755,34 @@ func (g *gen) writeStruct(b *buffer, n *a.Struct) error { } } b.writes("} private_impl;\n\n") + return nil +} + +func (g *gen) writeStruct(b *buffer, n *a.Struct) error { + structName := n.QID().Str(g.tm) + fullStructName := g.pkgPrefix + structName + "__struct" + b.printf("struct %s {\n", fullStructName) + + b.writex(wiStart) + if err := g.writeStructPrivateImpl(b, n); err != nil { + return err + } + + b.writex(wiElse) + b.writes("// When WUFFS_IMPLEMENTATION is not defined, this placeholder private_impl is\n") + b.writes("// large enough to discourage trying to allocate one on the stack. The sizeof\n") + b.writes("// the real private_impl (and the sizeof the real outermost wuffs_foo__bar\n") + b.writes("// struct) is not part of the public, stable, memory-safe API. Call\n") + b.writes("// wuffs_foo__bar__baz methods (which all take a \"this\"-like pointer as their\n") + b.writes("// first argument) instead of fiddling with bar.private_impl.qux fields.\n") + b.writes("//\n") + b.writes("// Even when WUFFS_IMPLEMENTATION is not defined, the outermost struct still\n") + b.writes("// defines C++ convenience methods. These methods forward on \"this\", so that\n") + b.writes("// you can write \"bar->baz(etc)\" instead of \"wuffs_foo__bar__baz(bar, etc)\".\n") + b.writes("struct {\n") + b.writes("uint8_t placeholder[1073741824]; // 1 GiB.\n") + b.writes("} private_impl;\n\n") + b.writex(wiEnd) if n.AsNode().AsRaw().Flags()&a.FlagsPublic != 0 { if err := g.writeCppMethods(b, n); err != nil { @@ -763,14 +790,15 @@ func (g *gen) writeStruct(b *buffer, n *a.Struct) error { } } - b.printf("}; // struct %s%s__struct\n\n", g.pkgPrefix, structName) + b.printf("}; // struct %s\n\n", fullStructName) return nil } func (g *gen) writeCppMethods(b *buffer, n *a.Struct) error { structName := n.QID().Str(g.tm) - + fullStructName := g.pkgPrefix + structName + "__struct" b.writes("#ifdef __cplusplus\n\n") + // The empty // comment makes clang-format place the function name // at the start of a line. b.writes("inline wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT //\n" + @@ -805,6 +833,12 @@ func (g *gen) writeCppMethods(b *buffer, n *a.Struct) error { } } + b.writes("#if (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)\n") + b.writes("// Disallow copy and assign.\n") + b.printf("%s(const %s&) = delete;\n", fullStructName, fullStructName) + b.printf("%s& operator=(const %s&) = delete;\n", fullStructName, fullStructName) + b.writes("#endif // (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)\n\n") + b.writes("#endif // __cplusplus\n\n") return nil } @@ -812,6 +846,7 @@ func (g *gen) writeCppMethods(b *buffer, n *a.Struct) error { var ( wiStartImpl = []byte("\n// WUFFS C HEADER ENDS HERE.\n#ifdef WUFFS_IMPLEMENTATION\n\n") wiStart = []byte("\n#ifdef WUFFS_IMPLEMENTATION\n\n") + wiElse = []byte("\n#else // WUFFS_IMPLEMENTATION\n\n") wiEnd = []byte("\n#endif // WUFFS_IMPLEMENTATION\n\n") ) diff --git a/release/c/wuffs-unsupported-snapshot.c b/release/c/wuffs-unsupported-snapshot.c index 8fdd0d61..0584956a 100644 --- a/release/c/wuffs-unsupported-snapshot.c +++ b/release/c/wuffs-unsupported-snapshot.c @@ -2297,16 +2297,17 @@ wuffs_adler32__hasher__update(wuffs_adler32__hasher* self, // // See https://en.wikipedia.org/wiki/Opaque_pointer#C -#ifdef WUFFS_IMPLEMENTATION +#if defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION) struct wuffs_adler32__hasher__struct { +#ifdef WUFFS_IMPLEMENTATION + // Do not access the private_impl's fields directly. There is no API/ABI // compatibility or safety guarantee if you do so. Instead, use the - // wuffs_adler32__hasher__etc functions. + // wuffs_foo__bar__baz functions. // - // In C++, these fields would be "private", but C does not support that. - // - // It is a struct, not a struct*, so that it can be stack allocated. + // It is a struct, not a struct*, so that the outermost wuffs_foo__bar + // struct can be stack allocated when WUFFS_IMPLEMENTATION is defined. struct { uint32_t magic; @@ -2315,6 +2316,24 @@ struct wuffs_adler32__hasher__struct { } private_impl; +#else // WUFFS_IMPLEMENTATION + + // When WUFFS_IMPLEMENTATION is not defined, this placeholder private_impl is + // large enough to discourage trying to allocate one on the stack. The sizeof + // the real private_impl (and the sizeof the real outermost wuffs_foo__bar + // struct) is not part of the public, stable, memory-safe API. Call + // wuffs_foo__bar__baz methods (which all take a "this"-like pointer as their + // first argument) instead of fiddling with bar.private_impl.qux fields. + // + // Even when WUFFS_IMPLEMENTATION is not defined, the outermost struct still + // defines C++ convenience methods. These methods forward on "this", so that + // you can write "bar->baz(etc)" instead of "wuffs_foo__bar__baz(bar, etc)". + struct { + uint8_t placeholder[1073741824]; // 1 GiB. + } private_impl; + +#endif // WUFFS_IMPLEMENTATION + #ifdef __cplusplus inline wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT // @@ -2328,11 +2347,18 @@ struct wuffs_adler32__hasher__struct { return wuffs_adler32__hasher__update(this, a_x); } +#if (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION) + // Disallow copy and assign. + wuffs_adler32__hasher__struct(const wuffs_adler32__hasher__struct&) = delete; + wuffs_adler32__hasher__struct& operator=( + const wuffs_adler32__hasher__struct&) = delete; +#endif // (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION) + #endif // __cplusplus }; // struct wuffs_adler32__hasher__struct -#endif // WUFFS_IMPLEMENTATION +#endif // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION) #ifdef __cplusplus } // extern "C" @@ -2378,16 +2404,17 @@ wuffs_crc32__ieee_hasher__update(wuffs_crc32__ieee_hasher* self, // // See https://en.wikipedia.org/wiki/Opaque_pointer#C -#ifdef WUFFS_IMPLEMENTATION +#if defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION) struct wuffs_crc32__ieee_hasher__struct { +#ifdef WUFFS_IMPLEMENTATION + // Do not access the private_impl's fields directly. There is no API/ABI // compatibility or safety guarantee if you do so. Instead, use the - // wuffs_crc32__ieee_hasher__etc functions. + // wuffs_foo__bar__baz functions. // - // In C++, these fields would be "private", but C does not support that. - // - // It is a struct, not a struct*, so that it can be stack allocated. + // It is a struct, not a struct*, so that the outermost wuffs_foo__bar + // struct can be stack allocated when WUFFS_IMPLEMENTATION is defined. struct { uint32_t magic; @@ -2395,6 +2422,24 @@ struct wuffs_crc32__ieee_hasher__struct { } private_impl; +#else // WUFFS_IMPLEMENTATION + + // When WUFFS_IMPLEMENTATION is not defined, this placeholder private_impl is + // large enough to discourage trying to allocate one on the stack. The sizeof + // the real private_impl (and the sizeof the real outermost wuffs_foo__bar + // struct) is not part of the public, stable, memory-safe API. Call + // wuffs_foo__bar__baz methods (which all take a "this"-like pointer as their + // first argument) instead of fiddling with bar.private_impl.qux fields. + // + // Even when WUFFS_IMPLEMENTATION is not defined, the outermost struct still + // defines C++ convenience methods. These methods forward on "this", so that + // you can write "bar->baz(etc)" instead of "wuffs_foo__bar__baz(bar, etc)". + struct { + uint8_t placeholder[1073741824]; // 1 GiB. + } private_impl; + +#endif // WUFFS_IMPLEMENTATION + #ifdef __cplusplus inline wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT // @@ -2408,11 +2453,19 @@ struct wuffs_crc32__ieee_hasher__struct { return wuffs_crc32__ieee_hasher__update(this, a_x); } +#if (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION) + // Disallow copy and assign. + wuffs_crc32__ieee_hasher__struct(const wuffs_crc32__ieee_hasher__struct&) = + delete; + wuffs_crc32__ieee_hasher__struct& operator=( + const wuffs_crc32__ieee_hasher__struct&) = delete; +#endif // (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION) + #endif // __cplusplus }; // struct wuffs_crc32__ieee_hasher__struct -#endif // WUFFS_IMPLEMENTATION +#endif // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION) #ifdef __cplusplus } // extern "C" @@ -2473,16 +2526,17 @@ wuffs_deflate__decoder__decode_io_writer(wuffs_deflate__decoder* self, // // See https://en.wikipedia.org/wiki/Opaque_pointer#C -#ifdef WUFFS_IMPLEMENTATION +#if defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION) struct wuffs_deflate__decoder__struct { +#ifdef WUFFS_IMPLEMENTATION + // Do not access the private_impl's fields directly. There is no API/ABI // compatibility or safety guarantee if you do so. Instead, use the - // wuffs_deflate__decoder__etc functions. + // wuffs_foo__bar__baz functions. // - // In C++, these fields would be "private", but C does not support that. - // - // It is a struct, not a struct*, so that it can be stack allocated. + // It is a struct, not a struct*, so that the outermost wuffs_foo__bar + // struct can be stack allocated when WUFFS_IMPLEMENTATION is defined. struct { uint32_t magic; @@ -2538,6 +2592,24 @@ struct wuffs_deflate__decoder__struct { } c_decode_huffman_slow[1]; } private_impl; +#else // WUFFS_IMPLEMENTATION + + // When WUFFS_IMPLEMENTATION is not defined, this placeholder private_impl is + // large enough to discourage trying to allocate one on the stack. The sizeof + // the real private_impl (and the sizeof the real outermost wuffs_foo__bar + // struct) is not part of the public, stable, memory-safe API. Call + // wuffs_foo__bar__baz methods (which all take a "this"-like pointer as their + // first argument) instead of fiddling with bar.private_impl.qux fields. + // + // Even when WUFFS_IMPLEMENTATION is not defined, the outermost struct still + // defines C++ convenience methods. These methods forward on "this", so that + // you can write "bar->baz(etc)" instead of "wuffs_foo__bar__baz(bar, etc)". + struct { + uint8_t placeholder[1073741824]; // 1 GiB. + } private_impl; + +#endif // WUFFS_IMPLEMENTATION + #ifdef __cplusplus inline wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT // @@ -2551,11 +2623,19 @@ struct wuffs_deflate__decoder__struct { return wuffs_deflate__decoder__decode_io_writer(this, a_dst, a_src); } +#if (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION) + // Disallow copy and assign. + wuffs_deflate__decoder__struct(const wuffs_deflate__decoder__struct&) = + delete; + wuffs_deflate__decoder__struct& operator=( + const wuffs_deflate__decoder__struct&) = delete; +#endif // (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION) + #endif // __cplusplus }; // struct wuffs_deflate__decoder__struct -#endif // WUFFS_IMPLEMENTATION +#endif // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION) #ifdef __cplusplus } // extern "C" @@ -2610,16 +2690,17 @@ wuffs_lzw__decoder__flush(wuffs_lzw__decoder* self); // // See https://en.wikipedia.org/wiki/Opaque_pointer#C -#ifdef WUFFS_IMPLEMENTATION +#if defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION) struct wuffs_lzw__decoder__struct { +#ifdef WUFFS_IMPLEMENTATION + // Do not access the private_impl's fields directly. There is no API/ABI // compatibility or safety guarantee if you do so. Instead, use the - // wuffs_lzw__decoder__etc functions. + // wuffs_foo__bar__baz functions. // - // In C++, these fields would be "private", but C does not support that. - // - // It is a struct, not a struct*, so that it can be stack allocated. + // It is a struct, not a struct*, so that the outermost wuffs_foo__bar + // struct can be stack allocated when WUFFS_IMPLEMENTATION is defined. struct { uint32_t magic; @@ -2648,6 +2729,24 @@ struct wuffs_lzw__decoder__struct { } c_write_to[1]; } private_impl; +#else // WUFFS_IMPLEMENTATION + + // When WUFFS_IMPLEMENTATION is not defined, this placeholder private_impl is + // large enough to discourage trying to allocate one on the stack. The sizeof + // the real private_impl (and the sizeof the real outermost wuffs_foo__bar + // struct) is not part of the public, stable, memory-safe API. Call + // wuffs_foo__bar__baz methods (which all take a "this"-like pointer as their + // first argument) instead of fiddling with bar.private_impl.qux fields. + // + // Even when WUFFS_IMPLEMENTATION is not defined, the outermost struct still + // defines C++ convenience methods. These methods forward on "this", so that + // you can write "bar->baz(etc)" instead of "wuffs_foo__bar__baz(bar, etc)". + struct { + uint8_t placeholder[1073741824]; // 1 GiB. + } private_impl; + +#endif // WUFFS_IMPLEMENTATION + #ifdef __cplusplus inline wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT // @@ -2671,11 +2770,18 @@ struct wuffs_lzw__decoder__struct { return wuffs_lzw__decoder__flush(this); } +#if (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION) + // Disallow copy and assign. + wuffs_lzw__decoder__struct(const wuffs_lzw__decoder__struct&) = delete; + wuffs_lzw__decoder__struct& operator=(const wuffs_lzw__decoder__struct&) = + delete; +#endif // (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION) + #endif // __cplusplus }; // struct wuffs_lzw__decoder__struct -#endif // WUFFS_IMPLEMENTATION +#endif // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION) #ifdef __cplusplus } // extern "C" @@ -2762,16 +2868,17 @@ wuffs_gif__decoder__decode_frame(wuffs_gif__decoder* self, // // See https://en.wikipedia.org/wiki/Opaque_pointer#C -#ifdef WUFFS_IMPLEMENTATION +#if defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION) struct wuffs_gif__decoder__struct { +#ifdef WUFFS_IMPLEMENTATION + // Do not access the private_impl's fields directly. There is no API/ABI // compatibility or safety guarantee if you do so. Instead, use the - // wuffs_gif__decoder__etc functions. + // wuffs_foo__bar__baz functions. // - // In C++, these fields would be "private", but C does not support that. - // - // It is a struct, not a struct*, so that it can be stack allocated. + // It is a struct, not a struct*, so that the outermost wuffs_foo__bar + // struct can be stack allocated when WUFFS_IMPLEMENTATION is defined. struct { uint32_t magic; @@ -2874,6 +2981,24 @@ struct wuffs_gif__decoder__struct { } c_decode_id_part2[1]; } private_impl; +#else // WUFFS_IMPLEMENTATION + + // When WUFFS_IMPLEMENTATION is not defined, this placeholder private_impl is + // large enough to discourage trying to allocate one on the stack. The sizeof + // the real private_impl (and the sizeof the real outermost wuffs_foo__bar + // struct) is not part of the public, stable, memory-safe API. Call + // wuffs_foo__bar__baz methods (which all take a "this"-like pointer as their + // first argument) instead of fiddling with bar.private_impl.qux fields. + // + // Even when WUFFS_IMPLEMENTATION is not defined, the outermost struct still + // defines C++ convenience methods. These methods forward on "this", so that + // you can write "bar->baz(etc)" instead of "wuffs_foo__bar__baz(bar, etc)". + struct { + uint8_t placeholder[1073741824]; // 1 GiB. + } private_impl; + +#endif // WUFFS_IMPLEMENTATION + #ifdef __cplusplus inline wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT // @@ -2933,11 +3058,18 @@ struct wuffs_gif__decoder__struct { a_opts); } +#if (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION) + // Disallow copy and assign. + wuffs_gif__decoder__struct(const wuffs_gif__decoder__struct&) = delete; + wuffs_gif__decoder__struct& operator=(const wuffs_gif__decoder__struct&) = + delete; +#endif // (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION) + #endif // __cplusplus }; // struct wuffs_gif__decoder__struct -#endif // WUFFS_IMPLEMENTATION +#endif // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION) #ifdef __cplusplus } // extern "C" @@ -2992,16 +3124,17 @@ wuffs_gzip__decoder__decode_io_writer(wuffs_gzip__decoder* self, // // See https://en.wikipedia.org/wiki/Opaque_pointer#C -#ifdef WUFFS_IMPLEMENTATION +#if defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION) struct wuffs_gzip__decoder__struct { +#ifdef WUFFS_IMPLEMENTATION + // Do not access the private_impl's fields directly. There is no API/ABI // compatibility or safety guarantee if you do so. Instead, use the - // wuffs_gzip__decoder__etc functions. + // wuffs_foo__bar__baz functions. // - // In C++, these fields would be "private", but C does not support that. - // - // It is a struct, not a struct*, so that it can be stack allocated. + // It is a struct, not a struct*, so that the outermost wuffs_foo__bar + // struct can be stack allocated when WUFFS_IMPLEMENTATION is defined. struct { uint32_t magic; @@ -3019,6 +3152,24 @@ struct wuffs_gzip__decoder__struct { } c_decode_io_writer[1]; } private_impl; +#else // WUFFS_IMPLEMENTATION + + // When WUFFS_IMPLEMENTATION is not defined, this placeholder private_impl is + // large enough to discourage trying to allocate one on the stack. The sizeof + // the real private_impl (and the sizeof the real outermost wuffs_foo__bar + // struct) is not part of the public, stable, memory-safe API. Call + // wuffs_foo__bar__baz methods (which all take a "this"-like pointer as their + // first argument) instead of fiddling with bar.private_impl.qux fields. + // + // Even when WUFFS_IMPLEMENTATION is not defined, the outermost struct still + // defines C++ convenience methods. These methods forward on "this", so that + // you can write "bar->baz(etc)" instead of "wuffs_foo__bar__baz(bar, etc)". + struct { + uint8_t placeholder[1073741824]; // 1 GiB. + } private_impl; + +#endif // WUFFS_IMPLEMENTATION + #ifdef __cplusplus inline wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT // @@ -3037,11 +3188,18 @@ struct wuffs_gzip__decoder__struct { return wuffs_gzip__decoder__decode_io_writer(this, a_dst, a_src); } +#if (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION) + // Disallow copy and assign. + wuffs_gzip__decoder__struct(const wuffs_gzip__decoder__struct&) = delete; + wuffs_gzip__decoder__struct& operator=(const wuffs_gzip__decoder__struct&) = + delete; +#endif // (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION) + #endif // __cplusplus }; // struct wuffs_gzip__decoder__struct -#endif // WUFFS_IMPLEMENTATION +#endif // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION) #ifdef __cplusplus } // extern "C" @@ -3096,16 +3254,17 @@ wuffs_zlib__decoder__decode_io_writer(wuffs_zlib__decoder* self, // // See https://en.wikipedia.org/wiki/Opaque_pointer#C -#ifdef WUFFS_IMPLEMENTATION +#if defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION) struct wuffs_zlib__decoder__struct { +#ifdef WUFFS_IMPLEMENTATION + // Do not access the private_impl's fields directly. There is no API/ABI // compatibility or safety guarantee if you do so. Instead, use the - // wuffs_zlib__decoder__etc functions. + // wuffs_foo__bar__baz functions. // - // In C++, these fields would be "private", but C does not support that. - // - // It is a struct, not a struct*, so that it can be stack allocated. + // It is a struct, not a struct*, so that the outermost wuffs_foo__bar + // struct can be stack allocated when WUFFS_IMPLEMENTATION is defined. struct { uint32_t magic; @@ -3120,6 +3279,24 @@ struct wuffs_zlib__decoder__struct { } c_decode_io_writer[1]; } private_impl; +#else // WUFFS_IMPLEMENTATION + + // When WUFFS_IMPLEMENTATION is not defined, this placeholder private_impl is + // large enough to discourage trying to allocate one on the stack. The sizeof + // the real private_impl (and the sizeof the real outermost wuffs_foo__bar + // struct) is not part of the public, stable, memory-safe API. Call + // wuffs_foo__bar__baz methods (which all take a "this"-like pointer as their + // first argument) instead of fiddling with bar.private_impl.qux fields. + // + // Even when WUFFS_IMPLEMENTATION is not defined, the outermost struct still + // defines C++ convenience methods. These methods forward on "this", so that + // you can write "bar->baz(etc)" instead of "wuffs_foo__bar__baz(bar, etc)". + struct { + uint8_t placeholder[1073741824]; // 1 GiB. + } private_impl; + +#endif // WUFFS_IMPLEMENTATION + #ifdef __cplusplus inline wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT // @@ -3138,11 +3315,18 @@ struct wuffs_zlib__decoder__struct { return wuffs_zlib__decoder__decode_io_writer(this, a_dst, a_src); } +#if (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION) + // Disallow copy and assign. + wuffs_zlib__decoder__struct(const wuffs_zlib__decoder__struct&) = delete; + wuffs_zlib__decoder__struct& operator=(const wuffs_zlib__decoder__struct&) = + delete; +#endif // (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION) + #endif // __cplusplus }; // struct wuffs_zlib__decoder__struct -#endif // WUFFS_IMPLEMENTATION +#endif // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION) #ifdef __cplusplus } // extern "C"