[uim-commit] r3020 - branches/r5rs/sigscheme/src
yamaken at freedesktop.org
yamaken at freedesktop.org
Sun Jan 29 12:08:41 PST 2006
Author: yamaken
Date: 2006-01-29 12:08:36 -0800 (Sun, 29 Jan 2006)
New Revision: 3020
Added:
branches/r5rs/sigscheme/src/vector.c
Modified:
branches/r5rs/sigscheme/src/Makefile.am
branches/r5rs/sigscheme/src/operations.c
branches/r5rs/sigscheme/src/sigscheme.h
Log:
* sigscheme/src/vector.c
- New file copied from operations.c
- (scm_p_vectorp, scm_p_make_vector, scm_p_vector,
scm_p_vector_length, scm_p_vector_ref, scm_p_vector_setd,
scm_p_vector2list, scm_p_list2vector, scm_p_vector_filld): Moved
from operations.c
* sigscheme/src/operations.c
- (scm_p_vectorp, scm_p_make_vector, scm_p_vector,
scm_p_vector_length, scm_p_vector_ref, scm_p_vector_setd,
scm_p_vector2list, scm_p_list2vector, scm_p_vector_filld): Move to
vector.c
* sigscheme/src/sigscheme.h
- Move prototype section
* sigscheme/src/Makefile.am
- (R5RS_PROC_SOURCES): Rename to R5RS_PROC_SRCS to avoid conflicting
with libtool naming convention
- (R5RS_PROC_SRCS):
* Renamed from R5RS_PROC_SOURCES
* Add vector.c
- (libsscm_la_SOURCES): Add vector.c
Modified: branches/r5rs/sigscheme/src/Makefile.am
===================================================================
--- branches/r5rs/sigscheme/src/Makefile.am 2006-01-29 19:57:59 UTC (rev 3019)
+++ branches/r5rs/sigscheme/src/Makefile.am 2006-01-29 20:08:36 UTC (rev 3020)
@@ -23,14 +23,15 @@
./script/functable-header.txt \
./script/functable-footer.txt
-R5RS_PROC_SOURCES = sigscheme.c operations.c eval.c number.c string.c io.c
+R5RS_PROC_SRCS = sigscheme.c operations.c eval.c number.c string.c \
+ vector.c io.c
sigschemefunctable.c: $(FUNC_TABLES)
sigschemefunctable-r5rs-syntax.c: syntax.c $(BUILD_FUNCTBL_SOURCES)
$(BUILD_FUNCTBL) "scm_r5rs_syntax_func_info_table" $< > $@
-sigschemefunctable-r5rs-procedure.c: $(R5RS_PROC_SOURCES) $(BUILD_FUNCTBL_SOURCES)
+sigschemefunctable-r5rs-procedure.c: $(R5RS_PROC_SRCS) $(BUILD_FUNCTBL_SOURCES)
$(BUILD_FUNCTBL) "scm_r5rs_procedure_func_info_table" \
- $(R5RS_PROC_SOURCES) > $@
+ $(R5RS_PROC_SRCS) > $@
sigschemefunctable-r5rs-deepcadrs.c: operations-r5rs-deepcadrs.c $(BUILD_FUNCTBL_SOURCES)
$(BUILD_FUNCTBL) "scm_r5rs_deepcadrs_func_info_table" $< > $@
sigschemefunctable-error.c: error.c $(BUILD_FUNCTBL_SOURCES)
@@ -65,7 +66,7 @@
storage-symbol.c \
storage-continuation.c \
encoding.c error.c \
- env.c eval.c syntax.c number.c string.c io.c \
+ env.c eval.c syntax.c number.c string.c vector.c io.c \
basecport.c fileport.c \
operations.c \
read.c sigscheme.c sigschemefunctable.c \
Modified: branches/r5rs/sigscheme/src/operations.c
===================================================================
--- branches/r5rs/sigscheme/src/operations.c 2006-01-29 19:57:59 UTC (rev 3019)
+++ branches/r5rs/sigscheme/src/operations.c 2006-01-29 20:08:36 UTC (rev 3020)
@@ -648,159 +648,6 @@
return scm_intern(SCM_STRING_STR(str));
}
-/*===========================================================================
- R5RS : 6.3 Other data types : 6.3.6 Vectors
-===========================================================================*/
-ScmObj
-scm_p_vectorp(ScmObj obj)
-{
- DECLARE_FUNCTION("vector?", procedure_fixed_1);
-
- return MAKE_BOOL(VECTORP(obj));
-}
-
-ScmObj
-scm_p_make_vector(ScmObj scm_len, ScmObj args)
-{
- ScmObj *vec, filler;
- scm_int_t len, i;
- DECLARE_FUNCTION("make-vector", procedure_variadic_1);
-
- ENSURE_INT(scm_len);
-
- len = SCM_INT_VALUE(scm_len);
- if (len < 0)
- ERR_OBJ("length must be a positive integer", scm_len);
-
- vec = scm_malloc(sizeof(ScmObj) * len);
- if (NULLP(args)) {
- filler = SCM_UNDEF;
- } else {
- filler = POP(args);
- ASSERT_NO_MORE_ARG(args);
- }
- for (i = 0; i < len; i++)
- vec[i] = filler;
-
- return MAKE_VECTOR(vec, len);
-}
-
-ScmObj
-scm_p_vector(ScmObj args)
-{
- DECLARE_FUNCTION("vector", procedure_variadic_0);
-
- return scm_p_list2vector(args);
-}
-
-ScmObj
-scm_p_vector_length(ScmObj vec)
-{
- DECLARE_FUNCTION("vector-length", procedure_fixed_1);
-
- ENSURE_VECTOR(vec);
-
- return MAKE_INT(SCM_VECTOR_LEN(vec));
-}
-
-ScmObj
-scm_p_vector_ref(ScmObj vec, ScmObj scm_k)
-{
- scm_int_t k;
- DECLARE_FUNCTION("vector-ref", procedure_fixed_2);
-
- ENSURE_VECTOR(vec);
- ENSURE_INT(scm_k);
-
- k = SCM_INT_VALUE(scm_k);
-
- if (!SCM_VECTOR_VALID_INDEXP(vec, k))
- ERR_OBJ("index out of range", scm_k);
-
- return SCM_VECTOR_VEC(vec)[k];
-}
-
-ScmObj
-scm_p_vector_setd(ScmObj vec, ScmObj scm_k, ScmObj obj)
-{
- scm_int_t k;
- DECLARE_FUNCTION("vector-set!", procedure_fixed_3);
-
- ENSURE_VECTOR(vec);
-#if SCM_CONST_VECTOR_LITERAL
- ENSURE_MUTABLE_VECTOR(vec);
-#endif
- ENSURE_INT(scm_k);
-
- k = SCM_INT_VALUE(scm_k);
-
- if (!SCM_VECTOR_VALID_INDEXP(vec, k))
- ERR_OBJ("index out of range", scm_k);
-
- SCM_VECTOR_VEC(vec)[k] = obj;
-
- return SCM_UNDEF;
-}
-
-ScmObj
-scm_p_vector2list(ScmObj vec)
-{
- ScmQueue q;
- ScmObj res, *v;
- scm_int_t len, i;
- DECLARE_FUNCTION("vector->list", procedure_fixed_1);
-
- ENSURE_VECTOR(vec);
-
- v = SCM_VECTOR_VEC(vec);
- len = SCM_VECTOR_LEN(vec);
-
- res = SCM_NULL;
- SCM_QUEUE_POINT_TO(q, res);
- for (i = 0; i < len; i++)
- SCM_QUEUE_ADD(q, v[i]);
-
- return res;
-}
-
-ScmObj
-scm_p_list2vector(ScmObj lst)
-{
- ScmObj *vec;
- scm_int_t len, i;
- DECLARE_FUNCTION("list->vector", procedure_fixed_1);
-
- len = scm_length(lst);
- if (!SCM_LISTLEN_PROPERP(len))
- ERR_OBJ("proper list required but got", lst);
-
- vec = scm_malloc(sizeof(ScmObj) * len);
- for (i = 0; i < len; i++)
- vec[i] = POP(lst);
-
- return MAKE_VECTOR(vec, len);
-}
-
-ScmObj
-scm_p_vector_filld(ScmObj vec, ScmObj fill)
-{
- ScmObj *v;
- scm_int_t len, i;
- DECLARE_FUNCTION("vector-fill!", procedure_fixed_2);
-
- ENSURE_VECTOR(vec);
-#if SCM_CONST_VECTOR_LITERAL
- ENSURE_MUTABLE_VECTOR(vec);
-#endif
-
- v = SCM_VECTOR_VEC(vec);
- len = SCM_VECTOR_LEN(vec);
- for (i = 0; i < len; i++)
- v[i] = fill;
-
- return vec;
-}
-
/*=======================================
R5RS : 6.4 Control Features
=======================================*/
Modified: branches/r5rs/sigscheme/src/sigscheme.h
===================================================================
--- branches/r5rs/sigscheme/src/sigscheme.h 2006-01-29 19:57:59 UTC (rev 3019)
+++ branches/r5rs/sigscheme/src/sigscheme.h 2006-01-29 20:08:36 UTC (rev 3020)
@@ -1192,16 +1192,6 @@
ScmObj scm_p_symbolp(ScmObj obj);
ScmObj scm_p_symbol2string(ScmObj sym);
ScmObj scm_p_string2symbol(ScmObj str);
-
-ScmObj scm_p_vectorp(ScmObj obj);
-ScmObj scm_p_make_vector(ScmObj scm_len, ScmObj args);
-ScmObj scm_p_vector(ScmObj args);
-ScmObj scm_p_vector_length(ScmObj vec);
-ScmObj scm_p_vector_ref(ScmObj vec, ScmObj scm_k);
-ScmObj scm_p_vector_setd(ScmObj vec, ScmObj scm_k, ScmObj obj);
-ScmObj scm_p_vector2list(ScmObj vec);
-ScmObj scm_p_list2vector(ScmObj lst);
-ScmObj scm_p_vector_filld(ScmObj vec, ScmObj fill);
ScmObj scm_p_procedurep(ScmObj obj);
ScmObj scm_p_map(ScmObj proc, ScmObj args);
ScmObj scm_p_for_each(ScmObj proc, ScmObj args);
@@ -1288,6 +1278,17 @@
ScmObj scm_p_string_copy(ScmObj str);
ScmObj scm_p_string_filld(ScmObj str, ScmObj ch);
+/* vector.c */
+ScmObj scm_p_vectorp(ScmObj obj);
+ScmObj scm_p_make_vector(ScmObj scm_len, ScmObj args);
+ScmObj scm_p_vector(ScmObj args);
+ScmObj scm_p_vector_length(ScmObj vec);
+ScmObj scm_p_vector_ref(ScmObj vec, ScmObj scm_k);
+ScmObj scm_p_vector_setd(ScmObj vec, ScmObj scm_k, ScmObj obj);
+ScmObj scm_p_vector2list(ScmObj vec);
+ScmObj scm_p_list2vector(ScmObj lst);
+ScmObj scm_p_vector_filld(ScmObj vec, ScmObj fill);
+
/* operations-r5rs-deepcadrs.c */
#if SCM_USE_DEEP_CADRS
ScmObj scm_p_caaar(ScmObj lst);
Copied: branches/r5rs/sigscheme/src/vector.c (from rev 3019, branches/r5rs/sigscheme/src/operations.c)
===================================================================
--- branches/r5rs/sigscheme/src/operations.c 2006-01-29 19:57:59 UTC (rev 3019)
+++ branches/r5rs/sigscheme/src/vector.c 2006-01-29 20:08:36 UTC (rev 3020)
@@ -0,0 +1,217 @@
+/*===========================================================================
+ * FileName : vector.c
+ * About : R5RS vectors
+ *
+ * Copyright (C) 2005-2006 Kazuki Ohta <mover AT hct.zaq.ne.jp>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of authors nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
+ * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+===========================================================================*/
+
+#include "config.h"
+
+/*=======================================
+ System Include
+=======================================*/
+
+/*=======================================
+ Local Include
+=======================================*/
+#include "sigscheme.h"
+#include "sigschemeinternal.h"
+
+/*=======================================
+ File Local Struct Declarations
+=======================================*/
+
+/*=======================================
+ File Local Macro Declarations
+=======================================*/
+
+/*=======================================
+ Variable Declarations
+=======================================*/
+
+/*=======================================
+ File Local Function Declarations
+=======================================*/
+
+/*=======================================
+ Function Implementations
+=======================================*/
+/*===========================================================================
+ R5RS : 6.3 Other data types : 6.3.6 Vectors
+===========================================================================*/
+ScmObj
+scm_p_vectorp(ScmObj obj)
+{
+ DECLARE_FUNCTION("vector?", procedure_fixed_1);
+
+ return MAKE_BOOL(VECTORP(obj));
+}
+
+ScmObj
+scm_p_make_vector(ScmObj scm_len, ScmObj args)
+{
+ ScmObj *vec, filler;
+ scm_int_t len, i;
+ DECLARE_FUNCTION("make-vector", procedure_variadic_1);
+
+ ENSURE_INT(scm_len);
+
+ len = SCM_INT_VALUE(scm_len);
+ if (len < 0)
+ ERR_OBJ("length must be a positive integer", scm_len);
+
+ vec = scm_malloc(sizeof(ScmObj) * len);
+ if (NULLP(args)) {
+ filler = SCM_UNDEF;
+ } else {
+ filler = POP(args);
+ ASSERT_NO_MORE_ARG(args);
+ }
+ for (i = 0; i < len; i++)
+ vec[i] = filler;
+
+ return MAKE_VECTOR(vec, len);
+}
+
+ScmObj
+scm_p_vector(ScmObj args)
+{
+ DECLARE_FUNCTION("vector", procedure_variadic_0);
+
+ return scm_p_list2vector(args);
+}
+
+ScmObj
+scm_p_vector_length(ScmObj vec)
+{
+ DECLARE_FUNCTION("vector-length", procedure_fixed_1);
+
+ ENSURE_VECTOR(vec);
+
+ return MAKE_INT(SCM_VECTOR_LEN(vec));
+}
+
+ScmObj
+scm_p_vector_ref(ScmObj vec, ScmObj scm_k)
+{
+ scm_int_t k;
+ DECLARE_FUNCTION("vector-ref", procedure_fixed_2);
+
+ ENSURE_VECTOR(vec);
+ ENSURE_INT(scm_k);
+
+ k = SCM_INT_VALUE(scm_k);
+
+ if (!SCM_VECTOR_VALID_INDEXP(vec, k))
+ ERR_OBJ("index out of range", scm_k);
+
+ return SCM_VECTOR_VEC(vec)[k];
+}
+
+ScmObj
+scm_p_vector_setd(ScmObj vec, ScmObj scm_k, ScmObj obj)
+{
+ scm_int_t k;
+ DECLARE_FUNCTION("vector-set!", procedure_fixed_3);
+
+ ENSURE_VECTOR(vec);
+#if SCM_CONST_VECTOR_LITERAL
+ ENSURE_MUTABLE_VECTOR(vec);
+#endif
+ ENSURE_INT(scm_k);
+
+ k = SCM_INT_VALUE(scm_k);
+
+ if (!SCM_VECTOR_VALID_INDEXP(vec, k))
+ ERR_OBJ("index out of range", scm_k);
+
+ SCM_VECTOR_VEC(vec)[k] = obj;
+
+ return SCM_UNDEF;
+}
+
+ScmObj
+scm_p_vector2list(ScmObj vec)
+{
+ ScmQueue q;
+ ScmObj res, *v;
+ scm_int_t len, i;
+ DECLARE_FUNCTION("vector->list", procedure_fixed_1);
+
+ ENSURE_VECTOR(vec);
+
+ v = SCM_VECTOR_VEC(vec);
+ len = SCM_VECTOR_LEN(vec);
+
+ res = SCM_NULL;
+ SCM_QUEUE_POINT_TO(q, res);
+ for (i = 0; i < len; i++)
+ SCM_QUEUE_ADD(q, v[i]);
+
+ return res;
+}
+
+ScmObj
+scm_p_list2vector(ScmObj lst)
+{
+ ScmObj *vec;
+ scm_int_t len, i;
+ DECLARE_FUNCTION("list->vector", procedure_fixed_1);
+
+ len = scm_length(lst);
+ if (!SCM_LISTLEN_PROPERP(len))
+ ERR_OBJ("proper list required but got", lst);
+
+ vec = scm_malloc(sizeof(ScmObj) * len);
+ for (i = 0; i < len; i++)
+ vec[i] = POP(lst);
+
+ return MAKE_VECTOR(vec, len);
+}
+
+ScmObj
+scm_p_vector_filld(ScmObj vec, ScmObj fill)
+{
+ ScmObj *v;
+ scm_int_t len, i;
+ DECLARE_FUNCTION("vector-fill!", procedure_fixed_2);
+
+ ENSURE_VECTOR(vec);
+#if SCM_CONST_VECTOR_LITERAL
+ ENSURE_MUTABLE_VECTOR(vec);
+#endif
+
+ v = SCM_VECTOR_VEC(vec);
+ len = SCM_VECTOR_LEN(vec);
+ for (i = 0; i < len; i++)
+ v[i] = fill;
+
+ return vec;
+}
More information about the uim-commit
mailing list