guile-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.5-14-g1d00ab


From: Mark H Weaver
Subject: [Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.5-14-g1d00abb
Date: Thu, 02 Feb 2012 23:36:34 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Guile".

http://git.savannah.gnu.org/cgit/guile.git/commit/?id=1d00abb04fd8c11d872dc6dc2a49ebb9767d0c18

The branch, stable-2.0 has been updated
       via  1d00abb04fd8c11d872dc6dc2a49ebb9767d0c18 (commit)
      from  7fb9c4aff29daab35d0726bac58f8fbd6bd2e26c (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 1d00abb04fd8c11d872dc6dc2a49ebb9767d0c18
Author: Mark H Weaver <address@hidden>
Date:   Thu Feb 2 17:23:35 2012 -0500

    Implement scm_to_pointer
    
    * libguile/foreign.c, libguile/foreign.h (scm_to_pointer):
      New C function.
    
    * test-suite/standalone/test-loose-ends.c: Add test.

-----------------------------------------------------------------------

Summary of changes:
 libguile/foreign.c                      |    9 +++++++++
 libguile/foreign.h                      |    1 +
 test-suite/standalone/test-loose-ends.c |   17 +++++++++++++++++
 3 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/libguile/foreign.c b/libguile/foreign.c
index 611b08f..b3d1cc6 100644
--- a/libguile/foreign.c
+++ b/libguile/foreign.c
@@ -139,6 +139,15 @@ SCM_DEFINE (scm_make_pointer, "make-pointer", 1, 1, 0,
 }
 #undef FUNC_NAME
 
+void *
+scm_to_pointer (SCM pointer)
+#define FUNC_NAME "scm_to_pointer"
+{
+  SCM_VALIDATE_POINTER (1, pointer);
+  return SCM_POINTER_VALUE (pointer);
+}
+#undef FUNC_NAME
+
 SCM
 scm_from_pointer (void *ptr, scm_t_pointer_finalizer finalizer)
 {
diff --git a/libguile/foreign.h b/libguile/foreign.h
index 75e3bf5..41c0b65 100644
--- a/libguile/foreign.h
+++ b/libguile/foreign.h
@@ -55,6 +55,7 @@ typedef void (*scm_t_pointer_finalizer) (void *);
 #define SCM_POINTER_VALUE(x)                   \
   ((void *) SCM_CELL_WORD_1 (x))
 
+SCM_API void *scm_to_pointer (SCM pointer);
 SCM_API SCM scm_from_pointer (void *, scm_t_pointer_finalizer);
 
 SCM_API SCM scm_alignof (SCM type);
diff --git a/test-suite/standalone/test-loose-ends.c 
b/test-suite/standalone/test-loose-ends.c
index ee0fcf3..b4ea5b9 100644
--- a/test-suite/standalone/test-loose-ends.c
+++ b/test-suite/standalone/test-loose-ends.c
@@ -75,11 +75,28 @@ test_scm_call ()
 }
 
 static void
+test_scm_to_pointer ()
+{
+  int (*add3) (int a, int b, int c);
+  SCM int_type = scm_c_public_ref ("system foreign", "int");
+
+  add3 = scm_to_pointer
+    (scm_procedure_to_pointer (int_type,
+                               scm_c_public_ref ("guile", "+"),
+                               scm_list_3 (int_type,
+                                           int_type,
+                                           int_type)));
+
+  assert ((*add3) (1000000, 1000, -1) == 1000999);
+}
+
+static void
 tests (void *data, int argc, char **argv)
 {
   test_scm_from_locale_keywordn ();
   test_scm_local_eval ();
   test_scm_call ();
+  test_scm_to_pointer ();
 }
 
 int


hooks/post-receive
-- 
GNU Guile



reply via email to

[Prev in Thread] Current Thread [Next in Thread]