1
/*===========================================================================
2
* Filename : module-srfi38.c
3
* About : SRFI-38 External Representation for Data With Shared Structure
5
* Copyright (C) 2005-2006 Jun Inoue <jun.lambda AT gmail.com>
6
* Copyright (c) 2007 SigScheme Project <uim AT freedesktop.org>
10
* Redistribution and use in source and binary forms, with or without
11
* modification, are permitted provided that the following conditions
14
* 1. Redistributions of source code must retain the above copyright
15
* notice, this list of conditions and the following disclaimer.
16
* 2. Redistributions in binary form must reproduce the above copyright
17
* notice, this list of conditions and the following disclaimer in the
18
* documentation and/or other materials provided with the distribution.
19
* 3. Neither the name of authors nor the names of its contributors
20
* may be used to endorse or promote products derived from this software
21
* without specific prior written permission.
23
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
24
* IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
25
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
26
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
27
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
28
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
29
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
30
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
31
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
32
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
33
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
===========================================================================*/
36
/* Only write/ss is provided currently. */
40
#include "sigscheme.h"
41
#include "sigschemeinternal.h"
43
/*=======================================
44
File Local Macro Definitions
45
=======================================*/
47
/*=======================================
48
File Local Type Definitions
49
=======================================*/
51
/*=======================================
53
=======================================*/
54
#include "functable-srfi38.c"
56
/*=======================================
57
File Local Function Declarations
58
=======================================*/
60
/*=======================================
62
=======================================*/
64
scm_initialize_srfi38(void)
66
scm_register_funcs(scm_functable_srfi38);
68
/* SRFI-38 allows providing (read/ss) and (write/ss) */
69
scm_define_alias("write/ss", "write-with-shared-structure");
71
scm_write_ss_func = scm_write_ss;
74
/*===========================================================================
75
SRFI38 : External Representation for Data With Shared Structure
76
===========================================================================*/
78
scm_p_srfi38_write_with_shared_structure(ScmObj obj, ScmObj args)
81
DECLARE_FUNCTION("write-with-shared-structure", procedure_variadic_1);
83
/* Omit optarg as same as the reference implementation. */
84
if (CONSP(args) && CONSP(CDR(args)))
85
args = LIST_1(CAR(args));
86
port = scm_prepare_port(args, scm_out);
88
scm_write_ss(port, obj);