Skip to content

Commit

Permalink
Added REPLICATION_MORE, REPLICATION_NOMORE, DATE_PARAMETERS, DATE_PAR…
Browse files Browse the repository at this point in the history
…AMETERS_IN and DATE_PARAMETERS_OUT.
  • Loading branch information
SteveIves committed Jun 9, 2023
1 parent d2267d9 commit fe3c020
Show file tree
Hide file tree
Showing 9 changed files with 209 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ namespace CodeGen.Engine
loopUtilityExpressionEvaluators.Add("LAST", evaluateLast)
loopUtilityExpressionEvaluators.Add("MORE", evaluateMore)
loopUtilityExpressionEvaluators.Add("NOMORE", evaluateNoMore)
loopUtilityExpressionEvaluators.Add("REPLICATION_MORE",evaluateReplicationMore)
loopUtilityExpressionEvaluators.Add("REPLICATION_NOMORE",evaluateReplicationNoMore)

endmethod

Expand Down Expand Up @@ -121,6 +123,57 @@ namespace CodeGen.Engine
mreturn (loop.CurrentIndex == loop.MaxIndex)
endmethod

private static method evaluateReplicationMore, boolean
tkn, @Token
template, @FileNode
loops, @IEnumerable<LoopNode>
endparams
proc
;The bahavior is similar to that of identical to that of evaluateMore (above)
;except that this code takes into account any fields being excluded via the
;special token REPLICATOR_EXCLUDE in field user text or long descripotion.

data excludedFields = 0
foreach data fld in template.Context.GetCurrentStructure().Fields as @RpsField
begin
if (fld.HasProperty(template, "REPLICATOR_EXCLUDE"))
begin
excludedFields += 1
end
end

lambda isLoopNode(node) (node .is. LoopNode)
data loop, @LoopNode, loops.Last(isLoopNode)

mreturn (loop.CurrentIndex < loop.MaxIndex - excludedFields)

endmethod

private static method evaluateReplicationNoMore, boolean
tkn, @Token
template, @FileNode
loops, @IEnumerable<LoopNode>
endparams
proc
;The bahavior is similar to that of identical to that of evaluateNoMore (above)
;except that this code takes into account any fields being excluded via the
;special token REPLICATOR_EXCLUDE in field user text or long descripotion.

data excludedFields = 0
foreach data fld in template.Context.GetCurrentStructure().Fields as @RpsField
begin
if (fld.HasProperty(template, "REPLICATOR_EXCLUDE"))
begin
excludedFields += 1
end
end

lambda isLoopNode(node) (node .is. LoopNode)
data loop, @LoopNode, loops.Last(isLoopNode)
;; TODO: Should always return true if it's a primary key loop
mreturn (loop.CurrentIndex == loop.MaxIndex - excludedFields)
endmethod

;; *********************************************************************

private static method evaluateLoopProgress, boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ namespace CodeGen.Engine
methodLoopExpressionEvaluators.Add("COERCE_USHORT", evaluateMethodReturnCorecedType)

;;Parameter types
methodLoopExpressionEvaluators.Add("DATE_PARAMETERS", evaluateMethodDateParameters)
methodLoopExpressionEvaluators.Add("DATE_PARAMETERS_IN", evaluateMethodDateParametersIn)
methodLoopExpressionEvaluators.Add("DATE_PARAMETERS_OUT", evaluateMethodDateParametersOut)
methodLoopExpressionEvaluators.Add("IN", evaluateMethodParametersIn)
methodLoopExpressionEvaluators.Add("INOUT", evaluateMethodParametersInOut)
methodLoopExpressionEvaluators.Add("IN_OR_INOUT", evaluateMethodParametersInOrInOut)
Expand Down Expand Up @@ -258,6 +261,82 @@ namespace CodeGen.Engine
mreturn EvaluateMethodLoopExpression(tkn, template, loops, doEvaluate)
endmethod

