Skip to content

Commit

Permalink
Improved support for using the @NOCODEGEN structure decoration when p…
Browse files Browse the repository at this point in the history
…rocessing all structures (-s *).
  • Loading branch information
SteveIves committed Jul 19, 2023
1 parent 2a32cec commit 0a51ef9
Show file tree
Hide file tree
Showing 134 changed files with 220 additions and 173 deletions.
51 changes: 30 additions & 21 deletions CodeGenEngine/CodeGenerator.dbl
Expand Up @@ -6,7 +6,7 @@
;;
;; Description: In-process callable interface to CodeGen
;;
;; Date:
;; Date:
;;
;; Author: Steve Ives, Synergex Professional Services Group
;; http://www.synergex.com
Expand Down Expand Up @@ -206,11 +206,11 @@ namespace CodeGen.Engine
if (File.Exists(extensionsAssembly)) then
begin
;;Report the extensions assembly we're going to use
context.Taskset.DevDebugLog(String.Format("Found Harmony Core extensions assembly {0}",extensionsAssembly))
context.Taskset.DevDebugLog(String.Format("Found Harmony Core extensions assembly {0}",extensionsAssembly))

;;Open the assembly and load extensions
if (!loadExtensionsFromAssembly(extensionsAssembly,context))
context.Taskset.DevDebugLog("No extension classes were found in the extensions assembly!")
context.Taskset.DevDebugLog("No extension classes were found in the extensions assembly!")
end
else
begin
Expand Down Expand Up @@ -290,7 +290,7 @@ namespace CodeGen.Engine
begin
;;Open the assembly and load extensions
if (!loadExtensionsFromAssembly(extensionsAssembly,context))
errStatus = context.Taskset.ErrorLog("No extensions were found in the proforma extensions assembly!")
errStatus = context.Taskset.ErrorLog("No extensions were found in the proforma extensions assembly!")
end

mreturn !errStatus
Expand Down Expand Up @@ -446,7 +446,7 @@ namespace CodeGen.Engine
end

;;--------------------------------------------------------------------------------------
;;
;;

if (!context.CurrentTask.MethodCatalogStructureMode)
begin
Expand All @@ -459,7 +459,7 @@ namespace CodeGen.Engine
begin
mreturn context.CurrentTask.ErrorLog(String.Format("Interface {0} was not found in the method catalog!",context.CurrentTask.MethodCatalogInterface))
end

;;And remove all other interfaces
context.MethodCatalog.Interfaces.RemoveAll(lambda(intf) {intf!=selectedInterface})
context.MethodCatalogCustomized = true
Expand All @@ -480,7 +480,7 @@ namespace CodeGen.Engine
mreturn context.CurrentTask.ErrorLog(String.Format("Interface {0} was not found in the method catalog!",context.CurrentTask.MethodCatalogInterface))
end
end

if (context.MethodCatalog.Structures.Count == 0)
begin
mreturn context.CurrentTask.ErrorLog("Method catalog export file contains no structures!")
Expand Down Expand Up @@ -766,7 +766,7 @@ namespace CodeGen.Engine
end
end
end

endmethod

;;; <summary>
Expand Down Expand Up @@ -889,6 +889,7 @@ namespace CodeGen.Engine
proc

data errStatus = false
data structureWildcard = false

;;-------------------------------------------------------------------------
;;Echo command line?
Expand Down Expand Up @@ -1372,7 +1373,7 @@ namespace CodeGen.Engine
else
begin
context.SelectionWindowScript = fileSpec
context.CurrentTask.DebugLog(String.Format("Selection window processing enabled from file {0}",fileSpec))
context.CurrentTask.DebugLog(String.Format("Selection window processing enabled from file {0}",fileSpec))
end
end
end
Expand All @@ -1394,6 +1395,7 @@ namespace CodeGen.Engine
if (context.CurrentTask.Structures[0]=="*") then
begin
;;Process all structures
structureWildcard = true
try
begin
context.Structures = new RpsStructureCollection(RpsLoadMode.Load,context.CurrentTask.UseAlternateFieldNames)
Expand All @@ -1410,7 +1412,7 @@ namespace CodeGen.Engine
begin
;;Process specified structures
data ix, int
for ix from 0 thru context.CurrentTask.Structures.Count-1
for ix from 0 thru context.CurrentTask.Structures.Count-1
begin
try
begin
Expand Down Expand Up @@ -1439,6 +1441,7 @@ namespace CodeGen.Engine
if (context.Taskset.Structures[0]=="*") then
begin
;;Process all structures
structureWildcard = true
try
begin
context.Structures = new RpsStructureCollection(RpsLoadMode.Load,context.CurrentTask.UseAlternateFieldNames)
Expand All @@ -1455,7 +1458,7 @@ namespace CodeGen.Engine
begin
;;Process specified structures
data ix, int
for ix from 0 thru context.Taskset.Structures.Count-1
for ix from 0 thru context.Taskset.Structures.Count-1
begin
try
begin
Expand Down Expand Up @@ -1494,7 +1497,7 @@ namespace CodeGen.Engine
;;Are we being asked to process a subset of the fields in a structure?

