]> git.jsancho.org Git - guile-irrlicht.git/commitdiff
event-receiver
authorJavier Sancho <jsf@jsancho.org>
Fri, 8 May 2020 15:32:13 +0000 (17:32 +0200)
committerJavier Sancho <jsf@jsancho.org>
Fri, 8 May 2020 15:32:13 +0000 (17:32 +0200)
12 files changed:
src/animated-mesh-scene-node.cpp
src/animated-mesh-scene-node.h
src/animated-mesh.cpp
src/animated-mesh.h
src/box3d.cpp
src/box3d.h
src/cursor-control.cpp
src/cursor-control.h
src/device.cpp
src/device.h
src/event-receiver.cpp
src/event-receiver.h

index 01286e9dfb921c164179d4499c336210f44df8da..474ef8f0f20445a630904fe65d5727fd03a1ca0f 100644 (file)
@@ -30,9 +30,9 @@ using namespace irr;
 
 
 SCM
-irr_scene_IAnimatedMeshSceneNode_setFrameLoop (SCM animated_mesh_scene_node,
-                                               SCM begin,
-                                               SCM end)
+scene_IAnimatedMeshSceneNode_setFrameLoop (SCM animated_mesh_scene_node,
+                                           SCM begin,
+                                           SCM end)
 {
   return scm_from_bool
     (((scene::IAnimatedMeshSceneNode*)scm_to_pointer (animated_mesh_scene_node))->
@@ -42,8 +42,8 @@ irr_scene_IAnimatedMeshSceneNode_setFrameLoop (SCM animated_mesh_scene_node,
 
 
 SCM
-irr_scene_IAnimatedMeshSceneNode_setMD2Animation (SCM animated_mesh_scene_node,
-                                                  SCM anim)
+scene_IAnimatedMeshSceneNode_setMD2Animation (SCM animated_mesh_scene_node,
+                                              SCM anim)
 {
   return scm_from_bool
     (((scene::IAnimatedMeshSceneNode*)scm_to_pointer (animated_mesh_scene_node))->
@@ -56,10 +56,10 @@ extern "C" {
   void
   init_animated_mesh_scene_node (void)
   {
-    DEFINE_GSUBR ("irr_scene_IAnimatedMeshSceneNode_setFrameLoop", 3, 0, 0,
-                  irr_scene_IAnimatedMeshSceneNode_setFrameLoop);
-    DEFINE_GSUBR ("irr_scene_IAnimatedMeshSceneNode_setMD2Animation", 2, 0, 0,
-                  irr_scene_IAnimatedMeshSceneNode_setMD2Animation);
+    DEFINE_GSUBR ("scene_IAnimatedMeshSceneNode_setFrameLoop", 3, 0, 0,
+                  scene_IAnimatedMeshSceneNode_setFrameLoop);
+    DEFINE_GSUBR ("scene_IAnimatedMeshSceneNode_setMD2Animation", 2, 0, 0,
+                  scene_IAnimatedMeshSceneNode_setMD2Animation);
   }
 
 }
index 32cb02fa2bc5752187d90f013c8c15d27339c274..4cd5c7b5d7b5c5b487d86d6a32e1cf10132b63ae 100644 (file)
 #include <libguile.h>
 
 SCM
-irr_scene_IAnimatedMeshSceneNode_setFrameLoop (SCM animated_mesh_scene_node,
-                                               SCM begin,
-                                               SCM end);
+scene_IAnimatedMeshSceneNode_setFrameLoop (SCM animated_mesh_scene_node,
+                                           SCM begin,
+                                           SCM end);
 
 SCM
-irr_scene_IAnimatedMeshSceneNode_setMD2Animation (SCM animated_mesh_scene_node,
-                                                  SCM anim);
+scene_IAnimatedMeshSceneNode_setMD2Animation (SCM animated_mesh_scene_node,
+                                              SCM anim);
 
 extern "C" {
   void
index dd1a2c152428a50763238d01754e18d9e31e1b3c..c7013b20363c9353902f12d81ca6f2b9b9780f2f 100644 (file)
@@ -29,8 +29,8 @@ using namespace irr;
 
 
 SCM
-irr_scene_IAnimatedMesh_setAnimationSpeed (SCM animated_mesh,
-                                           SCM frames_per_second)
+scene_IAnimatedMesh_setAnimationSpeed (SCM animated_mesh,
+                                       SCM frames_per_second)
 {
   ((scene::IAnimatedMesh*)scm_to_pointer (animated_mesh))->
     setAnimationSpeed (scm_to_double (frames_per_second));
@@ -43,8 +43,8 @@ extern "C" {
   void
   init_animated_mesh (void)
   {
-    DEFINE_GSUBR ("irr_scene_IAnimatedMesh_setAnimationSpeed", 2, 0, 0,
-                  irr_scene_IAnimatedMesh_setAnimationSpeed);
+    DEFINE_GSUBR ("scene_IAnimatedMesh_setAnimationSpeed", 2, 0, 0,
+                  scene_IAnimatedMesh_setAnimationSpeed);
   }
 
 }
index 2afec61b7cb8ec925091faeb05b2938fd893ec08..2795d557ab676bc4e1c946640470aba45b9e342e 100644 (file)
@@ -27,8 +27,8 @@
 
 
 SCM
-irr_scene_IAnimatedMesh_setAnimationSpeed (SCM animated_mesh,
-                                           SCM frames_per_second);
+scene_IAnimatedMesh_setAnimationSpeed (SCM animated_mesh,
+                                       SCM frames_per_second);
 
 extern "C" {
   void
index 1c0152a186739f6dec133fa47e118f88bb957be9..f9a688b7c848ea9f598b38660afdddecce04f7bd 100644 (file)
@@ -30,8 +30,8 @@ using namespace irr;
 
 
 SCM
-irr_core_aabbox3d_addInternalPoint (SCM box3d,
-                                    SCM point)
+core_aabbox3d_addInternalPoint (SCM box3d,
+                                SCM point)
 {
   ((core::aabbox3df*)scm_to_pointer (box3d))->addInternalPoint (scm_to_vector3df (point));
   return SCM_UNSPECIFIED;
@@ -39,7 +39,7 @@ irr_core_aabbox3d_addInternalPoint (SCM box3d,
 
 
 SCM
-irr_core_aabbox3d_make ()
+core_aabbox3d_make ()
 {
   core::aabbox3df* aabbox = new core::aabbox3df ();
   return scm_from_pointer ((void*)aabbox, NULL);
@@ -47,8 +47,8 @@ irr_core_aabbox3d_make ()
 
 
 SCM
-irr_core_aabbox3d_reset (SCM box3d,
-                         SCM init_value)
+core_aabbox3d_reset (SCM box3d,
+                     SCM init_value)
 {
   ((core::aabbox3df*)scm_to_pointer (box3d))->reset (scm_to_vector3df (init_value));
   return SCM_UNSPECIFIED;
@@ -60,12 +60,12 @@ extern "C" {
   void
   init_box3d (void)
   {
-    DEFINE_GSUBR ("irr_core_aabbox3d_addInternalPoint", 2, 0, 0,
-                  irr_core_aabbox3d_addInternalPoint);
-    DEFINE_GSUBR ("irr_core_aabbox3d_make", 0, 0, 0,
-                  irr_core_aabbox3d_make);
-    DEFINE_GSUBR ("irr_core_aabbox3d_reset", 2, 0, 0,
-                  irr_core_aabbox3d_reset);
+    DEFINE_GSUBR ("core_aabbox3d_addInternalPoint", 2, 0, 0,
+                  core_aabbox3d_addInternalPoint);
+    DEFINE_GSUBR ("core_aabbox3d_make", 0, 0, 0,
+                  core_aabbox3d_make);
+    DEFINE_GSUBR ("core_aabbox3d_reset", 2, 0, 0,
+                  core_aabbox3d_reset);
   }
 
 }
index 75b34825e8fc21b2a5fc6736d8c9ec58a4638382..4bb2731dcc72ffc893477086b47c1ff5f124fe9b 100644 (file)
 #include <libguile.h>
 
 SCM
-irr_core_aabbox3d_addInternalPoint (SCM box3d,
-                                    SCM point);
+core_aabbox3d_addInternalPoint (SCM box3d,
+                                SCM point);
 
 SCM
-irr_core_aabbox3d_make ();
+core_aabbox3d_make ();
 
 SCM
-irr_core_aabbox3d_reset (SCM box3d,
-                         SCM init_value);
+core_aabbox3d_reset (SCM box3d,
+                     SCM init_value);
 
 extern "C" {
   void
index fba412c0f4092df9926d0a9fcf0409296460673b..4efe056d14627248c4a2e2a76de6f5e57711fdad 100644 (file)
@@ -30,7 +30,7 @@ using namespace irr;
 
 
 SCM
-irr_gui_ICursorControl_getPosition (SCM cursor_control)
+gui_ICursorControl_getPosition (SCM cursor_control)
 {
   return scm_from_position2d_s32
     (((gui::ICursorControl*)scm_to_pointer (cursor_control))->getPosition ());
@@ -38,8 +38,8 @@ irr_gui_ICursorControl_getPosition (SCM cursor_control)
 
 
 SCM
-irr_gui_ICursorControl_setPosition (SCM cursor_control,
-                                    SCM position)
+gui_ICursorControl_setPosition (SCM cursor_control,
+                                SCM position)
 {
   ((gui::ICursorControl*)scm_to_pointer (cursor_control))->
     setPosition (scm_to_position2d_s32 (position));
@@ -52,10 +52,10 @@ extern "C" {
   void
   init_cursor_control (void)
   {
-    DEFINE_GSUBR ("irr_gui_ICursorControl_getPosition", 1, 0, 0,
-                  irr_gui_ICursorControl_getPosition);
-    DEFINE_GSUBR ("irr_gui_ICursorControl_setPosition", 2, 0, 0,
-                  irr_gui_ICursorControl_setPosition);
+    DEFINE_GSUBR ("gui_ICursorControl_getPosition", 1, 0, 0,
+                  gui_ICursorControl_getPosition);
+    DEFINE_GSUBR ("gui_ICursorControl_setPosition", 2, 0, 0,
+                  gui_ICursorControl_setPosition);
   }
 
 }
index 5b398a83de24136ab363396da55e05303aec779b..dba60649981fd253392abb321d5df08b585e4038 100644 (file)
 #include <libguile.h>
 
 SCM
-irr_gui_ICursorControl_getPosition (SCM cursor_control);
+gui_ICursorControl_getPosition (SCM cursor_control);
 
 SCM
-irr_gui_ICursorControl_setPosition (SCM cursor_control,
-                                    SCM position);
+gui_ICursorControl_setPosition (SCM cursor_control,
+                                SCM position);
 
 extern "C" {
   void
index 4ff21a56aa38a32e671f751a0535a1c52e459f72..10ba8ad6c2e67086e5dc27ddcc76e685c3916b1e 100644 (file)
@@ -33,13 +33,13 @@ using namespace irr;
 
 template <typename TEventReceiver>
 SCM
-irr_createDevice (SCM device_type,
-                  SCM window_size,
-                  SCM bits,
-                  SCM fullscreen,
-                  SCM stencilbuffer,
-                  SCM vsync,
-                  SCM receiver)
+createDevice (SCM device_type,
+              SCM window_size,
+              SCM bits,
+              SCM fullscreen,
+              SCM stencilbuffer,
+              SCM vsync,
+              SCM receiver)
 {
   IrrlichtDevice* device =
     createDevice (scm_to_driver_type (device_type),
@@ -54,7 +54,7 @@ irr_createDevice (SCM device_type,
 
 
 SCM
-irr_IrrlichtDevice_getCursorControl (SCM device)
+IrrlichtDevice_getCursorControl (SCM device)
 {
   gui::ICursorControl* cursor_control =
     ((IrrlichtDevice*)scm_to_pointer (device))->getCursorControl ();
@@ -63,7 +63,7 @@ irr_IrrlichtDevice_getCursorControl (SCM device)
 
 
 SCM
-irr_IrrlichtDevice_getGUIEnvironment (SCM device)
+IrrlichtDevice_getGUIEnvironment (SCM device)
 {
   gui::IGUIEnvironment* gui_env =
     ((IrrlichtDevice*)scm_to_pointer (device))->getGUIEnvironment ();
@@ -72,7 +72,7 @@ irr_IrrlichtDevice_getGUIEnvironment (SCM device)
 
 
 SCM
-irr_IrrlichtDevice_getSceneManager (SCM device)
+IrrlichtDevice_getSceneManager (SCM device)
 {
   scene::ISceneManager* manager =
     ((IrrlichtDevice*)scm_to_pointer (device))->getSceneManager ();
@@ -81,7 +81,7 @@ irr_IrrlichtDevice_getSceneManager (SCM device)
 
 
 SCM
-irr_IrrlichtDevice_getTimer (SCM device)
+IrrlichtDevice_getTimer (SCM device)
 {
   ITimer* timer =
     ((IrrlichtDevice*)scm_to_pointer (device))->getTimer ();
@@ -90,7 +90,7 @@ irr_IrrlichtDevice_getTimer (SCM device)
 
 
 SCM
-irr_IrrlichtDevice_getVideoDriver (SCM device)
+IrrlichtDevice_getVideoDriver (SCM device)
 {
   video::IVideoDriver* driver =
     ((IrrlichtDevice*)scm_to_pointer (device))->getVideoDriver ();
@@ -99,7 +99,7 @@ irr_IrrlichtDevice_getVideoDriver (SCM device)
 
 
 SCM
-irr_IrrlichtDevice_isWindowActive (SCM device)
+IrrlichtDevice_isWindowActive (SCM device)
 {
   return scm_from_bool
     (((IrrlichtDevice*)scm_to_pointer (device))->isWindowActive ());
@@ -107,7 +107,7 @@ irr_IrrlichtDevice_isWindowActive (SCM device)
 
 
 SCM
-irr_IrrlichtDevice_run (SCM device)
+IrrlichtDevice_run (SCM device)
 {
   return scm_from_bool
     (((IrrlichtDevice*)scm_to_pointer (device))->run ());
@@ -116,8 +116,8 @@ irr_IrrlichtDevice_run (SCM device)
 
 template <typename TEventReceiver>
 SCM
-irr_IrrlichtDevice_setEventReceiver (SCM device,
-                                     SCM receiver)
+IrrlichtDevice_setEventReceiver (SCM device,
+                                 SCM receiver)
 {
   ((IrrlichtDevice*)scm_to_pointer (device))->
     setEventReceiver ((TEventReceiver)scm_to_pointer (receiver));
@@ -126,8 +126,8 @@ irr_IrrlichtDevice_setEventReceiver (SCM device,
 
 
 SCM
-irr_IrrlichtDevice_setResizable (SCM device,
-                                 SCM resize)
+IrrlichtDevice_setResizable (SCM device,
+                             SCM resize)
 {
   ((IrrlichtDevice*)scm_to_pointer (device))->
     setResizable (scm_to_bool (resize));
@@ -136,8 +136,8 @@ irr_IrrlichtDevice_setResizable (SCM device,
 
 
 SCM
-irr_IrrlichtDevice_setWindowCaption (SCM device,
-                                     SCM text)
+IrrlichtDevice_setWindowCaption (SCM device,
+                                 SCM text)
 {
   ((IrrlichtDevice*)scm_to_pointer (device))->
     setWindowCaption (scm_to_wide_char_string (text));
@@ -146,7 +146,7 @@ irr_IrrlichtDevice_setWindowCaption (SCM device,
 
 
 SCM
-irr_IrrlichtDevice_yield (SCM device)
+IrrlichtDevice_yield (SCM device)
 {
   ((IrrlichtDevice*)scm_to_pointer (device))->yield ();
   return SCM_UNSPECIFIED;
@@ -159,30 +159,30 @@ extern "C" {
   init_device (void)
   {
     init_device_type ();
-    DEFINE_GSUBR ("irr_createDevice_IEventReceiver", 7, 0, 0,
-                  irr_createDevice<IEventReceiver*>);
-    DEFINE_GSUBR ("irr_IrrlichtDevice_getCursorControl", 1, 0, 0,
-                  irr_IrrlichtDevice_getCursorControl);
-    DEFINE_GSUBR ("irr_IrrlichtDevice_getGUIEnvironment", 1, 0, 0,
-                  irr_IrrlichtDevice_getGUIEnvironment);
-    DEFINE_GSUBR ("irr_IrrlichtDevice_getSceneManager", 1, 0, 0,
-                  irr_IrrlichtDevice_getSceneManager);
-    DEFINE_GSUBR ("irr_IrrlichtDevice_getTimer", 1, 0, 0,
-                  irr_IrrlichtDevice_getTimer);
-    DEFINE_GSUBR ("irr_IrrlichtDevice_getVideoDriver", 1, 0, 0,
-                  irr_IrrlichtDevice_getVideoDriver);
-    DEFINE_GSUBR ("irr_IrrlichtDevice_isWindowActive", 1, 0, 0,
-                  irr_IrrlichtDevice_isWindowActive);
-    DEFINE_GSUBR ("irr_IrrlichtDevice_run", 1, 0, 0,
-                  irr_IrrlichtDevice_run);
-    DEFINE_GSUBR ("irr_IrrlichtDevice_setEventReceiver_IEventReceiver", 2, 0, 0,
-                  irr_IrrlichtDevice_setEventReceiver<IEventReceiver*>);
-    DEFINE_GSUBR ("irr_IrrlichtDevice_setResizable", 2, 0, 0,
-                  irr_IrrlichtDevice_setResizable);
-    DEFINE_GSUBR ("irr_IrrlichtDevice_setWindowCaption", 2, 0, 0,
-                  irr_IrrlichtDevice_setWindowCaption);
-    DEFINE_GSUBR ("irr_IrrlichtDevice_yield", 1, 0, 0,
-                  irr_IrrlichtDevice_yield);
+    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 ("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);
   }
 
 }
index 3e0e27b0dc96af4b13234622f0bcedf6c36a7f17..63732b2dce7265c5224788df1bfaab3d99a34e4b 100644 (file)
 
 template <typename TEventReceiver>
 SCM
-irr_createDevice (SCM device_type,
-                  SCM window_size,
-                  SCM bits,
-                  SCM fullscreen,
-                  SCM stencilbuffer,
-                  SCM vsync,
-                  SCM receiver);
+createDevice (SCM device_type,
+              SCM window_size,
+              SCM bits,
+              SCM fullscreen,
+              SCM stencilbuffer,
+              SCM vsync,
+              SCM receiver);
 
 SCM
-irr_IrrlichtDevice_getCursorControl (SCM device);
+IrrlichtDevice_getCursorControl (SCM device);
 
 SCM
-irr_IrrlichtDevice_getGUIEnvironment (SCM device);
+IrrlichtDevice_getGUIEnvironment (SCM device);
 
 SCM
-irr_IrrlichtDevice_getSceneManager (SCM device);
+IrrlichtDevice_getSceneManager (SCM device);
 
 SCM
-irr_IrrlichtDevice_getTimer (SCM device);
+IrrlichtDevice_getTimer (SCM device);
 
 SCM
-irr_IrrlichtDevice_getVideoDriver (SCM device);
+IrrlichtDevice_getVideoDriver (SCM device);
 
 SCM
-irr_IrrlichtDevice_isWindowActive (SCM device);
+IrrlichtDevice_isWindowActive (SCM device);
 
 SCM
-irr_IrrlichtDevice_run (SCM device);
+IrrlichtDevice_run (SCM device);
 
 template <typename TEventReceiver>
 SCM
-irr_IrrlichtDevice_setEventReceiver (SCM device,
-                                     SCM receiver);
+IrrlichtDevice_setEventReceiver (SCM device,
+                                 SCM receiver);
 
 SCM
-irr_IrrlichtDevice_setResizable (SCM device,
-                                 SCM resize);
+IrrlichtDevice_setResizable (SCM device,
+                             SCM resize);
 
 SCM
-irr_IrrlichtDevice_setWindowCaption (SCM device,
-                                     SCM text);
+IrrlichtDevice_setWindowCaption (SCM device,
+                                 SCM text);
 
 SCM
-irr_IrrlichtDevice_yield (SCM device);
+IrrlichtDevice_yield (SCM device);
 
 extern "C" {
   void
index 56affaf44c429920b88ad3e9880f0f4657b60afb..3f2e6839ade8f84d31894bf015b6a3df0808787b 100644 (file)
 
 #include <irrlicht/irrlicht.h>
 #include <libguile.h>
-
 #include "event-receiver.h"
-#include "gui-element.h"
 #include "gsubr.h"
 #include "keycodes.h"
-#include "wrapped.h"
 
-extern "C" {
 
-  void
-  init_event_receiver (void)
+using namespace irr;
+
+
+SCM
+IEventRecevier_make (SCM proc_on_event)
+{
+  class CustomReceiver : public IEventReceiver
   {
-    init_event_receiver_type ();
-    init_event_type ();
-    DEFINE_GSUBR ("get-event-gui-caller", 1, 0, 0, get_event_gui_caller);
-    DEFINE_GSUBR ("get-event-gui-type", 1, 0, 0, get_event_gui_type);
-    DEFINE_GSUBR ("get-event-key-input-key", 1, 0, 0, get_event_key_input_key);
-    DEFINE_GSUBR ("get-event-key-input-pressed", 1, 0, 0, get_event_key_input_pressed);
-    DEFINE_GSUBR ("get-event-type", 1, 0, 0, get_event_type);
-    DEFINE_GSUBR ("make-event-receiver", 1, 0, 0, make_event_receiver);
-  }
+    SCM scm_on_event;
 
-  DEFINE_WRAPPED_TYPE (irr::IEventReceiver*, "event-receiver",
-                       init_event_receiver_type, event_receiver_p,
-                       wrap_event_receiver, unwrap_event_receiver);
+  public:
+    CustomReceiver (SCM on_event)
+    {
+      scm_on_event = on_event;
+    }
 
-  DEFINE_WRAPPED_TYPE (irr::SEvent*, "event",
-                       init_event_type, event_p,
-                       wrap_event, unwrap_event);
+    virtual bool OnEvent (const SEvent& event)
+    {
+      return scm_to_bool (scm_call_1 (scm_on_event, scm_from_pointer ((void*)&event, NULL)));
+    }
+  };
 
-  SCM
-  get_event_gui_caller (SCM event)
-  {
-    return wrap_gui_element (unwrap_event (event)->GUIEvent.Caller);
-  }
+  CustomReceiver* receiver = new CustomReceiver (proc_on_event);
+  return scm_from_pointer ((void*)receiver, NULL);
+}
 
-  SCM
-  get_event_gui_type (SCM event)
-  {
-    return scm_from_gui_event_type (unwrap_event (event)->GUIEvent.EventType);
-  }
 
-  SCM
-  get_event_key_input_key (SCM event)
-  {
-    return scm_from_key_code (unwrap_event (event)->KeyInput.Key);
-  }
+SCM
+SEvent_EventType (SCM event)
+{
+  return scm_from_event_type
+    (((SEvent*)scm_to_pointer (event))->EventType);
+}
 
-  SCM
-  get_event_key_input_pressed (SCM event)
-  {
-    return scm_from_bool (unwrap_event (event)->KeyInput.PressedDown);
-  }
 
-  SCM
-  get_event_type (SCM event)
-  {
-    return scm_from_event_type (unwrap_event (event)->EventType);
-  }
+SCM
+SEvent_SGUIEvent_Caller (SCM event)
+{
+  gui::IGUIElement* caller =
+    ((SEvent*)scm_to_pointer (event))->GUIEvent.Caller;
+  return scm_from_pointer ((void*)caller, NULL);
+}
+
+
+SCM
+SEvent_SGUIEvent_EventType (SCM event)
+{
+  return scm_from_gui_event_type
+    (((SEvent*)scm_to_pointer (event))->GUIEvent.EventType);
+}
+
+
+SCM
+SEvent_SKeyInput_Key (SCM event)
+{
+  return scm_from_key_code
+    (((SEvent*)scm_to_pointer (event))->KeyInput.Key);
+}
+
+
+SCM
+SEvent_SKeyInput_PressedDown (SCM event)
+{
+  return scm_from_key_code
+    (((SEvent*)scm_to_pointer (event))->KeyInput.PressedDown);
+}
 
-  SCM
-  make_event_receiver (SCM proc_on_event)
-  {
-    class CustomReceiver : public irr::IEventReceiver
-    {
-      SCM scm_on_event;
-
-    public:
-      CustomReceiver (SCM on_event)
-      {
-        scm_on_event = on_event;
-      }
-
-      virtual bool OnEvent (const irr::SEvent& event)
-      {
-        return scm_to_bool (scm_call_1 (scm_on_event, wrap_event ((irr::SEvent*)&event)));
-      }
-    };
-
-    CustomReceiver* receiver = new CustomReceiver (proc_on_event);
-    return wrap_event_receiver (receiver);
-  }
 
-  SCM
-  scm_from_event_type (irr::EEVENT_TYPE event_type)
+extern "C" {
+
+  void
+  init_event_receiver (void)
   {
-    switch (event_type)
-      {
-      case irr::EET_GUI_EVENT:
-        return scm_from_utf8_symbol ("gui-event");
-        break;
-
-      case irr::EET_MOUSE_INPUT_EVENT:
-        return scm_from_utf8_symbol ("mouse-input-event");
-        break;
-
-      case irr::EET_KEY_INPUT_EVENT:
-        return scm_from_utf8_symbol ("key-input-event");
-        break;
-
-      case irr::EET_JOYSTICK_INPUT_EVENT:
-        return scm_from_utf8_symbol ("joystick-input-event");
-        break;
-
-      case irr::EET_LOG_TEXT_EVENT:
-        return scm_from_utf8_symbol ("log-text-event");
-        break;
-
-      case irr::EET_USER_EVENT:
-        return scm_from_utf8_symbol ("user-event");
-        break;
-
-      default:
-        SCM type = scm_from_uint (event_type);
-        scm_error (scm_arg_type_key, NULL, "Wrong event type: ~S",
-                   scm_list_1 (type), scm_list_1 (type));
-      }
+    DEFINE_GSUBR ("IEventRecevier_make", 1, 0, 0, IEventRecevier_make);
+    DEFINE_GSUBR ("SEvent_EventType", 1, 0, 0, SEvent_EventType);
+    DEFINE_GSUBR ("SEvent_SGUIEvent_Caller", 1, 0, 0, SEvent_SGUIEvent_Caller);
+    DEFINE_GSUBR ("SEvent_SGUIEvent_EventType", 1, 0, 0, SEvent_SGUIEvent_EventType);
+    DEFINE_GSUBR ("SEvent_SKeyInput_Key", 1, 0, 0, SEvent_SKeyInput_Key);
+    DEFINE_GSUBR ("SEvent_SKeyInput_PressedDown", 1, 0, 0, SEvent_SKeyInput_PressedDown);
   }
 
-  SCM
-  scm_from_gui_event_type (irr::gui::EGUI_EVENT_TYPE gui_event_type)
-  {
-    switch (gui_event_type)
-      {
-      case irr::gui::EGET_ELEMENT_FOCUS_LOST:
-        return scm_from_utf8_symbol ("element-focus-lost");
-        break;
+}
 
-      case irr::gui::EGET_ELEMENT_FOCUSED:
-        return scm_from_utf8_symbol ("element-focused");
-        break;
+SCM
+scm_from_event_type (EEVENT_TYPE event_type)
+{
+  switch (event_type)
+    {
+    case EET_GUI_EVENT:
+      return scm_from_utf8_symbol ("gui-event");
+      break;
+
+    case EET_MOUSE_INPUT_EVENT:
+      return scm_from_utf8_symbol ("mouse-input-event");
+      break;
+
+    case EET_KEY_INPUT_EVENT:
+      return scm_from_utf8_symbol ("key-input-event");
+      break;
+
+    case EET_JOYSTICK_INPUT_EVENT:
+      return scm_from_utf8_symbol ("joystick-input-event");
+      break;
+
+    case EET_LOG_TEXT_EVENT:
+      return scm_from_utf8_symbol ("log-text-event");
+      break;
+
+    case EET_USER_EVENT:
+      return scm_from_utf8_symbol ("user-event");
+      break;
+
+    default:
+      SCM type = scm_from_uint (event_type);
+      scm_error (scm_arg_type_key, NULL, "Wrong event type: ~S",
+                 scm_list_1 (type), scm_list_1 (type));
+    }
+}
 
-      case irr::gui::EGET_ELEMENT_HOVERED:
-        return scm_from_utf8_symbol ("element-hovered");
-        break;
 
-      case irr::gui::EGET_ELEMENT_LEFT:
-        return scm_from_utf8_symbol ("element-left");
-        break;
+SCM
+scm_from_gui_event_type (gui::EGUI_EVENT_TYPE gui_event_type)
+{
+  switch (gui_event_type)
+    {
+    case gui::EGET_ELEMENT_FOCUS_LOST:
+      return scm_from_utf8_symbol ("element-focus-lost");
+      break;
 
-      case irr::gui::EGET_ELEMENT_CLOSED:
-        return scm_from_utf8_symbol ("element-closed");
-        break;
+    case gui::EGET_ELEMENT_FOCUSED:
+      return scm_from_utf8_symbol ("element-focused");
+      break;
 
-      case irr::gui::EGET_BUTTON_CLICKED:
-        return scm_from_utf8_symbol ("button-clicked");
-        break;
+    case gui::EGET_ELEMENT_HOVERED:
+      return scm_from_utf8_symbol ("element-hovered");
+      break;
 
-      case irr::gui::EGET_SCROLL_BAR_CHANGED:
-        return scm_from_utf8_symbol ("scrollbar-changed");
-        break;
-
-      case irr::gui::EGET_CHECKBOX_CHANGED:
-        return scm_from_utf8_symbol ("checkbox-changed");
-        break;
-
-      case irr::gui::EGET_LISTBOX_CHANGED:
-        return scm_from_utf8_symbol ("listbox-changed");
-        break;
-
-      case irr::gui::EGET_LISTBOX_SELECTED_AGAIN:
-        return scm_from_utf8_symbol ("listbox-selected-again");
-        break;
-
-      case irr::gui::EGET_FILE_SELECTED:
-        return scm_from_utf8_symbol ("file-selected");
-        break;
-
-      case irr::gui::EGET_DIRECTORY_SELECTED:
-        return scm_from_utf8_symbol ("directory-selected");
-        break;
-
-      case irr::gui::EGET_FILE_CHOOSE_DIALOG_CANCELLED:
-        return scm_from_utf8_symbol ("file-choose-dialog-cancelled");
-        break;
-
-      case irr::gui::EGET_MESSAGEBOX_YES:
-        return scm_from_utf8_symbol ("messagebox-yes");
-        break;
-
-      case irr::gui::EGET_MESSAGEBOX_NO:
-        return scm_from_utf8_symbol ("messagebox-no");
-        break;
-
-      case irr::gui::EGET_MESSAGEBOX_OK:
-        return scm_from_utf8_symbol ("messagebox-ok");
-        break;
-
-      case irr::gui::EGET_MESSAGEBOX_CANCEL:
-        return scm_from_utf8_symbol ("messagebox-cancel");
-        break;
-
-      case irr::gui::EGET_EDITBOX_ENTER:
-        return scm_from_utf8_symbol ("editbox-enter");
-        break;
-
-      case irr::gui::EGET_EDITBOX_CHANGED:
-        return scm_from_utf8_symbol ("editbox-changed");
-        break;
-
-      case irr::gui::EGET_EDITBOX_MARKING_CHANGED:
-        return scm_from_utf8_symbol ("editbox-marking-changed");
-        break;
-
-      case irr::gui::EGET_TAB_CHANGED:
-        return scm_from_utf8_symbol ("tab-changed");
-        break;
-
-      case irr::gui::EGET_MENU_ITEM_SELECTED:
-        return scm_from_utf8_symbol ("menu-item-selected");
-        break;
-
-      case irr::gui::EGET_COMBO_BOX_CHANGED:
-        return scm_from_utf8_symbol ("combo-box-changed");
-        break;
-
-      case irr::gui::EGET_SPINBOX_CHANGED:
-        return scm_from_utf8_symbol ("spinbox-changed");
-        break;
-
-      case irr::gui::EGET_TABLE_CHANGED:
-        return scm_from_utf8_symbol ("table-changed");
-        break;
-
-      case irr::gui::EGET_TABLE_HEADER_CHANGED:
-        return scm_from_utf8_symbol ("table-header-changed");
-        break;
+    case gui::EGET_ELEMENT_LEFT:
+      return scm_from_utf8_symbol ("element-left");
+      break;
 
-      case irr::gui::EGET_TABLE_SELECTED_AGAIN:
-        return scm_from_utf8_symbol ("table-selected-again");
-        break;
+    case gui::EGET_ELEMENT_CLOSED:
+      return scm_from_utf8_symbol ("element-closed");
+      break;
 
-      case irr::gui::EGET_TREEVIEW_NODE_DESELECT:
-        return scm_from_utf8_symbol ("treeview-node-deselect");
-        break;
+    case gui::EGET_BUTTON_CLICKED:
+      return scm_from_utf8_symbol ("button-clicked");
+      break;
 
-      case irr::gui::EGET_TREEVIEW_NODE_SELECT:
-        return scm_from_utf8_symbol ("treeview-node-select");
-        break;
+    case gui::EGET_SCROLL_BAR_CHANGED:
+      return scm_from_utf8_symbol ("scrollbar-changed");
+      break;
+
+    case gui::EGET_CHECKBOX_CHANGED:
+      return scm_from_utf8_symbol ("checkbox-changed");
+      break;
+
+    case gui::EGET_LISTBOX_CHANGED:
+      return scm_from_utf8_symbol ("listbox-changed");
+      break;
+
+    case gui::EGET_LISTBOX_SELECTED_AGAIN:
+      return scm_from_utf8_symbol ("listbox-selected-again");
+      break;
+
+    case gui::EGET_FILE_SELECTED:
+      return scm_from_utf8_symbol ("file-selected");
+      break;
+
+    case gui::EGET_DIRECTORY_SELECTED:
+      return scm_from_utf8_symbol ("directory-selected");
+      break;
+
+    case gui::EGET_FILE_CHOOSE_DIALOG_CANCELLED:
+      return scm_from_utf8_symbol ("file-choose-dialog-cancelled");
+      break;
+
+    case gui::EGET_MESSAGEBOX_YES:
+      return scm_from_utf8_symbol ("messagebox-yes");
+      break;
+
+    case gui::EGET_MESSAGEBOX_NO:
+      return scm_from_utf8_symbol ("messagebox-no");
+      break;
+
+    case gui::EGET_MESSAGEBOX_OK:
+      return scm_from_utf8_symbol ("messagebox-ok");
+      break;
+
+    case gui::EGET_MESSAGEBOX_CANCEL:
+      return scm_from_utf8_symbol ("messagebox-cancel");
+      break;
+
+    case gui::EGET_EDITBOX_ENTER:
+      return scm_from_utf8_symbol ("editbox-enter");
+      break;
+
+    case gui::EGET_EDITBOX_CHANGED:
+      return scm_from_utf8_symbol ("editbox-changed");
+      break;
+
+    case gui::EGET_EDITBOX_MARKING_CHANGED:
+      return scm_from_utf8_symbol ("editbox-marking-changed");
+      break;
+
+    case gui::EGET_TAB_CHANGED:
+      return scm_from_utf8_symbol ("tab-changed");
+      break;
+
+    case gui::EGET_MENU_ITEM_SELECTED:
+      return scm_from_utf8_symbol ("menu-item-selected");
+      break;
+
+    case gui::EGET_COMBO_BOX_CHANGED:
+      return scm_from_utf8_symbol ("combo-box-changed");
+      break;
+
+    case gui::EGET_SPINBOX_CHANGED:
+      return scm_from_utf8_symbol ("spinbox-changed");
+      break;
+
+    case gui::EGET_TABLE_CHANGED:
+      return scm_from_utf8_symbol ("table-changed");
+      break;
+
+    case gui::EGET_TABLE_HEADER_CHANGED:
+      return scm_from_utf8_symbol ("table-header-changed");
+      break;
 
-      case irr::gui::EGET_TREEVIEW_NODE_EXPAND:
-        return scm_from_utf8_symbol ("treeview-node-expand");
-        break;
+    case gui::EGET_TABLE_SELECTED_AGAIN:
+      return scm_from_utf8_symbol ("table-selected-again");
+      break;
 
-      case irr::gui::EGET_TREEVIEW_NODE_COLLAPSE:
-        return scm_from_utf8_symbol ("treeview-node-collapse");
-        break;
+    case gui::EGET_TREEVIEW_NODE_DESELECT:
+      return scm_from_utf8_symbol ("treeview-node-deselect");
+      break;
 
-      default:
-        SCM type = scm_from_uint (gui_event_type);
-        scm_error (scm_arg_type_key, NULL, "Wrong GUI event type: ~S",
-                   scm_list_1 (type), scm_list_1 (type));
-      }
-  }
+    case gui::EGET_TREEVIEW_NODE_SELECT:
+      return scm_from_utf8_symbol ("treeview-node-select");
+      break;
+
+    case gui::EGET_TREEVIEW_NODE_EXPAND:
+      return scm_from_utf8_symbol ("treeview-node-expand");
+      break;
+
+    case gui::EGET_TREEVIEW_NODE_COLLAPSE:
+      return scm_from_utf8_symbol ("treeview-node-collapse");
+      break;
 
+    default:
+      SCM type = scm_from_uint (gui_event_type);
+      scm_error (scm_arg_type_key, NULL, "Wrong GUI event type: ~S",
+                 scm_list_1 (type), scm_list_1 (type));
+    }
 }
index b85efd4eabb4f5097131babcfab5caac58fa04be..516c7b57dd5cc6c41ff72c51e52187c4009268a2 100644 (file)
 
 #include <irrlicht/irrlicht.h>
 #include <libguile.h>
-#include "wrapped.h"
 
-extern "C" {
-
-  void
-  init_event_receiver (void);
-
-  DECLARE_WRAPPED_TYPE (irr::IEventReceiver*, init_event_receiver_type,
-                        event_receiver_p, wrap_event_receiver, unwrap_event_receiver);
-
-  DECLARE_WRAPPED_TYPE (irr::SEvent*, init_event_type,
-                        event_p, wrap_event, unwrap_event);
+SCM
+IEventRecevier_make (SCM proc_on_event);
 
-  SCM
-  get_event_gui_caller (SCM event);
+SCM
+SEvent_EventType (SCM event);
 
-  SCM
-  get_event_gui_type (SCM event);
+SCM
+SEvent_SGUIEvent_Caller (SCM event);
 
-  SCM
-  get_event_key_input_key (SCM event);
+SCM
+SEvent_SGUIEvent_EventType (SCM event);
 
-  SCM
-  get_event_key_input_pressed (SCM event);
+SCM
+SEvent_SKeyInput_Key (SCM event);
 
-  SCM
-  get_event_type (SCM event);
+SCM
+SEvent_SKeyInput_PressedDown (SCM event);
 
-  SCM
-  make_event_receiver (SCM proc_on_event);
-
-  SCM
-  scm_from_event_type (irr::EEVENT_TYPE event_type);
+extern "C" {
+  void
+  init_event_receiver (void);
+}
 
-  SCM
-  scm_from_gui_event_type (irr::gui::EGUI_EVENT_TYPE gui_event_type);
+SCM
+scm_from_event_type (irr::EEVENT_TYPE event_type);
 
-}
+SCM
+scm_from_gui_event_type (irr::gui::EGUI_EVENT_TYPE gui_event_type);
 
 #endif