Allows one to register a JanetAbstractType with Janet.
The returned object can be used as an argument for the janet_abstract function, which will return a void*.
This void* can be safely(?) cast to T (TODO: prove safety, make function to ensure it if so).
One can add static string to the class by the name of "janetPackage", which will be prepended to its class name in Janet before a '/'.
For example: register class "Bar" with janetPackage "Foo" will result in "Foo/Bar".
This process may be made easier in a later version.
A registered class looks for the following functions:
- Janet __janetGet(void* data,Janet key)
- void __janetPut(void* data,Janet key,Janet value)
- void __janetMarshal (void* p, JanetMarshalContext* ctx)
- void __janetUnmarshal (void* p, JanetMarshalContext* ctx)
- void __janetTostring (void* p, JanetBuffer* buffer)
- int __janetGC (void* data, size_t len)
- int __janetGCMark (void* data, size_t len)
All of these are optional; get and put will have defaults applied (see the source code for info) if none is defined.
See Implementation
Allows one to register a JanetAbstractType with Janet.
The returned object can be used as an argument for the janet_abstract function, which will return a void*.
This void* can be safely(?) cast to T (TODO: prove safety, make function to ensure it if so).
One can add static string to the class by the name of "janetPackage", which will be prepended to its class name in Janet before a '/'.
For example: register class "Bar" with janetPackage "Foo" will result in "Foo/Bar".
This process may be made easier in a later version.
A registered class looks for the following functions:
- Janet __janetGet(void* data,Janet key)
- void __janetPut(void* data,Janet key,Janet value)
- void __janetMarshal (void* p, JanetMarshalContext* ctx)
- void __janetUnmarshal (void* p, JanetMarshalContext* ctx)
- void __janetTostring (void* p, JanetBuffer* buffer)
- int __janetGC (void* data, size_t len)
- int __janetGCMark (void* data, size_t len)
All of these are optional; get and put will have defaults applied (see the source code for info) if none is defined.