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

Switch to nbind, add asm.js support #2

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.clang_complete
node_modules
dist
.DS_Store
npm-debug.log*
build
debug.html

*.gypi
!/extra.gypi
7 changes: 7 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules

/build
!/build/Release/nbind.js
!/build/Release/nbind.js.mem

*.gypi
20 changes: 15 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sudo: false
sudo: required

git:
depth: 10
Expand All @@ -7,12 +7,22 @@ language: node_js

node_js: 6

env:
- CC=clang CXX=clang++ npm_config_clang=1

script: npm test
script: npm run test:noasmjs

notifications:
email:
on_success: never
on_failure: change

env:
- CXX=clang++-3.8

addons:
apt:
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.8
packages:
- gcc-5
- g++-5
- clang-3.8
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# buffer-offset-index
6 changes: 6 additions & 0 deletions autogypi.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"dependencies": [
"nbind"
],
"includes": []
}
41 changes: 17 additions & 24 deletions binding.gyp
Original file line number Diff line number Diff line change
@@ -1,26 +1,19 @@
{
"targets": [
{
"target_name": "buffer_offset_index",
"cflags_cc": ["-std=c++11"],
"sources": [
"src/binding.cc",
"src/buffer_offset_index.cc"
],
"include_dirs": [
"src",
'<!(node -e "require(\'nan\')")'
],
"conditions": [
['OS=="mac"', {
"xcode_settings": {
"cflags_cc": ["-std=c++11", "-stdlib=libc++"],
'OTHER_CPLUSPLUSFLAGS' : ['-std=c++11','-stdlib=libc++'],
'OTHER_LDFLAGS': ['-stdlib=libc++'],
'MACOSX_DEPLOYMENT_TARGET': '10.9'
}
}]
]
}
]
"targets": [
{
"variables": {
"asmjs%": 0
},
"includes": [
"auto.gypi",
"extra.gypi"
],
"sources": [
"src/bindings.cc"
]
}
],
"includes": [
"auto-top.gypi"
]
}
10 changes: 10 additions & 0 deletions extra.gypi
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"conditions": [
[ "asmjs==1", {
"ldflags": [
"--memory-init-file", "0",
"-s", "TOTAL_MEMORY=134217728"
]
} ]
]
}
27 changes: 21 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,36 @@
{
"name": "buffer-offset-index",
"version": "0.0.1",
"version": "0.1.0",
"description": "An index that maps character indices in the buffer to 2d coordinates.",
"main": "build/Release/buffer_offset_index",
"main": "src/entry-node",
"browser": "src/entry-browser",
"scripts": {
"test": "node-gyp rebuild && mocha test/**/*.test.js",
"install": "node-gyp rebuild"
"autogypi": "autogypi",
"node-gyp": "node-gyp",
"emcc-path": "emcc-path",
"copyasm": "copyasm",
"ndts": "ndts",
"build:all": "npm run build:native && npm run build:browser",
"build:native": "npm run node-gyp configure build",
"build:browser": "npm run node-gyp configure build --asmjs=1",
"test": "npm run build:all && npm run test:nobuild",
"bench": "npm run build:all && TEST_ASMJS=0 time mocha test/buffer-index.test.js && TEST_NATIVE=0 time mocha test/buffer-index.test.js",
"test:nobuild": "mocha test/**/*.test.js",
"test:noasmjs": "npm run build:native && TEST_ASMJS=0 mocha --full-trace test/**/*.test.js",
"install": "npm run autogypi && npm run build:native && npm run install-browser",
"install-browser": "test -e build/Release/nbind.js || ! command -v emsdk 2>&1 > /dev/null || npm run build:browser",
"prepublish": "[ \"$CI\" = true ] || npm run build:browser"
},
"author": "",
"license": "MIT",
"gypfile": true,
"devDependencies": {
"mocha": "^3.1.2",
"random-seed": "^0.3.0",
"segfault-handler": "^1.0.0"
},
"dependencies": {
"nan": "^2.4.0"
"autogypi": "^0.2.2",
"nbind": "^0.3.5",
"node-gyp": "^3.4.0"
}
}
154 changes: 0 additions & 154 deletions src/binding.cc

This file was deleted.

26 changes: 26 additions & 0 deletions src/bindings.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include "point.h"

#include "buffer_offset_index.h"
#include "buffer_offset_index.cc"

#include "nbind/nbind.h"

NBIND_CLASS(Point) {

construct<>();
construct<unsigned, unsigned>();

getset(getRow, setRow);
getset(getColumn, setColumn);

}

NBIND_CLASS(BufferOffsetIndex) {

construct<>();

method(splice);
method(characterIndexForPosition);
method(positionForCharacterIndex);

}
Loading