private static method evaluateMethodDateParameters, boolean
tkn, @Token
template, @FileNode
loops, @IEnumerable<LoopNode>
proc
lambda doEvaluate(iface, meth, index)
begin
;;If there are no parameters we have our answer
if (meth.Parameters.Count==0)
mreturn false
;;Otherwise go looking for any date parameters
data param, @SmcParameter
foreach param in meth.Parameters
begin
if param.Type == ParameterType.Decimal && (param.CoerceType == CoerceType.DateTime || param.CoerceType == CoerceType.DecimalNullable)
begin
mreturn true
end
end
mreturn false
end
mreturn EvaluateMethodLoopExpression(tkn, template, loops, doEvaluate)
endmethod

private static method evaluateMethodDateParametersIn, boolean
tkn, @Token
template, @FileNode
loops, @IEnumerable<LoopNode>
proc
lambda doEvaluate(iface, meth, index)
begin
;;If there are no parameters we have our answer
if (meth.Parameters.Count==0)
mreturn false
;;Otherwise go looking for any date parameters
data param, @SmcParameter
foreach param in meth.Parameters
begin
if param.Type == ParameterType.Decimal
& && (param.CoerceType == CoerceType.DateTime || param.CoerceType == CoerceType.DecimalNullable)
& && (param.Direction == ParameterDirection.In || param.Direction == ParameterDirection.InOut)
begin
mreturn true
end
end
mreturn false
end
mreturn EvaluateMethodLoopExpression(tkn, template, loops, doEvaluate)
endmethod

private static method evaluateMethodDateParametersOut, boolean
tkn, @Token
template, @FileNode
loops, @IEnumerable<LoopNode>
proc
lambda doEvaluate(iface, meth, index)
begin
;;If there are no parameters we have our answer
if (meth.Parameters.Count==0)
mreturn false
;;Otherwise go looking for any date parameters
data param, @SmcParameter
foreach param in meth.Parameters
begin
if param.Type == ParameterType.Decimal
& && (param.CoerceType == CoerceType.DateTime || param.CoerceType == CoerceType.DecimalNullable)
& && (param.Direction == ParameterDirection.Out || param.Direction == ParameterDirection.InOut)
begin
mreturn true
end
end
mreturn false
end
mreturn EvaluateMethodLoopExpression(tkn, template, loops, doEvaluate)
endmethod

