dwscript - how to enumerate all available types?
Asked Answered
F

1

7

Hey, Delphi Web Script is really great scripting engine. I'm trying to use it in one of my projects. However, I'm not sure if it is possible to enumerate all the types, functions that are available within the scripting engine, e.g. I want to have a list with all the methods which I could use while scripting (this includes all the internal and external types, functions, procedures, etc.). Fast script has the treeview component which exposes all the types you can use. I'm looking for something like this in dwscript. Thanks in advance.

Fatima answered 30/5, 2011 at 20:42 Comment(0)
K
2

You'll find all the types in the symbol tables (TSymbolTable) that are attached to every compiled DWScript entity, you have one in the compiled programs, in the compiled functions/methods, and in the blocks that have a scope.

If you want to enumerate all the symbols visible in a particular scope, you'll have not only to look at what a particular TSymbolTable contains, but also look at its parents (which are TSymbolTable too), which hold the symbols from the parent scopes (including unit and library symbols). For class methods & types, you'll find them in the Members[] of a TClassSymbol.

DWS2 repository on sourceforge contains some samples which haven't been converted yet in the DWS2.x repository, but should be reasonably straightforward to adapt.

Kare answered 31/5, 2011 at 6:23 Comment(4)
Thanks for the answer. I managed to get everything by enumerating compiled IdwsProgram Table. But is it possible to get the same table without compiling my script? It's not a big deal, I can live with that if it's not possible because I found out that it works even when script compiles with errors. But still, it would be interesting to know.Fatima
@Linas: As a matter of interest, did you create anything neat in the way of a simple IDE with breakpoints for DWS? I'm soon to replace a horrible scripting engine in my code and would really appreciate a simple IDE+breakpoints example.Monasticism
@Brian I'm only starting to integrate dwscript in my application. Currently I have just very simple scripting IDE without breakpoints, etc. But I'm planning to add more features to it later.Fatima
If you want a list of symbols independently from your script (ie. only those in libraries), you can compile an empty script.Kare

© 2022 - 2024 — McMap. All rights reserved.