From: Javier Sancho Date: Mon, 9 Mar 2020 16:55:04 +0000 (+0100) Subject: refactor X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=2dfe078cf4082caf641c96449907f36a9029b486;p=guile-irrlicht.git refactor --- diff --git a/Makefile.am b/Makefile.am index 36003c1..8f92257 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 \ diff --git a/irrlicht.scm b/irrlicht.scm index 327c45e..1b635f2 100644 --- a/irrlicht.scm +++ b/irrlicht.scm @@ -25,6 +25,7 @@ (let ((public-modules '((irrlicht device) (irrlicht gui) + (irrlicht irr) (irrlicht scene))) (current-interface (module-public-interface (current-module)))) diff --git a/irrlicht/device.scm b/irrlicht/device.scm index 2a61890..e07a812 100644 --- a/irrlicht/device.scm +++ b/irrlicht/device.scm @@ -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 index 0000000..9b89142 --- /dev/null +++ b/irrlicht/irr.scm @@ -0,0 +1,24 @@ +;;; guile-irrlicht --- FFI bindings for Irrlicht Engine +;;; Copyright (C) 2019 Javier Sancho +;;; +;;; 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 +;;; . + + +(define-module (irrlicht irr) + #:export (drop!)) + +(load-extension "libguile-irrlicht" "init_guile_irrlicht") diff --git a/irrlicht/scene.scm b/irrlicht/scene.scm index b815700..17437fe 100644 --- a/irrlicht/scene.scm +++ b/irrlicht/scene.scm @@ -18,7 +18,7 @@ ;;; . -(define-module (irrlicht gui) +(define-module (irrlicht scene) #:export (add-animated-mesh-scene-node get-mesh)) diff --git a/src/EDriverTypes.cpp b/src/EDriverTypes.cpp index ec41fe9..8b3f678 100644 --- a/src/EDriverTypes.cpp +++ b/src/EDriverTypes.cpp @@ -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 index 0000000..7c38fe8 --- /dev/null +++ b/src/EMaterialFlags.cpp @@ -0,0 +1,114 @@ +/* guile-irrlicht --- GNU Guile bindings for Irrlicht Engine + + Copyright (C) 2020 Javier Sancho + + 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 + . +*/ + +#include +#include +#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 index 0000000..be94343 --- /dev/null +++ b/src/EMaterialFlags.h @@ -0,0 +1,35 @@ +/* guile-irrlicht --- GNU Guile bindings for Irrlicht Engine + + Copyright (C) 2020 Javier Sancho + + 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 + . +*/ + +#ifndef __GUILE_IRRLICHT_E_MATERIAL_FLAGS_INCLUDED__ +#define __GUILE_IRRLICHT_E_MATERIAL_FLAGS_INCLUDED__ + +#include +#include + +extern "C" { + + irr::video::E_MATERIAL_FLAG + scm_to_material_flag (SCM material_flag); + +} + +#endif diff --git a/src/GuileIrrlicht.cpp b/src/GuileIrrlicht.cpp index 2c20385..8b6275f 100644 --- a/src/GuileIrrlicht.cpp +++ b/src/GuileIrrlicht.cpp @@ -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 (); diff --git a/src/IAnimatedMesh.cpp b/src/IAnimatedMesh.cpp index 52394ef..883527e 100644 --- a/src/IAnimatedMesh.cpp +++ b/src/IAnimatedMesh.cpp @@ -22,7 +22,7 @@ #include #include #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); } diff --git a/src/IAnimatedMesh.h b/src/IAnimatedMesh.h index 3926002..b9f77c3 100644 --- a/src/IAnimatedMesh.h +++ b/src/IAnimatedMesh.h @@ -24,7 +24,7 @@ #include #include -#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 diff --git a/src/IAnimatedMeshSceneNode.cpp b/src/IAnimatedMeshSceneNode.cpp index d10b9b4..ae6e29c 100644 --- a/src/IAnimatedMeshSceneNode.cpp +++ b/src/IAnimatedMeshSceneNode.cpp @@ -22,7 +22,7 @@ #include #include #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); } diff --git a/src/IAnimatedMeshSceneNode.h b/src/IAnimatedMeshSceneNode.h index 14752e9..b4dfd9b 100644 --- a/src/IAnimatedMeshSceneNode.h +++ b/src/IAnimatedMeshSceneNode.h @@ -24,7 +24,7 @@ #include #include -#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); } diff --git a/src/IGUIElement.cpp b/src/IGUIElement.cpp index 80d7676..810fdb6 100644 --- a/src/IGUIElement.cpp +++ b/src/IGUIElement.cpp @@ -22,7 +22,7 @@ #include #include #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); } diff --git a/src/IGUIElement.h b/src/IGUIElement.h index 659dcbc..ab8db92 100644 --- a/src/IGUIElement.h +++ b/src/IGUIElement.h @@ -24,7 +24,7 @@ #include #include -#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 diff --git a/src/IGUIEnvironment.cpp b/src/IGUIEnvironment.cpp index de4f9f6..bea7f1e 100644 --- a/src/IGUIEnvironment.cpp +++ b/src/IGUIEnvironment.cpp @@ -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 diff --git a/src/IGUIEnvironment.h b/src/IGUIEnvironment.h index 6e28bfe..e4d6731 100644 --- a/src/IGUIEnvironment.h +++ b/src/IGUIEnvironment.h @@ -24,7 +24,7 @@ #include #include -#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, diff --git a/src/IGUIStaticText.cpp b/src/IGUIStaticText.cpp index 4a66db5..2ae1b97 100644 --- a/src/IGUIStaticText.cpp +++ b/src/IGUIStaticText.cpp @@ -22,7 +22,7 @@ #include #include #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); } diff --git a/src/IGUIStaticText.h b/src/IGUIStaticText.h index 39e2fbd..8fe6492 100644 --- a/src/IGUIStaticText.h +++ b/src/IGUIStaticText.h @@ -24,7 +24,7 @@ #include #include -#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 index 0000000..b787821 --- /dev/null +++ b/src/IReferenceCounted.cpp @@ -0,0 +1,51 @@ +/* guile-irrlicht --- GNU Guile bindings for Irrlicht Engine + + Copyright (C) 2020 Javier Sancho + + 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 + . +*/ + +#include +#include + +#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 index 0000000..6d965d0 --- /dev/null +++ b/src/IReferenceCounted.h @@ -0,0 +1,38 @@ +/* guile-irrlicht --- GNU Guile bindings for Irrlicht Engine + + Copyright (C) 2020 Javier Sancho + + 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 + . +*/ + +#ifndef __GUILE_I_REFERENCE_COUNTED_INCLUDED__ +#define __GUILE_I_REFERENCE_COUNTED_INCLUDED__ + +#include +#include + +extern "C" { + + void + init_reference_counted (void); + + SCM + irr_drop (SCM wrapped_obj); + +} + +#endif diff --git a/src/ISceneManager.cpp b/src/ISceneManager.cpp index e6cebf4..5e8d2d5 100644 --- a/src/ISceneManager.cpp +++ b/src/ISceneManager.cpp @@ -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 diff --git a/src/ISceneManager.h b/src/ISceneManager.h index 02b27de..d5b4b2f 100644 --- a/src/ISceneManager.h +++ b/src/ISceneManager.h @@ -24,7 +24,7 @@ #include #include -#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, diff --git a/src/ISceneNode.cpp b/src/ISceneNode.cpp index fd9b60c..29b094c 100644 --- a/src/ISceneNode.cpp +++ b/src/ISceneNode.cpp @@ -22,7 +22,7 @@ #include #include #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); } diff --git a/src/ISceneNode.h b/src/ISceneNode.h index 79aa0a0..b663091 100644 --- a/src/ISceneNode.h +++ b/src/ISceneNode.h @@ -24,7 +24,7 @@ #include #include -#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 diff --git a/src/IVideoDriver.cpp b/src/IVideoDriver.cpp index a784437..839db75 100644 --- a/src/IVideoDriver.cpp +++ b/src/IVideoDriver.cpp @@ -22,7 +22,7 @@ #include #include #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); } diff --git a/src/IVideoDriver.h b/src/IVideoDriver.h index 4e9f032..df5c3de 100644 --- a/src/IVideoDriver.h +++ b/src/IVideoDriver.h @@ -24,7 +24,7 @@ #include #include -#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); } diff --git a/src/IrrlichtDevice.cpp b/src/IrrlichtDevice.cpp index a220cac..9cccd58 100644 --- a/src/IrrlichtDevice.cpp +++ b/src/IrrlichtDevice.cpp @@ -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) { diff --git a/src/IrrlichtDevice.h b/src/IrrlichtDevice.h index 4b5b604..898341b 100644 --- a/src/IrrlichtDevice.h +++ b/src/IrrlichtDevice.h @@ -24,7 +24,7 @@ #include #include -#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 index eb5b8a8..0000000 --- a/src/util.cpp +++ /dev/null @@ -1,33 +0,0 @@ -/* guile-irrlicht --- GNU Guile bindings for Irrlicht Engine - - Copyright (C) 2020 Javier Sancho - - 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 - . -*/ - -#include -#include -#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 index 3ce84a4..0000000 --- a/src/util.h +++ /dev/null @@ -1,67 +0,0 @@ -/* guile-irrlicht --- GNU Guile bindings for Irrlicht Engine - - Copyright (C) 2020 Javier Sancho - - 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 - . -*/ - -#include -#include - -#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 index 0000000..872c87a --- /dev/null +++ b/src/wchar.cpp @@ -0,0 +1,33 @@ +/* guile-irrlicht --- GNU Guile bindings for Irrlicht Engine + + Copyright (C) 2020 Javier Sancho + + 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 + . +*/ + +#include +#include +#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 index 0000000..d9697d2 --- /dev/null +++ b/src/wchar.h @@ -0,0 +1,26 @@ +/* guile-irrlicht --- GNU Guile bindings for Irrlicht Engine + + Copyright (C) 2020 Javier Sancho + + 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 + . +*/ + +#include +#include + +wchar_t* +scm_to_wide_char_string (SCM text); diff --git a/src/wrapped.h b/src/wrapped.h new file mode 100644 index 0000000..2412d7e --- /dev/null +++ b/src/wrapped.h @@ -0,0 +1,72 @@ +/* guile-irrlicht --- GNU Guile bindings for Irrlicht Engine + + Copyright (C) 2020 Javier Sancho + + 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 + . +*/ + +#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); + + +#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); \ + }