Documenting sexp_register_c_type and sexp_make_cpointer.

This commit is contained in:
Alex Shinn 2018-02-18 09:19:36 +09:00
parent e5f6c1bbba
commit d07170d6c3

View file

@ -904,6 +904,28 @@ to any inherited from the parent type \var{parent}. If \var{parent} is false,
inherits from the default \var{object} record type. inherits from the default \var{object} record type.
}} }}
\item{\ccode{sexp sexp_register_c_type(sexp ctx, sexp name, sexp finalizer)}
\p{
Shortcut to defines a new type as a wrapper around a C pointer.
Returns the type object, which can be used with sexp_make_cpointer to
wrap instances of the type. The finalizer may be sexp_finalize_c_type
in which case managed pointers are freed as if allocated with malloc,
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)}
\p{
Creates a new instance of the type indicated by type_id 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).
}}
] ]
See the C FFI for an easy way to automate adding bindings for C See the C FFI for an easy way to automate adding bindings for C