From c812c92d1a1835f0bda783e709481188c8d92225 Mon Sep 17 00:00:00 2001 From: Ben Longbons Date: Sat, 15 Mar 2014 19:34:59 -0700 Subject: Clean up header organization --- src/io/cxxstdio.cpp | 2 ++ src/io/cxxstdio.hpp | 61 +++++++++++++++++++++++++---------------------------- src/io/fd.cpp | 1 + src/io/fd.hpp | 2 +- src/io/fwd.hpp | 2 +- src/io/line.hpp | 2 +- src/io/read.hpp | 2 +- src/io/tty.cpp | 2 ++ src/io/tty.hpp | 2 +- src/io/write.hpp | 2 +- 10 files changed, 40 insertions(+), 38 deletions(-) (limited to 'src/io') diff --git a/src/io/cxxstdio.cpp b/src/io/cxxstdio.cpp index 47617cb..aa603e4 100644 --- a/src/io/cxxstdio.cpp +++ b/src/io/cxxstdio.cpp @@ -1 +1,3 @@ #include "cxxstdio.hpp" + +#include "../poison.hpp" diff --git a/src/io/cxxstdio.hpp b/src/io/cxxstdio.hpp index 753a1fc..0324ebc 100644 --- a/src/io/cxxstdio.hpp +++ b/src/io/cxxstdio.hpp @@ -24,9 +24,10 @@ # include # include -// TODO get rid of these header order violations -# include "../common/const_array.hpp" -# include "../common/utils2.hpp" +# include "../compat/cast.hpp" + +# include "../generic/const_array.hpp" +# include "../generic/enum.hpp" # include "fwd.hpp" @@ -213,27 +214,25 @@ namespace cxxstdio } }; -# define XPRINTF(out, fmt, ...) \ - (/*[&]() -> int*/ \ - { \ - struct format_impl \ - { \ - constexpr static \ - const char *print_format() { return fmt; } \ - }; \ - /*return*/ cxxstdio::PrintFormatter::print(out, ## __VA_ARGS__); \ - }/*()*/) +# define XPRINTF(out, fmt, ...) \ + ({ \ + struct format_impl \ + { \ + constexpr static \ + const char *print_format() { return fmt; } \ + }; \ + cxxstdio::PrintFormatter::print(out, ## __VA_ARGS__); \ + }) -# define XSCANF(out, fmt, ...) \ - (/*[&]() -> int*/ \ - { \ - struct format_impl \ - { \ - constexpr static \ - const char *scan_format() { return fmt; } \ - }; \ - /*return*/ cxxstdio::ScanFormatter::scan(out, ## __VA_ARGS__); \ - }/*()*/) +# define XSCANF(out, fmt, ...) \ + ({ \ + struct format_impl \ + { \ + constexpr static \ + const char *scan_format() { return fmt; } \ + }; \ + cxxstdio::ScanFormatter::scan(out, ## __VA_ARGS__); \ + }) # define FPRINTF(file, fmt, ...) XPRINTF(/*no_cast*/(file), fmt, ## __VA_ARGS__) # define FSCANF(file, fmt, ...) XSCANF(no_cast(file), fmt, ## __VA_ARGS__) @@ -241,23 +240,21 @@ namespace cxxstdio # define SPRINTF(str, fmt, ...) XPRINTF(base_cast(str), fmt, ## __VA_ARGS__) # define SNPRINTF(str, n, fmt, ...) XPRINTF(base_cast&>(str), fmt, ## __VA_ARGS__) # define SCANF(fmt, ...) FSCANF(stdin, fmt, ## __VA_ARGS__) -# define SSCANF(str, fmt, ...) XSCANF(/*ZString or compatible*/str, fmt, ## __VA_ARGS__) +# define SSCANF(str, fmt, ...) XSCANF(maybe_cast(str), fmt, ## __VA_ARGS__) # define STRPRINTF(fmt, ...) \ - (/*[&]() -> AString*/ \ - { \ + ({ \ AString _out_impl; \ SPRINTF(_out_impl, fmt, ## __VA_ARGS__); \ - /*return*/ _out_impl; \ - }/*()*/) + _out_impl; \ + }) # define STRNPRINTF(n, fmt, ...) \ - (/*[&]() -> VString*/ \ - { \ + ({ \ VString _out_impl; \ SNPRINTF(_out_impl, n, fmt, ## __VA_ARGS__); \ - /*return*/ _out_impl; \ - }/*()*/) + _out_impl; \ + }) } // namespace cxxstdio diff --git a/src/io/fd.cpp b/src/io/fd.cpp index 87d3967..4fc33e9 100644 --- a/src/io/fd.cpp +++ b/src/io/fd.cpp @@ -23,6 +23,7 @@ #include "../strings/zstring.hpp" +#include "../poison.hpp" namespace io { diff --git a/src/io/fd.hpp b/src/io/fd.hpp index ca703d6..7afb40f 100644 --- a/src/io/fd.hpp +++ b/src/io/fd.hpp @@ -165,4 +165,4 @@ namespace io }; } // namespace io -#endif //TMWA_IO_FD_HPP +#endif // TMWA_IO_FD_HPP diff --git a/src/io/fwd.hpp b/src/io/fwd.hpp index 52e6d6d..1e5fa82 100644 --- a/src/io/fwd.hpp +++ b/src/io/fwd.hpp @@ -29,4 +29,4 @@ namespace io class AppendFile; } // namespace io -#endif //TMWA_IO_FWD_HPP +#endif // TMWA_IO_FWD_HPP diff --git a/src/io/line.hpp b/src/io/line.hpp index bdff1bb..321cdf7 100644 --- a/src/io/line.hpp +++ b/src/io/line.hpp @@ -94,4 +94,4 @@ namespace io }; } // namespace io -#endif //TMWA_IO_LINE_HPP +#endif // TMWA_IO_LINE_HPP diff --git a/src/io/read.hpp b/src/io/read.hpp index 2355e46..f99fb56 100644 --- a/src/io/read.hpp +++ b/src/io/read.hpp @@ -50,4 +50,4 @@ namespace io }; } // namespace io -#endif //TMWA_IO_READ_HPP +#endif // TMWA_IO_READ_HPP diff --git a/src/io/tty.cpp b/src/io/tty.cpp index d2e084e..e71ee44 100644 --- a/src/io/tty.cpp +++ b/src/io/tty.cpp @@ -18,4 +18,6 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . +#include "../poison.hpp" + /* Nothing to see here, move along */ diff --git a/src/io/tty.hpp b/src/io/tty.hpp index 86616f1..97487b8 100644 --- a/src/io/tty.hpp +++ b/src/io/tty.hpp @@ -35,4 +35,4 @@ # define SGR_RESET "\e[0m" -#endif //TMWA_IO_TTY_HPP +#endif // TMWA_IO_TTY_HPP diff --git a/src/io/write.hpp b/src/io/write.hpp index 0a238c0..870ebb5 100644 --- a/src/io/write.hpp +++ b/src/io/write.hpp @@ -66,4 +66,4 @@ namespace io int do_vprint(WriteFile& out, const char *fmt, va_list ap); } // namespace io -#endif //TMWA_IO_WRITE_HPP +#endif // TMWA_IO_WRITE_HPP -- cgit v1.2.3-70-g09d2