Commit 11d285d6 authored by Niels Möller's avatar Niels Möller
Browse files

Bug fixes.

Rev: src/make_class:1.4
Rev: src/service.c:1.10
Rev: src/service.h:1.10
Rev: src/xalloc.c:1.12
Rev: src/xalloc.h:1.12
parent 9642473c
......@@ -115,10 +115,10 @@
(type->mark `(simple ,type) expr)
(case (car type)
((string simple function space bignum) #f)
((object) (list "mark(" expr ");\n"))
((object) (list "mark((struct lsh_object *) " expr ");\n"))
((pointer) (type->mark (cadr type) (list "*(" expr ")")))
((special) (let ((mark-fn (caddr type)))
(and mark-fn (list mark-fn "(" expr ");\n"))))
(and mark-fn (list mark-fn "(" expr ", mark);\n"))))
;; FIXME: Doesn't handle nested arrays
((array)
......@@ -142,7 +142,7 @@
((string) (free/f "lsh_string_free"))
((bignum) (free/f "mpz_clear"))
((space) (free/f "lsh_space_free"))
((special (free/f (cadddr type))))
((special) (free/f (cadddr type)))
((array)
(let ((free-k (type->free (cadr type) (list "(" expr ")[k]"))))
......@@ -224,11 +224,12 @@
(werror "do-mark-function\n")
(let ((markers (filter identity
(map (lambda (var)
(type->mark (var-type var) (var-name var)))
(type->mark (var-type var)
(list "i->" (var-name var))))
vars))))
(werror "gazonk\n")
(and (not (null? markers))
(list "static struct lsh_object *do_"
(list "static void do_"
name "_mark(struct lsh_object *o, \n"
"void (*mark)(struct lsh_object *o))\n"
"{\n"
......@@ -241,7 +242,9 @@
(werror "do-free-function\n")
(let ((freers (filter identity
(map (lambda (var)
(type->free (var-type var) (var-name var)))
(type->free (var-type var)
(list "i->" (var-name var))))
vars))))
(werror "gazonk\n")
......
......@@ -41,7 +41,7 @@
(name service_handler)
(super packet_handler)
(vars
(object alist services)))
(services object alist)))
*/
#if 0
......@@ -104,9 +104,7 @@ static int do_service(struct packet_handler *c,
struct packet_handler *make_service_handler(struct alist *services)
{
struct service_handler *self;
NEW(self);
NEW(service_handler, self);
self->super.handler = do_service;
self->services = services;
......@@ -119,7 +117,7 @@ struct packet_handler *make_service_handler(struct alist *services)
(name meta_service)
(super ssh_service)
(vars
(object packet_handler service_handler)))
(service_handler object packet_handler)))
*/
#if 0
......@@ -136,8 +134,6 @@ static int init_meta_service(struct ssh_service *c,
{
CAST(meta_service, closure, c);
MDEBUG(closure);
connection->dispatch[SSH_MSG_SERVICE_REQUEST] = closure->service_handler;
return LSH_OK | LSH_GOON;
......@@ -145,9 +141,7 @@ static int init_meta_service(struct ssh_service *c,
struct ssh_service *make_meta_service(struct alist *services)
{
struct meta_service *self;
NEW(self);
NEW(meta_service, self);
self->super.init = init_meta_service;
self->service_handler = make_service_handler(services);
......
......@@ -48,8 +48,7 @@ struct ssh_service
(class
(name ssh_service)
(vars
(method
int (function "struct ssh_service *self, struct ssh_connection *c"))))
(init method int "struct ssh_connection *c")))
*/
#define SERVICE_INIT(s, c) ((s)->init((s), (c)))
......
......@@ -160,8 +160,8 @@ void lsh_object_free(void *p)
#endif
#ifdef DEBUG_ALLOC
struct lsh_object *lsh_object_check(struct lsh_object *instance,
struct lsh_class *class)
struct lsh_object *lsh_object_check(struct lsh_class *class,
struct lsh_object *instance)
{
if (instance->marked)
fatal("lsh_object_check: Unexpected marked object!\n");
......@@ -175,8 +175,8 @@ struct lsh_object *lsh_object_check(struct lsh_object *instance,
return instance;
}
struct lsh_object *lsh_object_check_subtype(struct lsh_object *instance,
struct lsh_class *class)
struct lsh_object *lsh_object_check_subtype(struct lsh_class *class,
struct lsh_object *instance)
{
struct lsh_class *type;
......
......@@ -56,27 +56,26 @@ void lsh_space_free(void *p);
#ifdef DEBUG_ALLOC
struct lsh_object *lsh_object_check(struct lsh_object *instance,
struct lsh_class *class);
struct lsh_object *lsh_object_check_subtype(struct lsh_object *instance,
struct lsh_class *class);
struct lsh_object *lsh_object_check(struct lsh_class *class,
struct lsh_object *instance);
struct lsh_object *lsh_object_check_subtype(struct lsh_class *class,
struct lsh_object *instance);
#if 0
#define MDEBUG(x) lsh_object_check((x), sizeof(*(x)))
#define MDEBUG_SUBTYPE(x) lsh_object_check_subtype((x), sizeof(*(x)))
#endif
#define CHECK_TYPE(c, i) lsh_object_check((c), (struct lsh_object *) (i))
#define CHECK_TYPE(c, i) \
lsh_object_check(&CLASS(c), (struct lsh_object *) (i))
#define CHECK_SUBTYPE(c, i) \
lsh_object_check_subtype((c), (struct lsh_object *) (i))
#endif
lsh_object_check_subtype(&CLASS(c), (struct lsh_object *) (i))
#define CAST(class, var, o) \
struct class *(var) = (struct class *) \
(lsh_check_object(class##_class, (struct lsh_object *) (o))
struct class *(var) = (struct class *) CHECK_TYPE(class, o)
#define CAST_SUBTYPE(class, var, o) \
struct class *(var) = (struct class *) \
(lsh_check_object_subtype(class##_class, (struct lsh_object *) (o))
struct class *(var) = (struct class *) CHECK_SUBTYPE(class, o)
#else /* !DEBUG_ALLOC */
......@@ -86,14 +85,19 @@ struct lsh_object *lsh_object_check_subtype(struct lsh_object *instance,
#define MDEBUG_SUBTYPE(x)
#endif
#define CHECK_TYPE(c, o)
#define CHECK_SUBTYPE(c, o)
#define CAST(class, var, o) \
struct class *(var) = (struct class *) (o)
#define CAST_SUBTYPE(class, var, o) CAST(class, var, o)
#endif /* !DEBUG_ALLOC */
#define NEW(class, var) struct (class) * (var) = lsh_object_alloc(class##_class)
#define NEW(class, var) \
struct class *(var) = (struct class *) lsh_object_alloc(&CLASS(class))
#define NEW_SPACE(x) ((x) = lsh_space_alloc(sizeof(*(x))))
#include "gc.h"
......
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