mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-16 08:40:19 +02:00
Relax validation of source property accessors
* libguile/srcprop.c (scm_source_properties, scm_source_property, scm_i_has_source_properties): Relax validation to allow _any_ object to be queried for source properties.
This commit is contained in:
parent
bbd1281ae5
commit
fb3a112122
1 changed files with 51 additions and 39 deletions
|
@ -1,4 +1,5 @@
|
||||||
/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002, 2006, 2008, 2009, 2010, 2011 Free Software Foundation
|
/* Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2006,
|
||||||
|
* 2008, 2009, 2010, 2011, 2012 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
|
||||||
|
@ -163,9 +164,12 @@ SCM_DEFINE (scm_source_properties, "source-properties", 1, 0, 0,
|
||||||
(SCM obj),
|
(SCM obj),
|
||||||
"Return the source property association list of @var{obj}.")
|
"Return the source property association list of @var{obj}.")
|
||||||
#define FUNC_NAME s_scm_source_properties
|
#define FUNC_NAME s_scm_source_properties
|
||||||
|
{
|
||||||
|
if (SCM_IMP (obj))
|
||||||
|
return SCM_EOL;
|
||||||
|
else
|
||||||
{
|
{
|
||||||
SCM p;
|
SCM p;
|
||||||
SCM_VALIDATE_NIM (1, obj);
|
|
||||||
|
|
||||||
scm_i_pthread_mutex_lock (&source_lock);
|
scm_i_pthread_mutex_lock (&source_lock);
|
||||||
p = scm_hashq_ref (scm_source_whash, obj, SCM_EOL);
|
p = scm_hashq_ref (scm_source_whash, obj, SCM_EOL);
|
||||||
|
@ -177,6 +181,7 @@ SCM_DEFINE (scm_source_properties, "source-properties", 1, 0, 0,
|
||||||
/* list from set-source-properties!, or SCM_EOL for not found */
|
/* list from set-source-properties!, or SCM_EOL for not found */
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#undef FUNC_NAME
|
#undef FUNC_NAME
|
||||||
|
|
||||||
/* Perhaps this procedure should look through an alist
|
/* Perhaps this procedure should look through an alist
|
||||||
|
@ -200,17 +205,20 @@ SCM_DEFINE (scm_set_source_properties_x, "set-source-properties!", 2, 0, 0,
|
||||||
int
|
int
|
||||||
scm_i_has_source_properties (SCM obj)
|
scm_i_has_source_properties (SCM obj)
|
||||||
#define FUNC_NAME "%set-source-properties"
|
#define FUNC_NAME "%set-source-properties"
|
||||||
|
{
|
||||||
|
if (SCM_IMP (obj))
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
SCM_VALIDATE_NIM (1, obj);
|
|
||||||
|
|
||||||
scm_i_pthread_mutex_lock (&source_lock);
|
scm_i_pthread_mutex_lock (&source_lock);
|
||||||
ret = scm_is_true (scm_hashq_ref (scm_source_whash, obj, SCM_BOOL_F));
|
ret = scm_is_true (scm_hashq_ref (scm_source_whash, obj, SCM_BOOL_F));
|
||||||
scm_i_pthread_mutex_unlock (&source_lock);
|
scm_i_pthread_mutex_unlock (&source_lock);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#undef FUNC_NAME
|
#undef FUNC_NAME
|
||||||
|
|
||||||
|
|
||||||
|
@ -236,9 +244,12 @@ SCM_DEFINE (scm_source_property, "source-property", 2, 0, 0,
|
||||||
"Return the source property specified by @var{key} from\n"
|
"Return the source property specified by @var{key} from\n"
|
||||||
"@var{obj}'s source property list.")
|
"@var{obj}'s source property list.")
|
||||||
#define FUNC_NAME s_scm_source_property
|
#define FUNC_NAME s_scm_source_property
|
||||||
|
{
|
||||||
|
if (SCM_IMP (obj))
|
||||||
|
return SCM_BOOL_F;
|
||||||
|
else
|
||||||
{
|
{
|
||||||
SCM p;
|
SCM p;
|
||||||
SCM_VALIDATE_NIM (1, obj);
|
|
||||||
|
|
||||||
scm_i_pthread_mutex_lock (&source_lock);
|
scm_i_pthread_mutex_lock (&source_lock);
|
||||||
p = scm_hashq_ref (scm_source_whash, obj, SCM_EOL);
|
p = scm_hashq_ref (scm_source_whash, obj, SCM_EOL);
|
||||||
|
@ -261,6 +272,7 @@ SCM_DEFINE (scm_source_property, "source-property", 2, 0, 0,
|
||||||
}
|
}
|
||||||
return SCM_UNBNDP (p) ? SCM_BOOL_F : p;
|
return SCM_UNBNDP (p) ? SCM_BOOL_F : p;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#undef FUNC_NAME
|
#undef FUNC_NAME
|
||||||
|
|
||||||
SCM_DEFINE (scm_set_source_property_x, "set-source-property!", 3, 0, 0,
|
SCM_DEFINE (scm_set_source_property_x, "set-source-property!", 3, 0, 0,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue