diff options
author | Mark H Weaver <mhw@netris.org> | 2012-02-14 02:14:10 -0500 |
---|---|---|
committer | Mark H Weaver <mhw@netris.org> | 2012-02-15 11:23:27 -0500 |
commit | 76b9bac565182dd7d0ffe416c3382ac7d59d93ab (patch) | |
tree | 10f39a44fdefc7598828f819b161a59d1231d775 | |
parent | fb3a112122b6406e88adbff2299aacc5230cc8ec (diff) |
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.
-rw-r--r-- | doc/ref/api-debug.texi | 6 | ||||
-rw-r--r-- | libguile/srcprop.c | 18 | ||||
-rw-r--r-- | libguile/srcprop.h | 4 |
3 files changed, 27 insertions, 1 deletions
diff --git a/doc/ref/api-debug.texi b/doc/ref/api-debug.texi index c5fbe5629..18371f0fc 100644 --- a/doc/ref/api-debug.texi +++ b/doc/ref/api-debug.texi @@ -258,6 +258,12 @@ ERROR: Unbound variable: xxx In the latter case, no source properties were stored, so the error 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 named ``positions'' (@pxref{Scheme Read}). This option is switched @emph{on} by default. diff --git a/libguile/srcprop.c b/libguile/srcprop.c index c43acdf95..c632bb0c5 100644 --- a/libguile/srcprop.c +++ b/libguile/srcprop.c @@ -94,6 +94,14 @@ static SCM scm_srcprops_to_alist (SCM obj); 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 srcprops_print (SCM obj, SCM port, scm_print_state *pstate) { @@ -160,6 +168,16 @@ scm_srcprops_to_alist (SCM obj) 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 obj), "Return the source property association list of @var{obj}.") diff --git a/libguile/srcprop.h b/libguile/srcprop.h index 250756dcc..0252e54a1 100644 --- a/libguile/srcprop.h +++ b/libguile/srcprop.h @@ -3,7 +3,8 @@ #ifndef 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 * 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_source_property (SCM obj, SCM key); SCM_API SCM scm_set_source_property_x (SCM obj, SCM key, SCM datum); |