]> git.jsancho.org Git - guile-irrlicht.git/commitdiff
file-system
authorJavier Sancho <jsf@jsancho.org>
Sat, 9 May 2020 08:42:32 +0000 (10:42 +0200)
committerJavier Sancho <jsf@jsancho.org>
Sat, 9 May 2020 08:42:32 +0000 (10:42 +0200)
src/device.cpp
src/device.h
src/file-system.cpp
src/file-system.h

index 10ba8ad6c2e67086e5dc27ddcc76e685c3916b1e..95b6429d8c129f12e7b19357fb606d0b6c5fc9bb 100644 (file)
@@ -62,6 +62,15 @@ IrrlichtDevice_getCursorControl (SCM device)
 }
 
 
+SCM
+IrrlichtDevice_getFileSystem (SCM device)
+{
+  io::IFileSystem* file_system =
+    ((IrrlichtDevice*)scm_to_pointer (device))->getFileSystem ();
+  return scm_from_pointer ((void*)file_system, NULL);
+}
+
+
 SCM
 IrrlichtDevice_getGUIEnvironment (SCM device)
 {
@@ -159,30 +168,20 @@ extern "C" {
   init_device (void)
   {
     init_device_type ();
-    DEFINE_GSUBR ("createDevice_IEventReceiver", 7, 0, 0,
-                  createDevice<IEventReceiver*>);
-    DEFINE_GSUBR ("IrrlichtDevice_getCursorControl", 1, 0, 0,
-                  IrrlichtDevice_getCursorControl);
-    DEFINE_GSUBR ("IrrlichtDevice_getGUIEnvironment", 1, 0, 0,
-                  IrrlichtDevice_getGUIEnvironment);
-    DEFINE_GSUBR ("IrrlichtDevice_getSceneManager", 1, 0, 0,
-                  IrrlichtDevice_getSceneManager);
-    DEFINE_GSUBR ("IrrlichtDevice_getTimer", 1, 0, 0,
-                  IrrlichtDevice_getTimer);
-    DEFINE_GSUBR ("IrrlichtDevice_getVideoDriver", 1, 0, 0,
-                  IrrlichtDevice_getVideoDriver);
-    DEFINE_GSUBR ("IrrlichtDevice_isWindowActive", 1, 0, 0,
-                  IrrlichtDevice_isWindowActive);
-    DEFINE_GSUBR ("IrrlichtDevice_run", 1, 0, 0,
-                  IrrlichtDevice_run);
+    DEFINE_GSUBR ("createDevice_IEventReceiver", 7, 0, 0, createDevice<IEventReceiver*>);
+    DEFINE_GSUBR ("IrrlichtDevice_getCursorControl", 1, 0, 0, IrrlichtDevice_getCursorControl);
+    DEFINE_GSUBR ("IrrlichtDevice_getFileSystem", 1, 0, 0, IrrlichtDevice_getFileSystem);
+    DEFINE_GSUBR ("IrrlichtDevice_getGUIEnvironment", 1, 0, 0, IrrlichtDevice_getGUIEnvironment);
+    DEFINE_GSUBR ("IrrlichtDevice_getSceneManager", 1, 0, 0, IrrlichtDevice_getSceneManager);
+    DEFINE_GSUBR ("IrrlichtDevice_getTimer", 1, 0, 0, IrrlichtDevice_getTimer);
+    DEFINE_GSUBR ("IrrlichtDevice_getVideoDriver", 1, 0, 0, IrrlichtDevice_getVideoDriver);
+    DEFINE_GSUBR ("IrrlichtDevice_isWindowActive", 1, 0, 0, IrrlichtDevice_isWindowActive);
+    DEFINE_GSUBR ("IrrlichtDevice_run", 1, 0, 0, IrrlichtDevice_run);
     DEFINE_GSUBR ("IrrlichtDevice_setEventReceiver_IEventReceiver", 2, 0, 0,
                   IrrlichtDevice_setEventReceiver<IEventReceiver*>);
-    DEFINE_GSUBR ("IrrlichtDevice_setResizable", 2, 0, 0,
-                  IrrlichtDevice_setResizable);
-    DEFINE_GSUBR ("IrrlichtDevice_setWindowCaption", 2, 0, 0,
-                  IrrlichtDevice_setWindowCaption);
-    DEFINE_GSUBR ("IrrlichtDevice_yield", 1, 0, 0,
-                  IrrlichtDevice_yield);
+    DEFINE_GSUBR ("IrrlichtDevice_setResizable", 2, 0, 0, IrrlichtDevice_setResizable);
+    DEFINE_GSUBR ("IrrlichtDevice_setWindowCaption", 2, 0, 0, IrrlichtDevice_setWindowCaption);
+    DEFINE_GSUBR ("IrrlichtDevice_yield", 1, 0, 0, IrrlichtDevice_yield);
   }
 
 }
index 63732b2dce7265c5224788df1bfaab3d99a34e4b..94f63c99e6b37cde78c57baef52eddf18327ff1f 100644 (file)
@@ -38,6 +38,9 @@ createDevice (SCM device_type,
 SCM
 IrrlichtDevice_getCursorControl (SCM device);
 
+SCM
+IrrlichtDevice_getFileSystem (SCM device);
+
 SCM
 IrrlichtDevice_getGUIEnvironment (SCM device);
 
index 44171b362c46f4ecce38a9503a11f29c22cc9d82..76892ef7a74ac78a86113ff06659b36b5b996b2d 100644 (file)
 
 #include <irrlicht/irrlicht.h>
 #include <libguile.h>
-
-#include "device.h"
 #include "file-archive.h"
 #include "file-system.h"
 #include "gsubr.h"
-#include "gui-environment.h"
-#include "scene-manager.h"
 
-extern "C" {
 
-  void
-  init_file_system (void)
-  {
-    init_file_system_type ();
-    DEFINE_GSUBR ("add-file-archive!", 2, 0, 1, irr_io_addFileArchive);
-    DEFINE_GSUBR ("get-file-system", 1, 0, 0, irr_getFileSystem);
-  }
+using namespace irr;
 
-  DEFINE_WRAPPED_TYPE (irr::io::IFileSystem*, "file-system",
-                       init_file_system_type, file_system_p,
-                       wrap_file_system, unwrap_file_system);
 
-  SCM
-  irr_io_addFileArchive (SCM wrapped_file_system,
-                         SCM filename,
-                         SCM rest)
-  {
-    SCM ignore_case = SCM_BOOL_T;
-    SCM ignore_paths = SCM_BOOL_T;
-    SCM archive_type = scm_from_utf8_symbol ("unknown");
-    SCM password = scm_from_utf8_string ("");
-    SCM ret_archive = SCM_UNDEFINED;
+SCM
+io_IFileSystem_addFileArchive (SCM file_system,
+                               SCM filename,
+                               SCM ignore_case,
+                               SCM ignore_paths,
+                               SCM archive_type,
+                               SCM password,
+                               SCM ret_archive)
+{
+  io::IFileArchive* retArchive = (io::IFileArchive*)scm_to_pointer (ret_archive);
+  io::IFileArchive** retArchiveReference = 0;
+  if (retArchive != NULL)
+    {
+      retArchiveReference = &retArchive;
+    }
 
-    scm_c_bind_keyword_arguments ("add-file-archive!", rest, (scm_t_keyword_arguments_flags)0,
-                                  scm_from_utf8_keyword ("ignore-case"), &ignore_case,
-                                  scm_from_utf8_keyword ("ignore-paths"), &ignore_paths,
-                                  scm_from_utf8_keyword ("archive-type"), &archive_type,
-                                  scm_from_utf8_keyword ("password"), &password,
-                                  scm_from_utf8_keyword ("ret-archive"), &ret_archive,
-                                  SCM_UNDEFINED);
+  return scm_from_bool
+    (((io::IFileSystem*)scm_to_pointer (file_system))->
+     addFileArchive (scm_to_utf8_stringn (filename, NULL),
+                     scm_to_bool (ignore_case),
+                     scm_to_bool (ignore_paths),
+                     scm_to_file_archive_type (archive_type),
+                     scm_to_utf8_stringn (password, NULL),
+                     retArchiveReference));
+}
 
-    irr::io::IFileArchive** retArchiveReference = 0;
-    if (ret_archive != SCM_UNDEFINED)
-      {
-        irr::io::IFileArchive* retArchive = unwrap_file_archive (ret_archive);
-        retArchiveReference = &retArchive;
-      }
-    irr::io::IFileSystem* file_system = unwrap_file_system (wrapped_file_system);
-    return scm_from_bool
-      (file_system->addFileArchive (scm_to_utf8_stringn (filename, NULL),
-                                    scm_to_bool (ignore_case),
-                                    scm_to_bool (ignore_paths),
-                                    scm_to_file_archive_type (archive_type),
-                                    scm_to_utf8_stringn (password, NULL),
-                                    retArchiveReference));
-  }
 
-  SCM
-  irr_getFileSystem (SCM wrapped_obj)
+extern "C" {
+
+  void
+  init_file_system (void)
   {
-    irr::io::IFileSystem* file_system;
-    if (gui_environment_p (wrapped_obj))
-      {
-        file_system = unwrap_gui_environment (wrapped_obj)->getFileSystem ();
-      }
-    else if (device_p (wrapped_obj))
-      {
-        file_system = unwrap_device (wrapped_obj)->getFileSystem ();
-      }
-    else if (scene_manager_p (wrapped_obj))
-      {
-        file_system = unwrap_scene_manager (wrapped_obj)->getFileSystem ();
-      }
-    else
-      {
-        scm_error (scm_arg_type_key, NULL, "Cannot get file system from object: ~S",
-                   scm_list_1 (wrapped_obj), scm_list_1 (wrapped_obj));
-      }
-    return wrap_file_system (file_system);
+    DEFINE_GSUBR ("io_IFileSystem_addFileArchive", 7, 0, 0, io_IFileSystem_addFileArchive);
   }
 
 }
index 35a06270a5752491ba1dbff11ad42139d9ccc970..774dbcf5b6b777b76f1f74e18cb22ed367201b4b 100644 (file)
 
 #include <irrlicht/irrlicht.h>
 #include <libguile.h>
-#include "wrapped.h"
 
-extern "C" {
+SCM
+io_IFileSystem_addFileArchive (SCM file_system,
+                               SCM filename,
+                               SCM ignore_case,
+                               SCM ignore_paths,
+                               SCM archive_type,
+                               SCM password,
+                               SCM ret_archive);
 
+extern "C" {
   void
   init_file_system (void);
-
-  DECLARE_WRAPPED_TYPE (irr::io::IFileSystem*, init_file_system_type,
-                        file_system_p, wrap_file_system, unwrap_file_system);
-
-  SCM
-  irr_io_addFileArchive (SCM wrapped_file_system,
-                         SCM filename,
-                         SCM rest);
-
-  SCM
-  irr_getFileSystem (SCM wrapped_obj);
-
 }
 
 #endif