Skip to content

Commit 9770558

Browse files
committed
Added a new Harmony Core custom field loop expression <HARMONYCORE_CUSTOM_FIELD_TYPE_type> that makes it possible to detect specific custom field types.
1 parent cb91cd2 commit 9770558

5 files changed

Lines changed: 41 additions & 1 deletion

File tree

CodeGenEngine/ExpressionEvaluators/ExpressionEvaluator.dbl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,13 @@ namespace CodeGen.Engine
184184
if (template.Context.CurrentTask.Tweaks != ^null) then
185185
mreturn template.Context.CurrentTask.Tweaks.Contains(expression.Value.Value.Replace("TWEAK_",""))
186186
else
187-
mreturn false
187+
mreturn false
188188
end
189189

190+
;;HARMONYCORE_CUSTOM_FIELD_TYPE_
191+
else if ((currentContext == TokenType.FieldLoop) && expression.Value.Value.StartsWith("HARMONYCORE_CUSTOM_FIELD_TYPE_")) then
192+
mreturn evaluateFieldHcCustomType(expression.Value, template, loops)
193+
190194
;;COUNTER_
191195
else if ((expression.Value.Value.StartsWith("COUNTER_1_")
192196
& || expression.Value.Value.StartsWith("COUNTER_2_"))

CodeGenEngine/ExpressionEvaluators/ExpressionEvaluatorFieldLoop.dbl

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2898,6 +2898,33 @@ namespace CodeGen.Engine
28982898

28992899
endmethod
29002900

2901+
private static method evaluateFieldHcCustomType, boolean
2902+
tkn, @Token
2903+
template, @FileNode
2904+
loops, @IEnumerable<LoopNode>
2905+
proc
2906+
lambda doEvaluate(str, field, index)
2907+
begin
2908+
;; Extract the search text from the token
2909+
data searchText, string, tkn.Value.ToUpper().Replace("HARMONYCORE_CUSTOM_FIELD_TYPE_", "")
2910+
2911+
;; Make sure we have search text
2912+
if (String.IsNullOrWhiteSpace(searchText))
2913+
throw new ApplicationException(String.Format("Invalid custom field expression token {0} at line {1} in template {2}", tkn.Value, tkn.StartLineNumber, template.Context.CurrentTemplateBaseName))
2914+
2915+
;Expand it to the full sting that we're looking for
2916+
searchText = String.Format("HARMONYCORE_CUSTOM_FIELD_TYPE={0};",searchText).ToUpper()
2917+
2918+
;Is it there? Return the result
2919+
mreturn ((field.UserText.ToUpper().Contains(searchText)) || (field.LongDescription.ToUpper().Contains(searchText)))
2920+
end
2921+
2922+
;; We get here for any field loop expression <IF CUSTOM_xxx> or <IF_CUSTOM_NOT_xxx> and we are
2923+
;; looking for text to be or not to be present in the current fields user text or long description.
2924+
mreturn EvaluateFieldLoopExpression(tkn, template, loops, doEvaluate)
2925+
2926+
endmethod
2927+
29012928
endclass
29022929

29032930
endnamespace

CodeGenEngine/Tokenizer.dbl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ namespace CodeGen.Engine
8585
private customExpressionValidity, @List<TokenValidity>
8686
private userTokenValidity, @List<TokenValidity>
8787
private loopUtilityTokenValidity, @List<TokenValidity>
88+
private hcFieldExpressionValidity, @List<TokenValidity>
8889

8990
private context, @CodeGenContext
9091
private errorsReported, boolean, false
@@ -111,6 +112,10 @@ namespace CodeGen.Engine
111112
customExpressionValidity.Add(TokenValidity.MethodLoop)
112113
customExpressionValidity.Add(TokenValidity.ParameterLoop)
113114

115+
;;Define where <IF HARMONYCORE_CUSTOM_FIELD_TYPE_ expressions may be used
116+
hcFieldExpressionValidity = new List<TokenValidity>()
117+
hcFieldExpressionValidity.Add(TokenValidity.FieldLoop)
118+
114119
userTokenValidity = new List<TokenValidity>()
115120
userTokenValidity.Add(TokenValidity.Anywhere)
116121

@@ -2050,6 +2055,10 @@ namespace CodeGen.Engine
20502055
begin
20512056
mreturn Tuple.Create(startedTokenIndex, ix, userTokenValidity)
20522057
end
2058+
else if (expstring.StartsWith("HARMONYCORE_CUSTOM_FIELD_TYPE_")) then
2059+
begin
2060+
mreturn Tuple.Create(startedTokenIndex, ix, hcFieldExpressionValidity)
2061+
end
20532062
else if (
20542063
& ( expstring.StartsWith("COUNTER_1_")
20552064
& || expstring.StartsWith("COUNTER_2_"))

Documentation/CodeGen.chm

478 Bytes
Binary file not shown.

Documentation/CodeGen.hsmx

256 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)