private static method evaluateMethodParametersIn, boolean
tkn, @Token
template, @FileNode
Expand Down Expand Up @@ -389,10 +468,10 @@ namespace CodeGen.Engine
proc
lambda doEvaluate(iface, meth, index)
begin
;;If it's a function then we have our answer
;;If there are no parameters we have our answer
if (meth.Parameters.Count==0)
mreturn false
;;Otherwise go looking for any structure parameter
;;Otherwise go looking for any structure parameters
data param, @SmcParameter
foreach param in meth.Parameters
begin
Expand Down
5 changes: 5 additions & 0 deletions CodeGenEngine/Tokenizer.dbl
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,9 @@ namespace CodeGen.Engine
expressions.Add("DATE_NOT_YMD", TokenValidity.FieldLoop | TokenValidity.KeySegmentLoop | TokenValidity.RelationSegmentLoop)
expressions.Add("DATE_NOT_YYYYMMDD", TokenValidity.FieldLoop | TokenValidity.KeySegmentLoop | TokenValidity.RelationSegmentLoop | TokenValidity.ParameterLoop)
expressions.Add("DATE_NULLABLE", TokenValidity.FieldLoop | TokenValidity.KeySegmentLoop | TokenValidity.RelationSegmentLoop)
expressions.Add("DATE_PARAMETERS", TokenValidity.MethodLoop)
expressions.Add("DATE_PARAMETERS_IN", TokenValidity.MethodLoop)
expressions.Add("DATE_PARAMETERS_OUT", TokenValidity.MethodLoop)
expressions.Add("DATE_PERIOD", TokenValidity.FieldLoop | TokenValidity.KeySegmentLoop | TokenValidity.RelationSegmentLoop)
expressions.Add("DATE_YMD", TokenValidity.FieldLoop | TokenValidity.KeySegmentLoop | TokenValidity.RelationSegmentLoop)
expressions.Add("DATE_YYJJJ", TokenValidity.FieldLoop | TokenValidity.KeySegmentLoop | TokenValidity.RelationSegmentLoop | TokenValidity.ParameterLoop)
Expand Down Expand Up @@ -1025,6 +1028,8 @@ namespace CodeGen.Engine
expressions.Add("REFERENCE", TokenValidity.ParameterLoop)
expressions.Add("RELATION", TokenValidity.FieldLoop)
expressions.Add("RELATIVE", TokenValidity.FileLoop)
expressions.Add("REPLICATION_MORE", TokenValidity.FieldLoop)
expressions.Add("REPLICATION_NOMORE", TokenValidity.FieldLoop)
expressions.Add("REPORT", TokenValidity.FieldLoop | TokenValidity.KeySegmentLoop | TokenValidity.RelationSegmentLoop)
expressions.Add("REPORT_CENTER", TokenValidity.FieldLoop | TokenValidity.KeySegmentLoop | TokenValidity.RelationSegmentLoop)
expressions.Add("REPORT_LEFT", TokenValidity.FieldLoop | TokenValidity.KeySegmentLoop | TokenValidity.RelationSegmentLoop)
Expand Down
25 changes: 21 additions & 4 deletions SampleRepository/CodeGen.sch
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@

; SYNERGY DATA LANGUAGE OUTPUT
;
; REPOSITORY : D:\CodeGen\SampleRepository\rpsmain.ism
; : D:\CodeGen\SampleRepository\rpstext.ism
; REPOSITORY : C:\DEV_SYNERGEX\CodeGen\SampleRepository\rpsmain.ism
; : C:\DEV_SYNERGEX\CodeGen\SampleRepository\rpstext.ism
; : Version 9.1.5b
;
; GENERATED : 03-JUN-2022, 14:58:42
; : Version 12.1.1
; GENERATED : 08-JUN-2023, 09:52:15
; : Version 12.2.1
; EXPORT OPTIONS : [ALL]


Expand Down Expand Up @@ -491,6 +491,23 @@ Field USER_DATE Type USER Size 14 Stored DATE
User Type "YYYYMMDDHHMMSS"
Description "User defined date YYYYMMDDHHMMSS"

Structure EXCLUDED_OVERLAY_TEST DBL ISAM
Description "Excluded overlay test"

Field F1 Type ALPHA Size 10
Description "f1"

Field F2 Type ALPHA Size 10
Description "f2"

Field F3 Type ALPHA Size 10
Description "F3"

Field ALLREC Type ALPHA Size 30 Overlay F1:0
Description "All record data"
Long Description
"REPLICATOR_EXCLUDE"

Structure GROUP_TEST DBL ISAM
Description "Structure to test GROUP functionality"

