D scripting (c++ integration)
mike
vertex at gmx.at
Tue Oct 3 08:41:52 PDT 2006
Maybe for DMD 3.0 ...
' import std.compiler;
'
' char[] source = "writefln(\"Hello World!\");";
' void delegate() foo = compile(source);
' foo();
That would be just awesome :-)
- mike
> 1) Launch the D compiler from within your app directly, to compile the
> "script" you want to run - std.process works well.
> 2) Use DDL to bind the .obj file from the compiler output. The linker
> will return a DynamicLibrary object to use.
> 3) Use the DynamicLibrary to bind any functions, classes, or static
> fields that you know to exist in the compiled script.
>
> That last point is kind of tricky. While you can simply force script
> coders to adhere to a particular interface, I found it easier to wrap
> the whole script in a function (call that step #0) before compilation.
> This ensures that the starting point of the script was always known, at
> the cost of disallowing some D constructs (bang-line, imports, module
> static init, etc). It also allows the script author to start from line
> 1, much like one can in PHP or JavaScript.
>
--
Erstellt mit Operas revolutionärem E-Mail-Modul: http://www.opera.com/mail/
More information about the Digitalmars-d
mailing list