if (!errStatus && (!String.IsNullOrWhiteSpace(context.CurrentTask.Subset)))
context.CurrentTask.DevDebugLog("Subset processing was enabled for subset " + context.CurrentTask.Subset)
context.CurrentTask.DevDebugLog("Subset processing was enabled for subset " + context.CurrentTask.Subset)

;;-------------------------------------------------------------------------
;;Are we being asked to create a subset from a list of field names?
Expand Down Expand Up @@ -1539,7 +1542,7 @@ namespace CodeGen.Engine
;;Now parse the script file
if (!String.IsNullOrWhiteSpace(context.CurrentTask.WindowScript)) then
begin
context.CurrentTask.DevDebugLog("Parsing window script " + context.CurrentTask.WindowScript)
context.CurrentTask.DevDebugLog("Parsing window script " + context.CurrentTask.WindowScript)
errStatus = (boolean)ParseWindowScript(context)
end
else if (!String.IsNullOrWhiteSpace(context.CurrentTask.ProformaFile))
Expand All @@ -1552,7 +1555,7 @@ namespace CodeGen.Engine
errStatus = true
else
begin
context.CurrentTask.DevDebugLog("Parsing ProForma file " + context.CurrentTask.ProFormaFile)
context.CurrentTask.DevDebugLog("Parsing ProForma file " + context.CurrentTask.ProFormaFile)

if (address = %xaddr("ParseProForma",,1)) then
begin
Expand Down Expand Up @@ -1629,7 +1632,7 @@ namespace CodeGen.Engine

if ((!errStatus) && (context.DebugLoggingEnabled) && (context.Structures.Count>0))
begin
context.CurrentTask.Log("Structure(s):",true,false)
context.CurrentTask.Log("Structure(s):",true,false)
data str, @RpsStructure
foreach str in context.Structures
context.CurrentTask.Log(" - " + str.Name)
Expand Down Expand Up @@ -1823,7 +1826,7 @@ namespace CodeGen.Engine
end
else if (context.DebugLoggingEnabled)
begin
context.CurrentTask.Log("Custom field filters in use", true, false)
context.CurrentTask.Log("Custom field filters in use", true, false)
if (context.CurrentTask.IncludeOverlayFields)
context.CurrentTask.Log(" - Overlays will be included")
if (context.CurrentTask.IgnoreExcludeLanguage)
Expand Down Expand Up @@ -1852,7 +1855,7 @@ namespace CodeGen.Engine
end
else if (context.DebugLoggingEnabled)
begin
context.CurrentTask.Log("Custom group processing rules are in use", true, false)
context.CurrentTask.Log("Custom group processing rules are in use", true, false)
if (context.CurrentTask.ExplicitGroupNoExpand)
context.CurrentTask.Log(" - Explicit groups will not be expanded to individual fields")
if (context.CurrentTask.GroupFieldNoGroupPrefix) ;;Do not prefix group fields with group name
Expand Down Expand Up @@ -1908,7 +1911,7 @@ namespace CodeGen.Engine
begin
data token, @UserToken
foreach token in context.CurrentTask.UserTokens
context.UserTokens.Add(token)
context.UserTokens.Add(token)
end
else
UserTokenCollection.AddTokens(context.CurrentTask.UserTokens,context.CurrentTask,context)
Expand Down Expand Up @@ -2060,7 +2063,7 @@ namespace CodeGen.Engine
if (context.MultiStructureMode) then
begin
;;Process the template once for all structures

