]> git.jsancho.org Git - guile-irrlicht.git/commitdiff
refactor
authorJavier Sancho <jsf@jsancho.org>
Mon, 9 Mar 2020 16:55:04 +0000 (17:55 +0100)
committerJavier Sancho <jsf@jsancho.org>
Mon, 9 Mar 2020 16:55:04 +0000 (17:55 +0100)
34 files changed:
Makefile.am
irrlicht.scm
irrlicht/device.scm
irrlicht/irr.scm [new file with mode: 0644]
irrlicht/scene.scm
src/EDriverTypes.cpp
src/EMaterialFlags.cpp [new file with mode: 0644]
src/EMaterialFlags.h [new file with mode: 0644]
src/GuileIrrlicht.cpp
src/IAnimatedMesh.cpp
src/IAnimatedMesh.h
src/IAnimatedMeshSceneNode.cpp
src/IAnimatedMeshSceneNode.h
src/IGUIElement.cpp
src/IGUIElement.h
src/IGUIEnvironment.cpp
src/IGUIEnvironment.h
src/IGUIStaticText.cpp
src/IGUIStaticText.h
src/IReferenceCounted.cpp [new file with mode: 0644]
src/IReferenceCounted.h [new file with mode: 0644]
src/ISceneManager.cpp
src/ISceneManager.h
src/ISceneNode.cpp
src/ISceneNode.h
src/IVideoDriver.cpp
src/IVideoDriver.h
src/IrrlichtDevice.cpp
src/IrrlichtDevice.h
src/util.cpp [deleted file]
src/util.h [deleted file]
src/wchar.cpp [new file with mode: 0644]
src/wchar.h [new file with mode: 0644]
src/wrapped.h [new file with mode: 0644]

index 36003c1f0793d5a74ca1e3e4bc5c95113a24f382..8f92257a8c33eb3beab4abb413144e1fbf6d76ae 100644 (file)
@@ -3,6 +3,7 @@ lib_LTLIBRARIES = libguile-irrlicht.la
 libguile_irrlicht_la_SOURCES = \
   src/dimension2d.cpp \
   src/EDriverTypes.cpp \
+  src/EMaterialFlags.cpp \
   src/GuileIrrlicht.cpp \
   src/IAnimatedMesh.cpp \
   src/IAnimatedMeshSceneNode.cpp \
@@ -12,10 +13,11 @@ libguile_irrlicht_la_SOURCES = \
   src/IrrlichtDevice.cpp \
   src/ISceneManager.cpp \
   src/ISceneNode.cpp \
+  src/IReferenceCounted.cpp \
   src/IVideoDriver.cpp \
   src/rect.cpp \
-  src/util.cpp \
-  src/vector3d.cpp
+  src/vector3d.cpp \
+  src/wchar.cpp
 libguile_irrlicht_la_CPPFLAGS = @GUILE_CFLAGS@
 libguile_irrlicht_la_LDFLAGS = \
   -version-info 0:1 \
index 327c45ea94d79076f7ae57cb05d3b063bc63a01c..1b635f2dc4365aea0e47d8f6d4e41bb2b8177568 100644 (file)
@@ -25,6 +25,7 @@
   (let ((public-modules
          '((irrlicht device)
            (irrlicht gui)
+           (irrlicht irr)
            (irrlicht scene)))
         (current-interface
          (module-public-interface (current-module))))
