X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=src%2Freference-counted.cpp;h=24394a4d850a67dd90d887aecf5f6a4fde4b6ee6;hb=e310847d00a2fd941405b0d417542310dad63965;hp=eabc3efa0706d16d07deb53dc69fa3925f554a53;hpb=3394d6066c9092a5444c9273f52cea01e2eaf10f;p=guile-irrlicht.git diff --git a/src/reference-counted.cpp b/src/reference-counted.cpp index eabc3ef..24394a4 100644 --- a/src/reference-counted.cpp +++ b/src/reference-counted.cpp @@ -21,33 +21,23 @@ #include #include - -#include "device.h" +#include "gsubr.h" #include "reference-counted.h" +#include "wrapped.h" + +using namespace irr; -extern "C" { - - void - init_reference_counted (void) - { - scm_c_define_gsubr ("drop!", 1, 0, 0, (scm_t_subr)irr_drop); - scm_c_export ("drop!", NULL); - } - - SCM - irr_drop (SCM wrapped_obj) - { - bool result = 0; - if (device_p (wrapped_obj)) - { - result = unwrap_device (wrapped_obj)->drop (); - } - else - { - scm_error (scm_arg_type_key, NULL, "Object cannot be dropped: ~S", - scm_list_1 (wrapped_obj), scm_list_1 (wrapped_obj)); - } - return scm_from_bool (result); - } +template +SCM +IReferenceCounted_drop (SCM obj) +{ + return scm_from_bool (((T) scm_to_irr_pointer (obj))->drop ()); +} +void +init_reference_counted (void) +{ + DEFINE_GSUBR ("IrrlichtDevice_drop", 1, 0, 0, IReferenceCounted_drop); + DEFINE_GSUBR ("ISceneNodeAnimator_drop", 1, 0, 0, + IReferenceCounted_drop); }