v8

Binary array using V8 engine

夙愿已清 提交于 2019-12-06 12:01:32
I have an array of bytes defined as unsigned char ptr = new unsigned char[1024]; fillWithSomething(ptr, 1024); Then, I need to store the ptr variable in a Local< Array> variable of V8 Engine or another kind of V8 data type. Currently, I am converting the array of bytes into a string in order to store in a Local< String> variable, but this approach is inefficient to my application. Thanks in advance. UPDATED (thanks to Vyacheslav Egorov) I test the solution with an external array but I can't use it on my node.js server code. I have the following code (on my extension side C++): Handle<Object>

Embed basic WebKit + V8 in my app

自古美人都是妖i 提交于 2019-12-06 09:34:57
问题 I want a very basic HTML/CSS/JS renderer embedded in my app using WebKit and preferably V8. All I need is to always render one page and possibly make network and local requests (load JSON/msgpack). I don't need prefetch, tabs, omnibox, profiles and other chromium features, but from what I see looking at CEF is that it embeds a full featured chromium. Are there any other solutions? 来源: https://stackoverflow.com/questions/15155331/embed-basic-webkit-v8-in-my-app

JavaScript engine for Java

狂风中的少年 提交于 2019-12-06 09:20:35
Currently I'm using Rhino in my application. I need to eval some JavaScript ant get values from it (I don't need to use Java classes through JavaScript). But it is too slow. Maybe there are any ways to use V8 with Java application? Update: I have a large collection of objects of different types. I need a flexible mechanism for validation and transformation these objects to the required form (the user should be able to change the rules of validation and transformation (in runtime), ie hardcoding these rules in Java not suitable). Now everything works on Rhino, but performance is bad. I thought

Can you call COM components from server side javascript?

一个人想着一个人 提交于 2019-12-06 09:04:39
Is it possible (using one of the server side implementations of javascript .. see http://www.nakedjavascript.com/getting-started-55 ) to instantiate a COM object and invoke methods on it? idobatter There is node-win32ole ( npm install win32ole ). That depends on which server-side implementation you’re using. When using ASP/JS (or any other framework using Microsoft’s Windows Scripting engine), that’s not a problem using the ActiveXObject constructor. When using JSDB , you can use the ActiveX constructor. Node.js doesn’t really work on Windows, only thru Cygwin, so ActiveX probably won’t be

how to a return a vector<T> from v8 c++ function

不想你离开。 提交于 2019-12-06 08:05:48
struct empDetails { int empId; string name; }; v8::Handle<v8::Value> GetEMPDetails(const v8::Arguments &args) { std::vector<empDetails> e1; e1.push_back(empDetails(23, "paul")); e1.push_back(empDetails(45, "john")); // how can I return V8 handle so that I can use this vector in // my javascript module return e1; } here I wanna return e1 to javascript module, could someone please let me know how to do this? Use v8::Array , e.g: v8::Handle<v8::Array> result = v8::Array::New(e1.size()); for (size_t i = 0; i < e1.size(); i++) result->Set(i, someObject); Obviously you still need to convert your

Different result from JavaScript RegExp in “rhino1.7.6” vs “V8”

三世轮回 提交于 2019-12-06 07:16:52
currently, I found the same JavaScript RegExp might generate different result in different JavaScript Engines, here is an example: In Chrome V8 JS engine, /\x3c/.test("\x3c") --> returns true /\x3c/.test(function() { return "\x3c" }) -->returns ***false*** In rhino1.7.6,I typed the command like this: >java -jar js.jar Rhino 1.7.6 2015 04 15 js> /\x3c/.test(function() { return "\x3c" }) true js> And I tested these two: /\x3c/.test("\x3c") --> returns true /\x3c/.test(function() { return "\x3c" }) -->returns ***true*** I am wondering why these two engines generate different result. I believe

Linux 卸载删除node和npm并重新安装(升级)

走远了吗. 提交于 2019-12-06 06:52:57
卸载: 1.先卸载npm sudo npm uninstall npm -g 2.卸载node yum remove nodejs npm -y 看看是否有残留 进入 /usr/local/lib 删除所有 node 和 node_modules文件夹 进入 /usr/local/include 删除所有 node 和 node_modules 文件夹 进入 /usr/local/bin 删除 node 的可执行文件 安装:(新node版本是带有npm) 登录linux机器,cd /usr/local目录去下载安装包 1、wget https://nodejs.org/dist/v8.11.4/node-v8.11.4-linux-x64.tar.xz #在/usr/local目录下 下载nodejs安装包 2、tar xvf node-v8.11.4-linux-x64.tar.xz #解压 3、mv node-v8.11.4-linux-x64 nodejs #改短名 4、配置,需要创建软链接,以便全局使用:(否则node -v 报错:-bash: /usr/bin/node: 没有那个文件或目录) ln -s /usr/local/nodejs/bin/node /usr/bin/node ln -s /usr/local/nodejs/bin/npm /usr/bin

Javascript generator function — written in C++

让人想犯罪 __ 提交于 2019-12-06 06:48:29
问题 Using the V8 C++ API, how can I implement the generator interface for use in Javascript? I'd like to create an object that can be used as the iterator for a for-of loop. 回答1: Looks like the first thing that's necessary is to check for a property lookup for Symbol.iterator : NAN_PROPERTY_GETTER(My_Obj::Getter) { auto self = Nan::ObjectWrap::Unwrap<My_Obj>(info.This()); if (property->IsSymbol()) { if (Nan::Equals(property, v8::Symbol::GetIterator(info.GetIsolate())).FromJust()) { ... Respond

In the V8 Javascript Engine, how do you add a FunctionTemplate as an attribute of another FunctionTemplate with the C++ API?

余生颓废 提交于 2019-12-06 06:01:07
I have a function set up to return a wrapped C++ object when called as new MyClass(); but I want to also be able to say MyClass.do_something(); I know how to do what I want in pure javascript: MyClass.prototype = { do_something: function(){}}; but how do I do the same in C++? I'm aware of the InstanceTemplate() and PrototypeTemplate() methods on v8::FunctionTemplate, but those seem to only be used in the creation of the new object returned when new MyClass() is called. How do I get at the actual function's prototype? Thank you. I saw this post, but am not sure if it's relevant: Add a function

v8 WeakCallback never gets called

纵饮孤独 提交于 2019-12-06 05:37:43
I know that this question is old but all the answers I found doesn't work and are outdated. But here is my code: void Destroyed(const v8::WeakCallbackData<v8::Object, int>& info) { std::cout << "d: " << *info.GetParameter() << std::endl; } std::vector<v8::Persistent<v8::Object, v8::CopyablePersistentTraits<v8::Object>>> persistent; int i = 0; void Constructor(const v8::FunctionCallbackInfo<v8::Value>& info) { v8::HandleScope scope(v8::Isolate::GetCurrent()); v8::Persistent<v8::Object, v8::CopyablePersistentTraits<v8::Object>> per; per = v8::Persistent<v8::Object>(v8::Isolate::GetCurrent(),