~ubuntu-branches/ubuntu/maverick/uim/maverick

« back to all changes in this revision

Viewing changes to sigscheme/src/module-srfi43.c

  • Committer: Bazaar Package Importer
  • Author(s): Masahito Omote
  • Date: 2008-06-25 19:56:33 UTC
  • mfrom: (3.1.18 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080625195633-8jljph4rfq00l8o7
Tags: 1:1.5.1-2
* uim-tcode: provide tutcode-custom.scm, tutcode-bushudic.scm
  and tutcode-rule.scm (Closes: #482659)
* Fix FTBFS: segv during compile (Closes: #483078).
  I personally think this bug is not specific for uim but is a optimization
  problem on gcc-4.3.1. (https://bugs.freedesktop.org/show_bug.cgi?id=16477)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*===========================================================================
 
2
 *  Filename : module-srfi43.c
 
3
 *  About    : SRFI-43 Vector library
 
4
 *
 
5
 *  Copyright (c) 2007-2008 SigScheme Project <uim-en AT googlegroups.com>
 
6
 *
 
7
 *  All rights reserved.
 
8
 *
 
9
 *  Redistribution and use in source and binary forms, with or without
 
10
 *  modification, are permitted provided that the following conditions
 
11
 *  are met:
 
12
 *
 
13
 *  1. Redistributions of source code must retain the above copyright
 
14
 *     notice, this list of conditions and the following disclaimer.
 
15
 *  2. Redistributions in binary form must reproduce the above copyright
 
16
 *     notice, this list of conditions and the following disclaimer in the
 
17
 *     documentation and/or other materials provided with the distribution.
 
18
 *  3. Neither the name of authors nor the names of its contributors
 
19
 *     may be used to endorse or promote products derived from this software
 
20
 *     without specific prior written permission.
 
21
 *
 
22
 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
 
23
 *  IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 
24
 *  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 
25
 *  PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
 
26
 *  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 
27
 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 
28
 *  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 
29
 *  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 
30
 *  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 
31
 *  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 
32
 *  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
33
===========================================================================*/
 
34
 
 
35
#include <config.h>
 
36
 
 
37
#include "sigscheme.h"
 
38
#include "sigschemeinternal.h"
 
39
 
 
40
/*=======================================
 
41
  File Local Macro Definitions
 
42
=======================================*/
 
43
#define QUOTE(obj) (LIST_2(SYM_QUOTE, (obj)))
 
44
 
 
45
/*=======================================
 
46
  File Local Type Definitions
 
47
=======================================*/
 
48
 
 
49
/*=======================================
 
50
  File Local Function Declarations
 
51
=======================================*/
 
52
SCM_EXPORT ScmObj scm_s_let_vector_start_plus_end(ScmObj callee, ScmObj vec,
 
53
                                                  ScmObj args,
 
54
                                                  ScmObj start_plus_end,
 
55
                                                  ScmObj body,
 
56
                                                  ScmEvalState *eval_state);
 
57
 
 
58
/*=======================================
 
59
  Variable Definitions
 
60
=======================================*/
 
61
#include "functable-srfi43.c"
 
62
 
 
63
SCM_GLOBAL_VARS_BEGIN(static_srfi43);
 
64
#define static
 
65
static ScmObj l_sym_vector_parse_start_plus_end;
 
66
static ScmObj l_sym_check_type, l_sym_vectorp;
 
67
#undef static
 
68
SCM_GLOBAL_VARS_END(static_srfi43);
 
69
#define l_sym_vector_parse_start_plus_end                               \
 
70
    SCM_GLOBAL_VAR(static_srfi43, l_sym_vector_parse_start_plus_end)
 
71
#define l_sym_check_type SCM_GLOBAL_VAR(static_srfi43, l_sym_check_type)
 
72
#define l_sym_vectorp    SCM_GLOBAL_VAR(static_srfi43, l_sym_vectorp)
 
73
SCM_DEFINE_STATIC_VARS(static_srfi43);
 
74
 
 
75
/*=======================================
 
76
  Function Definitions
 
77
=======================================*/
 
78
SCM_EXPORT void
 
79
scm_initialize_srfi43(void)
 
80
{
 
81
    SCM_GLOBAL_VARS_INIT(static_srfi43);
 
82
 
 
83
    scm_register_funcs(scm_functable_srfi43);
 
84
 
 
85
    scm_require_module("srfi-8");
 
86
    scm_require_module("srfi-23");
 
87
    scm_require_module("sscm-ext");  /* for let-optionals* */
 
88
    scm_load_system_file("srfi-43.scm");
 
89
 
 
90
    l_sym_vector_parse_start_plus_end = scm_intern("vector-parse-start+end");
 
91
    l_sym_check_type                  = scm_intern("check-type");
 
92
    l_sym_vectorp                     = scm_intern("vector?");
 
93
 
 
94
    scm_define_alias("let*-optionals", "let-optionals*");
 
95
}
 
96
 
 
97
/* let-vector-start+end is not a part of SRFI-43. */
 
98
SCM_EXPORT ScmObj
 
99
scm_s_let_vector_start_plus_end(ScmObj callee, ScmObj vec,
 
100
                                ScmObj args, ScmObj start_plus_end,
 
101
                                ScmObj body,
 
102
                                ScmEvalState *eval_state)
 
103
{
 
104
    ScmObj env, start_name, end_name, proc_check_type, check_type_args;
 
105
    ScmObj receive_expr;
 
106
    DECLARE_FUNCTION("let-vector-start+end", syntax_variadic_tailrec_4);
 
107
 
 
108
    if (!LIST_2_P(start_plus_end))
 
109
        ERR_OBJ("invalid start+end form", start_plus_end);
 
110
    /* The responsibility of type checks for other args are delegated to
 
111
     * 'check-type' and 'receive'. */
 
112
 
 
113
    env = eval_state->env;
 
114
 
 
115
    proc_check_type = EVAL(l_sym_check_type, env);
 
116
    check_type_args = LIST_3(EVAL(l_sym_vectorp, env),
 
117
                             EVAL(vec, env),
 
118
                             EVAL(callee, env));
 
119
    vec = scm_call(proc_check_type, check_type_args);
 
120
 
 
121
    start_name = QUOTE(CAR(start_plus_end));
 
122
    end_name   = QUOTE(CADR(start_plus_end));
 
123
    receive_expr = CONS(l_sym_vector_parse_start_plus_end,
 
124
                        LIST_5(QUOTE(vec), args, start_name, end_name, callee));
 
125
    return scm_s_srfi8_receive(start_plus_end, receive_expr, body, eval_state);
 
126
}