Commit 77aff799 authored by Niels Möller's avatar Niels Möller
Browse files

* src/command.h (STATIC_CATCH_REPORT): New macro.

* src/command.c: New command catch_report.

Rev: src/command.c:1.34
Rev: src/command.h:1.42
parent b21fd8af
......@@ -612,3 +612,65 @@ do_catch_simple(struct command_simple *s,
self->value, self->ignore_value, f))
->super);
}
/* Catch and report some exceptions.
*
* FIXME: This duplicates most of the catch command. */
/* GABA:
(class
(name catch_report_apply)
(super command)
(vars
(info object report_exception_info)
(body object command)))
*/
static void
do_catch_report_apply(struct command *s,
struct lsh_object *a,
struct command_continuation *c,
struct exception_handler *e)
{
CAST(catch_report_apply, self, s);
COMMAND_CALL(self->body, a, c,
make_report_exception_handler(self->info, e,
HANDLER_CONTEXT));
}
struct command *
make_catch_report_apply(struct report_exception_info *info,
struct command *body)
{
NEW(catch_report_apply, self);
self->super.call = do_catch_report_apply;
self->info = info;
self->body = body;
return &self->super;
}
struct lsh_object *
do_catch_report_collect(struct command_simple *s,
struct lsh_object *a)
{
CAST(catch_report_collect, self, s);
CAST_SUBTYPE(command, body, a);
return &make_catch_report_apply(self->info, body)->super;
}
#if 0
static struct command *
make_catch_report_collect_body(struct catch_handler_info *info)
{
NEW(catch_report_collect_body, self);
self->super.super.call = do_call_simple_command;
self->super.call_simple = do_catch_report_collect_body;
self->info = info;
return &self->super.super;
}
#endif
......@@ -28,7 +28,7 @@
#include "exception.h"
#include "list.h"
#include "io.h"
/* #include "io.h" */
#include <stdarg.h>
......@@ -164,6 +164,26 @@ do_catch_simple(struct command_simple *s,
{ STATIC_COMMAND_SIMPLE(do_catch_simple), (m), (v), (i) }
/* GABA:
(class
(name catch_report_collect)
(super command_simple)
(vars
(info object report_exception_info)))
*/
struct command *
make_catch_report_apply(struct report_exception_info *info,
struct command *body);
struct lsh_object *
do_catch_report_collect(struct command_simple *s,
struct lsh_object *a);
#define STATIC_CATCH_REPORT(i) \
{ STATIC_COMMAND_SIMPLE(do_catch_report_collect), i }
/* Commands that need to collect some arguments before actually doing
* anything. */
......
Markdown is supported
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