libguile_irrlicht_la_SOURCES = \
src/dimension2d.cpp \
src/EDriverTypes.cpp \
+ src/EMaterialFlags.cpp \
src/GuileIrrlicht.cpp \
src/IAnimatedMesh.cpp \
src/IAnimatedMeshSceneNode.cpp \
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 \
(let ((public-modules
'((irrlicht device)
(irrlicht gui)
+ (irrlicht irr)
(irrlicht scene)))
(current-interface
(module-public-interface (current-module))))
(define-module (irrlicht device)
#:export (create-device
- device-drop!
get-gui-environment
get-scene-manager
get-video-driver
--- /dev/null
+;;; 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")
;;; <http://www.gnu.org/licenses/>.
-(define-module (irrlicht gui)
+(define-module (irrlicht scene)
#:export (add-animated-mesh-scene-node
get-mesh))
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;
}
--- /dev/null
+/* 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;
+ }
+ }
+
+}
--- /dev/null
+/* 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
#include "IrrlichtDevice.h"
#include "ISceneManager.h"
#include "ISceneNode.h"
+#include "IReferenceCounted.h"
#include "IVideoDriver.h"
extern "C" {
init_gui_element ();
init_gui_environment ();
init_gui_static_text ();
+ init_reference_counted ();
init_scene_manager ();
init_scene_node ();
init_video_driver ();
#include <irrlicht/irrlicht.h>
#include <libguile.h>
#include "IAnimatedMesh.h"
-#include "util.h"
+#include "wrapped.h"
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);
}
#include <irrlicht/irrlicht.h>
#include <libguile.h>
-#include "util.h"
+#include "wrapped.h"
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
#include <irrlicht/irrlicht.h>
#include <libguile.h>
#include "IAnimatedMeshSceneNode.h"
-#include "util.h"
+#include "wrapped.h"
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);
}
#include <irrlicht/irrlicht.h>
#include <libguile.h>
-#include "util.h"
+#include "wrapped.h"
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);
}
#include <irrlicht/irrlicht.h>
#include <libguile.h>
#include "IGUIElement.h"
-#include "util.h"
+#include "wrapped.h"
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);
}
#include <irrlicht/irrlicht.h>
#include <libguile.h>
-#include "util.h"
+#include "wrapped.h"
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
#include "IGUIEnvironment.h"
#include "IGUIStaticText.h"
#include "rect.h"
-#include "util.h"
+#include "wchar.h"
+#include "wrapped.h"
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
#include <irrlicht/irrlicht.h>
#include <libguile.h>
-#include "util.h"
+#include "wrapped.h"
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,
#include <irrlicht/irrlicht.h>
#include <libguile.h>
#include "IGUIStaticText.h"
-#include "util.h"
+#include "wrapped.h"
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);
}
#include <irrlicht/irrlicht.h>
#include <libguile.h>
-#include "util.h"
+#include "wrapped.h"
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
--- /dev/null
+/* 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 ());
+ }
+ }
+
+}
--- /dev/null
+/* 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
#include "IAnimatedMeshSceneNode.h"
#include "ISceneManager.h"
#include "ISceneNode.h"
-#include "util.h"
#include "vector3d.h"
+#include "wrapped.h"
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
#include <irrlicht/irrlicht.h>
#include <libguile.h>
-#include "util.h"
+#include "wrapped.h"
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,
#include <irrlicht/irrlicht.h>
#include <libguile.h>
#include "ISceneNode.h"
-#include "util.h"
+#include "wrapped.h"
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);
}
#include <irrlicht/irrlicht.h>
#include <libguile.h>
-#include "util.h"
+#include "wrapped.h"
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
#include <irrlicht/irrlicht.h>
#include <libguile.h>
#include "IVideoDriver.h"
-#include "util.h"
+#include "wrapped.h"
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);
}
#include <irrlicht/irrlicht.h>
#include <libguile.h>
-#include "util.h"
+#include "wrapped.h"
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);
}
#include "IrrlichtDevice.h"
#include "ISceneManager.h"
#include "IVideoDriver.h"
-#include "util.h"
+#include "wchar.h"
+#include "wrapped.h"
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);
}
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,
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)
{
#include <irrlicht/irrlicht.h>
#include <libguile.h>
-#include "util.h"
+#include "wrapped.h"
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,
SCM vsync,
SCM receiver);
- SCM
- irr_deviceDrop (SCM wrapped_device);
-
SCM
irr_getGUIEnvironment (SCM wrapped_device);
+++ /dev/null
-/* 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;
-}
+++ /dev/null
-/* 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);
--- /dev/null
+/* 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;
+}
--- /dev/null
+/* 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);
--- /dev/null
+/* 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); \
+ }