ModuleInfo, Object.localClasses(), and Object.find() - any users?

H. S. Teoh hsteoh at qfbox.info
Mon Dec 12 22:54:25 UTC 2022


On Mon, Dec 12, 2022 at 09:49:41PM +0000, cc via Digitalmars-d wrote:
[...]
> It would be nice to be able to preemptively scan/register classes in
> arbitrary modules without needing to list them in a second area of
> code.
[...]

The way I did it in one project was to tag each struct (I was using
structs instead of classes, but the same principle applies) with a UDA,
and then import all modules that contain the struct definitions, and use
getSymbolsByUDA to retrieve all the corresponding symbols. Using this
mechanism, I didn't have to manually maintain a list of structs to
include; the code automatically picked up the complete list. Of course,
modulo importing all the modules that contain the definitions.

Of course, having classes self-register also works too.


T

-- 
MASM = Mana Ada Sistem, Man!


More information about the Digitalmars-d mailing list