1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-16 08:40:19 +02:00

deprecate scm_whash API

* libguile/deprecated.h:
* libguile/deprecated.c (scm_whash_get_handle, SCM_WHASHFOUNDP)
  (SCM_WHASHREF, SCM_WHASHSET, scm_whash_create_handle)
  (scm_whash_lookup, scm_whash_insert): Deprecate this API.

* libguile/srcprop.c:
* libguile/srcprop.h:
* libguile/read.c (scm_read_sexp): Use the hashq API instead of the
  whash API.
This commit is contained in:
Andy Wingo 2011-05-01 20:30:54 +02:00
parent ecc9d1b547
commit d1c4720ca3
5 changed files with 132 additions and 82 deletions

View file

@ -2499,6 +2499,70 @@ SCM_DEFINE (scm_primitive_property_del_x, "primitive-property-del!", 2, 0, 0,
SCM
scm_whash_get_handle (SCM whash, SCM key)
{
scm_c_issue_deprecation_warning
("The `scm_whash' API is deprecated. Use the `scm_hashq' API instead.");
return scm_hashq_get_handle (whash, key);
}
int
SCM_WHASHFOUNDP (SCM h)
{
scm_c_issue_deprecation_warning
("The `scm_whash' API is deprecated. Use the `scm_hashq' API instead.");
return scm_is_true (h);
}
SCM
SCM_WHASHREF (SCM whash, SCM handle)
{
scm_c_issue_deprecation_warning
("The `scm_whash' API is deprecated. Use the `scm_hashq' API instead.");
return SCM_CDR (handle);
}
void
SCM_WHASHSET (SCM whash, SCM handle, SCM obj)
{
scm_c_issue_deprecation_warning
("The `scm_whash' API is deprecated. Use the `scm_hashq' API instead.");
SCM_SETCDR (handle, obj);
}
SCM
scm_whash_create_handle (SCM whash, SCM key)
{
scm_c_issue_deprecation_warning
("The `scm_whash' API is deprecated. Use the `scm_hashq' API instead.");
return scm_hashq_create_handle_x (whash, key, SCM_UNSPECIFIED);
}
SCM
scm_whash_lookup (SCM whash, SCM obj)
{
scm_c_issue_deprecation_warning
("The `scm_whash' API is deprecated. Use the `scm_hashq' API instead.");
return scm_hashq_ref (whash, obj, SCM_BOOL_F);
}
void
scm_whash_insert (SCM whash, SCM key, SCM obj)
{
scm_c_issue_deprecation_warning
("The `scm_whash' API is deprecated. Use the `scm_hashq' API instead.");
scm_hashq_set_x (whash, key, obj);
}
void void
scm_i_init_deprecated () scm_i_init_deprecated ()

View file

@ -750,6 +750,24 @@ SCM_DEPRECATED SCM scm_primitive_property_ref (SCM prop, SCM obj);
SCM_DEPRECATED SCM scm_primitive_property_set_x (SCM prop, SCM obj, SCM val); SCM_DEPRECATED SCM scm_primitive_property_set_x (SCM prop, SCM obj, SCM val);
SCM_DEPRECATED SCM scm_primitive_property_del_x (SCM prop, SCM obj); SCM_DEPRECATED SCM scm_primitive_property_del_x (SCM prop, SCM obj);
/* {The old whash table interface}
* Deprecated, as the hash table interface is sufficient, and accessing
* handles of weak hash tables is no longer supported.
*/
#define scm_whash_handle SCM
SCM_DEPRECATED SCM scm_whash_get_handle (SCM whash, SCM key);
SCM_DEPRECATED int SCM_WHASHFOUNDP (SCM h);
SCM_DEPRECATED SCM SCM_WHASHREF (SCM whash, SCM handle);
SCM_DEPRECATED void SCM_WHASHSET (SCM whash, SCM handle, SCM obj);
SCM_DEPRECATED SCM scm_whash_create_handle (SCM whash, SCM key);
SCM_DEPRECATED SCM scm_whash_lookup (SCM whash, SCM obj);
SCM_DEPRECATED void scm_whash_insert (SCM whash, SCM key, SCM obj);
void scm_i_init_deprecated (void); void scm_i_init_deprecated (void);

View file

@ -442,14 +442,14 @@ scm_read_sexp (scm_t_wchar chr, SCM port)
exit: exit:
if (SCM_RECORD_POSITIONS_P) if (SCM_RECORD_POSITIONS_P)
scm_whash_insert (scm_source_whash, scm_hashq_set_x (scm_source_whash,
ans, ans,
scm_make_srcprops (line, column, scm_make_srcprops (line, column,
SCM_FILENAME (port), SCM_FILENAME (port),
SCM_COPY_SOURCE_P SCM_COPY_SOURCE_P
? ans2 ? ans2
: SCM_UNDEFINED, : SCM_UNDEFINED,
SCM_EOL)); SCM_EOL));
return ans; return ans;
} }
#undef FUNC_NAME #undef FUNC_NAME
@ -805,15 +805,15 @@ scm_read_quote (int chr, SCM port)
p = scm_cons2 (p, scm_read_expression (port), SCM_EOL); p = scm_cons2 (p, scm_read_expression (port), SCM_EOL);
if (SCM_RECORD_POSITIONS_P) if (SCM_RECORD_POSITIONS_P)
scm_whash_insert (scm_source_whash, p, scm_hashq_set_x (scm_source_whash, p,
scm_make_srcprops (line, column, scm_make_srcprops (line, column,
SCM_FILENAME (port), SCM_FILENAME (port),
SCM_COPY_SOURCE_P SCM_COPY_SOURCE_P
? (scm_cons2 (SCM_CAR (p), ? (scm_cons2 (SCM_CAR (p),
SCM_CAR (SCM_CDR (p)), SCM_CAR (SCM_CDR (p)),
SCM_EOL)) SCM_EOL))
: SCM_UNDEFINED, : SCM_UNDEFINED,
SCM_EOL)); SCM_EOL));
return p; return p;
@ -864,15 +864,15 @@ scm_read_syntax (int chr, SCM port)
p = scm_cons2 (p, scm_read_expression (port), SCM_EOL); p = scm_cons2 (p, scm_read_expression (port), SCM_EOL);
if (SCM_RECORD_POSITIONS_P) if (SCM_RECORD_POSITIONS_P)
scm_whash_insert (scm_source_whash, p, scm_hashq_set_x (scm_source_whash, p,
scm_make_srcprops (line, column, scm_make_srcprops (line, column,
SCM_FILENAME (port), SCM_FILENAME (port),
SCM_COPY_SOURCE_P SCM_COPY_SOURCE_P
? (scm_cons2 (SCM_CAR (p), ? (scm_cons2 (SCM_CAR (p),
SCM_CAR (SCM_CDR (p)), SCM_CAR (SCM_CDR (p)),
SCM_EOL)) SCM_EOL))
: SCM_UNDEFINED, : SCM_UNDEFINED,
SCM_EOL)); SCM_EOL));
return p; return p;
@ -1561,7 +1561,7 @@ recsexpr (SCM obj, long line, int column, SCM filename)
/* If this sexpr is visible in the read:sharp source, we want to /* If this sexpr is visible in the read:sharp source, we want to
keep that information, so only record non-constant cons cells keep that information, so only record non-constant cons cells
which haven't previously been read by the reader. */ which haven't previously been read by the reader. */
if (scm_is_false (scm_whash_lookup (scm_source_whash, obj))) if (scm_is_false (scm_hashq_ref (scm_source_whash, obj, SCM_BOOL_F)))
{ {
if (SCM_COPY_SOURCE_P) if (SCM_COPY_SOURCE_P)
{ {
@ -1585,13 +1585,13 @@ recsexpr (SCM obj, long line, int column, SCM filename)
recsexpr (SCM_CAR (tmp), line, column, filename); recsexpr (SCM_CAR (tmp), line, column, filename);
copy = SCM_UNDEFINED; copy = SCM_UNDEFINED;
} }
scm_whash_insert (scm_source_whash, scm_hashq_set_x (scm_source_whash,
obj, obj,
scm_make_srcprops (line, scm_make_srcprops (line,
column, column,
filename, filename,
copy, copy,
SCM_EOL)); SCM_EOL));
} }
return obj; return obj;
} }

