]> git.jsancho.org Git - guile-irrlicht.git/blobdiff - src/reference-counted.cpp
Some doc
[guile-irrlicht.git] / src / reference-counted.cpp
index 1060df4b56c9d657216ace980e44190719c7df89..24394a4d850a67dd90d887aecf5f6a4fde4b6ee6 100644 (file)
 
 #include <irrlicht/irrlicht.h>
 #include <libguile.h>
-
-#include "device.h"
 #include "gsubr.h"
 #include "reference-counted.h"
-#include "scene-node-animator.h"
-
-extern "C" {
-
-  void
-  init_reference_counted (void)
-  {
-    DEFINE_GSUBR ("drop!", 1, 0, 0, irr_drop);
-  }
-
-  SCM
-  irr_drop (SCM wrapped_obj)
-  {
-    bool result = 0;
-    if (device_p (wrapped_obj))
-      {
-        result = unwrap_device (wrapped_obj)->drop ();
-      }
-    else if (scene_node_animator_p (wrapped_obj))
-      {
-        result = unwrap_scene_node_animator (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);
-  }
+#include "wrapped.h"
+
+using namespace irr;
+
+template <typename T>
+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<IrrlichtDevice*>);
+  DEFINE_GSUBR ("ISceneNodeAnimator_drop", 1, 0, 0,
+                IReferenceCounted_drop<scene::ISceneNodeAnimator*>);
 }