From: Javier Sancho Date: Sun, 26 Apr 2020 18:34:23 +0000 (+0200) Subject: get-id X-Git-Url: https://git.jsancho.org/?p=guile-irrlicht.git;a=commitdiff_plain;h=a7852a8af5c3dc6a58da64a908c4f00fcbe584d1 get-id --- diff --git a/Makefile.am b/Makefile.am index ca35926..cb1b1a6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -35,6 +35,7 @@ libguile_irrlicht_la_SOURCES = \ src/driver-types.cpp \ src/event-receiver.cpp \ src/file-archive.cpp \ + src/file-list.cpp \ src/file-system.cpp \ src/gui.cpp \ src/gui-button.cpp \ @@ -50,6 +51,7 @@ libguile_irrlicht_la_SOURCES = \ src/gui-static-text.cpp \ src/gui-toolbar.cpp \ src/guile-irrlicht.cpp \ + src/io.cpp \ src/keycodes.cpp \ src/keymap.cpp \ src/material.cpp \ diff --git a/src/file-list.cpp b/src/file-list.cpp new file mode 100644 index 0000000..878d608 --- /dev/null +++ b/src/file-list.cpp @@ -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 + . +*/ + +#include +#include +#include "file-list.h" + +extern "C" { + + void + init_file_list (void) + { + init_file_list_type (); + } + + DEFINE_WRAPPED_TYPE (irr::io::IFileList*, "file-list", + init_file_list_type, file_list_p, + wrap_file_list, unwrap_file_list); + +} diff --git a/src/file-list.h b/src/file-list.h new file mode 100644 index 0000000..84f3b66 --- /dev/null +++ b/src/file-list.h @@ -0,0 +1,39 @@ +/* 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_FILE_LIST_H_INCLUDED__ +#define __GUILE_IRRLICHT_FILE_LIST_H_INCLUDED__ + +#include +#include +#include "wrapped.h" + +extern "C" { + + void + init_file_list (void); + + DECLARE_WRAPPED_TYPE (irr::io::IFileList*, init_file_list_type, + file_list_p, wrap_file_list, unwrap_file_list); + +} + +#endif diff --git a/src/guile-irrlicht.cpp b/src/guile-irrlicht.cpp index bc76b72..7ea6f7a 100644 --- a/src/guile-irrlicht.cpp +++ b/src/guile-irrlicht.cpp @@ -28,13 +28,13 @@ #include "cursor-control.h" #include "device.h" #include "event-receiver.h" -#include "file-archive.h" -#include "file-system.h" +#include "file-list.h" #include "gsubr.h" #include "gui.h" #include "gui-element.h" #include "gui-environment.h" #include "guile-irrlicht.h" +#include "io.h" #include "keymap.h" #include "material.h" #include "mesh.h" @@ -62,9 +62,8 @@ extern "C" { init_cursor_control (); init_device (); init_event_receiver (); - init_file_archive (); - init_file_system (); init_gui (); + init_io (); init_keymap (); init_material (); init_mesh (); @@ -80,8 +79,9 @@ extern "C" { // Shared procedures (used by two or more objects) DEFINE_GSUBR ("draw-all", 1, 0, 0, irr_drawAll); - DEFINE_GSUBR ("get-position", 1, 1, 0, irr_getPosition); + DEFINE_GSUBR ("get-id", 1, 1, 0, irr_getID); DEFINE_GSUBR ("get-name", 1, 0, 0, irr_getName); + DEFINE_GSUBR ("get-position", 1, 1, 0, irr_getPosition); DEFINE_GSUBR ("set-material!", 2, 0, 0, irr_setMaterial); DEFINE_GSUBR ("set-material-flag!", 3, 0, 0, irr_setMaterialFlag); DEFINE_GSUBR ("set-position!", 2, 0, 0, irr_setPosition); @@ -107,6 +107,29 @@ extern "C" { return SCM_UNSPECIFIED; } + SCM + irr_getID (SCM wrapped_obj, + SCM index) + { + if (file_list_p (wrapped_obj)) + { + return scm_from_uint32 (unwrap_file_list (wrapped_obj)->getID (scm_to_uint32 (index))); + } + else if (gui_element_p (wrapped_obj)) + { + return scm_from_int32 (unwrap_gui_element (wrapped_obj)->getID ()); + } + else if (scene_node_p (wrapped_obj)) + { + return scm_from_int32 (unwrap_scene_node (wrapped_obj)->getID ()); + } + else + { + scm_error (scm_arg_type_key, NULL, "Cannot get id from object: ~S", + scm_list_1 (wrapped_obj), scm_list_1 (wrapped_obj)); + } + } + SCM irr_getName (SCM wrapped_obj) { diff --git a/src/guile-irrlicht.h b/src/guile-irrlicht.h index c60fddd..45c02b2 100644 --- a/src/guile-irrlicht.h +++ b/src/guile-irrlicht.h @@ -34,12 +34,16 @@ extern "C" { irr_drawAll (SCM wrapped_obj); SCM - irr_getPosition (SCM wrapped_obj, - SCM i); + irr_getID (SCM wrapped_obj, + SCM index); SCM irr_getName (SCM wrapped_obj); + SCM + irr_getPosition (SCM wrapped_obj, + SCM i); + SCM irr_setMaterial (SCM wrapped_obj, SCM material); diff --git a/src/io.cpp b/src/io.cpp new file mode 100644 index 0000000..1c5a3b8 --- /dev/null +++ b/src/io.cpp @@ -0,0 +1,43 @@ +/* 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 "file-archive.h" +#include "file-list.h" +#include "file-system.h" +#include "io.h" + +extern "C" { + + void + init_io (void) + { + // Init objects + init_file_archive (); + init_file_list (); + init_file_system (); + + // Shared procedures (used by two or more objects) + } + +} diff --git a/src/io.h b/src/io.h new file mode 100644 index 0000000..c9657aa --- /dev/null +++ b/src/io.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_IO_H_INCLUDED__ +#define __GUILE_IRRLICHT_IO_H_INCLUDED__ + +#include +#include + +extern "C" { + + void + init_io (void); + +} + +#endif