X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=src%2Ffile-system.cpp;h=afb9f0b95af39dff8979de7ea62a00cce5a13bdc;hb=4f049544ec827a9f1f16a913d7241f29179fdde7;hp=4c643ae3e05272eb5abc695ed254cff0fd21a822;hpb=437db80e9b374e32d0bb5f7beeb4516fc1dd65c3;p=guile-irrlicht.git diff --git a/src/file-system.cpp b/src/file-system.cpp index 4c643ae..afb9f0b 100644 --- a/src/file-system.cpp +++ b/src/file-system.cpp @@ -21,85 +21,41 @@ #include #include - -#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); - } - - 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_BOOL_F; - - 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); - - irr::io::IFileArchive** retArchiveReference = 0; - if (!scm_is_false (ret_archive)) - { - 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) - { - 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); - } +#include "wrapped.h" + +using namespace irr; + +SCM +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_irr_pointer (ret_archive); + io::IFileArchive** retArchiveReference = 0; + if (retArchive != NULL) + { + retArchiveReference = &retArchive; + } + + return scm_from_bool + (((io::IFileSystem*)scm_to_irr_pointer (file_system))-> + addFileArchive (scm_to_utf8_string (filename), + scm_to_bool (ignore_case), + scm_to_bool (ignore_paths), + scm_to_file_archive_type (archive_type), + scm_to_utf8_string (password), + retArchiveReference)); +} +void +init_file_system (void) +{ + DEFINE_GSUBR ("IFileSystem_addFileArchive", 7, 0, 0, IFileSystem_addFileArchive); }