Project

General

Profile

Bug #4841

com-handle to handle automatic input parameter conversion

Added by Vladimir Tsichevski over 3 years ago. Updated over 3 years ago.

Status:
Review
Priority:
Normal
Target version:
-
Start date:
08/05/2020
Due date:
% Done:

0%

billable:
No
vendor_id:
GCD
case_num:

incompatible-data-types.png (4.43 KB) Vladimir Tsichevski, 08/05/2020 10:23 AM

History

#1 Updated by Vladimir Tsichevski over 3 years ago

The problem:

In OE, it is Ok to pass a com-handle value as a parameter to a procedure, which declares the corresponding parameter type as handle, not as com-handle.

Example:

DEFINE VARIABLE CtrlFrame AS WIDGET-HANDLE NO-UNDO.
DEFINE VARIABLE chCtrlFrame AS COMPONENT-HANDLE NO-UNDO.
def frame default-frame.

CREATE CONTROL-FRAME CtrlFrame ASSIGN
       FRAME = FRAME DEFAULT-FRAME:HANDLE.

chCtrlFrame = CtrlFrame:COM-HANDLE.

PROCEDURE proc0.
  DEFINE INPUT PARAM h AS HANDLE.
end.

RUN proc0(INPUT chCtrlFrame).

This example runs Ok in OE, but in FWD it causes:

FWD shall be patched to support this type of parameter type conversion.

#2 Updated by Vladimir Tsichevski over 3 years ago

The proposed patch (in ControlFlowOps.InternalEntryCalled.valid(...) and handle.assign(BaseDataType)):

=== modified file 'src/com/goldencode/p2j/util/ControlFlowOps.java'
@@ -8499,6 +8499,15 @@
                   continue;
                }

+               // provide compatibility between comhandles and handles
+               if (comhandle.class.isAssignableFrom(argType) && 
+                   handle.class.equals(expectedType))
+               {
+                  newPars[i] = new handle((comhandle) param[i]);
+                  // TODO: check the OUTPUT mode case
+                  continue;
+               }
+               
                if (!expectedType.isAssignableFrom(argType))
                {
                   try

=== modified file 'src/com/goldencode/p2j/util/handle.java'
@@ -3801,6 +3801,10 @@
       {
          assign(fromResourceId((new integer(value)).longValue()));
       }
+      else if (value instanceof comhandle)
+      {
+         assign(((comhandle)value).value);
+      }
       else
       {
          String err = "Incompatible data types in expression or assignment.";

#4 Updated by Vladimir Tsichevski over 3 years ago

  • Status changed from New to WIP

Fixed in 3821c rev. 11439, 4011b rev. 11620.

#5 Updated by Vladimir Tsichevski over 3 years ago

  • Status changed from WIP to Review

Also available in: Atom PDF