Project

General

Profile

dyn_array_in_props.txt

Constantin Asofiei, 03/22/2021 06:11 PM

Download (8.11 KB)

 
1
### Eclipse Workspace Patch 1.0
2
#P p2j
3
Index: src/com/goldencode/p2j/util/ObjectOps.java
4
===================================================================
5
--- src/com/goldencode/p2j/util/ObjectOps.java	(revision 2731)
6
+++ src/com/goldencode/p2j/util/ObjectOps.java	(working copy)
7
@@ -47,6 +47,8 @@
8
 **     CA  20210215 An INPUT parameter at the property SETTER must be registered as pending, so its reference
9
 **                  can be tracked. 
10
 **     CA  20210310 Performance improvement in hasDestructor - cache the result of this method.
11
+**     CA  20210322 asResource(LegacyEnum) will always return an ObjectResource instance (and a resource ID
12
+**                  computed), so temp-table fields can refer enums. 
13
 */
14
 
15
 /*
16
@@ -1434,7 +1436,14 @@
17
     */
18
    public static ObjectResource asResource(_BaseObject_ ref)
19
    {
20
-      return local.get().objects.get(ref);
21
+      if (ref instanceof LegacyEnum)
22
+      {
23
+         return new ObjectResource(ref);
24
+      }
25
+      else
26
+      {
27
+         return local.get().objects.get(ref);
28
+      }
29
    }
30
 
31
    /**
32
Index: src/com/goldencode/p2j/util/ArrayAssigner.java
33
===================================================================
34
--- src/com/goldencode/p2j/util/ArrayAssigner.java	(revision 2731)
35
+++ src/com/goldencode/p2j/util/ArrayAssigner.java	(working copy)
36
@@ -58,8 +58,9 @@
37
 **     CA  20210203          Fixed registration of extent variables (defined in a procedure/function) and 
38
 **                           extent parameters - they need to be registered as 'pending' and registered when
39
 **                           the top-level scope is processed.
40
-** 007 CA  20210223          If a dynamic array parameter is resized by the top-level block code, then the
41
+**     CA  20210223          If a dynamic array parameter is resized by the top-level block code, then the
42
 **                           reference in the parameter instance must be updated.
43
+**     CA  20210322          Fixed dynamic arrays used in persistent programs or OO instances.
44
 */
45
 
46
 /*
47
@@ -1823,6 +1824,15 @@
48
       private Map<object<? extends _BaseObject_>[], Class<? extends _BaseObject_>> 
49
       dynamicArrayType = new IdentityHashMap<>();
50
       
51
+      /** Map of dynamic arrays created in a persistent program. */
52
+      private Map<Object, Set<BaseDataType[]>> persistentProcDynArrays = new IdentityHashMap<>();
53
+      
54
+      public WorkArea()
55
+      {
56
+         // add a scope for the 'global' block where all the persistent procedure arrays are kept
57
+         dynamicArrays.push(Collections.newSetFromMap(new IdentityHashMap<>()));
58
+      }
59
+      
60
       @Override
61
       public void scopeStart()
62
       {
63
@@ -1860,22 +1870,46 @@
64
          }
65
 
66
          dynamicUndoableArrays.remove(referent);
67
+         
68
+         Set<BaseDataType[]> refs = persistentProcDynArrays.remove(referent);
69
+         if (refs != null && !refs.isEmpty())
70
+         {
71
+            // cleanup after this persistent program - remove them from the global block and other collections
72
+            dynamicArrays.getFirst().removeAll(refs);
73
+            dynamicArrayPrecisions.keySet().removeAll(refs);
74
+            dynamicArrayCaseSens.keySet().removeAll(refs);
75
+            dynamicArrayType.keySet().removeAll(refs);
76
+         }
77
       }
78
 
79
       @Override
80
       public void scopeFinished()
81
       {
82
+         Object referent = pm._thisProcedure();
83
+
84
          if (!dynamicArrays.isEmpty())
85
          {
86
             // remove scope-registered arrays
87
             Set<BaseDataType[]> arrays = dynamicArrays.pop();
88
-            
89
-            // remove precisions and output extent param registrations 
90
-            // for the arrays being removed
91
-            for (BaseDataType[] array : arrays)
92
+          
93
+            if (!arrays.isEmpty())
94
             {
95
-               dynamicArrayPrecisions.remove(array);
96
-               dynamicArrayCaseSens.remove(array);
97
+               if (ProcedureManager._isPersistent(referent) && tm.isExternalBlock())
98
+               {
99
+                  // all dynamic arrays in a persistent program must be saved in the global block
100
+                  dynamicArrays.getFirst().addAll(arrays);
101
+                  persistentProcDynArrays.put(referent, arrays);
102
+               }
103
+               else
104
+               {
105
+                  // remove precisions and output extent param registrations for the arrays being removed
106
+                  for (BaseDataType[] array : arrays)
107
+                  {
108
+                     dynamicArrayPrecisions.remove(array);
109
+                     dynamicArrayCaseSens.remove(array);
110
+                     dynamicArrayType.remove(array);
111
+                  }
112
+               }
113
             }
114
          }
115
          
116
@@ -1884,7 +1918,6 @@
117
             extentParameters.pop();
118
          }