View file

@ -1,4 +1,4 @@
/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002, 2006, 2008, 2009, 2010 Free Software Foundation /* Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002, 2006, 2008, 2009, 2010, 2011 Free Software Foundation
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License
@ -180,10 +180,8 @@ SCM_DEFINE (scm_set_source_properties_x, "set-source-properties!", 2, 0, 0,
"list for @var{obj}.") "list for @var{obj}.")
#define FUNC_NAME s_scm_set_source_properties_x #define FUNC_NAME s_scm_set_source_properties_x
{ {
SCM handle;
SCM_VALIDATE_NIM (1, obj); SCM_VALIDATE_NIM (1, obj);
handle = scm_hashq_create_handle_x (scm_source_whash, obj, alist); scm_hashq_set_x (scm_source_whash, obj, alist);
SCM_SETCDR (handle, alist);
return alist; return alist;
} }
#undef FUNC_NAME #undef FUNC_NAME
@ -222,49 +220,43 @@ SCM_DEFINE (scm_set_source_property_x, "set-source-property!", 3, 0, 0,
"@var{key} to @var{datum}. Normally, the key will be a symbol.") "@var{key} to @var{datum}. Normally, the key will be a symbol.")
#define FUNC_NAME s_scm_set_source_property_x #define FUNC_NAME s_scm_set_source_property_x
{ {
scm_whash_handle h;
SCM p; SCM p;
SCM_VALIDATE_NIM (1, obj); SCM_VALIDATE_NIM (1, obj);
h = scm_whash_get_handle (scm_source_whash, obj); p = scm_hashq_ref (scm_source_whash, obj, SCM_EOL);
if (SCM_WHASHFOUNDP (h))
p = SCM_WHASHREF (scm_source_whash, h);
else
{
h = scm_whash_create_handle (scm_source_whash, obj);
p = SCM_EOL;
}
if (scm_is_eq (scm_sym_line, key)) if (scm_is_eq (scm_sym_line, key))
{ {
if (SRCPROPSP (p)) if (SRCPROPSP (p))
SETSRCPROPLINE (p, scm_to_int (datum)); SETSRCPROPLINE (p, scm_to_int (datum));
else else
SCM_WHASHSET (scm_source_whash, h, scm_hashq_set_x (scm_source_whash, obj,
scm_make_srcprops (scm_to_int (datum), 0, scm_make_srcprops (scm_to_int (datum), 0,
SCM_UNDEFINED, SCM_UNDEFINED, p)); SCM_UNDEFINED, SCM_UNDEFINED, p));
} }
else if (scm_is_eq (scm_sym_column, key)) else if (scm_is_eq (scm_sym_column, key))
{ {
if (SRCPROPSP (p)) if (SRCPROPSP (p))
SETSRCPROPCOL (p, scm_to_int (datum)); SETSRCPROPCOL (p, scm_to_int (datum));
else else
SCM_WHASHSET (scm_source_whash, h, scm_hashq_set_x (scm_source_whash, obj,
scm_make_srcprops (0, scm_to_int (datum), scm_make_srcprops (0, scm_to_int (datum),
SCM_UNDEFINED, SCM_UNDEFINED, p)); SCM_UNDEFINED, SCM_UNDEFINED, p));
} }
else if (scm_is_eq (scm_sym_copy, key)) else if (scm_is_eq (scm_sym_copy, key))
{ {
if (SRCPROPSP (p)) if (SRCPROPSP (p))
SETSRCPROPCOPY (p, datum); SETSRCPROPCOPY (p, datum);
else else
SCM_WHASHSET (scm_source_whash, h, scm_make_srcprops (0, 0, SCM_UNDEFINED, datum, p)); scm_hashq_set_x (scm_source_whash, obj,
scm_make_srcprops (0, 0, SCM_UNDEFINED, datum, p));
} }
else else
{ {
if (SRCPROPSP (p)) if (SRCPROPSP (p))
SETSRCPROPALIST (p, scm_acons (key, datum, SRCPROPALIST (p))); SETSRCPROPALIST (p, scm_acons (key, datum, SRCPROPALIST (p)));
else else
SCM_WHASHSET (scm_source_whash, h, scm_acons (key, datum, p)); scm_hashq_set_x (scm_source_whash, obj,
scm_acons (key, datum, p));
} }
return SCM_UNSPECIFIED; return SCM_UNSPECIFIED;
} }
@ -281,9 +273,9 @@ SCM_DEFINE (scm_cons_source, "cons-source", 3, 0, 0,
SCM p, z; SCM p, z;
z = scm_cons (x, y); z = scm_cons (x, y);
/* Copy source properties possibly associated with xorig. */ /* Copy source properties possibly associated with xorig. */
p = scm_whash_lookup (scm_source_whash, xorig); p = scm_hashq_ref (scm_source_whash, xorig, SCM_BOOL_F);
if (scm_is_true (p)) if (scm_is_true (p))
scm_whash_insert (scm_source_whash, z, p); scm_hashq_set_x (scm_source_whash, z, p);
return z; return z;
} }
#undef FUNC_NAME #undef FUNC_NAME

