]> git.jsancho.org Git - guile-irrlicht.git/commitdiff
refactor
authorJavier Sancho <jsf@jsancho.org>
Sun, 15 Mar 2020 09:42:45 +0000 (10:42 +0100)
committerJavier Sancho <jsf@jsancho.org>
Sun, 15 Mar 2020 09:42:45 +0000 (10:42 +0100)
src/device.cpp
src/device.h
src/gui-environment.cpp
src/gui-environment.h
src/reference-counted.cpp
src/scene-manager.cpp
src/scene-manager.h
src/video-driver.cpp
src/video-driver.h

index bb43ddb702cf1ae99f04367b0595cb91d6e0a729..e578e057a9b04ac2f3857ca545f3a1ec54443636 100644 (file)
@@ -25,9 +25,6 @@
 #include "device.h"
 #include "dimension2d.h"
 #include "driver-types.h"
-#include "gui-environment.h"
-#include "scene-manager.h"
-#include "video-driver.h"
 #include "wchar.h"
 #include "wrapped.h"
 
@@ -38,9 +35,6 @@ extern "C" {
   {
     init_device_type ();
     scm_c_define_gsubr ("create-device", 7, 0, 0, (scm_t_subr)irr_createDevice);
-    scm_c_define_gsubr ("get-gui-environment", 1, 0, 0, (scm_t_subr)irr_getGUIEnvironment);
-    scm_c_define_gsubr ("get-scene-manager", 1, 0, 0, (scm_t_subr)irr_getSceneManager);
-    scm_c_define_gsubr ("get-video-driver", 1, 0, 0, (scm_t_subr)irr_getVideoDriver);
     scm_c_define_gsubr ("set-window-caption!", 2, 0, 0, (scm_t_subr)irr_setWindowCaption);
   }
 
@@ -67,30 +61,6 @@ extern "C" {
     return wrap_device (device);
   }
 
-  SCM
-  irr_getGUIEnvironment (SCM wrapped_device)
-  {
-    irr::IrrlichtDevice* device = unwrap_device (wrapped_device);
-    irr::gui::IGUIEnvironment* gui_environment = device->getGUIEnvironment ();
-    return wrap_gui_environment (gui_environment);
-  }
-
-  SCM
-  irr_getSceneManager (SCM wrapped_device)
-  {
-    irr::IrrlichtDevice* device = unwrap_device (wrapped_device);
-    irr::scene::ISceneManager* scene_manager = device->getSceneManager ();
-    return wrap_scene_manager (scene_manager);
-  }
-
-  SCM
-  irr_getVideoDriver (SCM wrapped_device)
-  {
-    irr::IrrlichtDevice* device = unwrap_device (wrapped_device);
-    irr::video::IVideoDriver* driver = device->getVideoDriver ();
-    return wrap_video_driver (driver);
-  }
-
   SCM
   irr_setWindowCaption (SCM wrapped_device,
                         SCM text)
index 0f3d243b890849d1d847021f07c18df4c0b7cbce..8c9f8a167ca3915d0f7c6df6d20184c4e77e895e 100644 (file)
@@ -43,15 +43,6 @@ extern "C" {
                     SCM vsync,
                     SCM receiver);
 
-  SCM
-  irr_getGUIEnvironment (SCM wrapped_device);
-
-  SCM
-  irr_getSceneManager (SCM wrapped_device);
-
-  SCM
-  irr_getVideoDriver (SCM wrapped_device);
-
   SCM
   irr_setWindowCaption (SCM wrapped_device,
                         SCM text);
index 76dc57ce75a60c6bd9dba229d6e37e9205101424..ca59a3196a809e167c39fbf365f6e21f38d884e1 100644 (file)
@@ -22,6 +22,7 @@
 #include <irrlicht/irrlicht.h>
 #include <libguile.h>
 
+#include "device.h"
 #include "gui-element.h"
 #include "gui-environment.h"
 #include "gui-static-text.h"
@@ -36,12 +37,29 @@ extern "C" {
   {
     init_gui_environment_type ();
     scm_c_define_gsubr ("add-static-text!", 8, 0, 0, (scm_t_subr)irr_gui_addStaticText);
+    scm_c_define_gsubr ("get-gui-environment", 1, 0, 0, (scm_t_subr)irr_getGUIEnvironment);
   }
 
   DEFINE_WRAPPED_TYPE (irr::gui::IGUIEnvironment*, "gui-environment",
                        init_gui_environment_type, gui_environment_p,
                        wrap_gui_environment, unwrap_gui_environment);
 
+  SCM
+  irr_getGUIEnvironment (SCM wrapped_obj)
+  {
+    irr::gui::IGUIEnvironment* gui_environment;
+    if (device_p (wrapped_obj))
+      {
+        gui_environment = unwrap_device (wrapped_obj)->getGUIEnvironment ();
+      }
+    else
+      {
+        scm_error (scm_arg_type_key, NULL, "Cannot get GUI environment from object: ~S",
+                   scm_list_1 (wrapped_obj), scm_list_1 (wrapped_obj));
+      }
+    return wrap_gui_environment (gui_environment);
+  }
+
   SCM
   irr_gui_addStaticText (SCM wrappedGUIEnvironment,
                          SCM text,
index 9b8d63653e3df8c03feaa3da6fc11125d098e1c4..caac2eeda7653f21c0ac15ab9f4797974101340d 100644 (file)
@@ -34,6 +34,9 @@ extern "C" {
   DECLARE_WRAPPED_TYPE (irr::gui::IGUIEnvironment*, init_gui_environment_type,
                         gui_environment_p, wrap_gui_environment, unwrap_gui_environment);
 
+  SCM
+  irr_getGUIEnvironment (SCM wrapped_obj);
+
   SCM
   irr_gui_addStaticText (SCM guienv,
                          SCM text,
index 85634d4560dce04011010fd2f103655a859f2201..58878d38f019c17d32bea88d9d9522b1f0f85909 100644 (file)
@@ -41,6 +41,11 @@ extern "C" {
       {
         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);
   }
 
index 5e81de7e0b35197c81e56e12ebe2ddebc6918c7f..d4234e8c10c043f799de78d122c2ab26f1f6e2a9 100644 (file)
@@ -24,6 +24,7 @@
 
 #include "animated-mesh.h"
 #include "animated-mesh-scene-node.h"
+#include "device.h"
 #include "scene-manager.h"
 #include "scene-node.h"
 #include "vector3d.h"
@@ -38,12 +39,29 @@ extern "C" {
     scm_c_define_gsubr ("add-animated-mesh-scene-node", 8, 0, 0,
                         (scm_t_subr)irr_scene_addAnimatedMeshSceneNode);
     scm_c_define_gsubr ("get-mesh", 2, 0, 0, (scm_t_subr)irr_scene_getMesh);
+    scm_c_define_gsubr ("get-scene-manager", 1, 0, 0, (scm_t_subr)irr_getSceneManager);
   }
 
   DEFINE_WRAPPED_TYPE (irr::scene::ISceneManager*, "scene-manager",
                        init_scene_manager_type, scene_manager_p,
                        wrap_scene_manager, unwrap_scene_manager);
 
+  SCM
+  irr_getSceneManager (SCM wrapped_obj)
+  {
+    irr::scene::ISceneManager* scene_manager;
+    if (device_p (wrapped_obj))
+      {
+        scene_manager = unwrap_device (wrapped_obj)->getSceneManager ();
+      }
+    else
+      {
+        scm_error (scm_arg_type_key, NULL, "Cannot get scene manager from object: ~S",
+                   scm_list_1 (wrapped_obj), scm_list_1 (wrapped_obj));
+      }
+    return wrap_scene_manager (scene_manager);
+  }
+
   SCM
   irr_scene_addAnimatedMeshSceneNode (SCM wrapped_scene_manager,
                                       SCM mesh,
index f52d2996e787cf3472276e21cc7b054cb34109bd..961b963096ff739cc9334370fa25b6e895398c0a 100644 (file)
@@ -34,6 +34,9 @@ extern "C" {
   DECLARE_WRAPPED_TYPE (irr::scene::ISceneManager*, init_scene_manager_type,
                         scene_manager_p, wrap_scene_manager, unwrap_scene_manager);
 
+  SCM
+  irr_getSceneManager (SCM wrapped_obj);
+
   SCM
   irr_scene_addAnimatedMeshSceneNode (SCM wrapped_scene_manager,
                                       SCM mesh,
index c746db3ae313727d9f7c42a3b6d8958755ec9d67..b768f58e5c81c7d506a7f3faa19a375543635362 100644 (file)
@@ -21,6 +21,8 @@
 
 #include <irrlicht/irrlicht.h>
 #include <libguile.h>
+
+#include "device.h"
 #include "video-driver.h"
 #include "wrapped.h"
 
@@ -30,10 +32,27 @@ extern "C" {
   init_video_driver (void)
   {
     init_video_driver_type ();
+    scm_c_define_gsubr ("get-video-driver", 1, 0, 0, (scm_t_subr)irr_getVideoDriver);
   }
 
   DEFINE_WRAPPED_TYPE (irr::video::IVideoDriver*, "video-driver",
                        init_video_driver_type, video_driver_p,
                        wrap_video_driver, unwrap_video_driver);
 
+  SCM
+  irr_getVideoDriver (SCM wrapped_obj)
+  {
+    irr::video::IVideoDriver* driver;
+    if (device_p (wrapped_obj))
+      {
+        driver = unwrap_device (wrapped_obj)->getVideoDriver ();
+      }
+    else
+      {
+        scm_error (scm_arg_type_key, NULL, "Cannot get video driver from object: ~S",
+                   scm_list_1 (wrapped_obj), scm_list_1 (wrapped_obj));
+      }
+    return wrap_video_driver (driver);
+  }
+
 }
index 1525edf717aaab831851c9dc14bf2d8fc6344278..7e3f7279acb09cd7ca329e2978ca13ae4a294f0b 100644 (file)
@@ -34,6 +34,9 @@ extern "C" {
   DECLARE_WRAPPED_TYPE (irr::video::IVideoDriver*, init_video_driver_type,
                         video_driver_p, wrap_video_driver, unwrap_video_driver);
 
+  SCM
+  irr_getVideoDriver (SCM wrapped_obj);
+
 }
 
 #endif