# Declaration of structures for nitni undelying the FFI
protected fun compile_nitni_structs
do
self.header.add_decl """
/* Native reference to Nit objects */
/* This structure is used to represent every Nit type in extern methods and custom C code. */
struct nitni_ref {
struct nitni_ref *next,
*prev; /* adjacent global references in global list */
int count; /* number of time this global reference has been marked */
};
/* List of global references from C code to Nit objects */
/* Instanciated empty at init of Nit system and filled explicitly by user in C code */
struct nitni_global_ref_list_t {
struct nitni_ref *head, *tail;
};
extern struct nitni_global_ref_list_t *nitni_global_ref_list;
/* Initializer of global reference list */
extern void nitni_global_ref_list_init();
/* Intern function to add a global reference to the list */
extern void nitni_global_ref_add( struct nitni_ref *ref );
/* Intern function to remove a global reference from the list */
extern void nitni_global_ref_remove( struct nitni_ref *ref );
/* Increase count on an existing global reference */
extern void nitni_global_ref_incr( struct nitni_ref *ref );
/* Decrease count on an existing global reference */
extern void nitni_global_ref_decr( struct nitni_ref *ref );
"""
end
src/compiler/abstract_compiler.nit:823,2--857,4
redef fun compile_nitni_structs
do
self.header.add_decl """
struct nitni_instance \{
struct nitni_instance *next,
*prev; /* adjacent global references in global list */
int count; /* number of time this global reference has been marked */
struct instance *value;
\};
"""
super
end
src/compiler/separate_compiler.nit:1232,2--1243,4
redef fun compile_nitni_structs
do
self.header.add_decl """
struct nitni_instance \{
struct nitni_instance *next,
*prev; /* adjacent global references in global list */
int count; /* number of time this global reference has been marked */
val *value;
\};"""
super
end
src/compiler/global_compiler.nit:318,2--328,4