mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-18 21:29:19 +02:00
Documenting sexp_register_c_type and sexp_make_cpointer.
This commit is contained in:
parent
e5f6c1bbba
commit
d07170d6c3
1 changed files with 22 additions and 0 deletions
|
@ -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.
|
||||
}}
|
||||
|
||||
\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
|
||||
|
|
Loading…
Add table
Reference in a new issue