Skip to content
This repository was archived by the owner on Aug 24, 2018. It is now read-only.

Commit ef22f04

Browse files
committed
Switch to nbind, add asm.js support
1 parent 9588080 commit ef22f04

16 files changed

+306
-265
lines changed

.gitignore

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
.clang_complete
21
node_modules
3-
dist
4-
.DS_Store
2+
npm-debug.log*
53
build
6-
debug.html
4+
5+
*.gypi
6+
!/extra.gypi

.npmignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
node_modules
2+
3+
/build
4+
!/build/Release/nbind.js
5+
!/build/Release/nbind.js.mem
6+
7+
*.gypi

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# buffer-offset-index

autogypi.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"dependencies": [
3+
"nbind"
4+
],
5+
"includes": []
6+
}

binding.gyp

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,19 @@
11
{
2-
"targets": [
3-
{
4-
"target_name": "buffer_offset_index",
5-
"cflags_cc": ["-std=c++11"],
6-
"sources": [
7-
"src/binding.cc",
8-
"src/buffer_offset_index.cc"
9-
],
10-
"include_dirs": [
11-
"src",
12-
'<!(node -e "require(\'nan\')")'
13-
],
14-
"conditions": [
15-
['OS=="mac"', {
16-
"xcode_settings": {
17-
"cflags_cc": ["-std=c++11", "-stdlib=libc++"],
18-
'OTHER_CPLUSPLUSFLAGS' : ['-std=c++11','-stdlib=libc++'],
19-
'OTHER_LDFLAGS': ['-stdlib=libc++'],
20-
'MACOSX_DEPLOYMENT_TARGET': '10.9'
21-
}
22-
}]
23-
]
24-
}
25-
]
2+
"targets": [
3+
{
4+
"variables": {
5+
"asmjs%": 0
6+
},
7+
"includes": [
8+
"auto.gypi",
9+
"extra.gypi"
10+
],
11+
"sources": [
12+
"src/bindings.cc"
13+
]
14+
}
15+
],
16+
"includes": [
17+
"auto-top.gypi"
18+
]
2619
}

extra.gypi

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"conditions": [
3+
[ "asmjs==1", {
4+
"ldflags": [
5+
"--memory-init-file", "0",
6+
"-s", "TOTAL_MEMORY=134217728"
7+
]
8+
} ]
9+
]
10+
}

package.json

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,33 @@
11
{
22
"name": "buffer-offset-index",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "An index that maps character indices in the buffer to 2d coordinates.",
5-
"main": "build/Release/buffer_offset_index",
5+
"main": "src/entry-node",
6+
"browser": "src/entry-browser",
67
"scripts": {
7-
"test": "node-gyp rebuild && mocha test/**/*.test.js",
8-
"install": "node-gyp rebuild"
8+
"autogypi": "autogypi",
9+
"node-gyp": "node-gyp",
10+
"emcc-path": "emcc-path",
11+
"copyasm": "copyasm",
12+
"ndts": "ndts",
13+
"build:all": "npm run build:native && npm run build:browser",
14+
"build:native": "npm run node-gyp configure build",
15+
"build:browser": "npm run node-gyp configure build --asmjs=1",
16+
"test": "npm run build:all && npm run test:nobuild",
17+
"test:nobuild": "mocha --full-trace test/**/*.test.js",
18+
"install": "npm run autogypi && npm run build:native && npm run install-browser",
19+
"install-browser": "test -e build/Release/nbind.js || which em++ 2>&1 > /dev/null && npm run build:browser",
20+
"prepublish": "npm run build:browser"
921
},
1022
"author": "",
1123
"license": "MIT",
12-
"gypfile": true,
1324
"devDependencies": {
1425
"mocha": "^3.1.2",
15-
"random-seed": "^0.3.0",
16-
"segfault-handler": "^1.0.0"
26+
"random-seed": "^0.3.0"
1727
},
1828
"dependencies": {
19-
"nan": "^2.4.0"
29+
"autogypi": "^0.2.2",
30+
"nbind": "^0.3.5",
31+
"node-gyp": "^3.4.0"
2032
}
2133
}

src/binding.cc

Lines changed: 0 additions & 154 deletions
This file was deleted.

src/bindings.cc

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#include "point.h"
2+
3+
#include "buffer_offset_index.h"
4+
#include "buffer_offset_index.cc"
5+
6+
#include "nbind/nbind.h"
7+
8+
NBIND_CLASS(Point) {
9+
10+
construct<>();
11+
construct<unsigned, unsigned>();
12+
13+
getset(getRow, setRow);
14+
getset(getColumn, setColumn);
15+
16+
}
17+
18+
NBIND_CLASS(BufferOffsetIndex) {
19+
20+
construct<>();
21+
22+
method(splice);
23+
method(characterIndexForPosition);
24+
method(positionForCharacterIndex);
25+
26+
}

0 commit comments

Comments
 (0)