[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[augeas-devel] augeas: master - * src/lens.h (struct lens): explain better how we handle recursive lenses



Gitweb:        http://git.fedorahosted.org/git/augeas.git?p=augeas.git;a=commitdiff;h=6dc551f62fcec0b16a6b17b7ac109c72e320430f
Commit:        6dc551f62fcec0b16a6b17b7ac109c72e320430f
Parent:        aa5a167aa623d0be9aebcf845f97bf501c86aa5a
Author:        David Lutterkort <lutter redhat com>
AuthorDate:    Mon Jan 25 17:09:27 2010 -0800
Committer:     David Lutterkort <lutter redhat com>
CommitterDate: Mon Jan 25 18:04:33 2010 -0800

* src/lens.h (struct lens): explain better how we handle recursive lenses

---
 src/lens.h |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/lens.h b/src/lens.h
index 9742c87..889cdd4 100644
--- a/src/lens.h
+++ b/src/lens.h
@@ -65,20 +65,24 @@ enum lens_tag {
  * means that recursive lenses accept context free languages in the string
  * -> tree direction, but only regular tree languages in the tree -> string
  * direction.
+ *
+ * Any lens that uses a recursive lens somehow is marked as recursive
+ * itself.
  */
 struct lens {
     unsigned int              ref;
     enum lens_tag             tag;
     struct info              *info;
-    struct regexp            *ctype;
+    struct regexp            *ctype;  /* NULL when recursive == 1 */
     struct regexp            *atype;
     struct regexp            *ktype;
     struct regexp            *vtype;
+    struct jmt               *jmt;    /* NULL when recursive == 0 */
     unsigned int              value : 1;
     unsigned int              key : 1;
     unsigned int              recursive : 1;
     unsigned int              consumes_value : 1;
-    /* Flag to help avoid cycles in recursive lenses */
+    /* Whether we are inside a recursive lens or outside */
     unsigned int              rec_internal : 1;
     unsigned int              ctype_nullable : 1;
     union {
@@ -102,6 +106,13 @@ struct lens {
              * is necessary to break the cycles inherent in recursive
              * lenses with reference counting. The link through alias is
              * set up in lns_check_rec, and not reference counted.
+             *
+             * Generally, any lens used in the body of a recursive lens is
+             * marked with rec_internal == 1; lenses that use the recursive
+             * lens 'from the outside' are marked with rec_internal ==
+             * 0. In the latter case, we can assign types right away,
+             * except for the ctype, which we never have for any recursive
+             * lens.
              */
             struct lens *alias;
             struct jmt  *jmt;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]