From ec7182cfbf6e3c7f3afa89e230fac8d048790467 Mon Sep 17 00:00:00 2001 From: rschoene <rene.schoene@tu-dresden.de> Date: Mon, 30 Jul 2018 16:42:53 +0200 Subject: [PATCH] Add flush option 'api'. It acts similar to tracing=api, i.e., it will generate the flush* methods but without a method body. This allows to use the same code base for both incremental and non-incremental variants. --- src/java/org/jastadd/Configuration.java | 7 ++++--- src/template/flush/Flush.tt | 24 ++++++++++++++---------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/java/org/jastadd/Configuration.java b/src/java/org/jastadd/Configuration.java index b891cee3..1328c61a 100644 --- a/src/java/org/jastadd/Configuration.java +++ b/src/java/org/jastadd/Configuration.java @@ -317,7 +317,8 @@ public class Configuration { .addAcceptedValue("full", "flushing of all computed values (combines attr, coll, and rewrite)") .addDefaultValue("attr", "adds flushing of attributes (syn,inh)") .addDefaultValue("coll", "adds flushing of collection attributes") - .addAcceptedValue("rewrite", "adds flushing of rewrites"); + .addAcceptedValue("rewrite", "adds flushing of rewrites") + .addAcceptedValue("api", "flushing is disabled, but generate methods"); ValueOption packageNameOption = new ValueOption("package", "optional package name for generated classes"); @@ -1155,10 +1156,10 @@ public class Configuration { } /** - * @return {@code true} if --flush=none + * @return {@code true} if not --flush=api */ public boolean flushEnabled() { - return !flushOption.hasValue("none"); + return !flushOption.hasValue("api"); } /** diff --git a/src/template/flush/Flush.tt b/src/template/flush/Flush.tt index 115dde28..4520b2ff 100644 --- a/src/template/flush/Flush.tt +++ b/src/template/flush/Flush.tt @@ -26,10 +26,10 @@ # POSSIBILITY OF SUCH DAMAGE. ASTNode.flushTreeCacheMethod [[ -$if(FlushEnabled) $if(#isASTNodeDecl) /** @apilevel low-level */ public void $ASTNode.flushTreeCache() { +$if(FlushEnabled) flushCache(); if (children != null) { for (int i = 0; i < children.length; i++) { @@ -42,61 +42,65 @@ $if(#isASTNodeDecl) } } } - } $endif + } $endif ]] ASTDecl.flushCacheMethod [[ -$if(FlushEnabled) $if(#isASTNodeDecl) /** @apilevel low-level */ public void #name.flushCache() { +$if(FlushEnabled) flushAttrAndCollectionCache(); - } $endif + } $endif ]] ASTDecl.flushAttrAndCollectionCacheMethod [[ -$if(FlushEnabled) $if(#isASTNodeDecl) /** @apilevel internal */ public void #name.flushAttrAndCollectionCache() { +$if(FlushEnabled) $if(FlushAttr) flushAttrCache(); $endif $if(FlushColl) flushCollectionCache(); $endif - } $endif + } $endif ]] ASTDecl.flushAttrCacheMethod [[ -$if(FlushAttr) /** @apilevel internal */ public void #name.flushAttrCache() { +$if(FlushEnabled) + $if(FlushAttr) $if(!#isASTNodeDecl) super.flushAttrCache(); $endif $FlushAttrCacheBody - } + $endif $endif + } ]] ASTDecl.flushCollectionCacheMethod [[ -$if(FlushColl) /** @apilevel internal */ public void #name.flushCollectionCache() { +$if(FlushEnabled) + $if(FlushColl) $if(!#isASTNodeDecl) super.flushCollectionCache(); $endif #flushCollectionCacheCode - } + $endif $endif + } ]] # TODO: Figure out if this can be removed -- GitLab