diff --git a/.gitignore b/.gitignore
index 0ca39c0..7be8199 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,6 @@
node_modules
dist
.DS_Store
+build
+debug.html
+.clang_complete
diff --git a/.travis.yml b/.travis.yml
index 8c5f3ff..a4a7788 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -20,5 +20,12 @@ branches:
sudo: false
+addons:
+ apt:
+ sources:
+ - ubuntu-toolchain-r-test
+ packages:
+ - g++-4.8
+
env:
- - CC=clang CXX=clang++ npm_config_clang=1
+ - CC=gcc-4.8 CXX=g++-4.8
diff --git a/README.md b/README.md
index ab0f71b..084b8c2 100644
--- a/README.md
+++ b/README.md
@@ -12,36 +12,4 @@ cd atom-patch
npm install
```
-Use `npm test` or `npm run tdd` to run the test suite.
-
-### Recompiling Patch's Flatbuffer Schema
-
-`Patch` uses [flat buffers](https://google.github.io/flatbuffers/) to represent its serialized state. If you want to make any change to the underlying schema you have to download and compile `flatc` first:
-
-```bash
-# clone flatbuffers repository and checkout the version tested with this library
-git clone https://github.com/google/flatbuffers
-git checkout 959866b
-
-# compile flatbuffers
-pushd flatbuffers/build/XCode/
-xcodebuild
-popd
-```
-
-This will create a `flatc` executable in flatbuffers top level directory. You can recompile `src/serialization-schema.fbs` by running:
-
-```bash
-cd atom-patch
-../flatbuffers/flatc -o src --js serialization-schema.fbs
-```
-
-After you do that, please make sure to to change the generated file's last line to:
-
-```diff
-// Exports for Node.js and RequireJS
-- this.Serialization = Serialization;
-+ module.exports = Serialization;
-```
-
-Please, note that we have included a patched version of the flatbuffers javascript library under vendor/flatbuffers.js because the original one has the same problem.
+Use `npm test` to run the test suite.
diff --git a/appveyor.yml b/appveyor.yml
new file mode 100644
index 0000000..31632a1
--- /dev/null
+++ b/appveyor.yml
@@ -0,0 +1,15 @@
+image: Visual Studio 2015
+
+environment:
+ nodejs_version: "6"
+
+install:
+ - ps: Install-Product node $env:nodejs_version
+ - npm install
+
+test_script:
+ - node --version
+ - npm --version
+ - npm run ci-windows
+
+build: off
diff --git a/binding.gyp b/binding.gyp
new file mode 100644
index 0000000..f260139
--- /dev/null
+++ b/binding.gyp
@@ -0,0 +1,78 @@
+{
+ "targets": [
+ {
+ "target_name": "atom_patch",
+ "sources": [
+ "src/binding.cc",
+ ]
+ },
+ ],
+
+ "variables": {
+ "tests": 0
+ },
+
+ "conditions": [
+ # If --tests is passed to node-gyp configure, we'll build a standalone
+ # executable that runs tests on the patch.
+ ['tests != 0', {
+ "targets": [{
+ "target_name": "tests",
+ "type": "executable",
+ "cflags_cc": ["-fexceptions"],
+ "sources": [
+ "test/patch_test.cc",
+ "test/tests.cc",
+ ],
+ "include_dirs": [
+ "test",
+ "vendor",
+ ],
+ "conditions": [
+ ['OS=="mac"', {
+ "xcode_settings": {
+ "GCC_ENABLE_CPP_EXCEPTIONS": "YES",
+ }
+ }],
+ # Enable debugger-friendly optimizations on Linux so we don't retain
+ # v8 symbols that won't be defined when linking the tests executable.
+ ['OS=="linux"', {
+ 'configurations': {
+ 'Debug': {
+ 'cflags!': [ '-O0' ],
+ 'cflags': [ '-Og' ]
+ }
+ }
+ }],
+ ]
+ }]
+ }]
+ ],
+
+ "target_defaults": {
+ "cflags_cc": ["-std=c++11"],
+ "sources": [
+ "src/patch.cc",
+ "src/point.cc",
+ "src/text.cc",
+ ],
+ "include_dirs": [
+ "src",
+ "' > debug.html
+echo '' >> debug.html
+mocha test/helpers/setup test/*.js 2> >(dot -Tsvg >> debug.html)
diff --git a/src/binding.cc b/src/binding.cc
new file mode 100644
index 0000000..d26a3b2
--- /dev/null
+++ b/src/binding.cc
@@ -0,0 +1,467 @@
+#include
+#include
+#include
+#include
+#include
+#include "nan.h"
+#include "point.h"
+#include "hunk.h"
+#include "patch.h"
+#include "text.h"
+
+using namespace v8;
+using std::vector;
+using std::unique_ptr;
+
+static Nan::Persistent row_string;
+static Nan::Persistent column_string;
+static Nan::Persistent new_text_string;
+static Nan::Persistent old_text_string;
+
+static Nan::Maybe PointFromJS(Nan::MaybeLocal