summaryrefslogtreecommitdiff
path: root/src/io
diff options
context:
space:
mode:
authorBen Longbons <b.r.longbons@gmail.com>2014-03-15 19:34:59 -0700
committerBen Longbons <b.r.longbons@gmail.com>2014-03-16 18:58:48 -0700
commitc812c92d1a1835f0bda783e709481188c8d92225 (patch)
treeb401ede48a088ad1aaed88fe3b997cd26ff7ae08 /src/io
parentde9ee1b9754af9d954487121947352f32d7ebb7e (diff)
downloadtmwa-c812c92d1a1835f0bda783e709481188c8d92225.tar.gz
tmwa-c812c92d1a1835f0bda783e709481188c8d92225.tar.bz2
tmwa-c812c92d1a1835f0bda783e709481188c8d92225.tar.xz
tmwa-c812c92d1a1835f0bda783e709481188c8d92225.zip
Clean up header organization
Diffstat (limited to 'src/io')
-rw-r--r--src/io/cxxstdio.cpp2
-rw-r--r--src/io/cxxstdio.hpp61
-rw-r--r--src/io/fd.cpp1
-rw-r--r--src/io/fd.hpp2
-rw-r--r--src/io/fwd.hpp2
-rw-r--r--src/io/line.hpp2
-rw-r--r--src/io/read.hpp2
-rw-r--r--src/io/tty.cpp2
-rw-r--r--src/io/tty.hpp2
-rw-r--r--src/io/write.hpp2
10 files changed, 40 insertions, 38 deletions
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 <cstdarg>
# include <cstdio>
-// 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<format_impl>::print(out, ## __VA_ARGS__); \
- }/*()*/)
+# define XPRINTF(out, fmt, ...) \
+ ({ \
+ struct format_impl \
+ { \
+ constexpr static \
+ const char *print_format() { return fmt; } \
+ }; \
+ cxxstdio::PrintFormatter<format_impl>::print(out, ## __VA_ARGS__); \
+ })
-# define XSCANF(out, fmt, ...) \
- (/*[&]() -> int*/ \
- { \
- struct format_impl \
- { \
- constexpr static \
- const char *scan_format() { return fmt; } \
- }; \
- /*return*/ cxxstdio::ScanFormatter<format_impl>::scan(out, ## __VA_ARGS__); \
- }/*()*/)
+# define XSCANF(out, fmt, ...) \
+ ({ \
+ struct format_impl \
+ { \
+ constexpr static \
+ const char *scan_format() { return fmt; } \
+ }; \
+ cxxstdio::ScanFormatter<format_impl>::scan(out, ## __VA_ARGS__); \
+ })
# define FPRINTF(file, fmt, ...) XPRINTF(/*no_cast<FILE *>*/(file), fmt, ## __VA_ARGS__)
# define FSCANF(file, fmt, ...) XSCANF(no_cast<FILE *>(file), fmt, ## __VA_ARGS__)
@@ -241,23 +240,21 @@ namespace cxxstdio
# define SPRINTF(str, fmt, ...) XPRINTF(base_cast<AString&>(str), fmt, ## __VA_ARGS__)
# define SNPRINTF(str, n, fmt, ...) XPRINTF(base_cast<VString<n-1>&>(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<ZString>(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<n - 1>*/ \
- { \
+ ({ \
VString<n - 1> _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 <http://www.gnu.org/licenses/>.
+#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