Project

General

Profile

Feature #9435

class-level virtual procedure/function definitions

Added by Greg Shah over 1 year ago. Updated over 1 year ago.

Status:
Closed
Priority:
Normal
Target version:
-
Start date:
Due date:
% Done:

100%

billable:
No
vendor_id:
GCD
case_num:
version_reported:
version_resolved:
reviewer:
production:
No
env_name:
topics:

History

#1 Updated by Greg Shah over 1 year ago

Some procedures and functions can be defined in classes.

  • PROCEDURE EXTERNAL
  • PROCEDURE/FUNCTION ... IN handle where the handle is a class var/prop (static or not, or from super-class?)

#2 Updated by Constantin Asofiei over 1 year ago

#9373 showed an issue with virtual 'in handle functions. The problem is related to the fact that the handle is static. See this:
  • oo/FProc.cls
    class oo.FProc.
       def private static property p1 as handle get. set.
    
       function func0 returns int in p1.
    
       constructor static FProc().
          run fproc.p persistent set p1.
       end.
    
       method public static int test1().
          return func0().
       end.
    end.
    
  • fproc.p
    function func0 returns int.
      return 1234.
    end.
    
    message "here".
    
  • fprocrun.p
    message oo.Fproc:test1().
    
The issues are:
  • in ProcedureManager.getAbsoluteName we need to check for Object.class referent (this is the pseudo-instance for the 'static instance' of the legacy class)
       static String getAbsoluteName(Object referent)
       {
          String jname = null;
    
          if (referent.getClass() == Object.class)
          {
             jname = ObjectOps.getStaticClass(referent).getName();
          }
          else
          {
             jname = referent.getClass().getName();
          }
    
          String pname = SourceNameMapper.getLegacySourceName(jname);
          return pname;
       }
    
  • in conversion:
    • the handle expression needs to be static (and context-local), the same the class:
         private static ContextLocal<HandleExpr0> handleExpr0 = new ContextLocal<HandleExpr0>()
         {
            protected HandleExpr0 initialValue()
            {
               return new HandleExpr0();
            }
         };   ...
         static class HandleExpr0
         extends GenericExpression
         {
            public BaseDataType resolve()
            {
               return getP1();
            }
         }
      
    • registerFunctionHandle needs to be in the static constructor (now is in the 'execute' method for the actual instances of this class)
         public static void __oo_Fproc_constructor__static__()
         {
            externalProcedure(Fproc.class, "FProc", new Block((Body) () -> 
            {
               ProcedureManager.registerFunctionHandle("func0", handleExpr0.get());
            }));
         }
      
      

So this is also conversion issue.

#4 Updated by Constantin Asofiei over 1 year ago

  • Status changed from New to Review
  • Assignee set to Constantin Asofiei
  • % Done changed from 0 to 100
  • reviewer Greg Shah added

Created task branch 9435a from trunk rev 15767.

Rev 15768 fixes virtual function support defined in 4GL classes, with static property/var as expression.

Please review.

The point is: for static expressions, emit them in the static constructor, and define the handle expr as 'ContextLocal'.

#5 Updated by Constantin Asofiei over 1 year ago

The changes will reach trunk via 9457a - see rev 15802. 9435a was archived as dead.

#6 Updated by Constantin Asofiei over 1 year ago

  • Status changed from Review to Closed

Also available in: Atom PDF