* discouraged.h, discouraged.c: New files.
* deprecated.h (SCM_FALSEP, SCM_NFALSEP, SCM_BOOLP, SCM_EQ_P,
SCM_NEGATE_BOOL, SCM_BOOL, SCM_BOOT_NOT): Promoted from being
deprecated to being discouraged by moving to discouraged.h.
* numbers.h, numbers.c, discouraged.h, discouraged.c
(scm_short2num, scm_ushort2num, scm_int2num, scm_uint2num,
scm_long2num, scm_ulong2num, scm_size2num, scm_ptrdiff2num,
scm_num2short, scm_num2ushort, scm_num2int, scm_num2uint,
scm_num2long, scm_num2ulong, scm_num2size, scm_num2ptrdiff,
scm_long_long2num, scm_ulong_long2num, scm_num2long_long,
scm_num2ulong_long): Discouraged by moving to discouraged.h and
discouraged.c and reimplementing in terms of scm_from_* and
scm_to_*.
* numbers.h, numbers.c: Removed GUILE_DEBUG code.
(scm_i_short2big, scm_i_ushort2big, scm_i_int2big, scm_i_uint2big,
scm_i_size2big, scm_i_ptrdiff2big): Removed.
(scm_i_long2big, scm_i_ulong2big): New, explicit definitions.
* conv-integer.i.c, conv-uinteger.i.c: Use them instead of
explicit code.
2004-08-02 15:57:04 +00:00
|
|
|
/* This file contains definitions for discouraged features. When you
|
|
|
|
|
discourage something, move it here when that is feasible.
|
|
|
|
|
*/
|
|
|
|
|
|
* strings.h, strings.c: (scm_i_string_chars, scm_i_string_length,
scm_i_string_writable_chars, scm_i_string_stop_writing): New, to
replace SCM_I_STRING_CHARS and SCM_I_STRING_LENGTH. Updated all
uses.
(scm_i_make_string, scm_c_make_string): New, to replace
scm_allocate_string. Updated all uses.
(SCM_STRINGP, SCM_STRING_CHARS, SCM_STRING_UCHARS,
SCM_STRING_LENGTH): Deprecated.
(scm_allocate_string, scm_take_str, scm_take0str, scm_mem2string,
scm_str2string, scm_makfrom0str, scm_makfrom0str_opt):
Discouraged. Replaced all uses with scm_from_locale_string or
similar, as appropriate.
(scm_c_string_length, scm_c_string_ref, scm_c_string_set_x,
scm_c_substring, scm_c_substring_shared, scm_c_substring_copy,
scm_substring_shared, scm_substring_copy): New.
* symbols.c, symbols.h (SCM_SYMBOLP, SCM_SYMBOL_FUNC,
SCM_SET_SYMBOL_FUNC, SCM_SYMBOL_PROPS, SCM_SET_SYMBOL_PROPS,
SCM_SYMBOL_HASH, SCM_SYMBOL_INTERNED_P, scm_mem2symbol,
scm_str2symbol, scm_mem2uninterned_symbol): Discouraged.
(SCM_SYMBOL_LENGTH, SCM_SYMBOL_CHARS, scm_c_symbol2str):
Deprecated.
(SCM_MAKE_SYMBOL_TAG, SCM_SET_SYMBOL_LENGTH, SCM_SET_SYMBOL_CHARS,
SCM_PROP_SLOTS, SCM_SET_PROP_SLOTS): Removed.
(scm_is_symbol, scm_from_locale_symbol, scm_from_locale_symboln):
New, to replace scm_str2symbol and scm_mem2symbol, respectively.
Updated all uses.
(scm_gensym): Generate only the number suffix in the buffer, just
string-append the prefix.
2004-08-19 16:49:42 +00:00
|
|
|
/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
|
* discouraged.h, discouraged.c: New files.
* deprecated.h (SCM_FALSEP, SCM_NFALSEP, SCM_BOOLP, SCM_EQ_P,
SCM_NEGATE_BOOL, SCM_BOOL, SCM_BOOT_NOT): Promoted from being
deprecated to being discouraged by moving to discouraged.h.
* numbers.h, numbers.c, discouraged.h, discouraged.c
(scm_short2num, scm_ushort2num, scm_int2num, scm_uint2num,
scm_long2num, scm_ulong2num, scm_size2num, scm_ptrdiff2num,
scm_num2short, scm_num2ushort, scm_num2int, scm_num2uint,
scm_num2long, scm_num2ulong, scm_num2size, scm_num2ptrdiff,
scm_long_long2num, scm_ulong_long2num, scm_num2long_long,
scm_num2ulong_long): Discouraged by moving to discouraged.h and
discouraged.c and reimplementing in terms of scm_from_* and
scm_to_*.
* numbers.h, numbers.c: Removed GUILE_DEBUG code.
(scm_i_short2big, scm_i_ushort2big, scm_i_int2big, scm_i_uint2big,
scm_i_size2big, scm_i_ptrdiff2big): Removed.
(scm_i_long2big, scm_i_ulong2big): New, explicit definitions.
* conv-integer.i.c, conv-uinteger.i.c: Use them instead of
explicit code.
2004-08-02 15:57:04 +00:00
|
|
|
*
|
|
|
|
|
* 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 2.1 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
|
2005-05-23 19:57:22 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* discouraged.h, discouraged.c: New files.
* deprecated.h (SCM_FALSEP, SCM_NFALSEP, SCM_BOOLP, SCM_EQ_P,
SCM_NEGATE_BOOL, SCM_BOOL, SCM_BOOT_NOT): Promoted from being
deprecated to being discouraged by moving to discouraged.h.
* numbers.h, numbers.c, discouraged.h, discouraged.c
(scm_short2num, scm_ushort2num, scm_int2num, scm_uint2num,
scm_long2num, scm_ulong2num, scm_size2num, scm_ptrdiff2num,
scm_num2short, scm_num2ushort, scm_num2int, scm_num2uint,
scm_num2long, scm_num2ulong, scm_num2size, scm_num2ptrdiff,
scm_long_long2num, scm_ulong_long2num, scm_num2long_long,
scm_num2ulong_long): Discouraged by moving to discouraged.h and
discouraged.c and reimplementing in terms of scm_from_* and
scm_to_*.
* numbers.h, numbers.c: Removed GUILE_DEBUG code.
(scm_i_short2big, scm_i_ushort2big, scm_i_int2big, scm_i_uint2big,
scm_i_size2big, scm_i_ptrdiff2big): Removed.
(scm_i_long2big, scm_i_ulong2big): New, explicit definitions.
* conv-integer.i.c, conv-uinteger.i.c: Use them instead of
explicit code.
2004-08-02 15:57:04 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "libguile.h"
|
|
|
|
|
|
|
|
|
|
#if (SCM_ENABLE_DISCOURAGED == 1)
|
|
|
|
|
|
|
|
|
|
#define DEFFROM(t,f1,f2) SCM f1(t x) { return f2 (x); }
|
|
|
|
|
#define DEFTO(t,f1,f2) t f1(SCM x, unsigned long pos, const char *s_caller) \
|
|
|
|
|
{ return f2 (x); }
|
|
|
|
|
|
|
|
|
|
DEFFROM (short, scm_short2num, scm_from_short);
|
|
|
|
|
DEFFROM (unsigned short, scm_ushort2num, scm_from_ushort);
|
|
|
|
|
DEFFROM (int, scm_int2num, scm_from_int);
|
|
|
|
|
DEFFROM (unsigned int, scm_uint2num, scm_from_uint);
|
|
|
|
|
DEFFROM (long, scm_long2num, scm_from_long);
|
|
|
|
|
DEFFROM (unsigned long, scm_ulong2num, scm_from_ulong);
|
|
|
|
|
DEFFROM (size_t, scm_size2num, scm_from_size_t);
|
|
|
|
|
DEFFROM (ptrdiff_t, scm_ptrdiff2num, scm_from_ssize_t);
|
|
|
|
|
|
|
|
|
|
DEFTO (short, scm_num2short, scm_to_short);
|
|
|
|
|
DEFTO (unsigned short, scm_num2ushort, scm_to_ushort);
|
|
|
|
|
DEFTO (int, scm_num2int, scm_to_int);
|
|
|
|
|
DEFTO (unsigned int, scm_num2uint, scm_to_uint);
|
|
|
|
|
DEFTO (long, scm_num2long, scm_to_long);
|
|
|
|
|
DEFTO (unsigned long, scm_num2ulong, scm_to_ulong);
|
|
|
|
|
DEFTO (size_t, scm_num2size, scm_to_size_t);
|
|
|
|
|
DEFTO (ptrdiff_t, scm_num2ptrdiff, scm_to_ssize_t);
|
|
|
|
|
|
|
|
|
|
#if SCM_SIZEOF_LONG_LONG != 0
|
|
|
|
|
DEFFROM (long long, scm_long_long2num, scm_from_long_long);
|
|
|
|
|
DEFFROM (unsigned long long, scm_ulong_long2num, scm_from_ulong_long);
|
|
|
|
|
DEFTO (long long, scm_num2long_long, scm_to_long_long);
|
|
|
|
|
DEFTO (unsigned long long, scm_num2ulong_long, scm_to_ulong_long);
|
|
|
|
|
#endif
|
|
|
|
|
|
(scm_is_rational): New.
(scm_i_short2big, scm_i_int2big, scm_i_uint2big, scm_i_size2big,
scm_i_ptrdiff2big, scm_i_long_long2big, scm_i_ulong_long2big):
Removed prototypes.
(scm_make_real, scm_num2dbl, scm_float2num, scm_double2num):
Discouraged by moving to discouraged.h and discouraged.c.
Replaced all uses with scm_from_double.
(scm_num2float, scm_num2double): Discouraged by moving prototype
to discouraged.h and rewriting in terms of scm_to_double.
Replaced all uses with scm_to_double.
(scm_to_double): Do not implement in terms of scm_num2dbl, use
explicit code.
(scm_from_double): Do not implement in terms of scm_make_real, use
explicit code.
2004-08-03 15:03:35 +00:00
|
|
|
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);
|
|
|
|
|
}
|
* discouraged.h, discouraged.c: New files.
* deprecated.h (SCM_FALSEP, SCM_NFALSEP, SCM_BOOLP, SCM_EQ_P,
SCM_NEGATE_BOOL, SCM_BOOL, SCM_BOOT_NOT): Promoted from being
deprecated to being discouraged by moving to discouraged.h.
* numbers.h, numbers.c, discouraged.h, discouraged.c
(scm_short2num, scm_ushort2num, scm_int2num, scm_uint2num,
scm_long2num, scm_ulong2num, scm_size2num, scm_ptrdiff2num,
scm_num2short, scm_num2ushort, scm_num2int, scm_num2uint,
scm_num2long, scm_num2ulong, scm_num2size, scm_num2ptrdiff,
scm_long_long2num, scm_ulong_long2num, scm_num2long_long,
scm_num2ulong_long): Discouraged by moving to discouraged.h and
discouraged.c and reimplementing in terms of scm_from_* and
scm_to_*.
* numbers.h, numbers.c: Removed GUILE_DEBUG code.
(scm_i_short2big, scm_i_ushort2big, scm_i_int2big, scm_i_uint2big,
scm_i_size2big, scm_i_ptrdiff2big): Removed.
(scm_i_long2big, scm_i_ulong2big): New, explicit definitions.
* conv-integer.i.c, conv-uinteger.i.c: Use them instead of
explicit code.
2004-08-02 15:57:04 +00:00
|
|
|
|
2004-08-03 17:12:14 +00:00
|
|
|
SCM
|
|
|
|
|
scm_make_complex (double x, double y)
|
|
|
|
|
{
|
|
|
|
|
return scm_c_make_rectangular (x, y);
|
|
|
|
|
}
|
|
|
|
|
|
* strings.h, strings.c: (scm_i_string_chars, scm_i_string_length,
scm_i_string_writable_chars, scm_i_string_stop_writing): New, to
replace SCM_I_STRING_CHARS and SCM_I_STRING_LENGTH. Updated all
uses.
(scm_i_make_string, scm_c_make_string): New, to replace
scm_allocate_string. Updated all uses.
(SCM_STRINGP, SCM_STRING_CHARS, SCM_STRING_UCHARS,
SCM_STRING_LENGTH): Deprecated.
(scm_allocate_string, scm_take_str, scm_take0str, scm_mem2string,
scm_str2string, scm_makfrom0str, scm_makfrom0str_opt):
Discouraged. Replaced all uses with scm_from_locale_string or
similar, as appropriate.
(scm_c_string_length, scm_c_string_ref, scm_c_string_set_x,
scm_c_substring, scm_c_substring_shared, scm_c_substring_copy,
scm_substring_shared, scm_substring_copy): New.
* symbols.c, symbols.h (SCM_SYMBOLP, SCM_SYMBOL_FUNC,
SCM_SET_SYMBOL_FUNC, SCM_SYMBOL_PROPS, SCM_SET_SYMBOL_PROPS,
SCM_SYMBOL_HASH, SCM_SYMBOL_INTERNED_P, scm_mem2symbol,
scm_str2symbol, scm_mem2uninterned_symbol): Discouraged.
(SCM_SYMBOL_LENGTH, SCM_SYMBOL_CHARS, scm_c_symbol2str):
Deprecated.
(SCM_MAKE_SYMBOL_TAG, SCM_SET_SYMBOL_LENGTH, SCM_SET_SYMBOL_CHARS,
SCM_PROP_SLOTS, SCM_SET_PROP_SLOTS): Removed.
(scm_is_symbol, scm_from_locale_symbol, scm_from_locale_symboln):
New, to replace scm_str2symbol and scm_mem2symbol, respectively.
Updated all uses.
(scm_gensym): Generate only the number suffix in the buffer, just
string-append the prefix.
2004-08-19 16:49:42 +00:00
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
* keywords.h, keywords.c, deprecated.h, deprecated.c
(SCM_KEYWORDP, SCM_KEYWORDSYM): Deprecated and implemented in
terms of scm_is_keyword and scm_keyword_dash_symbol.
* keywords.h, keywords.c, discouraged.h, discouraged.c
(scm_make_keyword_from_dash_symbol, scm_keyword_dash_symbol,
scm_c_make_keyword): Discouraged.
* keywords.h, keywords.c (scm_symbol_to_keyword,
scm_keyword_to_symbol): Implemented in C.
(scm_is_keyword, scm_from_locale_keyword,
scm_from_locale_keywordn): New.
2004-10-04 17:02:01 +00:00
|
|
|
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_chars(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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
* discouraged.h, discouraged.c: New files.
* deprecated.h (SCM_FALSEP, SCM_NFALSEP, SCM_BOOLP, SCM_EQ_P,
SCM_NEGATE_BOOL, SCM_BOOL, SCM_BOOT_NOT): Promoted from being
deprecated to being discouraged by moving to discouraged.h.
* numbers.h, numbers.c, discouraged.h, discouraged.c
(scm_short2num, scm_ushort2num, scm_int2num, scm_uint2num,
scm_long2num, scm_ulong2num, scm_size2num, scm_ptrdiff2num,
scm_num2short, scm_num2ushort, scm_num2int, scm_num2uint,
scm_num2long, scm_num2ulong, scm_num2size, scm_num2ptrdiff,
scm_long_long2num, scm_ulong_long2num, scm_num2long_long,
scm_num2ulong_long): Discouraged by moving to discouraged.h and
discouraged.c and reimplementing in terms of scm_from_* and
scm_to_*.
* numbers.h, numbers.c: Removed GUILE_DEBUG code.
(scm_i_short2big, scm_i_ushort2big, scm_i_int2big, scm_i_uint2big,
scm_i_size2big, scm_i_ptrdiff2big): Removed.
(scm_i_long2big, scm_i_ulong2big): New, explicit definitions.
* conv-integer.i.c, conv-uinteger.i.c: Use them instead of
explicit code.
2004-08-02 15:57:04 +00:00
|
|
|
void
|
|
|
|
|
scm_i_init_discouraged (void)
|
|
|
|
|
{
|
|
|
|
|
#include "libguile/discouraged.x"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif
|