duktaped 1.0.0

duktape high level bindings


To use this package, put the following dependency into your project's dependencies section:

dub.json
dub.sdl

d-duktape

High level duktape D bindings.

Quick start with dub

"dependencies": {
	"duktaped": "*"
}

Documentation

$ dub build --build=ddox
$ firefox docs/index.html

Example

/**
    Duktape exemples.
*/
import duktape;
import std.stdio;


enum Direction { up, down, left, right }

static void print(string msg)
{
    writeln(msg);
}

class Person
{
private:
    Direction[] _moveHistory;

public:
    this() { }


    void move(Direction dir)
    {
        _moveHistory ~= dir;
    }

    @property Direction[] moveHistory()
    {
        return _moveHistory;
    }
}

int main()
{
    auto ctx = new DukContext();

    ctx.registerGlobal!print;

    ctx.createNamespace("Game")
        .register!Direction
        .register!Person
        .finalize();

    ctx.evalString(q"{
        p = new Game.Person();

        p.move(Game.Direction.up);
        p.move(Game.Direction.down);
        p.move(Game.Direction.left);
        p.move(Game.Direction.right);

        print(p.moveHistory().toString());
    }");

    return 0;
}
Authors:
  • Eliott Dumeix
Dependencies:
none
Versions:
1.0.0 2018-Oct-31
~master 2018-Oct-31
Show all 2 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 0 downloads this month

  • 0 downloads total

Score:
0.3
Short URL:
duktaped.dub.pm