index 2a61890ab80f9de069fa852b99dff8e7ec0671b8..e07a812d2e0b6818473e2af7278f17dbb34dda9b 100644 (file)
@@ -20,7 +20,6 @@
 
 (define-module (irrlicht device)
   #:export (create-device
-            device-drop!
             get-gui-environment
             get-scene-manager
             get-video-driver
diff --git a/irrlicht/irr.scm b/irrlicht/irr.scm
new file mode 100644 (file)
index 0000000..9b89142
--- /dev/null
@@ -0,0 +1,24 @@
+;;; guile-irrlicht --- FFI bindings for Irrlicht Engine
+;;; Copyright (C) 2019 Javier Sancho <jsf@jsancho.org>
+;;;
+;;; This file is part of guile-irrlicht.
+;;;
+;;; Guile-irrlicht is free software; you can redistribute it and/or modify
+;;; it under the terms of the GNU Lesser General Public License as
+;;; published by the Free Software Foundation; either version 3 of the
+;;; License, or (at your option) any later version.
+;;;
+;;; Guile-irrlicht is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;;; General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU Lesser General Public
+;;; License along with guile-irrlicht.  If not, see
+;;; <http://www.gnu.org/licenses/>.
+
+
+(define-module (irrlicht irr)
+  #:export (drop!))
+
+(load-extension "libguile-irrlicht" "init_guile_irrlicht")
index b815700b436b0aef5e80f0a831237514d259b04c..17437fe80e7cfeb1b6d02cb7612e5f7d2a32a416 100644 (file)
@@ -18,7 +18,7 @@
 ;;; <http://www.gnu.org/licenses/>.
 
 
-(define-module (irrlicht gui)
+(define-module (irrlicht scene)
   #:export (add-animated-mesh-scene-node
             get-mesh))
 
index ec41fe9029930a5c7ca77674d49515341f658b24..8b3f67851f77ff8cadf2eb439bcb6d680ab0ea6d 100644 (file)
@@ -29,27 +29,27 @@ extern "C" {
   scm_to_driver_type (SCM driver_type)
   {
     char* driverType = scm_to_utf8_stringn (scm_symbol_to_string (driver_type), NULL);
-    if (!strcmp(driverType, "null"))
+    if (!strcmp (driverType, "null"))
       {
         return irr::video::EDT_NULL;
       }
-    else if (!strcmp(driverType, "software"))
+    else if (!strcmp (driverType, "software"))
       {
         return irr::video::EDT_SOFTWARE;
       }
-    else if (!strcmp(driverType, "burnings"))
+    else if (!strcmp (driverType, "burnings"))
       {
         return irr::video::EDT_BURNINGSVIDEO;
       }
-    else if (!strcmp(driverType, "direct3d8"))
+    else if (!strcmp (driverType, "direct3d8"))
       {
         return irr::video::EDT_DIRECT3D8;
       }
-    else if (!strcmp(driverType, "direct3d9"))
+    else if (!strcmp (driverType, "direct3d9"))
       {
         return irr::video::EDT_DIRECT3D9;
       }
-    else if (!strcmp(driverType, "opengl"))
+    else if (!strcmp (driverType, "opengl"))
       {
         return irr::video::EDT_OPENGL;
       }
diff --git a/src/EMaterialFlags.cpp b/src/EMaterialFlags.cpp
new file mode 100644 (file)
index 0000000..7c38fe8
--- /dev/null
@@ -0,0 +1,114 @@
+/* guile-irrlicht --- GNU Guile bindings for Irrlicht Engine
+
+   Copyright (C) 2020 Javier Sancho <jsf@jsancho.org>
+
+   This file is part of guile-irrlicht.
+
+   guile-irrlicht is free software; you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as
+   published by the Free Software Foundation; either version 3 of the
+   License, or (at your option) any later version.
+
+   guile-irrlicht is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with guile-irrlicht. If not, see
+   <http://www.gnu.org/licenses/>.
+*/
+
+#include <irrlicht/irrlicht.h>
+#include <libguile.h>
+#include "EMaterialFlags.h"
+
+extern "C" {
+
+  irr::video::E_MATERIAL_FLAG
+  scm_to_material_flag (SCM material_flag)
+  {
+    char* flag = scm_to_utf8_stringn (scm_symbol_to_string (material_flag), NULL);
+    if (!strcmp (flag, "wireframe"))
+      {
+        return irr::video::EMF_WIREFRAME;
+      }
+    else if (!strcmp (flag, "pointcloud"))
+      {
+        return irr::video::EMF_POINTCLOUD;
+      }
+    else if (!strcmp (flag, "gouraud-shading"))
+      {
+        return irr::video::EMF_GOURAUD_SHADING;
+      }
+    else if (!strcmp (flag, "lighting"))
+      {
+        return irr::video::EMF_LIGHTING;
+      }
+    else if (!strcmp (flag, "zbuffer"))
+      {
+        return irr::video::EMF_ZBUFFER;
+      }
+    else if (!strcmp (flag, "zwrite-enable"))
+      {
+        return irr::video::EMF_ZWRITE_ENABLE;
+      }
+    else if (!strcmp (flag, "back-face-culling"))
+      {
+        return irr::video::EMF_BACK_FACE_CULLING;
+      }
+    else if (!strcmp (flag, "front-face-culling"))
+      {
+        return irr::video::EMF_FRONT_FACE_CULLING;
+      }
+    else if (!strcmp (flag, "bilinear-filter"))
+      {
+        return irr::video::EMF_BILINEAR_FILTER;
+      }
+    else if (!strcmp (flag, "trilinear-filter"))
+      {
+        return irr::video::EMF_TRILINEAR_FILTER;
+      }
+    else if (!strcmp (flag, "anisotropic-filter"))
+      {
+        return irr::video::EMF_ANISOTROPIC_FILTER;
+      }
+    else if (!strcmp (flag, "fog-enable"))
+      {
+        return irr::video::EMF_FOG_ENABLE;
+      }
+    else if (!strcmp (flag, "normalize-normals"))
+      {
+        return irr::video::EMF_NORMALIZE_NORMALS;
+      }
+    else if (!strcmp (flag, "texture-wrap"))
+      {
+        return irr::video::EMF_TEXTURE_WRAP;
+      }
+    else if (!strcmp (flag, "anti-aliasing"))
+      {
+        return irr::video::EMF_ANTI_ALIASING;
+      }
+    else if (!strcmp (flag, "color-mask"))
+      {
+        return irr::video::EMF_COLOR_MASK;
+      }
+    else if (!strcmp (flag, "color-material"))
+      {
+        return irr::video::EMF_COLOR_MATERIAL;
+      }
+    else if (!strcmp (flag, "use-mip-maps"))
+      {
+        return irr::video::EMF_USE_MIP_MAPS;
+      }
+    else if (!strcmp (flag, "blend-operation"))
+      {
+        return irr::video::EMF_BLEND_OPERATION;
+      }
+    else if (!strcmp (flag, "polygon-offset"))
+      {
+        return irr::video::EMF_POLYGON_OFFSET;
+      }
+  }
+
+}
diff --git a/src/EMaterialFlags.h b/src/EMaterialFlags.h
new file mode 100644 (file)
index 0000000..be94343
--- /dev/null
@@ -0,0 +1,35 @@
+/* guile-irrlicht --- GNU Guile bindings for Irrlicht Engine
+
+   Copyright (C) 2020 Javier Sancho <jsf@jsancho.org>
+
+   This file is part of guile-irrlicht.
+
+   guile-irrlicht is free software; you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as
+   published by the Free Software Foundation; either version 3 of the
+   License, or (at your option) any later version.
+
+   guile-irrlicht is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with guile-irrlicht. If not, see
+   <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef __GUILE_IRRLICHT_E_MATERIAL_FLAGS_INCLUDED__
+#define __GUILE_IRRLICHT_E_MATERIAL_FLAGS_INCLUDED__
+
+#include <irrlicht/irrlicht.h>
+#include <libguile.h>
+
+extern "C" {
+
+  irr::video::E_MATERIAL_FLAG
+  scm_to_material_flag (SCM material_flag);
+
+}
+
+#endif
index 2c203851d9ec8cf60dd1c93224bcb236e411bfcd..8b6275f544666f52b0cebf6cac4d275325d11f52 100644 (file)
@@ -28,6 +28,7 @@
 #include "IrrlichtDevice.h"
 #include "ISceneManager.h"
 #include "ISceneNode.h"
+#include "IReferenceCounted.h"
 #include "IVideoDriver.h"
 
 extern "C" {
@@ -41,6 +42,7 @@ extern "C" {
     init_gui_element ();
     init_gui_environment ();
     init_gui_static_text ();
+    init_reference_counted ();
     init_scene_manager ();
     init_scene_node ();
     init_video_driver ();
index 52394ef93204296af80985f389090dfaf8e5e8c5..883527e3d17ba461e85dc98569fa2792775bf211 100644 (file)
@@ -22,7 +22,7 @@
 #include <irrlicht/irrlicht.h>
 #include <libguile.h>
 #include "IAnimatedMesh.h"
-#include "util.h"
+#include "wrapped.h"
 
 extern "C" {
 
@@ -33,7 +33,7 @@ extern "C" {
   }
 
   DEFINE_WRAPPED_TYPE (irr::scene::IAnimatedMesh*, "animated-mesh",
-                       init_animated_mesh_type,
+                       init_animated_mesh_type, animated_mesh_p,
                        wrap_animated_mesh, unwrap_animated_mesh);
 
 }
index 3926002635440df3746a40fb1678f5792621d6ee..b9f77c36c37ab35005ad09606a34b99be383333b 100644 (file)
@@ -24,7 +24,7 @@
 
 #include <irrlicht/irrlicht.h>
 #include <libguile.h>
-#include "util.h"
+#include "wrapped.h"
 
 extern "C" {
 
@@ -32,7 +32,7 @@ extern "C" {
   init_animated_mesh (void);
 
   DECLARE_WRAPPED_TYPE (irr::scene::IAnimatedMesh*, init_animated_mesh_type,
-                        wrap_animated_mesh, unwrap_animated_mesh);
+                        animated_mesh_p, wrap_animated_mesh, unwrap_animated_mesh);
 }
 
 #endif
index d10b9b47f4500a68b4283a3f656f0e3007d38ed6..ae6e29cedba499600fb03ee1a73ce9a6325117a0 100644 (file)
@@ -22,7 +22,7 @@
 #include <irrlicht/irrlicht.h>
 #include <libguile.h>
 #include "IAnimatedMeshSceneNode.h"
-#include "util.h"
+#include "wrapped.h"
 
 extern "C" {
 
@@ -33,7 +33,7 @@ extern "C" {
   }
 
   DEFINE_WRAPPED_TYPE (irr::scene::IAnimatedMeshSceneNode*, "animated-mesh-scene-node",
-                       init_animated_mesh_scene_node_type,
+                       init_animated_mesh_scene_node_type, animated_mesh_scene_node_p,
                        wrap_animated_mesh_scene_node, unwrap_animated_mesh_scene_node);
 
 }
index 14752e994c10c7d17acdbf3f6c9d2cd0cac83896..b4dfd9b7d07079ac6b282a91d42d8156314ea079 100644 (file)
@@ -24,7 +24,7 @@
 
 #include <irrlicht/irrlicht.h>
 #include <libguile.h>
-#include "util.h"
+#include "wrapped.h"
 
 extern "C" {
 
@@ -32,6 +32,7 @@ extern "C" {
   init_animated_mesh_scene_node (void);
 
   DECLARE_WRAPPED_TYPE (irr::scene::IAnimatedMeshSceneNode*, init_animated_mesh_scene_node_type,
+                        animated_mesh_scene_node_p,
                         wrap_animated_mesh_scene_node, unwrap_animated_mesh_scene_node);
 }
 
index 80d767696636dd3e65864503ec66d135a8989fea..810fdb6f694284784f14264c91c318c1dfdf841c 100644 (file)
@@ -22,7 +22,7 @@
 #include <irrlicht/irrlicht.h>
 #include <libguile.h>
 #include "IGUIElement.h"
-#include "util.h"
+#include "wrapped.h"
 
 extern "C" {
 
@@ -33,7 +33,7 @@ extern "C" {
   }
 
   DEFINE_WRAPPED_TYPE (irr::gui::IGUIElement*, "gui-element",
-                       init_gui_element_type,
+                       init_gui_element_type, gui_element_p,
                        wrap_gui_element, unwrap_gui_element);
 
 }
index 659dcbc4388c66ba897ab2582b2d42e4760ef4c9..ab8db9210550e28e21ad6dcca7796568bc7e3131 100644 (file)
@@ -24,7 +24,7 @@
 
 #include <irrlicht/irrlicht.h>
 #include <libguile.h>
-#include "util.h"
+#include "wrapped.h"
 
 extern "C" {
 
@@ -32,7 +32,7 @@ extern "C" {
   init_gui_element (void);
 
   DECLARE_WRAPPED_TYPE (irr::gui::IGUIElement*, init_gui_element_type,
-                        wrap_gui_element, unwrap_gui_element);
+                        gui_element_p, wrap_gui_element, unwrap_gui_element);
 }
 
 #endif
index de4f9f6ad0c58707144ea1d19bfed8482d984ed6..bea7f1e06bed4fd6e0ba82d774e0ebcacc389815 100644 (file)
@@ -25,7 +25,8 @@
 #include "IGUIEnvironment.h"
 #include "IGUIStaticText.h"
 #include "rect.h"
-#include "util.h"
+#include "wchar.h"
+#include "wrapped.h"
 
 extern "C" {
 
@@ -37,7 +38,7 @@ extern "C" {
   }
 
   DEFINE_WRAPPED_TYPE (irr::gui::IGUIEnvironment*, "gui-environment",
-                       init_gui_environment_type,
+                       init_gui_environment_type, gui_environment_p,
                        wrap_gui_environment, unwrap_gui_environment);
 
   SCM
index 6e28bfe77e626dd5c1c956f2f5392a354f3cb995..e4d67311920c4f19c822bf50ca8f90b4a9b947b9 100644 (file)
@@ -24,7 +24,7 @@
 
 #include <irrlicht/irrlicht.h>
 #include <libguile.h>
-#include "util.h"
+#include "wrapped.h"
 
 extern "C" {
 
@@ -32,7 +32,7 @@ extern "C" {
   init_gui_environment (void);
 
   DECLARE_WRAPPED_TYPE (irr::gui::IGUIEnvironment*, init_gui_environment_type,
-                        wrap_gui_environment, unwrap_gui_environment);
+                        gui_environment_p, wrap_gui_environment, unwrap_gui_environment);
 
   SCM
   irr_gui_addStaticText (SCM guienv,
index 4a66db50048f7843682448f62cc3e14c9ecd65dc..2ae1b97661a93c217328269e174912143c86e572 100644 (file)
@@ -22,7 +22,7 @@
 #include <irrlicht/irrlicht.h>
 #include <libguile.h>
 #include "IGUIStaticText.h"
-#include "util.h"
+#include "wrapped.h"
 
 extern "C" {
 
@@ -33,7 +33,7 @@ extern "C" {
   }
 
   DEFINE_WRAPPED_TYPE (irr::gui::IGUIStaticText*, "gui-static-text",
-                       init_gui_static_text_type,
+                       init_gui_static_text_type, gui_static_text_p,
                        wrap_gui_static_text, unwrap_gui_static_text);
 
 }
index 39e2fbd17de9a3704a89abd6e48c8b82acaa57e4..8fe649235d0bf4447f09a209a825adbbaf2d8016 100644 (file)
@@ -24,7 +24,7 @@
 
 #include <irrlicht/irrlicht.h>
 #include <libguile.h>
-#include "util.h"
+#include "wrapped.h"
 
 extern "C" {
 
@@ -32,7 +32,7 @@ extern "C" {
   init_gui_static_text (void);
 
   DECLARE_WRAPPED_TYPE (irr::gui::IGUIStaticText*, init_gui_static_text_type,
-                        wrap_gui_static_text, unwrap_gui_static_text);
+                        gui_static_text_p, wrap_gui_static_text, unwrap_gui_static_text);
 }
 
 #endif
diff --git a/src/IReferenceCounted.cpp b/src/IReferenceCounted.cpp
new file mode 100644 (file)
index 0000000..b787821
--- /dev/null
@@ -0,0 +1,51 @@
+/* guile-irrlicht --- GNU Guile bindings for Irrlicht Engine
+
+   Copyright (C) 2020 Javier Sancho <jsf@jsancho.org>
+
+   This file is part of guile-irrlicht.
+
+   guile-irrlicht is free software; you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as
+   published by the Free Software Foundation; either version 3 of the
+   License, or (at your option) any later version.
+
+   guile-irrlicht is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with guile-irrlicht. If not, see
+   <http://www.gnu.org/licenses/>.
+*/
+
+#include <irrlicht/irrlicht.h>
+#include <libguile.h>
+
+#include "IReferenceCounted.h"
+#include "IrrlichtDevice.h"
+
+extern "C" {
+
+  void
+  init_reference_counted (void)
+  {
+    scm_c_define_gsubr ("drop!", 1, 0, 0, (scm_t_subr)irr_drop);
+  }
+
+  SCM
+  irr_drop (SCM wrapped_obj)
+  {
+    if (device_p (wrapped_obj))
+      {
+        irr::IrrlichtDevice* obj = unwrap_device (wrapped_obj);
+        return scm_from_bool (obj->drop ());
+      }
+    else
+      {
+        irr::IReferenceCounted* obj = (irr::IReferenceCounted*)scm_foreign_object_ref (wrapped_obj, 0);
+        return scm_from_bool (obj->drop ());
+      }
+  }
+
+}
diff --git a/src/IReferenceCounted.h b/src/IReferenceCounted.h
new file mode 100644 (file)
index 0000000..6d965d0
--- /dev/null
@@ -0,0 +1,38 @@
+/* guile-irrlicht --- GNU Guile bindings for Irrlicht Engine
+
+   Copyright (C) 2020 Javier Sancho <jsf@jsancho.org>
+
+   This file is part of guile-irrlicht.
+
+   guile-irrlicht is free software; you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as
+   published by the Free Software Foundation; either version 3 of the
+   License, or (at your option) any later version.
+
+   guile-irrlicht is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with guile-irrlicht. If not, see
+   <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef __GUILE_I_REFERENCE_COUNTED_INCLUDED__
+#define __GUILE_I_REFERENCE_COUNTED_INCLUDED__
+
+#include <irrlicht/irrlicht.h>
+#include <libguile.h>
+
+extern "C" {
+
+  void
+  init_reference_counted (void);
+
+  SCM
+  irr_drop (SCM wrapped_obj);
+
+}
+
+#endif
index e6cebf48e9550c68cc255018c91d543eaf1873ae..5e8d2d5a13153d9c70a445fdc9815a75f5261941 100644 (file)
@@ -25,8 +25,8 @@
 #include "IAnimatedMeshSceneNode.h"
 #include "ISceneManager.h"
 #include "ISceneNode.h"
-#include "util.h"
 #include "vector3d.h"
+#include "wrapped.h"
 
 extern "C" {
 
@@ -40,7 +40,7 @@ extern "C" {
   }
 
   DEFINE_WRAPPED_TYPE (irr::scene::ISceneManager*, "scene-manager",
-                       init_scene_manager_type,
+                       init_scene_manager_type, scene_manager_p,
                        wrap_scene_manager, unwrap_scene_manager);
 
   SCM
index 02b27de13452703c36272cbd9b31ce5f34b5392d..d5b4b2fef28fbef74ada67df031675b27aaff4ce 100644 (file)
@@ -24,7 +24,7 @@
 
 #include <irrlicht/irrlicht.h>
 #include <libguile.h>
-#include "util.h"
+#include "wrapped.h"
 
 extern "C" {
 
@@ -32,7 +32,7 @@ extern "C" {
   init_scene_manager (void);
 
   DECLARE_WRAPPED_TYPE (irr::scene::ISceneManager*, init_scene_manager_type,
-                        wrap_scene_manager, unwrap_scene_manager);
+                        scene_manager_p, wrap_scene_manager, unwrap_scene_manager);
 
   SCM
   irr_scene_addAnimatedMeshSceneNode (SCM wrapped_scene_manager,
index fd9b60cbef2808d037970ab583ebfabb51a3f36c..29b094c379704723d332c4dc6e507c3229c33d50 100644 (file)
@@ -22,7 +22,7 @@
 #include <irrlicht/irrlicht.h>
 #include <libguile.h>
 #include "ISceneNode.h"
-#include "util.h"
+#include "wrapped.h"
 
 extern "C" {
 
@@ -33,7 +33,7 @@ extern "C" {
   }
 
   DEFINE_WRAPPED_TYPE (irr::scene::ISceneNode*, "scene-node",
-                       init_scene_node_type,
+                       init_scene_node_type, scene_node_p,
                        wrap_scene_node, unwrap_scene_node);
 
 }
index 79aa0a08534bc0e290be1de8b7a4536790bba980..b66309154c6809ebdce053ac165a5c501d12eed8 100644 (file)
@@ -24,7 +24,7 @@
 
 #include <irrlicht/irrlicht.h>
 #include <libguile.h>
-#include "util.h"
+#include "wrapped.h"
 
 extern "C" {
 
@@ -32,7 +32,7 @@ extern "C" {
   init_scene_node (void);
 
   DECLARE_WRAPPED_TYPE (irr::scene::ISceneNode*, init_scene_node_type,
-                        wrap_scene_node, unwrap_scene_node);
+                        scene_node_p, wrap_scene_node, unwrap_scene_node);
 }
 
 #endif
index a784437b693effd52cbbc49adde8924affff3d3e..839db75e862d39eca3ae617bf2b729ccd11e6398 100644 (file)
@@ -22,7 +22,7 @@
 #include <irrlicht/irrlicht.h>
 #include <libguile.h>
 #include "IVideoDriver.h"
-#include "util.h"
+#include "wrapped.h"
 
 extern "C" {
 
@@ -33,7 +33,7 @@ extern "C" {
   }
 
   DEFINE_WRAPPED_TYPE (irr::video::IVideoDriver*, "video-driver",
-                       init_video_driver_type,
+                       init_video_driver_type, video_driver_p,
                        wrap_video_driver, unwrap_video_driver);
 
 }
index 4e9f0326625c8715fd4f1f04fa340baceb75a0eb..df5c3de711ab2054f5f98cb615de558f7cc9b6bb 100644 (file)
@@ -24,7 +24,7 @@
 
 #include <irrlicht/irrlicht.h>
 #include <libguile.h>
-#include "util.h"
+#include "wrapped.h"
 
 extern "C" {
 
@@ -32,7 +32,7 @@ extern "C" {
   init_video_driver (void);
 
   DECLARE_WRAPPED_TYPE (irr::video::IVideoDriver*, init_video_driver_type,
-                        wrap_video_driver, unwrap_video_driver);
+                        video_driver_p, wrap_video_driver, unwrap_video_driver);
 
 }
 
index a220cac5a3e91cfa2681250ecee1b611175dcdcd..9cccd58067803b28daf69f74bd232e233ca1793d 100644 (file)
@@ -28,7 +28,8 @@
 #include "IrrlichtDevice.h"
 #include "ISceneManager.h"
 #include "IVideoDriver.h"
-#include "util.h"
+#include "wchar.h"
+#include "wrapped.h"
 
 extern "C" {
 
@@ -37,7 +38,6 @@ extern "C" {
   {
     init_device_type ();
     scm_c_define_gsubr ("create-device", 7, 0, 0, (scm_t_subr)irr_createDevice);
-    scm_c_define_gsubr ("device-drop!", 1, 0, 0, (scm_t_subr)irr_deviceDrop);
     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);
@@ -45,7 +45,8 @@ extern "C" {
   }
 
   DEFINE_WRAPPED_TYPE (irr::IrrlichtDevice*, "device",
-                       init_device_type, wrap_device, unwrap_device);
+                       init_device_type, device_p,
+                       wrap_device, unwrap_device);
 
   SCM
   irr_createDevice (SCM deviceType,
@@ -66,13 +67,6 @@ extern "C" {
     return wrap_device (device);
   }
 
-  SCM
-  irr_deviceDrop (SCM wrapped_device)
-  {
-    irr::IrrlichtDevice* device = unwrap_device (wrapped_device);
-    return scm_from_bool (device->drop ());
-  }
-
   SCM
   irr_getGUIEnvironment (SCM wrapped_device)
   {
index 4b5b604ce41098e7138c358161068bd46fd24430..898341bb24887fb87cb9b588bdd1a65b6420b211 100644 (file)
@@ -24,7 +24,7 @@
 
 #include <irrlicht/irrlicht.h>
 #include <libguile.h>
-#include "util.h"
+#include "wrapped.h"
 
 extern "C" {
 
@@ -32,7 +32,7 @@ extern "C" {
   init_device (void);
 
   DECLARE_WRAPPED_TYPE (irr::IrrlichtDevice*, init_device_type,
-                        wrap_device, unwrap_device);
+                        device_p, wrap_device, unwrap_device);
 
   SCM
   irr_createDevice (SCM deviceType,
@@ -43,9 +43,6 @@ extern "C" {
                     SCM vsync,
                     SCM receiver);
 
-  SCM
-  irr_deviceDrop (SCM wrapped_device);
-
   SCM
   irr_getGUIEnvironment (SCM wrapped_device);
 
diff --git a/src/util.cpp b/src/util.cpp
deleted file mode 100644 (file)
index eb5b8a8..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/* guile-irrlicht --- GNU Guile bindings for Irrlicht Engine
-
-   Copyright (C) 2020 Javier Sancho <jsf@jsancho.org>
-
-   This file is part of guile-irrlicht.
-
-   guile-irrlicht is free software; you can redistribute it and/or modify
-   it under the terms of the GNU Lesser General Public License as
-   published by the Free Software Foundation; either version 3 of the
-   License, or (at your option) any later version.
-
-   guile-irrlicht is distributed in the hope that it will be useful, but
-   WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with guile-irrlicht. If not, see
-   <http://www.gnu.org/licenses/>.
-*/
-
-#include <libguile.h>
-#include <wchar.h>
-#include "util.h"
-
-wchar_t*
-scm_to_wide_char_string (SCM text)
-{
-  char* ctext = scm_to_utf8_stringn (text, NULL);
-  wchar_t* wtext = (wchar_t*)malloc ((strlen (ctext) + 1) * sizeof (wchar_t));
-  mbstowcs (wtext, ctext, strlen (ctext) + 1);
-  return wtext;
-}
diff --git a/src/util.h b/src/util.h
deleted file mode 100644 (file)
index 3ce84a4..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/* guile-irrlicht --- GNU Guile bindings for Irrlicht Engine
-
-   Copyright (C) 2020 Javier Sancho <jsf@jsancho.org>
-
-   This file is part of guile-irrlicht.
-
-   guile-irrlicht is free software; you can redistribute it and/or modify
-   it under the terms of the GNU Lesser General Public License as
-   published by the Free Software Foundation; either version 3 of the
-   License, or (at your option) any later version.
-
-   guile-irrlicht is distributed in the hope that it will be useful, but
-   WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with guile-irrlicht. If not, see
-   <http://www.gnu.org/licenses/>.
-*/
-
-#include <libguile.h>
-#include <wchar.h>
-
-#define DECLARE_WRAPPED_TYPE(TYPE, INIT, WRAP, UNWRAP)                  \
-  void                                                                  \
-  INIT (void);                                                          \
-                                                                        \
-  SCM                                                                   \
-  WRAP (TYPE foreign_obj);                                              \
-                                                                        \
-  TYPE                                                                  \
-  UNWRAP (SCM wrapped_obj);
-
-
-#define DEFINE_WRAPPED_TYPE(TYPE, PRINT_NAME, INIT, WRAP, UNWRAP)       \
-  static SCM wrapped_type;                                              \
-                                                                        \
-  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_type =                                                      \
-      scm_make_foreign_object_type (name, slots, finalizer);            \
-  }                                                                     \
-                                                                        \
-  SCM                                                                   \
-  WRAP (TYPE foreign_obj)                                               \
-  {                                                                     \
-    return scm_make_foreign_object_1 (wrapped_type, foreign_obj);       \
-  }                                                                     \
-                                                                        \
-  TYPE                                                                  \
-  UNWRAP (SCM wrapped_obj)                                              \
-  {                                                                     \
-    scm_assert_foreign_object_type (wrapped_type, wrapped_obj);         \
-    return (TYPE)scm_foreign_object_ref (wrapped_obj, 0);               \
-  }
-
-wchar_t*
-scm_to_wide_char_string (SCM text);
diff --git a/src/wchar.cpp b/src/wchar.cpp
new file mode 100644 (file)
index 0000000..872c87a
--- /dev/null
@@ -0,0 +1,33 @@
+/* guile-irrlicht --- GNU Guile bindings for Irrlicht Engine
+
+   Copyright (C) 2020 Javier Sancho <jsf@jsancho.org>
+
+   This file is part of guile-irrlicht.
+
+   guile-irrlicht is free software; you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as
+   published by the Free Software Foundation; either version 3 of the
+   License, or (at your option) any later version.
+
+   guile-irrlicht is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with guile-irrlicht. If not, see
+   <http://www.gnu.org/licenses/>.
+*/
+
+#include <libguile.h>
+#include <wchar.h>
+#include "wchar.h"
+
+wchar_t*
+scm_to_wide_char_string (SCM text)
+{
+  char* ctext = scm_to_utf8_stringn (text, NULL);
+  wchar_t* wtext = (wchar_t*)malloc ((strlen (ctext) + 1) * sizeof (wchar_t));
+  mbstowcs (wtext, ctext, strlen (ctext) + 1);
+  return wtext;
+}
diff --git a/src/wchar.h b/src/wchar.h
new file mode 100644 (file)
index 0000000..d9697d2
--- /dev/null
@@ -0,0 +1,26 @@
+/* guile-irrlicht --- GNU Guile bindings for Irrlicht Engine
+
+   Copyright (C) 2020 Javier Sancho <jsf@jsancho.org>
+
+   This file is part of guile-irrlicht.
+
+   guile-irrlicht is free software; you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as
+   published by the Free Software Foundation; either version 3 of the
+   License, or (at your option) any later version.
+
+   guile-irrlicht is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with guile-irrlicht. If not, see
+   <http://www.gnu.org/licenses/>.
+*/
+
+#include <libguile.h>
+#include <wchar.h>
+
+wchar_t*
+scm_to_wide_char_string (SCM text);
diff --git a/src/wrapped.h b/src/wrapped.h
new file mode 100644 (file)
index 0000000..2412d7e
--- /dev/null
@@ -0,0 +1,72 @@
+/* guile-irrlicht --- GNU Guile bindings for Irrlicht Engine
+
+   Copyright (C) 2020 Javier Sancho <jsf@jsancho.org>
+
+   This file is part of guile-irrlicht.
+
+   guile-irrlicht is free software; you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as
+   published by the Free Software Foundation; either version 3 of the
+   License, or (at your option) any later version.
+
+   guile-irrlicht is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with guile-irrlicht. If not, see
+   <http://www.gnu.org/licenses/>.
+*/
+
+#include <libguile.h>
+
+#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);
+
+
+#define DEFINE_WRAPPED_TYPE(TYPE, PRINT_NAME, INIT, PRED, WRAP, UNWRAP) \
+  static SCM wrapped_type;                                              \
+                                                                        \
+  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_type =                                                      \
+      scm_make_foreign_object_type (name, slots, finalizer);            \
+  }                                                                     \
+                                                                        \
+  SCM                                                                   \
+  WRAP (TYPE foreign_obj)                                               \
+  {                                                                     \
+    return scm_make_foreign_object_1 (wrapped_type, foreign_obj);       \
+  }                                                                     \
+                                                                        \
+  TYPE                                                                  \
+  UNWRAP (SCM wrapped_obj)                                              \
+  {                                                                     \
+    scm_assert_foreign_object_type (wrapped_type, wrapped_obj);         \
+    return (TYPE)scm_foreign_object_ref (wrapped_obj, 0);               \
+  }                                                                     \
+                                                                        \
+  bool                                                                  \
+  PRED (SCM wrapped_obj)                                                \
+  {                                                                     \
+    return SCM_IS_A_P (wrapped_obj, wrapped_type);                      \
+  }