Lines Matching defs:writeln
57 f.writeln("// Generated by %s:" % sys.argv[0])
58 f.writeln("//")
59 f.writeln("// %s" % ' '.join(sys.argv))
60 f.writeln("//")
61 f.writeln()
63 f.writeln("#include <stdbool.h>")
64 f.writeln("#include <stdint.h>")
65 f.writeln("#include <inttypes.h>")
66 f.writeln("#include <stdio.h>")
67 f.writeln("#include <string.h>")
68 f.writeln("#include <signal.h>")
70 f.writeln("#undef _FEATURES_H")
71 f.writeln()
74 f.writeln("__attribute__((unused))")
75 f.writeln("static void __pretty_assert_print_bool(")
76 f.writeln(" const void *v, size_t size) {")
77 f.writeln(" (void)size;")
78 f.writeln(" printf(\"%s\", *(const bool*)v ? \"true\" : \"false\");")
79 f.writeln("}")
80 f.writeln()
81 f.writeln("__attribute__((unused))")
82 f.writeln("static void __pretty_assert_print_int(")
83 f.writeln(" const void *v, size_t size) {")
84 f.writeln(" (void)size;")
85 f.writeln(" printf(\"%\"PRIiMAX, *(const intmax_t*)v);")
86 f.writeln("}")
87 f.writeln()
88 f.writeln("__attribute__((unused))")
89 f.writeln("static void __pretty_assert_print_mem(")
90 f.writeln(" const void *v, size_t size) {")
91 f.writeln(" const uint8_t *v_ = v;")
92 f.writeln(" printf(\"\\\"\");")
93 f.writeln(" for (size_t i = 0; i < size && i < %d; i++) {" % limit)
94 f.writeln(" if (v_[i] >= ' ' && v_[i] <= '~') {")
95 f.writeln(" printf(\"%c\", v_[i]);")
96 f.writeln(" } else {")
97 f.writeln(" printf(\"\\\\x%02x\", v_[i]);")
98 f.writeln(" }")
99 f.writeln(" }")
100 f.writeln(" if (size > %d) {" % limit)
101 f.writeln(" printf(\"...\");")
102 f.writeln(" }")
103 f.writeln(" printf(\"\\\"\");")
104 f.writeln("}")
105 f.writeln()
106 f.writeln("__attribute__((unused))")
107 f.writeln("static void __pretty_assert_print_str(")
108 f.writeln(" const void *v, size_t size) {")
109 f.writeln(" __pretty_assert_print_mem(v, size);")
110 f.writeln("}")
111 f.writeln()
112 f.writeln("__attribute__((unused, noinline))")
113 f.writeln("static void __pretty_assert_fail(")
114 f.writeln(" const char *file, int line,")
115 f.writeln(" void (*type_print_cb)(const void*, size_t),")
116 f.writeln(" const char *cmp,")
117 f.writeln(" const void *lh, size_t lsize,")
118 f.writeln(" const void *rh, size_t rsize) {")
119 f.writeln(" printf(\"%s:%d:assert: assert failed with \", file, line);")
120 f.writeln(" type_print_cb(lh, lsize);")
121 f.writeln(" printf(\", expected %s \", cmp);")
122 f.writeln(" type_print_cb(rh, rsize);")
123 f.writeln(" printf(\"\\n\");")
124 f.writeln(" fflush(NULL);")
125 f.writeln(" raise(SIGABRT);")
126 f.writeln("}")
127 f.writeln()
131 f.writeln("#define __PRETTY_ASSERT_BOOL_%s(lh, rh) do { \\"
133 f.writeln(" bool _lh = !!(lh); \\")
134 f.writeln(" bool _rh = !!(rh); \\")
135 f.writeln(" if (!(_lh %s _rh)) { \\" % op)
136 f.writeln(" __pretty_assert_fail( \\")
137 f.writeln(" __FILE__, __LINE__, \\")
138 f.writeln(" __pretty_assert_print_bool, \"%s\", \\"
140 f.writeln(" &_lh, 0, \\")
141 f.writeln(" &_rh, 0); \\")
142 f.writeln(" } \\")
143 f.writeln("} while (0)")
145 f.writeln("#define __PRETTY_ASSERT_INT_%s(lh, rh) do { \\"
147 f.writeln(" __typeof__(lh) _lh = lh; \\")
148 f.writeln(" __typeof__(lh) _rh = rh; \\")
149 f.writeln(" if (!(_lh %s _rh)) { \\" % op)
150 f.writeln(" __pretty_assert_fail( \\")
151 f.writeln(" __FILE__, __LINE__, \\")
152 f.writeln(" __pretty_assert_print_int, \"%s\", \\"
154 f.writeln(" &(intmax_t){_lh}, 0, \\")
155 f.writeln(" &(intmax_t){_rh}, 0); \\")
156 f.writeln(" } \\")
157 f.writeln("} while (0)")
159 f.writeln("#define __PRETTY_ASSERT_MEM_%s(lh, rh, size) do { \\"
161 f.writeln(" const void *_lh = lh; \\")
162 f.writeln(" const void *_rh = rh; \\")
163 f.writeln(" if (!(memcmp(_lh, _rh, size) %s 0)) { \\" % op)
164 f.writeln(" __pretty_assert_fail( \\")
165 f.writeln(" __FILE__, __LINE__, \\")
166 f.writeln(" __pretty_assert_print_mem, \"%s\", \\"
168 f.writeln(" _lh, size, \\")
169 f.writeln(" _rh, size); \\")
170 f.writeln(" } \\")
171 f.writeln("} while (0)")
173 f.writeln("#define __PRETTY_ASSERT_STR_%s(lh, rh) do { \\"
175 f.writeln(" const char *_lh = lh; \\")
176 f.writeln(" const char *_rh = rh; \\")
177 f.writeln(" if (!(strcmp(_lh, _rh) %s 0)) { \\" % op)
178 f.writeln(" __pretty_assert_fail( \\")
179 f.writeln(" __FILE__, __LINE__, \\")
180 f.writeln(" __pretty_assert_print_str, \"%s\", \\"
182 f.writeln(" _lh, strlen(_lh), \\")
183 f.writeln(" _rh, strlen(_rh)); \\")
184 f.writeln(" } \\")
185 f.writeln("} while (0)")
186 f.writeln()
187 f.writeln()
400 def writeln(s=''):
403 f.writeln = writeln
408 f.writeln("#line %d \"%s\"" % (1, input))