Feature #9435
class-level virtual procedure/function definitions
Start date:
Due date:
% Done:
100%
billable:
No
vendor_id:
GCD
case_num:
version_reported:
version_resolved:
History
#1 Updated by Greg Shah over 1 year ago
Some procedures and functions can be defined in classes.
PROCEDURE EXTERNALPROCEDURE/FUNCTION ... IN handlewhere thehandleis 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.clsclass 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.pfunction func0 returns int. return 1234. end. message "here".
fprocrun.pmessage oo.Fproc:test1().
- in
ProcedureManager.getAbsoluteNamewe need to check forObject.classreferent (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(); } } registerFunctionHandleneeds 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()); })); }
- the handle expression needs to be static (and context-local), the same the class:
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