]> git.jsancho.org Git - guile-irrlicht.git/blobdiff - src/wrapped.h
GOOPS and POC with create-device
[guile-irrlicht.git] / src / wrapped.h
index c68b26af49282a261c3fbccdb789d5c245a0f0aa..4514fa64afbb769c2686bc5f46697b584007b4ac 100644 (file)
@@ -38,9 +38,9 @@
   PRED (SCM wrapped_obj);
 
 
-static SCM wrapped_type;
-
 #define DEFINE_WRAPPED_TYPE(TYPE, PRINT_NAME, INIT, PRED, WRAP, UNWRAP) \
+  static SCM wrapped_##INIT;                                            \
+                                                                        \
   void                                                                  \
   INIT (void)                                                           \
   {                                                                     \
@@ -51,27 +51,36 @@ static SCM wrapped_type;
     slots = scm_list_1 (scm_from_utf8_symbol ("data"));                 \
     finalizer = NULL;                                                   \
                                                                         \
-    wrapped_type =                                                      \
+    wrapped_##INIT =                                                    \
       scm_make_foreign_object_type (name, slots, finalizer);            \
   }                                                                     \
                                                                         \
   SCM                                                                   \
   WRAP (TYPE foreign_obj)                                               \
   {                                                                     \
-    return scm_make_foreign_object_1 (wrapped_type, foreign_obj);       \
+    return scm_make_foreign_object_1 (wrapped_##INIT, foreign_obj);     \
   }                                                                     \
                                                                         \
   TYPE                                                                  \
   UNWRAP (SCM wrapped_obj)                                              \
   {                                                                     \
-    scm_assert_foreign_object_type (wrapped_type, wrapped_obj);         \
+    scm_assert_foreign_object_type (wrapped_##INIT, 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);                      \
+    return SCM_IS_A_P (wrapped_obj, wrapped_##INIT);                    \
   }
 
+
+#define UNWRAP(OBJ)                                                     \
+  char* OBJ##_class = scm_to_utf8_stringn (scm_car (OBJ), NULL);        \
+  void* OBJ##_pointer = scm_to_pointer (scm_cdr (OBJ));
+
+
+#define UNWRAPPED(OBJ)                                                  \
+  (!strcmp (OBJ##_class, "irr::IEventReceiver") ? (irr::IEventReceiver*)OBJ##_pointer : 0)
+
 #endif