ghkweon / dwscript

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

OnNeedUnit doesn't fire for TdwsUnit's Dependencies #406

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I create an TdwsUnit descendant in code and add unit 'uFoo' to it's 
'Dependencies' as one of the functions in it returns type defined in uFoo. The 
uFoo is "source unit", ie it is written in DWS pascal, not as TdwsUnit. I 
expected that I can provide the unit source via the OnNeedUnit event, but it 
never fires and compilator gives error

Syntax Error: Unit "uFoo" referenced in unit "dwsUnitDescendant" not found

when compiling the main script. So is my expectation that OnNeedUnit should 
fire right (and this is a bug) or there is some other solution for this 
scenario?

Original issue reported on code.google.com by ain.val...@gmail.com on 29 May 2013 at 9:47

GoogleCodeExporter commented 8 years ago
Current TdwsUnit can only have dependencies to other TdwUnit

Original comment by zar...@gmail.com on 31 May 2013 at 8:55

GoogleCodeExporter commented 8 years ago
As a workaround I used TObject as the result type of the function in the 
dwsUnitDescendant, so that I could use code like

var f: TFoo := getFoo as TFoo;

in the script. In dwsUnitDescendant, in getFoo's OnEval handler I use following 
code to create an instance of TFoo:

Info.ResultAsVariant := Info.Vars['TFoo'].Method['Create'].Call([]).ScriptObj;

But this fails with runtime error:
Runtime Error: DataType "TFoo" not found in GetFoo [line: 71, column: 26]

The "source unit" which defines TFoo type is in the uses of the main script... 
Any suggestion how to solve this?

Original comment by ain.val...@gmail.com on 10 Jun 2013 at 8:58