build: Don't include <config.h> in native programs when cross-compiling.
[bpt/guile.git] / libguile / foreign.h
index 0b9ef10..41c0b65 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef SCM_FOREIGN_H
 #define SCM_FOREIGN_H
 
-/* Copyright (C) 2010  Free Software Foundation, Inc.
+/* Copyright (C) 2010, 2011, 2012  Free Software Foundation, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -23,8 +23,7 @@
 
 /* A "foreign pointer" is a wrapped C pointer.  It is represented by a
    cell whose second word is a pointer.  The first word has the
-   `scm_tc7_pointer' type code and a bit saying whether it has an
-   associated finalizer or not.
+   `scm_tc7_pointer' type code.
 
    The basic idea is that we can help the programmer to avoid cutting herself,
    but we won't take away her knives.  */
@@ -55,9 +54,8 @@ typedef void (*scm_t_pointer_finalizer) (void *);
   SCM_MAKE_VALIDATE (pos, x, POINTER_P)
 #define SCM_POINTER_VALUE(x)                   \
   ((void *) SCM_CELL_WORD_1 (x))
-#define SCM_POINTER_HAS_FINALIZER(x)           \
-  ((SCM_CELL_WORD_0 (x) >> 16) & 0x1)
 
+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);
@@ -66,13 +64,17 @@ SCM_API SCM scm_pointer_address (SCM pointer);
 SCM_API SCM scm_pointer_to_bytevector (SCM pointer, SCM type,
                                        SCM offset, SCM len);
 SCM_API SCM scm_set_pointer_finalizer_x (SCM pointer, SCM finalizer);
-SCM_API SCM scm_bytevector_to_pointer (SCM bv, SCM offset, SCM len);
+SCM_API SCM scm_bytevector_to_pointer (SCM bv, SCM offset);
 
+SCM_INTERNAL SCM scm_pointer_p (SCM obj);
 SCM_INTERNAL SCM scm_make_pointer (SCM address, SCM finalizer);
-SCM_INTERNAL SCM scm_dereference_pointer (SCM pointer);
 SCM_INTERNAL void scm_i_pointer_print (SCM pointer, SCM port,
                                        scm_print_state *pstate);
 
+SCM_INTERNAL SCM scm_dereference_pointer (SCM pointer);
+SCM_INTERNAL SCM scm_string_to_pointer (SCM string, SCM encoding);
+SCM_INTERNAL SCM scm_pointer_to_string (SCM pointer, SCM length, SCM encoding);
+
 \f
 
 /* Foreign functions */
@@ -90,8 +92,10 @@ SCM_INTERNAL void scm_i_pointer_print (SCM pointer, SCM port,
    arguments.
  */
 
-SCM_API SCM scm_make_foreign_function (SCM return_type, SCM func_ptr,
-                                       SCM arg_types);
+SCM_API SCM scm_pointer_to_procedure (SCM return_type, SCM func_ptr,
+                                     SCM arg_types);
+SCM_API SCM scm_procedure_to_pointer (SCM return_type, SCM func_ptr,
+                                     SCM arg_types);
 SCM_INTERNAL SCM scm_i_foreign_call (SCM foreign, const SCM *argv);
 
 \f