Commit 06a3e5ff authored by Niels Möller's avatar Niels Möller
Browse files

* src/sexp_commands.h (sexp_print_command): Inherit command_2.

Rev: src/sexp_commands.c:1.19
Rev: src/sexp_commands.h:1.8
parent e598b09c
...@@ -50,61 +50,41 @@ static struct read_sexp_command read_sexp; ...@@ -50,61 +50,41 @@ static struct read_sexp_command read_sexp;
* *
* Prints the sexp to tha abstract_write OUT. Returns the sexp. */ * Prints the sexp to tha abstract_write OUT. Returns the sexp. */
/* GABA:
(class
(name sexp_print_to)
(super command)
(vars
(format . int)
(dest object abstract_write)))
*/
static void static void
do_sexp_print(struct command *s, do_sexp_print(struct command_2 *s,
struct lsh_object *a, struct lsh_object *a1,
struct lsh_object *a2,
struct command_continuation *c, struct command_continuation *c,
struct exception_handler *e UNUSED) struct exception_handler *e UNUSED)
{ {
CAST(sexp_print_to, self, s); CAST(sexp_print_command, self, s);
CAST_SUBTYPE(sexp, o, a); CAST_SUBTYPE(abstract_write, dest, a1);
CAST_SUBTYPE(sexp, o, a2);
A_WRITE(self->dest, sexp_format(o, self->format, 0)); A_WRITE(dest, sexp_format(o, self->format, 0));
if (self->format != SEXP_CANONICAL) if (self->format != SEXP_CANONICAL)
A_WRITE(self->dest, ssh_format("\n")); A_WRITE(dest, ssh_format("\n"));
COMMAND_RETURN(c, a); COMMAND_RETURN(c, o);
} }
struct command * struct command_2 *
make_sexp_print_to(int format, struct abstract_write *dest) make_sexp_print_command(int format)
{ {
NEW(sexp_print_to, self); NEW(sexp_print_command, self);
self->super.call = do_sexp_print; self->super.super.call = do_command_2;
self->super.invoke = do_sexp_print;
self->format = format; self->format = format;
self->dest = dest;
return &self->super; return &self->super;
} }
struct lsh_object * struct command *
do_sexp_print_simple(struct command_simple *s, make_sexp_print_to(int format, struct abstract_write *dest)
struct lsh_object *a)
{
CAST(sexp_print_command, self, s);
CAST_SUBTYPE(abstract_write, dest, a);
return &make_sexp_print_to(self->format, dest)->super;
}
struct command_simple *
make_sexp_print_command(int format)
{ {
NEW(sexp_print_command, self); return
self->super.super.call = do_call_simple_command; make_command_2_invoke(make_sexp_print_command(format),
self->super.call_simple = do_sexp_print_simple; &dest->super);
self->format = format;
return &self->super;
} }
DEFINE_COMMAND3(sexp_print_raw_hash) DEFINE_COMMAND3(sexp_print_raw_hash)
...@@ -280,8 +260,12 @@ static struct read_sexp_command read_sexp ...@@ -280,8 +260,12 @@ static struct read_sexp_command read_sexp
(proc (read_sexp file))))))) (proc (read_sexp file)))))))
*/ */
DEFINE_COMMAND_SIMPLE(for_sexp_command, a) DEFINE_COMMAND(for_sexp_command)
(struct command *s UNUSED,
struct lsh_object *a,
struct command_continuation *c,
struct exception_handler *e UNUSED)
{ {
CAST_SUBTYPE(command, handler, a); CAST_SUBTYPE(command, handler, a);
return for_sexp(handler); COMMAND_RETURN(c, for_sexp(handler));
} }
...@@ -38,19 +38,15 @@ ...@@ -38,19 +38,15 @@
/* GABA: /* GABA:
(class (class
(name sexp_print_command) (name sexp_print_command)
(super command_simple) (super command_2)
(vars (vars
(format . int))) (format . int)))
*/ */
struct lsh_object *
do_sexp_print_simple(struct command_simple *s,
struct lsh_object *a);
#define STATIC_PRINT_SEXP(format) \ #define STATIC_PRINT_SEXP(format) \
{ STATIC_COMMAND_SIMPLE(do_sexp_print_simple), format } {{ STATIC_HEADER, do_command_2}, format }
struct command_simple * struct command_2 *
make_sexp_print_command(int format); make_sexp_print_command(int format);
struct command * struct command *
...@@ -85,7 +81,7 @@ do_read_sexp(struct command *s, ...@@ -85,7 +81,7 @@ do_read_sexp(struct command *s,
struct command * struct command *
make_read_sexp_command(int format, int goon, UINT32 max_size); make_read_sexp_command(int format, int goon, UINT32 max_size);
extern struct command_simple for_sexp_command; extern struct command for_sexp_command;
#define FOR_SEXP (&for_sexp_command.super.super) #define FOR_SEXP (&for_sexp_command.super)
#endif /* SEXP_COMMANDS_H_INCLUDED */ #endif /* SEXP_COMMANDS_H_INCLUDED */
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment