X-Git-Url: https://git.jsancho.org/?p=guile-irrlicht.git;a=blobdiff_plain;f=src%2Fwrapped.h;h=2518025c937a03d414ca0040a567c3aeffc20077;hp=4514fa64afbb769c2686bc5f46697b584007b4ac;hb=3bb58c2b45af12c0f9c9eac648e67ac6fa90e104;hpb=c9c098c6a9363eb59f435eb195a4bc5b9098b1dd diff --git a/src/wrapped.h b/src/wrapped.h index 4514fa6..2518025 100644 --- a/src/wrapped.h +++ b/src/wrapped.h @@ -22,65 +22,15 @@ #ifndef __GUILE_IRRLICHT_WRAPPED_H_INCLUDED__ #define __GUILE_IRRLICHT_WRAPPED_H_INCLUDED__ +#include #include -#define DECLARE_WRAPPED_TYPE(TYPE, INIT, PRED, WRAP, UNWRAP) \ - void \ - INIT (void); \ - \ - SCM \ - WRAP (TYPE foreign_obj); \ - \ - TYPE \ - UNWRAP (SCM wrapped_obj); \ - \ - bool \ - PRED (SCM wrapped_obj); +using namespace irr; +SCM +scm_from_irr_pointer (const char* class_name, void* pointer); -#define DEFINE_WRAPPED_TYPE(TYPE, PRINT_NAME, INIT, PRED, WRAP, UNWRAP) \ - static SCM wrapped_##INIT; \ - \ - void \ - INIT (void) \ - { \ - SCM name, slots; \ - scm_t_struct_finalize finalizer; \ - \ - name = scm_from_utf8_symbol (PRINT_NAME); \ - slots = scm_list_1 (scm_from_utf8_symbol ("data")); \ - finalizer = NULL; \ - \ - wrapped_##INIT = \ - scm_make_foreign_object_type (name, slots, finalizer); \ - } \ - \ - SCM \ - WRAP (TYPE foreign_obj) \ - { \ - return scm_make_foreign_object_1 (wrapped_##INIT, foreign_obj); \ - } \ - \ - TYPE \ - UNWRAP (SCM wrapped_obj) \ - { \ - scm_assert_foreign_object_type (wrapped_##INIT, wrapped_obj); \ - return (TYPE)scm_foreign_object_ref (wrapped_obj, 0); \ - } \ - \ - bool \ - PRED (SCM wrapped_obj) \ - { \ - return SCM_IS_A_P (wrapped_obj, wrapped_##INIT); \ - } - - -#define UNWRAP(OBJ) \ - char* OBJ##_class = scm_to_utf8_stringn (scm_car (OBJ), NULL); \ - void* OBJ##_pointer = scm_to_pointer (scm_cdr (OBJ)); - - -#define UNWRAPPED(OBJ) \ - (!strcmp (OBJ##_class, "irr::IEventReceiver") ? (irr::IEventReceiver*)OBJ##_pointer : 0) +void* +scm_to_irr_pointer (SCM obj); #endif