mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-15 16:20:17 +02:00
Add 'supports-source-properties?' predicate
* libguile/srcprop.c (scm_supports_source_properties_p): New procedure. (supports_source_props): New static C function. * libguile/srcprop.h (scm_supports_source_properties_p): Add prototype. * doc/ref/api-debug.texi (Source Properties): Add documentation.
This commit is contained in:
parent
fb3a112122
commit
76b9bac565
3 changed files with 27 additions and 1 deletions
|
@ -258,6 +258,12 @@ ERROR: Unbound variable: xxx
|
||||||
In the latter case, no source properties were stored, so the error
|
In the latter case, no source properties were stored, so the error
|
||||||
doesn't have any source information.
|
doesn't have any source information.
|
||||||
|
|
||||||
|
@deffn {Scheme Procedure} supports-source-properties? obj
|
||||||
|
@deffnx {C Function} scm_supports_source_properties_p (obj)
|
||||||
|
Return #t if source properties can be associated with @var{obj},
|
||||||
|
otherwise return #f.
|
||||||
|
@end deffn
|
||||||
|
|
||||||
The recording of source properties is controlled by the read option
|
The recording of source properties is controlled by the read option
|
||||||
named ``positions'' (@pxref{Scheme Read}). This option is switched
|
named ``positions'' (@pxref{Scheme Read}). This option is switched
|
||||||
@emph{on} by default.
|
@emph{on} by default.
|
||||||
|
|
|
@ -94,6 +94,14 @@ static SCM scm_srcprops_to_alist (SCM obj);
|
||||||
|
|
||||||
scm_t_bits scm_tc16_srcprops;
|
scm_t_bits scm_tc16_srcprops;
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
supports_source_props (SCM obj)
|
||||||
|
{
|
||||||
|
return SCM_NIMP (obj) && !scm_is_symbol (obj) && !scm_is_keyword (obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
srcprops_print (SCM obj, SCM port, scm_print_state *pstate)
|
srcprops_print (SCM obj, SCM port, scm_print_state *pstate)
|
||||||
{
|
{
|
||||||
|
@ -160,6 +168,16 @@ scm_srcprops_to_alist (SCM obj)
|
||||||
return alist;
|
return alist;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SCM_DEFINE (scm_supports_source_properties_p, "supports-source-properties?", 1, 0, 0,
|
||||||
|
(SCM obj),
|
||||||
|
"Return #t if @var{obj} supports adding source properties,\n"
|
||||||
|
"otherwise return #f.")
|
||||||
|
#define FUNC_NAME s_scm_supports_source_properties_p
|
||||||
|
{
|
||||||
|
return scm_from_bool (supports_source_props (obj));
|
||||||
|
}
|
||||||
|
#undef FUNC_NAME
|
||||||
|
|
||||||
SCM_DEFINE (scm_source_properties, "source-properties", 1, 0, 0,
|
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}.")
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
#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, 2011 Free Software Foundation, Inc.
|
/* Copyright (C) 1995, 1996, 2000, 2001, 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
|
||||||
|
@ -41,6 +42,7 @@ SCM_API SCM scm_sym_column;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
SCM_API SCM scm_supports_source_properties_p (SCM obj);
|
||||||
SCM_API SCM scm_make_srcprops (long line, int col, SCM fname, SCM copy, SCM plist);
|
SCM_API SCM scm_make_srcprops (long line, int col, SCM fname, SCM copy, SCM plist);
|
||||||
SCM_API SCM scm_source_property (SCM obj, SCM key);
|
SCM_API SCM scm_source_property (SCM obj, SCM key);
|
||||||
SCM_API SCM scm_set_source_property_x (SCM obj, SCM key, SCM datum);
|
SCM_API SCM scm_set_source_property_x (SCM obj, SCM key, SCM datum);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue