Using __traits (identifier, ...) and a template alias seems to work for me:
import std.stdio;
/// Two kinds of enums:
/// A named enum.
enum VmParams {
OBJ_MIN_CAP,
PROTO_SLOT_IDX,
FPTR_SLOT_IDX,
}
/// An anonymous one.
enum {
ATTR_CONFIGURABLE = 3,
ATTR_WRITABLE,
I have just checked it and yes, it works with a constant that is not an
enum: `const int FOO` defined in the module namespace or `static int
BAR` defined in the dummy Vm class.
On 08/14/2014 02:08 PM, Maxime Chevalier-Boisvert wrote:
Thanks. Does it also work with a constant that's not an
In my JavaScript VM, I have a function whose purpose is to expose
D/host constants to the JavaScript runtime code running inside
the VM. This makes for somewhat redundant code, as follows:
vm.defRTConst(OBJ_MIN_CAPw, OBJ_MIN_CAP);
vm.defRTConst(PROTO_SLOT_IDXw, PROTO_SLOT_IDX);
On Tue, 12 Aug 2014 17:36:40 +
Maxime Chevalier-Boisvert via Digitalmars-d-learn
digitalmars-d-learn@puremagic.com wrote:
I'm just wondering if there's a way to template defRTConst so
that the name of an identifier I'm passing (e.g.: ATTR_DEFAULT)
seems that this is the work for mixins.
On Tue, Aug 12, 2014 at 05:36:40PM +, Maxime Chevalier-Boisvert via
Digitalmars-d-learn wrote:
In my JavaScript VM, I have a function whose purpose is to expose
D/host constants to the JavaScript runtime code running inside the VM.
This makes for somewhat redundant code, as follows:
On Tuesday, 12 August 2014 at 17:36:41 UTC, Maxime
Chevalier-Boisvert wrote:
In my JavaScript VM, I have a function whose purpose is to
expose D/host constants to the JavaScript runtime code running
inside the VM. This makes for somewhat redundant code, as
follows: