[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.7-43-g84f5a8
From: |
Andy Wingo |
Subject: |
[Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.7-43-g84f5a82 |
Date: |
Tue, 22 Jan 2013 11:09:27 +0000 |
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Guile".
http://git.savannah.gnu.org/cgit/guile.git/commit/?id=84f5a8251710c7d2a01590aa083d9dd409a56279
The branch, stable-2.0 has been updated
via 84f5a8251710c7d2a01590aa083d9dd409a56279 (commit)
via f0b6d8c71d2be9d93b48a921a6388fa5acdbd94b (commit)
via 5b70b4e28468b4d1b5411c726200680bc35f27e2 (commit)
from 776491caa2802c990aa0c25415dbbc4b7c368c7b (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 84f5a8251710c7d2a01590aa083d9dd409a56279
Author: Andy Wingo <address@hidden>
Date: Sun Jan 20 20:26:59 2013 +0100
`include' relative paths relative to including file
* module/ice-9/psyntax.scm (include): Like `load', interpret relative
paths as being relative to the file that does the `include'.
* doc/ref/api-evaluation.texi: Update docs.
commit f0b6d8c71d2be9d93b48a921a6388fa5acdbd94b
Author: Andy Wingo <address@hidden>
Date: Tue Jan 22 11:48:47 2013 +0100
libguile examples use scm_c_vector functions instead of SCM_SIMPLE_VECTOR_*
* doc/ref/libguile-concepts.texi (Multi-Threading): Use functions in the
example instead of macros. Performance is really not a concern with
this interface, especially now that scm_car and scm_cdr are inline
functions.
commit 5b70b4e28468b4d1b5411c726200680bc35f27e2
Author: Andy Wingo <address@hidden>
Date: Tue Jan 22 11:35:25 2013 +0100
documentation recommends scm_new_smob instead of SCM_NEWSMOB
* doc/ref/api-smobs.texi (Smobs): Document scm_new_smob and
scm_new_double_smob instead of the SCM_NEWSMOB / SCM_RETURN_NEWSMOB
family of macros.
* doc/ref/libguile-smobs.texi (Creating Smob Instances): Use
scm_new_smob.
-----------------------------------------------------------------------
Summary of changes:
doc/ref/api-evaluation.texi | 3 ++
doc/ref/api-smobs.texi | 26 ++++-----------------
doc/ref/libguile-concepts.texi | 49 +++++++++++++++++++--------------------
doc/ref/libguile-smobs.texi | 22 ++++++++---------
module/ice-9/psyntax.scm | 25 ++++++++++++++------
5 files changed, 59 insertions(+), 66 deletions(-)
diff --git a/doc/ref/api-evaluation.texi b/doc/ref/api-evaluation.texi
index f80d7ad..0ffb501 100644
--- a/doc/ref/api-evaluation.texi
+++ b/doc/ref/api-evaluation.texi
@@ -1161,6 +1161,9 @@ parts of programs together at expansion-time instead of
at run-time.
Open @var{file-name}, at expansion-time, and read the Scheme forms that
it contains, splicing them into the location of the @code{include},
within a @code{begin}.
+
+If @var{file-name} is a relative path, it is searched for relative to
+the path that contains the file that the @code{include} for appears in.
@end deffn
If you are a C programmer, if @code{load} in Scheme is like
diff --git a/doc/ref/api-smobs.texi b/doc/ref/api-smobs.texi
index 6b04236..cb2034c 100644
--- a/doc/ref/api-smobs.texi
+++ b/doc/ref/api-smobs.texi
@@ -1,6 +1,6 @@
@c -*-texinfo-*-
@c This is part of the GNU Guile Reference Manual.
address@hidden Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2009
address@hidden Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2009,
2013
@c Free Software Foundation, Inc.
@c See the file guile.texi for copying conditions.
@@ -129,12 +129,10 @@ Return true iff @var{exp} is a smob instance of the type
indicated by
so it shouldn't contain any side effects.
@end deftypefn
address@hidden {C Macro} void SCM_NEWSMOB (SCM value, scm_t_bits tag, void
*data)
address@hidden {C Macro} void SCM_NEWSMOB2 (SCM value, scm_t_bits tag, void
*data, void *data2)
address@hidden {C Macro} void SCM_NEWSMOB3 (SCM value, scm_t_bits tag, void
*data, void *data2, void *data3)
-Make @var{value} contain a smob instance of the type with tag
address@hidden and smob data @var{data}, @var{data2}, and @var{data3}, as
-appropriate.
address@hidden {C Function} SCM scm_new_smob (scm_t_bits tag, void *data)
address@hidden {C Function} SCM scm_new_double_smob (scm_t_bits tag, void
*data, void *data2, void *data3)
+Make a new smob of the type with tag @var{tag} and smob data @var{data},
address@hidden, and @var{data3}, as appropriate.
The @var{tag} is what has been returned by @code{scm_make_smob_type}.
The initial values @var{data}, @var{data2}, and @var{data3} are of
@@ -145,20 +143,6 @@ by using @code{SCM_UNPACK}.
The flags of the smob instance start out as zero.
@end deftypefn
-Since it is often the case (e.g., in smob constructors) that you will
-create a smob instance and return it, there is also a slightly specialized
-macro for this situation:
-
address@hidden {C Macro} {} SCM_RETURN_NEWSMOB (scm_t_bits tag, void *data)
address@hidden {C Macro} {} SCM_RETURN_NEWSMOB2 (scm_t_bits tag, void *data1,
void *data2)
address@hidden {C Macro} {} SCM_RETURN_NEWSMOB3 (scm_t_bits tag, void *data1,
void *data2, void *data3)
-This macro expands to a block of code that creates a smob instance of
-the type with tag @var{tag} and smob data @var{data}, @var{data2}, and
address@hidden, as with @code{SCM_NEWSMOB}, etc., and causes the
-surrounding function to return that @code{SCM} value. It should be
-the last piece of code in a block.
address@hidden deftypefn
-
@deftypefn {C Macro} scm_t_bits SCM_SMOB_FLAGS (SCM obj)
Return the 16 extra bits of the smob @var{obj}. No meaning is
predefined for these bits, you can use them freely.
diff --git a/doc/ref/libguile-concepts.texi b/doc/ref/libguile-concepts.texi
index 6ebeb63..50c4355 100644
--- a/doc/ref/libguile-concepts.texi
+++ b/doc/ref/libguile-concepts.texi
@@ -1,6 +1,6 @@
@c -*-texinfo-*-
@c This is part of the GNU Guile Reference Manual.
address@hidden Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2005,
2010
address@hidden Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2005,
2010, 2013
@c Free Software Foundation, Inc.
@c See the file guile.texi for copying conditions.
@@ -492,12 +492,12 @@ my_list_to_vector (SCM list)
SCM vector = scm_make_vector (scm_length (list), SCM_UNDEFINED);
size_t len, i;
- len = SCM_SIMPLE_VECTOR_LENGTH (vector);
+ len = scm_c_vector_length (vector);
i = 0;
while (i < len && scm_is_pair (list))
@{
- SCM_SIMPLE_VECTOR_SET (vector, i, SCM_CAR (list));
- list = SCM_CDR (list);
+ scm_c_vector_set_x (vector, i, scm_car (list));
+ list = scm_cdr (list);
i++;
@}
@@ -514,22 +514,23 @@ But there is no guarantee that the list referenced by
@var{list} is not
modified in another thread while the loop iterates over it. Thus, while
copying its elements into the vector, the list might get longer or
shorter. For this reason, the loop must check both that it doesn't
-overrun the vector (@code{SCM_SIMPLE_VECTOR_SET} does no range-checking)
-and that it doesn't overrun the list (@code{SCM_CAR} and @code{SCM_CDR}
-likewise do no type checking).
+overrun the vector and that it doesn't overrun the list. Otherwise,
address@hidden would raise an error if the index is out of
+range, and @code{scm_car} and @code{scm_cdr} would raise an error if the
+value is not a pair.
-It is safe to use @code{SCM_CAR} and @code{SCM_CDR} on the local
+It is safe to use @code{scm_car} and @code{scm_cdr} on the local
variable @var{list} once it is known that the variable contains a pair.
The contents of the pair might change spontaneously, but it will always
stay a valid pair (and a local variable will of course not spontaneously
point to a different Scheme object).
-Likewise, a simple vector such as the one returned by
address@hidden is guaranteed to always stay the same length so
-that it is safe to only use SCM_SIMPLE_VECTOR_LENGTH once and store the
-result. (In the example, @var{vector} is safe anyway since it is a
-fresh object that no other thread can possibly know about until it is
-returned from @code{my_list_to_vector}.)
+Likewise, a vector such as the one returned by @code{scm_make_vector} is
+guaranteed to always stay the same length so that it is safe to only use
+scm_c_vector_length once and store the result. (In the example,
address@hidden is safe anyway since it is a fresh object that no other
+thread can possibly know about until it is returned from
address@hidden)
Of course the behavior of @code{my_list_to_vector} is suboptimal when
@var{list} does indeed get asynchronously lengthened or shortened in
@@ -547,11 +548,11 @@ my_pedantic_list_to_vector (SCM list)
SCM vector = scm_make_vector (scm_length (list), SCM_UNDEFINED);
size_t len, i;
- len = SCM_SIMPLE_VECTOR_LENGTH (vector);
+ len = scm_c_vector_length (vector);
i = 0;
while (i < len)
@{
- SCM_SIMPLE_VECTOR_SET (vector, i, scm_car (list));
+ scm_c_vector_set_x (vector, i, scm_car (list));
list = scm_cdr (list);
i++;
@}
@@ -560,12 +561,10 @@ my_pedantic_list_to_vector (SCM list)
@}
@end example
-This version uses the type-checking and thread-robust functions
address@hidden and @code{scm_cdr} instead of the faster, but less robust
-macros @code{SCM_CAR} and @code{SCM_CDR}. When the list is shortened
-(that is, when @var{list} holds a non-pair), @code{scm_car} will throw
-an error. This might be preferable to just returning a half-initialized
-vector.
+This version relies on the error-checking behavior of @code{scm_car} and
address@hidden When the list is shortened (that is, when @var{list}
+holds a non-pair), @code{scm_car} will throw an error. This might be
+preferable to just returning a half-initialized vector.
The API for accessing vectors and arrays of various kinds from C takes a
slightly different approach to thread-robustness. In order to get at
@@ -581,13 +580,13 @@ see, Guile itself is again only concerned about
robustness, not about
correctness: without proper synchronization, your program will likely
not be correct, but the worst consequence is an error message.
-Real thread-safeness often requires that a critical section of code is
+Real thread-safety often requires that a critical section of code is
executed in a certain restricted manner. A common requirement is that
the code section is not entered a second time when it is already being
executed. Locking a mutex while in that section ensures that no other
thread will start executing it, blocking asyncs ensures that no
-asynchronous code enters the section again from the current thread,
-and the error checking of Guile mutexes guarantees that an error is
+asynchronous code enters the section again from the current thread, and
+the error checking of Guile mutexes guarantees that an error is
signalled when the current thread accidentally reenters the critical
section via recursive function calls.
diff --git a/doc/ref/libguile-smobs.texi b/doc/ref/libguile-smobs.texi
index eb938f0..6f7c0f4 100644
--- a/doc/ref/libguile-smobs.texi
+++ b/doc/ref/libguile-smobs.texi
@@ -1,6 +1,6 @@
@c -*-texinfo-*-
@c This is part of the GNU Guile Reference Manual.
address@hidden Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2005,
2010, 2011
address@hidden Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2005,
2010, 2011, 2013
@c Free Software Foundation, Inc.
@c See the file guile.texi for copying conditions.
@@ -180,7 +180,7 @@ Initialize these fields with @code{SCM_BOOL_F}.
A valid state is one that can be safely acted upon by the @emph{mark}
and @emph{free} functions of your smob type.
@item
-Create the smob using @code{SCM_NEWSMOB}, passing it the initialized
+Create the smob using @code{scm_new_smob}, passing it the initialized
memory block. (This step will always succeed.)
@item
Complete the initialization of the memory block by, for example,
@@ -223,7 +223,7 @@ make_image (SCM name, SCM s_width, SCM s_height)
/* Step 3: Create the smob.
*/
- SCM_NEWSMOB (smob, image_tag, image);
+ smob = scm_new_smob (image_tag, image);
/* Step 4: Finish the initialization.
*/
@@ -254,7 +254,7 @@ After it, @var{smob} contains a valid smob that is properly
initialized
and protected, and in turn can properly protect the Scheme values in its
@var{image} struct.
-But before the smob is completely created, @code{SCM_NEWSMOB} might
+But before the smob is completely created, @code{scm_new_smob} might
cause the garbage collector to run. During this garbage collection, the
@code{SCM} values in the @var{image} struct would be invisible to Guile.
It only gets to know about them via the @code{mark_image} function, but
@@ -530,13 +530,11 @@ four-word cells, which are appropriately called
@dfn{double cells}.
You can use them for @dfn{double smobs} and get two more immediate
words of type @code{scm_t_bits}.
-A double smob is created with @code{SCM_NEWSMOB2} or
address@hidden instead of @code{SCM_NEWSMOB}. Its immediate
-words can be retrieved as @code{scm_t_bits} with
address@hidden and @code{SCM_SMOB_DATA_3} in addition to
address@hidden Unsurprisingly, the words can be set to
address@hidden values with @code{SCM_SET_SMOB_DATA_2} and
address@hidden
+A double smob is created with @code{scm_new_double_smob}. Its immediate
+words can be retrieved as @code{scm_t_bits} with @code{SCM_SMOB_DATA_2}
+and @code{SCM_SMOB_DATA_3} in addition to @code{SCM_SMOB_DATA}.
+Unsurprisingly, the words can be set to @code{scm_t_bits} values with
address@hidden and @code{SCM_SET_SMOB_DATA_3}.
Of course there are also @code{SCM_SMOB_OBJECT_2},
@code{SCM_SMOB_OBJECT_3}, @code{SCM_SET_SMOB_OBJECT_2}, and
@@ -599,7 +597,7 @@ make_image (SCM name, SCM s_width, SCM s_height)
/* Step 3: Create the smob.
*/
- SCM_NEWSMOB (smob, image_tag, image);
+ smob = scm_new_smob (image_tag, image);
/* Step 4: Finish the initialization.
*/
diff --git a/module/ice-9/psyntax.scm b/module/ice-9/psyntax.scm
index 6c264a6..d41a0eb 100644
--- a/module/ice-9/psyntax.scm
+++ b/module/ice-9/psyntax.scm
@@ -1,7 +1,7 @@
;;;; -*-scheme-*-
;;;;
;;;; Copyright (C) 2001, 2003, 2006, 2009, 2010, 2011,
-;;;; 2012 Free Software Foundation, Inc.
+;;;; 2012, 2013 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
@@ -2935,9 +2935,15 @@
(define-syntax include
(lambda (x)
+ (define (absolute-path? path)
+ (string-prefix? "/" path))
+
(define read-file
- (lambda (fn k)
- (let ((p (open-input-file fn)))
+ (lambda (fn dir k)
+ (let ((p (open-input-file
+ (if (absolute-path? fn)
+ fn
+ (in-vicinity dir fn)))))
(let f ((x (read p))
(result '()))
(if (eof-object? x)
@@ -2946,11 +2952,14 @@
(reverse result))
(f (read p)
(cons (datum->syntax k x) result)))))))
- (syntax-case x ()
- ((k filename)
- (let ((fn (syntax->datum #'filename)))
- (with-syntax (((exp ...) (read-file fn #'filename)))
- #'(begin exp ...)))))))
+ (let* ((src (syntax-source x))
+ (file (and src (assq-ref src 'filename)))
+ (dir (and (string? file) (dirname file))))
+ (syntax-case x ()
+ ((k filename)
+ (let ((fn (syntax->datum #'filename)))
+ (with-syntax (((exp ...) (read-file fn dir #'filename)))
+ #'(begin exp ...))))))))
(define-syntax include-from-path
(lambda (x)
hooks/post-receive
--
GNU Guile
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.7-43-g84f5a82,
Andy Wingo <=