119
          
120
-         Object referent = pm._thisProcedure();
121
          Deque<Map<BaseDataType[], Integer>> undoableExtStack = dynamicUndoableArrays.get(referent);
122
          if (undoableExtStack != null && undoableExtStack.size() > 1)
123
          {
124
Index: src/com/goldencode/p2j/util/TextOps.java
125
===================================================================
126
--- src/com/goldencode/p2j/util/TextOps.java	(revision 2731)
127
+++ src/com/goldencode/p2j/util/TextOps.java	(working copy)
128
@@ -2,7 +2,7 @@
129
 ** Module   : TextOps.java
130
 ** Abstract : Progress 4GL compatible TextOps object
131
 **
132
-** Copyright (c) 2012-2020, Golden Code Development Corporation.
133
+** Copyright (c) 2012-2021, Golden Code Development Corporation.
134
 **
135
 ** -#- -I- --Date-- ---------------------------------------Description---------------------------------------
136
 ** 001 AIL 20121206 Created initial version by moving static methods from the character class as 
137
@@ -38,7 +38,9 @@
138
 **     ME  20201127 Use resource id for objects in substitute.
139
 **     OM  20201202 Fixed support for substitution of Java Boolean values.
140
 **     VVT 20210106 splitInt(): typo in javadoc fixed.
141
-**     ME  20210128 Avoid using java's trim to check if string is empty, 4GL only consider spaces to be empty (not tab, cr, lf). 
142
+**     ME  20210128 Avoid using java's trim to check if string is empty, 4GL only consider spaces to be empty 
143
+**                  (not tab, cr, lf).
144
+**     CA  20210322 Fixed SUBSTITUTE when a legacy enum instance is used.
145
 */
146
 
147
 /*
148
@@ -104,6 +106,8 @@
149
 import java.util.regex.Pattern;
150
 import java.util.stream.Collectors;
151
 
152
+import com.goldencode.p2j.oo.lang.*;
153
+
154
 /**
155
  * A class that provides Progress 4GL compatible character and longchar 
156
  * functions and operators.  This class provides all functionality as statics
157
@@ -6455,7 +6459,18 @@
158
                      else if (obj instanceof object)
159
                      {
160
                         object o = (object) obj;
161
-                        sb.append(object.resourceId(o));
162
+                        if (o.isUnknown())
163
+                        {
164
+                           sb.append("?");
165
+                        }
166
+                        else if (o.ref instanceof LegacyEnum)
167
+                        {
168
+                           sb.append(((LegacyEnum) o.ref)._getValue()); 
169
+                        }
170
+                        else
171
+                        {
172
+                           sb.append(object.resourceId(o));
173
+                        }
174
                      }
175
                      else if (obj instanceof BaseDataType)
176
                      {
177
Index: src/com/goldencode/p2j/oo/net/serverconnection/ClientSocketConnectionParameters.java
178
===================================================================
179
--- src/com/goldencode/p2j/oo/net/serverconnection/ClientSocketConnectionParameters.java	(revision 2731)
180
+++ src/com/goldencode/p2j/oo/net/serverconnection/ClientSocketConnectionParameters.java	(working copy)
181
@@ -205,7 +205,7 @@
182
        
183
       internalProcedure(ClientSocketConnectionParameters.class, this, "SslCiphers", new Block((Body) () -> 
184
       {
185
-         assignMulti(sslCiphers, var);
186
+         sslCiphers = (character[]) assignMulti(sslCiphers, var);
187
       }));
188
    }
189
 
190
@@ -288,7 +288,7 @@
191
       
192
       internalProcedure(ClientSocketConnectionParameters.class, this, "SslProtocols", new Block((Body) () -> 
193
       {
194
-         assignMulti(sslProtocols, var);
195
+         sslProtocols = (character[]) assignMulti(sslProtocols, var);
196
       }));
197
    }
198