1 #ifndef SCM_FOREIGN_OBJECT_H
2 #define SCM_FOREIGN_OBJECT_H
4 /* Copyright (C) 2014 Free Software Foundation, Inc.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public License
8 * as published by the Free Software Foundation; either version 3 of
9 * the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24 #include "libguile/__scm.h"
25 #include "libguile/print.h"
30 SCM_API SCM
scm_make_foreign_object_type (SCM name
, SCM slot_names
,
31 scm_t_struct_finalize finalizer
);
33 SCM_API
void scm_assert_foreign_object_type (SCM type
, SCM val
);
35 /* All objects of a given foreign object type have the same number of
36 fields. When constructing a foreign object, you don't have to pass
37 initializers for all of the fields; it is always OK to call
38 scm_make_foreign_object_0 and initialize the fields by hand with
39 scm_foreign_object_set_x or other setters. The initial value of
40 fields that haven't been explicitly given a value is 0. */
41 SCM_API SCM
scm_make_foreign_object_0 (SCM type
);
42 SCM_API SCM
scm_make_foreign_object_1 (SCM type
, void *val0
);
43 SCM_API SCM
scm_make_foreign_object_2 (SCM type
, void *val0
, void *val1
);
44 SCM_API SCM
scm_make_foreign_object_3 (SCM type
, void *val0
, void *val1
,
46 SCM_API SCM
scm_make_foreign_object_n (SCM type
, size_t n
, void *vals
[]);
48 SCM_API
void* scm_foreign_object_ref (SCM obj
, size_t n
);
49 SCM_API
void scm_foreign_object_set_x (SCM obj
, size_t n
, void *val
);
51 SCM_API scm_t_bits
scm_foreign_object_unsigned_ref (SCM obj
, size_t n
);
52 SCM_API
void scm_foreign_object_unsigned_set_x (SCM obj
, size_t n
,
55 SCM_API scm_t_signed_bits
scm_foreign_object_signed_ref (SCM obj
, size_t n
);
56 SCM_API
void scm_foreign_object_signed_set_x (SCM obj
, size_t n
,
57 scm_t_signed_bits val
);
59 SCM_INTERNAL
void scm_register_foreign_object (void);
62 #endif /* SCM_FOREIGN_OBJECT_H */