;;Check each structure, flatten arrays and groups, etc.
context.CurrentTask.DebugLog("")
data ix, int
Expand Down Expand Up @@ -2088,8 +2091,14 @@ namespace CodeGen.Engine
for ix from 0 thru context.Structures.Count-1
begin
;;Check the structure, flatten arrays and groups, etc.
if (!RepositoryTools.CheckStructure(context,context.Structures[ix])) then
errStatus = true
data errContext ,ValidationContext
if (!RepositoryTools.CheckStructure(context,context.Structures[ix],errContext)) then
begin
if (structureWildcard && errContext == ValidationContext.Skipped) then
nop ;deliberatly skipping
else
errStatus = true
end
else
begin
;;Set structure context
Expand Down
61 changes: 46 additions & 15 deletions CodeGenEngine/RepositoryTools.dbl
Expand Up @@ -46,48 +46,74 @@ import CodeGen.RepositoryAPI

namespace CodeGen.Engine

public enum ValidationContext
Ok ,0
Skipped
NoFieldsInStructure
FieldSizeIssue
endenum

public partial class RepositoryTools

public static method CheckStructure, boolean
required in context, @CodeGenContext
required in Struct , @RpsStructure
endparams

stack record
errContext, ValidationContext
endrecord

proc
mreturn RepositoryTools.CheckStructure(context,Struct,errContext)
endmethod

public static method CheckStructure, boolean
required in context, @CodeGenContext
required in Struct , @RpsStructure
required out ErrContext,ValidationContext
endparams

stack record
ErrStatus, boolean
endrecord

proc

ErrStatus = false
ErrContext = ValidationContext.Ok

;; ==========================================================================================
;; STRUCTURE VALIDATION

context.CurrentTask.DebugLog(" - Checking structure " + Struct.Name)

;; Make sure the structure has fields
if (!Struct.Fields.Count)
ErrStatus = context.CurrentTask.Errorlog("Structure " + Struct.Name + " has no fields")

;; Do we have any tags?
if (!ErrStatus&&Struct.Tags.Count)
begin
;; Make sure it's a field=value tag
if (Struct.TagType!=RpsTagType.FieldAndValue)
context.CurrentTask.Log("WARNING: Structure "+Struct.Name+" has an unsupported record length tag. Tag loop tokens may not work!")
end

;; Make sure the structure has not been excluded with @NOCODEGEN
if (!ErrStatus)
begin
if ((Struct.UserText.ToUpper().Contains("@NOCODEGEN"))||(Struct.LongDescription.ToUpper().Contains("@NOCODEGEN")))
begin
context.CurrentTask.DebugLog(" - Structure " + Struct.Name + " is excluded from processing by @NOCODEGEN")
ErrStatus = true
ErrContext = ValidationContext.Skipped
end
end

;; Make sure the structure has fields
if (!ErrStatus && !Struct.Fields.Count)
begin
ErrStatus = context.CurrentTask.Errorlog("Structure " + Struct.Name + " has no fields")
ErrContext = ValidationContext.NoFieldsInStructure
end

;; Do we have any tags?
if (!ErrStatus && Struct.Tags.Count)
begin
;; Make sure it's a field=value tag
if (Struct.TagType!=RpsTagType.FieldAndValue)
context.CurrentTask.Log("WARNING: Structure "+Struct.Name+" has an unsupported record length tag. Tag loop tokens may not work!")
end

;; ==========================================================================================
;; FIELD FILTERS AND VALIDATION
;; The structure seems OK, now lets look at the fields
Expand All @@ -106,6 +132,7 @@ namespace CodeGen.Engine
if (Field.DataType == RpsFieldDataType.Decimal && Field.Precision==0 && Field.Size > 28)
begin
;;ErrStatus = context.CurrentTask.ErrorLog(String.Format("Decimal field {0}.{1} exceeds the maximum size of D28!", Struct.Name, Field.Name))
;;ErrContext = ValidationContext.FieldSizeIssue
;;exitloop
end

Expand All @@ -116,6 +143,7 @@ namespace CodeGen.Engine
if ((Field.Size-Field.Precision) > 28 || Field.Precision > 28)
begin
;;ErrStatus = context.CurrentTask.ErrorLog(String.Format("Implied decimal field {0}.{1} exceeds the maximum size of D56.28!", Struct.Name, Field.Name))
;;ErrContext = ValidationContext.FieldSizeIssue
;;exitloop
end
end
Expand Down Expand Up @@ -450,7 +478,7 @@ namespace CodeGen.Engine
begin
newField1.SqlName = StringTools.SqlName(newField1.Name)
end

;; Note: BaseName doesn't change because of array expansion

