https://github.com/boolangery/d-duktape
Duktape high level bindings
https://github.com/boolangery/d-duktape
Last synced: 3 months ago
JSON representation
Duktape high level bindings
- Host: GitHub
- URL: https://github.com/boolangery/d-duktape
- Owner: boolangery
- Created: 2018-10-31T16:26:43.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-11-11T10:29:55.000Z (over 5 years ago)
- Last Synced: 2025-01-18T20:07:53.720Z (over 1 year ago)
- Language: C
- Size: 907 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
d-duktape
=========
High level duktape D bindings.
Quick start with dub
--------------------
```json
"dependencies": {
"duktaped": "*"
}
```
Documentation
-------------
```bash
$ dub build --build=ddox
$ firefox docs/index.html
````
Example
-------
```d
/**
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;
}
```