On Tuesday, 5 September 2017 at 21:41:35 UTC, EntangledQuanta
wrote:
On Tuesday, 5 September 2017 at 19:59:27 UTC, Andre Pany wrote:
On Tuesday, 5 September 2017 at 19:44:40 UTC, EntangledQuanta
wrote:
Just an idea for you: in delphi you can set the properties
of a component (a class with runtime reflection enabled) on
runtime. You can even call the methods and events of a
component. I build a Delphi Bridge for D (see recent post on
announce). It is almost the same scenario as here are also
dll calls involved.
What I want to say, you could build something like the
Delphi rtti for your D classes and make generic methods
available via the dll interface.
But that would be quite a bit of work? Modifying the
compiler? I'm just looking for something relatively
straightforward and simple ;)
It is possible without modifying the compiler. In every class
you want enable for runtime reflection you need to add a
generic method which generates for all public
properties/methods coding to fill/call them. It is a mix of
templates and mixins.
In the end compile time reflection capabilities of D are so
powerful that you can write runtime reflection with it.
Thanks for the tip!
Kind regards
André
Thanks, Yeah, that is essentially what I was going to do with
attributes, but rather than having a member do it, have a free
function that tries to do the same thing...
But then the question remains how to output that information so
it can then be used to link in to the "script" that will be
compiled?
While thinking about it I only remember the points which makes
the story quite hard at the moment on windows:
The garbage collector is not shared between your exe and the
shared libraries. There is a D Wiki which explains how to
overcome this issue, but it seems it only works for statically
linked libraries. For dynamically linked libraries I didn't get
it working.
https://wiki.dlang.org/Win32_DLLs_in_D
The export attribute might also get into your way on Windows .
There is a D Conf video about it, I think from 2016.
I do not know wheter it helps you. There is a module jsvar which
is used in the script engine from Adam Ruppe. It is used for
getting access to the D functionality out of the script. He also
written a good book with information how to build runtime
reflection with D.
Kind regards
André