if (Field.MappedField)
Expand Down Expand Up @@ -508,7 +536,7 @@ namespace CodeGen.Engine
;; 2. Implicit GROUP (fields defined by another structure)
;;
;; And if the "include overlays" command line option (-f o) was used:
;;
;;
;; 3. Explicit GROUP OVERLAY
;; 4. Implicit GROUP OVERLAY

Expand Down Expand Up @@ -673,9 +701,12 @@ namespace CodeGen.Engine
data ix, int
for ix from 0 thru Struct.Fields.Count-1
Struct.Fields[ix].LogicalFieldNumber = ix+1
end
end
else
begin
ErrStatus = context.CurrentTask.Errorlog("After applying CodeGen rules structure " + Struct.Name + " has no remaining fields!")
ErrContext = ValidationContext.NoFieldsInStructure
end
end

if (!ErrStatus)
Expand Down
Binary file modified Documentation/CodeGen.chm
Binary file not shown.
Binary file modified Documentation/CodeGen.hsmx
Binary file not shown.
6 changes: 3 additions & 3 deletions docs/index.htm
Expand Up @@ -8,12 +8,12 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="generator" content="HelpSmith 9.6 (Build 23.117)" />
<link type="text/css" rel="stylesheet" href="css/index.css?0edcc3c9" />
<link type="text/css" rel="stylesheet" href="css/indexu.css?3855ee9e" />
<link type="text/css" rel="stylesheet" href="css/indexu.css?74d41026" />
<script type="text/javascript" src="js/jquery-3.6.0.min.js"></script>
<script type="text/javascript" src="js/core.min.js?0edcc3c9"></script>
<script type="text/javascript" src="js/settings.js?3855ee9e"></script>
<script type="text/javascript" src="js/settings.js?74d41026"></script>
<script type="text/javascript" src="js/index.min.js?0edcc3c9"></script>
<script type="text/javascript" src="js/topic-table.min.js?3855ee9e"></script>
<script type="text/javascript" src="js/topic-table.min.js?74d41026"></script>
<!-- Web Help IndexPage -->


Expand Down
2 changes: 1 addition & 1 deletion docs/js/search-index.min.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions docs/navi.htm
Expand Up @@ -9,17 +9,17 @@
<link type="text/css" rel="stylesheet" href="css/ui/jquery-ui-1.9.2.custom.min.css" />
<link type="text/css" rel="stylesheet" href="css/tree.css?0edcc3c9" />
<link type="text/css" rel="stylesheet" href="css/navi.css?0edcc3c9" />
<link type="text/css" rel="stylesheet" href="css/naviu.css?3855ee9e" />
<link type="text/css" rel="stylesheet" href="css/naviu.css?74d41026" />
<script type="text/javascript" src="js/jquery-3.6.0.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.9.2.custom.min.js"></script>
<script type="text/javascript" src="js/jquery.cookie.js?0edcc3c9"></script>
<script type="text/javascript" src="js/tree.min.js?0edcc3c9"></script>
<script type="text/javascript" src="js/settings.js?3855ee9e"></script>
<script type="text/javascript" src="js/settings.js?74d41026"></script>
<script type="text/javascript" src="js/core.min.js?0edcc3c9"></script>
<script type="text/javascript" src="js/search.min.js?0edcc3c9"></script>
<script type="text/javascript" src="js/navi.min.js?0edcc3c9"></script>
<script type="text/javascript" src="js/topic-table.min.js?3855ee9e"></script>
<script type="text/javascript" src="js/search-index.min.js?3855ee9e"></script>
<script type="text/javascript" src="js/topic-table.min.js?74d41026"></script>
<script type="text/javascript" src="js/search-index.min.js?74d41026"></script>
<!-- Web Help Layout -->


Expand Down
2 changes: 1 addition & 1 deletion docs/topics/buttonloopexpansiontokens.htm
Expand Up @@ -35,7 +35,7 @@
<link type="text/css" rel="stylesheet" href="../css/topics/style.css" />
<script type="text/javascript" src="../js/jquery-3.6.0.min.js"></script>
<script type="text/javascript" src="../js/nsa.js?0edcc3c9"></script>
<script type="text/javascript" src="../js/settings.js?3855ee9e"></script>
<script type="text/javascript" src="../js/settings.js?74d41026"></script>
<script type="text/javascript" src="../js/core.min.js?0edcc3c9"></script>
<script type="text/javascript" src="../js/topic.min.js?0edcc3c9"></script>
<script type="text/javascript">
Expand Down

0 comments on commit 0a51ef9

Please sign in to comment.