deprecated all discouraged functions
* libguile/Makefile.am: * libguile/discouraged.c: Remove discouraged.c. * libguile/deprecated.c: * libguile/deprecated.h: * libguile/discouraged.h: All functions and declarations moved from discouraged.[ch] to deprecated.[ch], adding deprecation warnings. * libguile/init.c: Remove discouraged init. * libguile/numbers.c (scm_num2float, scm_num2double): Deprecate. * test-suite/standalone/test-num2integral.c: Port to modern API.
This commit is contained in:
parent
3470a29911
commit
220058a835
8 changed files with 458 additions and 434 deletions
|
|
@ -128,7 +128,6 @@ libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES = \
|
|||
debug.c \
|
||||
deprecated.c \
|
||||
deprecation.c \
|
||||
discouraged.c \
|
||||
dynwind.c \
|
||||
eq.c \
|
||||
error.c \
|
||||
|
|
@ -230,7 +229,6 @@ DOT_X_FILES = \
|
|||
debug.x \
|
||||
deprecated.x \
|
||||
deprecation.x \
|
||||
discouraged.x \
|
||||
dynl.x \
|
||||
dynwind.x \
|
||||
eq.x \
|
||||
|
|
@ -330,7 +328,6 @@ DOT_DOC_FILES = \
|
|||
debug.doc \
|
||||
deprecated.doc \
|
||||
deprecation.doc \
|
||||
discouraged.doc \
|
||||
dynl.doc \
|
||||
dynwind.doc \
|
||||
eq.doc \
|
||||
|
|
|
|||
|
|
@ -1986,6 +1986,355 @@ scm_internal_stack_catch (SCM tag,
|
|||
|
||||
|
||||
|
||||
SCM
|
||||
scm_short2num (short x)
|
||||
{
|
||||
scm_c_issue_deprecation_warning
|
||||
("`scm_short2num' is deprecated. Use scm_from_short instead.");
|
||||
return scm_from_short (x);
|
||||
}
|
||||
|
||||
SCM
|
||||
scm_ushort2num (unsigned short x)
|
||||
{
|
||||
scm_c_issue_deprecation_warning
|
||||
("`scm_ushort2num' is deprecated. Use scm_from_ushort instead.");
|
||||
return scm_from_ushort (x);
|
||||
}
|
||||
|
||||
SCM
|
||||
scm_int2num (int x)
|
||||
{
|
||||
scm_c_issue_deprecation_warning
|
||||
("`scm_int2num' is deprecated. Use scm_from_int instead.");
|
||||
return scm_from_int (x);
|
||||
}
|
||||
|
||||
SCM
|
||||
scm_uint2num (unsigned int x)
|
||||
{
|
||||
scm_c_issue_deprecation_warning
|
||||
("`scm_uint2num' is deprecated. Use scm_from_uint instead.");
|
||||
return scm_from_uint (x);
|
||||
}
|
||||
|
||||
SCM
|
||||
scm_long2num (long x)
|
||||
{
|
||||
scm_c_issue_deprecation_warning
|
||||
("`scm_long2num' is deprecated. Use scm_from_long instead.");
|
||||
return scm_from_long (x);
|
||||
}
|
||||
|
||||
SCM
|
||||
scm_ulong2num (unsigned long x)
|
||||
{
|
||||
scm_c_issue_deprecation_warning
|
||||
("`scm_ulong2num' is deprecated. Use scm_from_ulong instead.");
|
||||
return scm_from_ulong (x);
|
||||
}
|
||||
|
||||
SCM
|
||||
scm_size2num (size_t x)
|
||||
{
|
||||
scm_c_issue_deprecation_warning
|
||||
("`scm_size2num' is deprecated. Use scm_from_size_t instead.");
|
||||
return scm_from_size_t (x);
|
||||
}
|
||||
|
||||
SCM
|
||||
scm_ptrdiff2num (ptrdiff_t x)
|
||||
{
|
||||
scm_c_issue_deprecation_warning
|
||||
("`scm_ptrdiff2num' is deprecated. Use scm_from_ssize_t instead.");
|
||||
return scm_from_ssize_t (x);
|
||||
}
|
||||
|
||||
short
|
||||
scm_num2short (SCM x, unsigned long pos, const char *s_caller)
|
||||
{
|
||||
scm_c_issue_deprecation_warning
|
||||
("`scm_num2short' is deprecated. Use scm_to_short instead.");
|
||||
return scm_to_short (x);
|
||||
}
|
||||
|
||||
unsigned short
|
||||
scm_num2ushort (SCM x, unsigned long pos, const char *s_caller)
|
||||
{
|
||||
scm_c_issue_deprecation_warning
|
||||
("`scm_num2ushort' is deprecated. Use scm_to_ushort instead.");
|
||||
return scm_to_ushort (x);
|
||||
}
|
||||
|
||||
int
|
||||
scm_num2int (SCM x, unsigned long pos, const char *s_caller)
|
||||
{
|
||||
scm_c_issue_deprecation_warning
|
||||
("`scm_num2int' is deprecated. Use scm_to_int instead.");
|
||||
return scm_to_int (x);
|
||||
}
|
||||
|
||||
unsigned int
|
||||
scm_num2uint (SCM x, unsigned long pos, const char *s_caller)
|
||||
{
|
||||
scm_c_issue_deprecation_warning
|
||||
("`scm_num2uint' is deprecated. Use scm_to_uint instead.");
|
||||
return scm_to_uint (x);
|
||||
}
|
||||
|
||||
long
|
||||
scm_num2long (SCM x, unsigned long pos, const char *s_caller)
|
||||
{
|
||||
scm_c_issue_deprecation_warning
|
||||
("`scm_num2long' is deprecated. Use scm_to_long instead.");
|
||||
return scm_to_long (x);
|
||||
}
|
||||
|
||||
unsigned long
|
||||
scm_num2ulong (SCM x, unsigned long pos, const char *s_caller)
|
||||
{
|
||||
scm_c_issue_deprecation_warning
|
||||
("`scm_num2ulong' is deprecated. Use scm_to_ulong instead.");
|
||||
return scm_to_ulong (x);
|
||||
}
|
||||
|
||||
size_t
|
||||
scm_num2size (SCM x, unsigned long pos, const char *s_caller)
|
||||
{
|
||||
scm_c_issue_deprecation_warning
|
||||
("`scm_num2size' is deprecated. Use scm_to_size_t instead.");
|
||||
return scm_to_size_t (x);
|
||||
}
|
||||
|
||||
ptrdiff_t
|
||||
scm_num2ptrdiff (SCM x, unsigned long pos, const char *s_caller)
|
||||
{
|
||||
scm_c_issue_deprecation_warning
|
||||
("`scm_num2ptrdiff' is deprecated. Use scm_to_ssize_t instead.");
|
||||
return scm_to_ssize_t (x);
|
||||
}
|
||||
|
||||
#if SCM_SIZEOF_LONG_LONG != 0
|
||||
|
||||
SCM
|
||||
scm_long_long2num (long long x)
|
||||
{
|
||||
scm_c_issue_deprecation_warning
|
||||
("`scm_long_long2num' is deprecated. Use scm_from_long_long instead.");
|
||||
return scm_from_long_long (x);
|
||||
}
|
||||
|
||||
SCM
|
||||
scm_ulong_long2num (unsigned long long x)
|
||||
{
|
||||
scm_c_issue_deprecation_warning
|
||||
("`scm_ulong_long2num' is deprecated. Use scm_from_ulong_long instead.");
|
||||
return scm_from_ulong_long (x);
|
||||
}
|
||||
|
||||
long long
|
||||
scm_num2long_long (SCM x, unsigned long pos, const char *s_caller)
|
||||
{
|
||||
scm_c_issue_deprecation_warning
|
||||
("`scm_num2long_long' is deprecated. Use scm_to_long_long instead.");
|
||||
return scm_to_long_long (x);
|
||||
}
|
||||
|
||||
unsigned long long
|
||||
scm_num2ulong_long (SCM x, unsigned long pos, const char *s_caller)
|
||||
{
|
||||
scm_c_issue_deprecation_warning
|
||||
("`scm_num2ulong_long' is deprecated. Use scm_from_ulong_long instead.");
|
||||
return scm_to_ulong_long (x);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
SCM
|
||||
scm_make_real (double x)
|
||||
{
|
||||
scm_c_issue_deprecation_warning
|
||||
("`scm_make_real' is deprecated. Use scm_from_double instead.");
|
||||
return scm_from_double (x);
|
||||
}
|
||||
|
||||
double
|
||||
scm_num2dbl (SCM a, const char *why)
|
||||
{
|
||||
scm_c_issue_deprecation_warning
|
||||
("`scm_num2dbl' is deprecated. Use scm_to_double instead.");
|
||||
return scm_to_double (a);
|
||||
}
|
||||
|
||||
SCM
|
||||
scm_float2num (float n)
|
||||
{
|
||||
scm_c_issue_deprecation_warning
|
||||
("`scm_float2num' is deprecated. Use scm_from_double instead.");
|
||||
return scm_from_double ((double) n);
|
||||
}
|
||||
|
||||
SCM
|
||||
scm_double2num (double n)
|
||||
{
|
||||
scm_c_issue_deprecation_warning
|
||||
("`scm_double2num' is deprecated. Use scm_from_double instead.");
|
||||
return scm_from_double (n);
|
||||
}
|
||||
|
||||
SCM
|
||||
scm_make_complex (double x, double y)
|
||||
{
|
||||
scm_c_issue_deprecation_warning
|
||||
("`scm_make_complex' is deprecated. Use scm_c_make_rectangular instead.");
|
||||
return scm_c_make_rectangular (x, y);
|
||||
}
|
||||
|
||||
SCM
|
||||
scm_mem2symbol (const char *mem, size_t len)
|
||||
{
|
||||
scm_c_issue_deprecation_warning
|
||||
("`scm_mem2symbol' is deprecated. Use scm_from_locale_symboln instead.");
|
||||
return scm_from_locale_symboln (mem, len);
|
||||
}
|
||||
|
||||
SCM
|
||||
scm_mem2uninterned_symbol (const char *mem, size_t len)
|
||||
{
|
||||
scm_c_issue_deprecation_warning
|
||||
("`scm_mem2uninterned_symbol' is deprecated. "
|
||||
"Use scm_make_symbol and scm_from_locale_symboln instead.");
|
||||
return scm_make_symbol (scm_from_locale_stringn (mem, len));
|
||||
}
|
||||
|
||||
SCM
|
||||
scm_str2symbol (const char *str)
|
||||
{
|
||||
scm_c_issue_deprecation_warning
|
||||
("`scm_str2symbol' is deprecated. Use scm_from_locale_symbol instead.");
|
||||
return scm_from_locale_symbol (str);
|
||||
}
|
||||
|
||||
|
||||
/* This function must only be applied to memory obtained via malloc,
|
||||
since the GC is going to apply `free' to it when the string is
|
||||
dropped.
|
||||
|
||||
Also, s[len] must be `\0', since we promise that strings are
|
||||
null-terminated. Perhaps we could handle non-null-terminated
|
||||
strings by claiming they're shared substrings of a string we just
|
||||
made up. */
|
||||
SCM
|
||||
scm_take_str (char *s, size_t len)
|
||||
{
|
||||
scm_c_issue_deprecation_warning
|
||||
("`scm_take_str' is deprecated. Use scm_take_locale_stringn instead.");
|
||||
return scm_take_locale_stringn (s, len);
|
||||
}
|
||||
|
||||
/* `s' must be a malloc'd string. See scm_take_str. */
|
||||
SCM
|
||||
scm_take0str (char *s)
|
||||
{
|
||||
scm_c_issue_deprecation_warning
|
||||
("`scm_take0str' is deprecated. Use scm_take_locale_string instead.");
|
||||
return scm_take_locale_string (s);
|
||||
}
|
||||
|
||||
SCM
|
||||
scm_mem2string (const char *src, size_t len)
|
||||
{
|
||||
scm_c_issue_deprecation_warning
|
||||
("`scm_mem2string' is deprecated. Use scm_from_locale_stringn instead.");
|
||||
return scm_from_locale_stringn (src, len);
|
||||
}
|
||||
|
||||
SCM
|
||||
scm_str2string (const char *src)
|
||||
{
|
||||
scm_c_issue_deprecation_warning
|
||||
("`scm_str2string' is deprecated. Use scm_from_locale_string instead.");
|
||||
return scm_from_locale_string (src);
|
||||
}
|
||||
|
||||
SCM
|
||||
scm_makfrom0str (const char *src)
|
||||
{
|
||||
scm_c_issue_deprecation_warning
|
||||
("`scm_makfrom0str' is deprecated."
|
||||
"Use scm_from_locale_string instead, but check for NULL first.");
|
||||
if (!src) return SCM_BOOL_F;
|
||||
return scm_from_locale_string (src);
|
||||
}
|
||||
|
||||
SCM
|
||||
scm_makfrom0str_opt (const char *src)
|
||||
{
|
||||
scm_c_issue_deprecation_warning
|
||||
("`scm_makfrom0str_opt' is deprecated."
|
||||
"Use scm_from_locale_string instead, but check for NULL first.");
|
||||
return scm_makfrom0str (src);
|
||||
}
|
||||
|
||||
|
||||
SCM
|
||||
scm_allocate_string (size_t len)
|
||||
{
|
||||
scm_c_issue_deprecation_warning
|
||||
("`scm_allocate_string' is deprecated. Use scm_c_make_string instead.");
|
||||
return scm_i_make_string (len, NULL);
|
||||
}
|
||||
|
||||
SCM_DEFINE (scm_make_keyword_from_dash_symbol, "make-keyword-from-dash-symbol", 1, 0, 0,
|
||||
(SCM symbol),
|
||||
"Make a keyword object from a @var{symbol} that starts with a dash.")
|
||||
#define FUNC_NAME s_scm_make_keyword_from_dash_symbol
|
||||
{
|
||||
SCM dash_string, non_dash_symbol;
|
||||
|
||||
scm_c_issue_deprecation_warning
|
||||
("`scm_make_keyword_from_dash_symbol' is deprecated. Don't use dash symbols.");
|
||||
|
||||
SCM_ASSERT (scm_is_symbol (symbol)
|
||||
&& (scm_i_symbol_ref (symbol, 0) == '-'),
|
||||
symbol, SCM_ARG1, FUNC_NAME);
|
||||
|
||||
dash_string = scm_symbol_to_string (symbol);
|
||||
non_dash_symbol =
|
||||
scm_string_to_symbol (scm_c_substring (dash_string,
|
||||
1,
|
||||
scm_c_string_length (dash_string)));
|
||||
|
||||
return scm_symbol_to_keyword (non_dash_symbol);
|
||||
}
|
||||
#undef FUNC_NAME
|
||||
|
||||
SCM_DEFINE (scm_keyword_dash_symbol, "keyword-dash-symbol", 1, 0, 0,
|
||||
(SCM keyword),
|
||||
"Return the dash symbol for @var{keyword}.\n"
|
||||
"This is the inverse of @code{make-keyword-from-dash-symbol}.")
|
||||
#define FUNC_NAME s_scm_keyword_dash_symbol
|
||||
{
|
||||
SCM symbol = scm_keyword_to_symbol (keyword);
|
||||
SCM parts = scm_list_2 (scm_from_locale_string ("-"),
|
||||
scm_symbol_to_string (symbol));
|
||||
scm_c_issue_deprecation_warning
|
||||
("`scm_keyword_dash_symbol' is deprecated. Don't use dash symbols.");
|
||||
|
||||
return scm_string_to_symbol (scm_string_append (parts));
|
||||
}
|
||||
#undef FUNC_NAME
|
||||
|
||||
SCM
|
||||
scm_c_make_keyword (const char *s)
|
||||
{
|
||||
scm_c_issue_deprecation_warning
|
||||
("`scm_c_make_keyword' is deprecated. Use scm_from_locale_keyword instead.");
|
||||
return scm_from_locale_keyword (s);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
scm_i_init_deprecated ()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -640,6 +640,95 @@ SCM_DEPRECATED SCM scm_internal_stack_catch (SCM tag,
|
|||
|
||||
|
||||
|
||||
/* These functions were "discouraged" in 1.8, and now are deprecated. */
|
||||
|
||||
/* scm_to_int, scm_from_int are the official functions to do the job,
|
||||
but there is nothing wrong with using scm_num2int, etc.
|
||||
|
||||
These could be trivially defined via macros, but we leave them as
|
||||
functions since existing code may take their addresses.
|
||||
*/
|
||||
|
||||
SCM_DEPRECATED SCM scm_short2num (short n);
|
||||
SCM_DEPRECATED SCM scm_ushort2num (unsigned short n);
|
||||
SCM_DEPRECATED SCM scm_int2num (int n);
|
||||
SCM_DEPRECATED SCM scm_uint2num (unsigned int n);
|
||||
SCM_DEPRECATED SCM scm_long2num (long n);
|
||||
SCM_DEPRECATED SCM scm_ulong2num (unsigned long n);
|
||||
SCM_DEPRECATED SCM scm_size2num (size_t n);
|
||||
SCM_DEPRECATED SCM scm_ptrdiff2num (scm_t_ptrdiff n);
|
||||
SCM_DEPRECATED short scm_num2short (SCM num, unsigned long int pos,
|
||||
const char *s_caller);
|
||||
SCM_DEPRECATED unsigned short scm_num2ushort (SCM num, unsigned long int pos,
|
||||
const char *s_caller);
|
||||
SCM_DEPRECATED int scm_num2int (SCM num, unsigned long int pos,
|
||||
const char *s_caller);
|
||||
SCM_DEPRECATED unsigned int scm_num2uint (SCM num, unsigned long int pos,
|
||||
const char *s_caller);
|
||||
SCM_DEPRECATED long scm_num2long (SCM num, unsigned long int pos,
|
||||
const char *s_caller);
|
||||
SCM_DEPRECATED unsigned long scm_num2ulong (SCM num, unsigned long int pos,
|
||||
const char *s_caller);
|
||||
SCM_DEPRECATED scm_t_ptrdiff scm_num2ptrdiff (SCM num, unsigned long int pos,
|
||||
const char *s_caller);
|
||||
SCM_DEPRECATED size_t scm_num2size (SCM num, unsigned long int pos,
|
||||
const char *s_caller);
|
||||
#if SCM_SIZEOF_LONG_LONG != 0
|
||||
SCM_DEPRECATED SCM scm_long_long2num (long long sl);
|
||||
SCM_DEPRECATED SCM scm_ulong_long2num (unsigned long long sl);
|
||||
SCM_DEPRECATED long long scm_num2long_long (SCM num, unsigned long int pos,
|
||||
const char *s_caller);
|
||||
SCM_DEPRECATED unsigned long long scm_num2ulong_long (SCM num, unsigned long int pos,
|
||||
const char *s_caller);
|
||||
#endif
|
||||
|
||||
SCM_DEPRECATED SCM scm_make_real (double x);
|
||||
SCM_DEPRECATED double scm_num2dbl (SCM a, const char * why);
|
||||
SCM_DEPRECATED SCM scm_float2num (float n);
|
||||
SCM_DEPRECATED SCM scm_double2num (double n);
|
||||
|
||||
/* The next two are implemented in numbers.c since they use features
|
||||
only available there.
|
||||
*/
|
||||
SCM_DEPRECATED float scm_num2float (SCM num, unsigned long int pos,
|
||||
const char *s_caller);
|
||||
SCM_DEPRECATED double scm_num2double (SCM num, unsigned long int pos,
|
||||
const char *s_caller);
|
||||
|
||||
SCM_DEPRECATED SCM scm_make_complex (double x, double y);
|
||||
|
||||
/* Discouraged because they don't make the encoding explicit.
|
||||
*/
|
||||
|
||||
SCM_DEPRECATED SCM scm_mem2symbol (const char *mem, size_t len);
|
||||
SCM_DEPRECATED SCM scm_mem2uninterned_symbol (const char *mem, size_t len);
|
||||
SCM_DEPRECATED SCM scm_str2symbol (const char *str);
|
||||
|
||||
SCM_DEPRECATED SCM scm_take_str (char *s, size_t len);
|
||||
SCM_DEPRECATED SCM scm_take0str (char *s);
|
||||
SCM_DEPRECATED SCM scm_mem2string (const char *src, size_t len);
|
||||
SCM_DEPRECATED SCM scm_str2string (const char *src);
|
||||
SCM_DEPRECATED SCM scm_makfrom0str (const char *src);
|
||||
SCM_DEPRECATED SCM scm_makfrom0str_opt (const char *src);
|
||||
|
||||
/* Discouraged because scm_c_make_string has a better name and is more
|
||||
consistent with make-string.
|
||||
*/
|
||||
SCM_DEPRECATED SCM scm_allocate_string (size_t len);
|
||||
|
||||
/* Discouraged because they are just strange.
|
||||
*/
|
||||
|
||||
SCM_DEPRECATED SCM scm_make_keyword_from_dash_symbol (SCM symbol);
|
||||
SCM_DEPRECATED SCM scm_keyword_dash_symbol (SCM keyword);
|
||||
|
||||
/* Discouraged because it does not state what encoding S is in.
|
||||
*/
|
||||
|
||||
SCM_DEPRECATED SCM scm_c_make_keyword (const char *s);
|
||||
|
||||
|
||||
|
||||
void scm_i_init_deprecated (void);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,307 +0,0 @@
|
|||
/* This file contains definitions for discouraged features. When you
|
||||
discourage something, move it here when that is feasible.
|
||||
*/
|
||||
|
||||
/* Copyright (C) 2003, 2004, 2006, 2008 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
|
||||
* as published by the Free Software Foundation; either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <libguile.h>
|
||||
|
||||
|
||||
#if (SCM_ENABLE_DISCOURAGED == 1)
|
||||
|
||||
SCM
|
||||
scm_short2num (short x)
|
||||
{
|
||||
return scm_from_short (x);
|
||||
}
|
||||
|
||||
SCM
|
||||
scm_ushort2num (unsigned short x)
|
||||
{
|
||||
return scm_from_ushort (x);
|
||||
}
|
||||
|
||||
SCM
|
||||
scm_int2num (int x)
|
||||
{
|
||||
return scm_from_int (x);
|
||||
}
|
||||
|
||||
SCM
|
||||
scm_uint2num (unsigned int x)
|
||||
{
|
||||
return scm_from_uint (x);
|
||||
}
|
||||
|
||||
SCM
|
||||
scm_long2num (long x)
|
||||
{
|
||||
return scm_from_long (x);
|
||||
}
|
||||
|
||||
SCM
|
||||
scm_ulong2num (unsigned long x)
|
||||
{
|
||||
return scm_from_ulong (x);
|
||||
}
|
||||
|
||||
SCM
|
||||
scm_size2num (size_t x)
|
||||
{
|
||||
return scm_from_size_t (x);
|
||||
}
|
||||
|
||||
SCM
|
||||
scm_ptrdiff2num (ptrdiff_t x)
|
||||
{
|
||||
return scm_from_ssize_t (x);
|
||||
}
|
||||
|
||||
short
|
||||
scm_num2short (SCM x, unsigned long pos, const char *s_caller)
|
||||
{
|
||||
return scm_to_short (x);
|
||||
}
|
||||
|
||||
unsigned short
|
||||
scm_num2ushort (SCM x, unsigned long pos, const char *s_caller)
|
||||
{
|
||||
return scm_to_ushort (x);
|
||||
}
|
||||
|
||||
int
|
||||
scm_num2int (SCM x, unsigned long pos, const char *s_caller)
|
||||
{
|
||||
return scm_to_int (x);
|
||||
}
|
||||
|
||||
unsigned int
|
||||
scm_num2uint (SCM x, unsigned long pos, const char *s_caller)
|
||||
{
|
||||
return scm_to_uint (x);
|
||||
}
|
||||
|
||||
long
|
||||
scm_num2long (SCM x, unsigned long pos, const char *s_caller)
|
||||
{
|
||||
return scm_to_long (x);
|
||||
}
|
||||
|
||||
unsigned long
|
||||
scm_num2ulong (SCM x, unsigned long pos, const char *s_caller)
|
||||
{
|
||||
return scm_to_ulong (x);
|
||||
}
|
||||
|
||||
size_t
|
||||
scm_num2size (SCM x, unsigned long pos, const char *s_caller)
|
||||
{
|
||||
return scm_to_size_t (x);
|
||||
}
|
||||
|
||||
ptrdiff_t
|
||||
scm_num2ptrdiff (SCM x, unsigned long pos, const char *s_caller)
|
||||
{
|
||||
return scm_to_ssize_t (x);
|
||||
}
|
||||
|
||||
#if SCM_SIZEOF_LONG_LONG != 0
|
||||
|
||||
SCM
|
||||
scm_long_long2num (long long x)
|
||||
{
|
||||
return scm_from_long_long (x);
|
||||
}
|
||||
|
||||
SCM
|
||||
scm_ulong_long2num (unsigned long long x)
|
||||
{
|
||||
return scm_from_ulong_long (x);
|
||||
}
|
||||
|
||||
long long
|
||||
scm_num2long_long (SCM x, unsigned long pos, const char *s_caller)
|
||||
{
|
||||
return scm_to_long_long (x);
|
||||
}
|
||||
|
||||
unsigned long long
|
||||
scm_num2ulong_long (SCM x, unsigned long pos, const char *s_caller)
|
||||
{
|
||||
return scm_to_ulong_long (x);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
SCM
|
||||
scm_make_real (double x)
|
||||
{
|
||||
return scm_from_double (x);
|
||||
}
|
||||
|
||||
double
|
||||
scm_num2dbl (SCM a, const char *why)
|
||||
{
|
||||
return scm_to_double (a);
|
||||
}
|
||||
|
||||
SCM
|
||||
scm_float2num (float n)
|
||||
{
|
||||
return scm_from_double ((double) n);
|
||||
}
|
||||
|
||||
SCM
|
||||
scm_double2num (double n)
|
||||
{
|
||||
return scm_from_double (n);
|
||||
}
|
||||
|
||||
SCM
|
||||
scm_make_complex (double x, double y)
|
||||
{
|
||||
return scm_c_make_rectangular (x, y);
|
||||
}
|
||||
|
||||
SCM
|
||||
scm_mem2symbol (const char *mem, size_t len)
|
||||
{
|
||||
return scm_from_locale_symboln (mem, len);
|
||||
}
|
||||
|
||||
SCM
|
||||
scm_mem2uninterned_symbol (const char *mem, size_t len)
|
||||
{
|
||||
return scm_make_symbol (scm_from_locale_stringn (mem, len));
|
||||
}
|
||||
|
||||
SCM
|
||||
scm_str2symbol (const char *str)
|
||||
{
|
||||
return scm_from_locale_symbol (str);
|
||||
}
|
||||
|
||||
|
||||
/* This function must only be applied to memory obtained via malloc,
|
||||
since the GC is going to apply `free' to it when the string is
|
||||
dropped.
|
||||
|
||||
Also, s[len] must be `\0', since we promise that strings are
|
||||
null-terminated. Perhaps we could handle non-null-terminated
|
||||
strings by claiming they're shared substrings of a string we just
|
||||
made up. */
|
||||
SCM
|
||||
scm_take_str (char *s, size_t len)
|
||||
{
|
||||
SCM answer = scm_from_locale_stringn (s, len);
|
||||
free (s);
|
||||
return answer;
|
||||
}
|
||||
|
||||
/* `s' must be a malloc'd string. See scm_take_str. */
|
||||
SCM
|
||||
scm_take0str (char *s)
|
||||
{
|
||||
return scm_take_locale_string (s);
|
||||
}
|
||||
|
||||
SCM
|
||||
scm_mem2string (const char *src, size_t len)
|
||||
{
|
||||
return scm_from_locale_stringn (src, len);
|
||||
}
|
||||
|
||||
SCM
|
||||
scm_str2string (const char *src)
|
||||
{
|
||||
return scm_from_locale_string (src);
|
||||
}
|
||||
|
||||
SCM
|
||||
scm_makfrom0str (const char *src)
|
||||
{
|
||||
if (!src) return SCM_BOOL_F;
|
||||
return scm_from_locale_string (src);
|
||||
}
|
||||
|
||||
SCM
|
||||
scm_makfrom0str_opt (const char *src)
|
||||
{
|
||||
return scm_makfrom0str (src);
|
||||
}
|
||||
|
||||
|
||||
SCM
|
||||
scm_allocate_string (size_t len)
|
||||
{
|
||||
return scm_i_make_string (len, NULL);
|
||||
}
|
||||
|
||||
SCM_DEFINE (scm_make_keyword_from_dash_symbol, "make-keyword-from-dash-symbol", 1, 0, 0,
|
||||
(SCM symbol),
|
||||
"Make a keyword object from a @var{symbol} that starts with a dash.")
|
||||
#define FUNC_NAME s_scm_make_keyword_from_dash_symbol
|
||||
{
|
||||
SCM dash_string, non_dash_symbol;
|
||||
|
||||
SCM_ASSERT (scm_is_symbol (symbol)
|
||||
&& (scm_i_symbol_ref (symbol, 0) == '-'),
|
||||
symbol, SCM_ARG1, FUNC_NAME);
|
||||
|
||||
dash_string = scm_symbol_to_string (symbol);
|
||||
non_dash_symbol =
|
||||
scm_string_to_symbol (scm_c_substring (dash_string,
|
||||
1,
|
||||
scm_c_string_length (dash_string)));
|
||||
|
||||
return scm_symbol_to_keyword (non_dash_symbol);
|
||||
}
|
||||
#undef FUNC_NAME
|
||||
|
||||
SCM_DEFINE (scm_keyword_dash_symbol, "keyword-dash-symbol", 1, 0, 0,
|
||||
(SCM keyword),
|
||||
"Return the dash symbol for @var{keyword}.\n"
|
||||
"This is the inverse of @code{make-keyword-from-dash-symbol}.")
|
||||
#define FUNC_NAME s_scm_keyword_dash_symbol
|
||||
{
|
||||
SCM symbol = scm_keyword_to_symbol (keyword);
|
||||
SCM parts = scm_list_2 (scm_from_locale_string ("-"),
|
||||
scm_symbol_to_string (symbol));
|
||||
return scm_string_to_symbol (scm_string_append (parts));
|
||||
}
|
||||
#undef FUNC_NAME
|
||||
|
||||
SCM
|
||||
scm_c_make_keyword (const char *s)
|
||||
{
|
||||
return scm_from_locale_keyword (s);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
scm_i_init_discouraged (void)
|
||||
{
|
||||
#include "libguile/discouraged.x"
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -59,80 +59,6 @@
|
|||
^ (SCM_UNPACK (SCM_BOOL_T) \
|
||||
^ SCM_UNPACK (SCM_BOOL_F))))
|
||||
|
||||
/* scm_to_int, scm_from_int are the official functions to do the job,
|
||||
but there is nothing wrong with using scm_num2int, etc.
|
||||
|
||||
These could be trivially defined via macros, but we leave them as
|
||||
functions since existing code may take their addresses.
|
||||
*/
|
||||
|
||||
SCM_API SCM scm_short2num (short n);
|
||||
SCM_API SCM scm_ushort2num (unsigned short n);
|
||||
SCM_API SCM scm_int2num (int n);
|
||||
SCM_API SCM scm_uint2num (unsigned int n);
|
||||
SCM_API SCM scm_long2num (long n);
|
||||
SCM_API SCM scm_ulong2num (unsigned long n);
|
||||
SCM_API SCM scm_size2num (size_t n);
|
||||
SCM_API SCM scm_ptrdiff2num (scm_t_ptrdiff n);
|
||||
SCM_API short scm_num2short (SCM num, unsigned long int pos,
|
||||
const char *s_caller);
|
||||
SCM_API unsigned short scm_num2ushort (SCM num, unsigned long int pos,
|
||||
const char *s_caller);
|
||||
SCM_API int scm_num2int (SCM num, unsigned long int pos,
|
||||
const char *s_caller);
|
||||
SCM_API unsigned int scm_num2uint (SCM num, unsigned long int pos,
|
||||
const char *s_caller);
|
||||
SCM_API long scm_num2long (SCM num, unsigned long int pos,
|
||||
const char *s_caller);
|
||||
SCM_API unsigned long scm_num2ulong (SCM num, unsigned long int pos,
|
||||
const char *s_caller);
|
||||
SCM_API scm_t_ptrdiff scm_num2ptrdiff (SCM num, unsigned long int pos,
|
||||
const char *s_caller);
|
||||
SCM_API size_t scm_num2size (SCM num, unsigned long int pos,
|
||||
const char *s_caller);
|
||||
#if SCM_SIZEOF_LONG_LONG != 0
|
||||
SCM_API SCM scm_long_long2num (long long sl);
|
||||
SCM_API SCM scm_ulong_long2num (unsigned long long sl);
|
||||
SCM_API long long scm_num2long_long (SCM num, unsigned long int pos,
|
||||
const char *s_caller);
|
||||
SCM_API unsigned long long scm_num2ulong_long (SCM num, unsigned long int pos,
|
||||
const char *s_caller);
|
||||
#endif
|
||||
|
||||
SCM_API SCM scm_make_real (double x);
|
||||
SCM_API double scm_num2dbl (SCM a, const char * why);
|
||||
SCM_API SCM scm_float2num (float n);
|
||||
SCM_API SCM scm_double2num (double n);
|
||||
|
||||
/* The next two are implemented in numbers.c since they use features
|
||||
only available there.
|
||||
*/
|
||||
SCM_API float scm_num2float (SCM num, unsigned long int pos,
|
||||
const char *s_caller);
|
||||
SCM_API double scm_num2double (SCM num, unsigned long int pos,
|
||||
const char *s_caller);
|
||||
|
||||
SCM_API SCM scm_make_complex (double x, double y);
|
||||
|
||||
/* Discouraged because they don't make the encoding explicit.
|
||||
*/
|
||||
|
||||
SCM_API SCM scm_mem2symbol (const char *mem, size_t len);
|
||||
SCM_API SCM scm_mem2uninterned_symbol (const char *mem, size_t len);
|
||||
SCM_API SCM scm_str2symbol (const char *str);
|
||||
|
||||
SCM_API SCM scm_take_str (char *s, size_t len);
|
||||
SCM_API SCM scm_take0str (char *s);
|
||||
SCM_API SCM scm_mem2string (const char *src, size_t len);
|
||||
SCM_API SCM scm_str2string (const char *src);
|
||||
SCM_API SCM scm_makfrom0str (const char *src);
|
||||
SCM_API SCM scm_makfrom0str_opt (const char *src);
|
||||
|
||||
/* Discouraged because scm_c_make_string has a better name and is more
|
||||
consistent with make-string.
|
||||
*/
|
||||
SCM_API SCM scm_allocate_string (size_t len);
|
||||
|
||||
/* Discouraged because scm_is_symbol has a better name,
|
||||
*/
|
||||
#define SCM_SYMBOLP scm_is_symbol
|
||||
|
|
@ -158,17 +84,6 @@ SCM_API SCM scm_allocate_string (size_t len);
|
|||
#define SCM_NULLP(x) (scm_is_null (x))
|
||||
#define SCM_NNULLP(x) (!scm_is_null (x))
|
||||
|
||||
/* Discouraged because they are just strange.
|
||||
*/
|
||||
|
||||
SCM_API SCM scm_make_keyword_from_dash_symbol (SCM symbol);
|
||||
SCM_API SCM scm_keyword_dash_symbol (SCM keyword);
|
||||
|
||||
/* Discouraged because it does not state what encoding S is in.
|
||||
*/
|
||||
|
||||
SCM_API SCM scm_c_make_keyword (const char *s);
|
||||
|
||||
/* Discouraged because the 'internal' and 'thread' moniker is
|
||||
confusing.
|
||||
*/
|
||||
|
|
@ -177,8 +92,6 @@ SCM_API SCM scm_c_make_keyword (const char *s);
|
|||
#define scm_thread_sleep scm_std_sleep
|
||||
#define scm_thread_usleep scm_std_usleep
|
||||
|
||||
SCM_INTERNAL void scm_i_init_discouraged (void);
|
||||
|
||||
#endif /* SCM_ENABLE_DISCOURAGED == 1 */
|
||||
|
||||
#endif /* SCM_DISCOURAGED_H */
|
||||
|
|
|
|||
|
|
@ -562,10 +562,6 @@ scm_i_init_guile (SCM_STACKITEM *base)
|
|||
|
||||
scm_init_goops ();
|
||||
|
||||
#if SCM_ENABLE_DISCOURAGED == 1
|
||||
scm_i_init_discouraged ();
|
||||
#endif
|
||||
|
||||
#if SCM_ENABLE_DEPRECATED == 1
|
||||
scm_i_init_deprecated ();
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -6353,11 +6353,14 @@ scm_from_double (double val)
|
|||
return z;
|
||||
}
|
||||
|
||||
#if SCM_ENABLE_DISCOURAGED == 1
|
||||
#if SCM_ENABLE_DEPRECATED == 1
|
||||
|
||||
float
|
||||
scm_num2float (SCM num, unsigned long int pos, const char *s_caller)
|
||||
{
|
||||
scm_c_issue_deprecation_warning
|
||||
("`scm_num2float' is deprecated. Use scm_to_double instead.");
|
||||
|
||||
if (SCM_BIGP (num))
|
||||
{
|
||||
float res = mpz_get_d (SCM_I_BIG_MPZ (num));
|
||||
|
|
@ -6373,6 +6376,9 @@ scm_num2float (SCM num, unsigned long int pos, const char *s_caller)
|
|||
double
|
||||
scm_num2double (SCM num, unsigned long int pos, const char *s_caller)
|
||||
{
|
||||
scm_c_issue_deprecation_warning
|
||||
("`scm_num2double' is deprecated. Use scm_to_double instead.");
|
||||
|
||||
if (SCM_BIGP (num))
|
||||
{
|
||||
double res = mpz_get_d (SCM_I_BIG_MPZ (num));
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 1999,2000,2001,2003,2004, 2006, 2008 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1999,2000,2001,2003,2004, 2006, 2008, 2010 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
|
||||
|
|
@ -25,8 +25,6 @@
|
|||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
|
||||
#if SCM_ENABLE_DISCOURAGED == 1
|
||||
|
||||
SCM out_of_range_handler (void *data, SCM key, SCM args);
|
||||
SCM call_num2long_long_body (void *data);
|
||||
SCM call_num2ulong_long_body (void *data);
|
||||
|
|
@ -35,37 +33,36 @@ SCM call_num2ulong_long_body (void *data);
|
|||
SCM
|
||||
out_of_range_handler (void *data, SCM key, SCM args)
|
||||
{
|
||||
assert (scm_equal_p (key, scm_str2symbol ("out-of-range")));
|
||||
assert (scm_equal_p (key, scm_from_locale_symbol ("out-of-range")));
|
||||
return SCM_BOOL_T;
|
||||
}
|
||||
|
||||
SCM
|
||||
call_num2long_long_body (void *data)
|
||||
{
|
||||
scm_num2long_long (* (SCM *) data, SCM_ARG1, "call_num2long_long_body");
|
||||
scm_to_long_long (* (SCM *) data);
|
||||
return SCM_BOOL_F;
|
||||
}
|
||||
|
||||
SCM
|
||||
call_num2ulong_long_body (void *data)
|
||||
{
|
||||
scm_num2ulong_long (* (SCM *) data, SCM_ARG1, "call_num2ulong_long_body");
|
||||
scm_to_ulong_long (* (SCM *) data);
|
||||
return SCM_BOOL_F;
|
||||
}
|
||||
|
||||
static void
|
||||
test_long_long ()
|
||||
{
|
||||
#if SCM_SIZEOF_LONG_LONG != 0
|
||||
{
|
||||
SCM n = scm_long_long2num (SCM_I_LLONG_MIN);
|
||||
long long result = scm_num2long_long(n, 0, "main");
|
||||
SCM n = scm_from_long_long (SCM_I_LLONG_MIN);
|
||||
long long result = scm_to_long_long(n);
|
||||
assert (result == SCM_I_LLONG_MIN);
|
||||
}
|
||||
|
||||
/* LLONG_MIN - 1 */
|
||||
{
|
||||
SCM n = scm_difference (scm_long_long2num (SCM_I_LLONG_MIN), scm_from_int (1));
|
||||
SCM n = scm_difference (scm_from_long_long (SCM_I_LLONG_MIN), scm_from_int (1));
|
||||
SCM caught = scm_internal_catch (SCM_BOOL_T, call_num2long_long_body, &n,
|
||||
out_of_range_handler, NULL);
|
||||
assert (scm_is_true (caught));
|
||||
|
|
@ -73,8 +70,8 @@ test_long_long ()
|
|||
|
||||
/* SCM_I_LLONG_MIN + SCM_I_LLONG_MIN/2 */
|
||||
{
|
||||
SCM n = scm_sum (scm_long_long2num (SCM_I_LLONG_MIN),
|
||||
scm_long_long2num (SCM_I_LLONG_MIN / 2));
|
||||
SCM n = scm_sum (scm_from_long_long (SCM_I_LLONG_MIN),
|
||||
scm_from_long_long (SCM_I_LLONG_MIN / 2));
|
||||
SCM caught = scm_internal_catch (SCM_BOOL_T, call_num2long_long_body, &n,
|
||||
out_of_range_handler, NULL);
|
||||
assert (scm_is_true (caught));
|
||||
|
|
@ -82,7 +79,7 @@ test_long_long ()
|
|||
|
||||
/* SCM_I_LLONG_MAX + 1 */
|
||||
{
|
||||
SCM n = scm_sum (scm_long_long2num (SCM_I_LLONG_MAX), scm_from_int (1));
|
||||
SCM n = scm_sum (scm_from_long_long (SCM_I_LLONG_MAX), scm_from_int (1));
|
||||
SCM caught = scm_internal_catch (SCM_BOOL_T, call_num2long_long_body, &n,
|
||||
out_of_range_handler, NULL);
|
||||
assert (scm_is_true (caught));
|
||||
|
|
@ -104,18 +101,14 @@ test_long_long ()
|
|||
out_of_range_handler, NULL);
|
||||
assert (scm_is_true (caught));
|
||||
}
|
||||
|
||||
#endif /* SCM_SIZEOF_LONG_LONG != 0 */
|
||||
}
|
||||
|
||||
static void
|
||||
test_ulong_long ()
|
||||
{
|
||||
#if SCM_SIZEOF_LONG_LONG != 0
|
||||
|
||||
{
|
||||
SCM n = scm_ulong_long2num (SCM_I_ULLONG_MAX);
|
||||
unsigned long long result = scm_num2ulong_long(n, 0, "main");
|
||||
SCM n = scm_from_ulong_long (SCM_I_ULLONG_MAX);
|
||||
unsigned long long result = scm_to_ulong_long(n);
|
||||
assert (result == SCM_I_ULLONG_MAX);
|
||||
}
|
||||
|
||||
|
|
@ -129,7 +122,7 @@ test_ulong_long ()
|
|||
|
||||
/* SCM_I_ULLONG_MAX + 1 */
|
||||
{
|
||||
SCM n = scm_sum (scm_ulong_long2num (SCM_I_ULLONG_MAX), scm_from_int (1));
|
||||
SCM n = scm_sum (scm_from_ulong_long (SCM_I_ULLONG_MAX), scm_from_int (1));
|
||||
SCM caught = scm_internal_catch (SCM_BOOL_T, call_num2ulong_long_body, &n,
|
||||
out_of_range_handler, NULL);
|
||||
assert (scm_is_true (caught));
|
||||
|
|
@ -142,8 +135,6 @@ test_ulong_long ()
|
|||
out_of_range_handler, NULL);
|
||||
assert (scm_is_true (caught));
|
||||
}
|
||||
|
||||
#endif /* SCM_SIZEOF_LONG_LONG != 0 */
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -159,13 +150,3 @@ main (int argc, char *argv[])
|
|||
scm_boot_guile (argc, argv, tests, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else /* SCM_ENABLE_DISCOURAGED == 0 */
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* SCM_ENABLE_DISCOURAGED == 0 */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue