ghkweon / dwscript

Automatically exported from code.google.com/p/dwscript
0 stars 0 forks source link

Virtual constructor loses ExternalObject value #465

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. In a TdwsUnit create a class ´Txxx´ containing a virtual constructor. In 
the implementation of this constructor: ´ASSERT(ExtObject<>nil)´.
2. In the same TdwsUnit create a function that returns an object of the above 
class: ´function XXX: Txxx´.
3. Implement XXX as: ´Info.ResultAsVariant := 
Info.Vars['Txxx'].GetConstructor('Create', pointer(-1)).Call.Value;´
4. From script call XXX -> Assertion failure

What version of the product are you using? On what operating system?
r2511

Please provide any additional information below.

The following change to ´TConstructorVirtualExpr.PreCall´ seems to fix the 
problem but I'm unsure if it is the correct solution.

Change:
  exec.SelfScriptObject^.ExternalObject := ExternalObject;
To:
  exec.SelfScriptObject^.ExternalObject := exec.ExternalObject;

Original issue reported on code.google.com by anders.b...@gmail.com on 16 Apr 2014 at 9:51

GoogleCodeExporter commented 8 years ago
This issue was closed by revision r2515.

Original comment by zar...@gmail.com on 16 Apr 2014 at 3:04

GoogleCodeExporter commented 8 years ago
Good catch. That ExternalObject property+field was actually obsolete and a 
leftover from before script execution was separated from script program.

Also added test case.

Original comment by zar...@gmail.com on 16 Apr 2014 at 3:05