diff --git a/doc/chibi.scrbl b/doc/chibi.scrbl index 11058228..0bbb957f 100755 --- a/doc/chibi.scrbl +++ b/doc/chibi.scrbl @@ -938,16 +938,27 @@ NULL in which case the pointers are never freed, or otherwise a procedure of one argument which should release any resources. }} -\item{\ccode{sexp sexp_make_cpointer(sexp ctx, sexp_uint_t type_id, void* value, sexp parent, int freep)} +\item{\ccode{sexp sexp_make_cpointer(sexp ctx, sexp_uint_t type_tag, void* value, sexp parent, int freep)} \p{ -Creates a new instance of the type indicated by type_id wrapping +Creates a new instance of the type indicated by type_tag wrapping value. If parent is provided, references to the child will also preserve the parent, important e.g. to preserve an enclosing struct when wrapped references to nested structs are still in use. If freep is true, then when reclaimed by the GC the finalizer for this type, if any, will be called on the instance. -You can retrieve the id from a type object with sexp_type_tag(type). +You can retrieve the tag from a type object with sexp_type_tag(type). +}} + +\item{\ccode{sexp sexp_lookup_type(sexp ctx, sexp name, sexp tag_or_id)} +\p{ +Returns the type whose name matches the string \var{name}. If +\var{tag_or_id} is an integer, it is taken as the tag and requires the +numeric type tag (as from sexp_type_tag) to also match. +} +\p{If \var{tag_or_id} is a string, it is taken as the unique id of the +type, and must match sexp_type_id(type). However, currently +sexp_type_id(type) is never set. }} ] diff --git a/sexp.c b/sexp.c index b708980d..11514564 100644 --- a/sexp.c +++ b/sexp.c @@ -440,7 +440,7 @@ sexp sexp_lookup_type_op(sexp ctx, sexp self, sexp_sint_t n, sexp name, sexp id) if (sexp_stringp(id) && !(sexp_stringp(sexp_type_id(res)) && strcmp(sexp_string_data(id), sexp_string_data(sexp_type_id(res))) == 0)) - return SEXP_FALSE; + continue; return res; } return SEXP_FALSE;