Add new types to be used for M_LET:
* m_serial_bin_write_t * m_serial_bin_read_t
This commit is contained in:
1 parent
100af17328
commit
daeaa242b8
2 files changed
+20
-9
No files matched your search
@@ -263,6 +263,12 @@ static inline void m_serial_bin_write_clear(m_serial_write_t serial)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Define a synonym of m_serial_read_t to the BIN serializer with its proper OPLIST */
|
||||||
|
typedef m_serial_write_t m_serial_bin_write_t;
|
||||||
|
#define M_OPL_m_serial_bin_write_t() \
|
||||||
|
(INIT_WITH(m_serial_bin_write_init), CLEAR(m_serial_bin_write_clear), TYPE(m_serial_bin_write_t) )
|
||||||
|
|
||||||
|
|
||||||
/* Read from the stream 'serial' a boolean.
|
/* Read from the stream 'serial' a boolean.
|
||||||
Set '*b' with the boolean value if succeeds
|
Set '*b' with the boolean value if succeeds
|
||||||
Return M_SERIAL_OK_DONE if it succeeds, M_SERIAL_FAIL otherwise */
|
Return M_SERIAL_OK_DONE if it succeeds, M_SERIAL_FAIL otherwise */
|
||||||
@@ -493,4 +499,9 @@ static inline void m_serial_bin_read_clear(m_serial_read_t serial)
|
|||||||
(void) serial; // Nothing to do
|
(void) serial; // Nothing to do
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Define a synonym of m_serial_read_t to the BIN serializer with its proper OPLIST */
|
||||||
|
typedef m_serial_read_t m_serial_bin_read_t;
|
||||||
|
#define M_OPL_m_serial_bin_read_t() \
|
||||||
|
(INIT_WITH(m_serial_bin_read_init), CLEAR(m_serial_bin_read_clear), TYPE(m_serial_bin_read_t) )
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -71,18 +71,18 @@ static void test_out_empty(void)
|
|||||||
|
|
||||||
FILE *f = fopen ("a-mbin.dat", "wt");
|
FILE *f = fopen ("a-mbin.dat", "wt");
|
||||||
if (!f) abort();
|
if (!f) abort();
|
||||||
m_serial_bin_write_init(out, f);
|
M_LET( (serial, f), m_serial_bin_write_t) {
|
||||||
ret = my2_out_serial(out, el1);
|
ret = my2_out_serial(out, el1);
|
||||||
assert (ret == M_SERIAL_OK_DONE);
|
assert (ret == M_SERIAL_OK_DONE);
|
||||||
m_serial_bin_write_clear(out);
|
}
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
f = fopen ("a-mbin.dat", "rt");
|
f = fopen ("a-mbin.dat", "rt");
|
||||||
if (!f) abort();
|
if (!f) abort();
|
||||||
m_serial_bin_read_init(in, f);
|
M_LET( (serial, f), m_serial_bin_read_t) {
|
||||||
ret = my2_in_serial(el2, in);
|
ret = my2_in_serial(el2, in);
|
||||||
assert (ret == M_SERIAL_OK_DONE);
|
assert (ret == M_SERIAL_OK_DONE);
|
||||||
m_serial_bin_read_clear(in);
|
}
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
assert (my2_equal_p (el1, el2));
|
assert (my2_equal_p (el1, el2));
|
||||||
@@ -142,7 +142,7 @@ static void test_out_fill(void)
|
|||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
//test_out_empty();
|
test_out_empty();
|
||||||
test_out_fill();
|
test_out_fill();
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user