Expand Down
Binary file modified SampleRepository/rpsmain.is1
Binary file not shown.
Binary file modified SampleRepository/rpsmain.ism
Binary file not shown.
Binary file modified SampleRepository/rpstext.is1
Binary file not shown.
Binary file modified SampleRepository/rpstext.ism
Binary file not shown.
52 changes: 49 additions & 3 deletions SampleTemplates/b.tpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,52 @@
;//This template is for development testing. It is not shipped by the installer.
<CODEGEN_FILENAME><structure_name>_b.txt</CODEGEN_FILENAME>
<NAMESPACE>
<COUNTER_1_RESET>
<FIELD_LOOP>
<FIELD_NAME>
</FIELD_LOOP>
<IF CUSTOM_NOT_REPLICATOR_EXCLUDE>
<COUNTER_1_INCREMENT>
<IF COUNTER_1_EQ_1>
if (ok && openAndBind)
begin
if (%ssc_bind(a_dbchn,c1<StructureName>,<REPLICATION_REMAINING_INCLUSIVE_MAX_250>,
</IF COUNTER_1_EQ_1>
<IF CUSTOM_DBL_TYPE>
& tmp<FieldSqlName><IF REPLICATION_NOMORE>)==SSQL_FAILURE)<ELSE><IF COUNTER_1_LT_250>,<ELSE>)==SSQL_FAILURE)</IF COUNTER_1_LT_250></IF>
<ELSE ALPHA>
& <structure_name>.<field_original_name_modified><IF REPLICATION_NOMORE>)==SSQL_FAILURE)<ELSE><IF COUNTER_1_LT_250>,<ELSE>)==SSQL_FAILURE)</IF COUNTER_1_LT_250></IF>
<ELSE DECIMAL>
& <structure_name>.<field_original_name_modified><IF REPLICATION_NOMORE>)==SSQL_FAILURE)<ELSE><IF COUNTER_1_LT_250>,<ELSE>)==SSQL_FAILURE)</IF COUNTER_1_LT_250></IF>
<ELSE INTEGER>
& <structure_name>.<field_original_name_modified><IF REPLICATION_NOMORE>)==SSQL_FAILURE)<ELSE><IF COUNTER_1_LT_250>,<ELSE>)==SSQL_FAILURE)</IF COUNTER_1_LT_250></IF>
<ELSE DATE>
& ^a(<structure_name>.<field_original_name_modified>)<IF REPLICATION_NOMORE>)==SSQL_FAILURE)<ELSE><IF COUNTER_1_LT_250>,<ELSE>)==SSQL_FAILURE)</IF COUNTER_1_LT_250></IF>
<ELSE TIME>
& tmp<FieldSqlName><IF REPLICATION_NOMORE>)==SSQL_FAILURE)<ELSE><IF COUNTER_1_LT_250>,<ELSE>)==SSQL_FAILURE)</IF COUNTER_1_LT_250></IF>
<ELSE USER AND USERTIMESTAMP>
& tmp<FieldSqlName><IF REPLICATION_NOMORE>)==SSQL_FAILURE)<ELSE><IF COUNTER_1_LT_250>,<ELSE>)==SSQL_FAILURE)</IF COUNTER_1_LT_250></IF>
<ELSE USER AND NOT USERTIMESTAMP>
<IF DEFINED_ASA_TIREMAX>
& tmp<FieldSqlName><IF REPLICATION_NOMORE>)==SSQL_FAILURE)<ELSE><IF COUNTER_1_LT_250>,<ELSE>)==SSQL_FAILURE)</IF COUNTER_1_LT_250></IF>
<ELSE>
& <structure_name>.<field_original_name_modified><IF REPLICATION_NOMORE>)==SSQL_FAILURE)<ELSE><IF COUNTER_1_LT_250>,<ELSE>)==SSQL_FAILURE)</IF COUNTER_1_LT_250></IF>
</IF DEFINED_ASA_TIREMAX>
</IF CUSTOM_DBL_TYPE>
<IF COUNTER_1_EQ_250>
begin
ok = false
sts = 0
if (%ssc_getemsg(a_dbchn,errtxt,length,,dberror)==SSQL_FAILURE)
errtxt="Failed to bind variables"
end
end
<COUNTER_1_RESET>
<ELSE NOMORE>
begin
ok = false
sts = 0
if (%ssc_getemsg(a_dbchn,errtxt,length,,dberror)==SSQL_FAILURE)
errtxt="Failed to bind variables"
end
end
</IF COUNTER_1_EQ_250>
</IF CUSTOM_NOT_REPLICATOR_EXCLUDE>
</FIELD_LOOP>

0 comments on commit fe3c020

Please sign in to comment.