View file

@ -3,7 +3,7 @@
#ifndef SCM_SRCPROP_H #ifndef SCM_SRCPROP_H
#define SCM_SRCPROP_H #define SCM_SRCPROP_H
/* Copyright (C) 1995,1996,2000,2001, 2006, 2008, 2009, 2010 Free Software Foundation, Inc. /* Copyright (C) 1995,1996,2000,2001, 2006, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License
@ -27,30 +27,6 @@
/* {The old whash table interface}
* *fixme* This is a temporary solution until weak hash table access
* has been optimized for speed (which is quite necessary, if they are
* used for recording of source code positions...)
*/
#define scm_whash_handle SCM
#define scm_whash_get_handle(whash, key) \
scm_hashq_get_handle ((whash), (key))
#define SCM_WHASHFOUNDP(h) (scm_is_true (h))
#define SCM_WHASHREF(whash, handle) SCM_CDR (handle)
#define SCM_WHASHSET(whash, handle, obj) SCM_SETCDR (handle, obj)
#define scm_whash_create_handle(whash, key) \
scm_hashq_create_handle_x ((whash), (key), SCM_UNSPECIFIED)
#define scm_whash_lookup(whash, obj) \
scm_hashq_ref ((whash), (obj), SCM_BOOL_F)
#define scm_whash_insert(whash, key, obj) \
do { \
register SCM w = (whash); \
SCM_WHASHSET (w, scm_whash_create_handle (w, key), obj); \
} while (0)
/* {Source properties} /* {Source properties}
*/ */
#define SCM_PROCTRACEP(x) (scm_is_true (scm_procedure_property (x, scm_sym_trace))) #define SCM_PROCTRACEP(x) (scm_is_true (scm_procedure_property (x, scm_sym_trace)))