[beast: 9/70] V8BSE: build v8bse.node from nodemodule.cc and include V8stub



commit c8011dc5872b60d403d2d6c9c465f870f9724c28
Author: Tim Janik <timj gnu org>
Date:   Sat Feb 18 00:27:04 2017 +0100

    V8BSE: build v8bse.node from nodemodule.cc and include V8stub
    
    Signed-off-by: Tim Janik <timj gnu org>

 ebeast/v8bse/Makefile.am   |    2 +-
 ebeast/v8bse/nodemodule.cc |   26 ++++++++++++++++++++++++++
 2 files changed, 27 insertions(+), 1 deletions(-)
---
diff --git a/ebeast/v8bse/Makefile.am b/ebeast/v8bse/Makefile.am
index 940cc79..f2afc6f 100644
--- a/ebeast/v8bse/Makefile.am
+++ b/ebeast/v8bse/Makefile.am
@@ -35,7 +35,7 @@ NODE_GYP = $(strip \
        $(if $(findstring 1, $(V)) , --verbose) \
        --target=$(shell ./node_modules/electron/dist/electron --version) \
 )
-v8bse.node: v8bse.cc ./node_modules/electron/dist/electron
+v8bse.node: v8bse.cc ./nodemodule.cc ./node_modules/electron/dist/electron
        $(AM_V_GEN)
        $(Q) rm -f v8bse.node build/Release/v8bse.node
        $(Q) $(NODE_GYP) rebuild --dist-url=https://atom.io/download/electron
diff --git a/ebeast/v8bse/nodemodule.cc b/ebeast/v8bse/nodemodule.cc
new file mode 100644
index 0000000..46f5365
--- /dev/null
+++ b/ebeast/v8bse/nodemodule.cc
@@ -0,0 +1,26 @@
+// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
+#include "../bse.hh"
+#include "v8bse.cc"
+#include <node.h>
+
+// v8pp binding for Bse
+static V8stub *bse_v8stub = NULL;
+
+// register bindings and start Bse
+static void
+v8bse_register_module (v8::Local<v8::Object> exports)
+{
+  assert (bse_v8stub == NULL);
+  // start Bse
+  Bse::String bseoptions = Bse::string_format ("debug-extensions=%d", 0);
+  Bse::init_async (NULL, NULL, "BEAST", Bse::string_split (bseoptions, ":"));
+  // register v8stub
+  v8::Isolate *const isolate = v8::Isolate::GetCurrent();
+  v8::Local<v8::Context> context = isolate->GetCurrentContext();
+  bse_v8stub = new V8stub (isolate);
+  v8::Maybe<bool> ok = exports->SetPrototype (context, bse_v8stub->module_.new_instance());
+  assert (ok.FromJust() == true);
+}
+
+// node.js registration
+NODE_MODULE (v8bse, v8bse_register_module);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]