v8

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

南楼画角 提交于 2019-12-10 10:37:56
问题 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? 回答1: Use v8::Array , e.g: v8::Handle<v8::Array> result = v8::Array::New(e1.size()); for

使用 nvm 安装、管理多个 NodeJS 版本

若如初见. 提交于 2019-12-10 07:42:11
本文主要介绍如何使用 nvm 对 Node 的版本进行管理,当然你也可以选择另一个工具 n 。 安装或升级( 参见这里 ) curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash 或 wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash 脚本的作用是将 nvm 仓库源码克隆到 ~/.nvm 下面,之后将环境变量添加到配置文件中,如: ~/.bash_profile , ~/.zshrc , ~/.profile ,或 ~/.bashrc 。 所以会用到 git 命令,如果没有 Git,请先安装。 安装完成之后,需要重新打开终端。 常用命令 # 查看当前安装的 nvm 版本 ➜ ~ nvm --version # 查看所有帮助信息 ➜ ~ nvm # 列出全部可安装的 LTS 版本 ➜ ~ nvm ls-remote --lts # 安装 Node # 10 表示安装 10 系列的最新版; # 也可以指定具体的版本号,如 10.15.0 ➜ ~ nvm install 10 # 使用淘宝镜像安装 ➜ ~ NVM_NODEJS_ORG_MIRROR=https:

How to debug remote v8-based application using Chrome Dev Tools

南笙酒味 提交于 2019-12-10 06:06:23
问题 v8 has its own JSON based remote-debugging protocol and two UI debuggers:console application D8 and a eclipse plugin(hosted at http://code.google.com/p/chromedevtools) Chrome use WebKit Remote Debugging Protocol including Console, DOM Debugger, ..., Debugger "WebKit Remote Debugging Protocol" is a Google Chrome/Chromium debug protocol. You will find its description at http://developers.google.com/chrome-developer-tools/docs/remote-debugging So is it possible to use the Chrome Dev Tools ships

Is this a Chrome bug or is my use of “use strict” and eval invalid?

纵然是瞬间 提交于 2019-12-10 02:21:50
问题 This code works alerts "ok" in all browsers except Chrome: eval("var outer = 0; function test() {'use strict'; outer = 1; } test(); alert('ok');"); (Try it on jsfiddle ). All I'm doing is referencing an outer variable from a 'use strict' function, all in eval context. Chrome says Uncaught ReferenceError: outer is not defined Note: I originally faced it when using devtool: 'eval' in Webpack. 回答1: To simplify the problem : http://jsfiddle.net/rokkkjcs/6/ eval("var outer=0;"); function test() {

In V8 why does Isolate::GetCurrent() return NULL?

☆樱花仙子☆ 提交于 2019-12-09 21:14:56
问题 I have compiled V8 on Ubuntu and have a very simple V8 program called isolate_test.cc. It is based on the Hello World example from Google: #include <v8.h> using namespace v8; int main(int argc, char* argv[]) { V8::initialize(); Isolate* isolate = Isolate::GetCurrent(); //Always returns NULL return 0; } The command I use to compile this program is: g++ -Iinclude -g isolate_test.cc -o isolate_test -Wl,--start-group out/x64.debug/obj.target/{tools/gyp/libv8_{base,snapshot},third_party/icu/libicu

Storing handles to objects in a hashmap or set in Google's V8 engine

喜你入骨 提交于 2019-12-09 19:08:46
问题 I would like to implement this functionality in an embedded JavaScript application that uses v8 engine. function myFunction1() { //do stuff } function myFunction2() { //do other stuff } myAddon.addCallback(myFunction1); myAddon.addCallback(myFunction2); myAddon.removeCallback(myFunction1); In order to do this I need to store these functions in a std::set like so void addCallback(const v8::FunctionCallbackInfo<v8::Value>& args) { v8::HandleScope scope(args.GetIsolate()); v8::Local<v8::Function

What is percent (%) in JavaScript?

人盡茶涼 提交于 2019-12-09 16:09:51
问题 I saw % in many codes. Can you explain to me its purpose or what it does? P.S: The % is ignored from Google searches, so I couldn't find it on Google. Edit: I know the operand in math 13 % 10 = 3 but what I saw is like return %foo . 回答1: Based on the link you provided in the comments, the % character appears to be used in some of the V8 JavaScript engine source code to indicate a method of the C++ runtime that will be executed while parsing the JavaScript source. For example, the line in

Is setTimeout a part of JavaScript it self or it is just an api that the browser provides?

瘦欲@ 提交于 2019-12-09 15:39:34
问题 Is setTimeout a part of JavaScript it self or it is just an api that the browser provides ? Is it a part of ES ? 回答1: From MDN: Specification WHATWG HTML Living Standard … and you won't see it in ECMA-262 5.1. 回答2: The setTimeout() function is actually exposed by the browser's window object as as such they aren't necessarily defined in the ECMAScript specification because they're not JavaScript features, they are features of the browser itself. You can see from the specification section in

What happens to v8 status code on optimization / function run?

谁说我不能喝 提交于 2019-12-09 12:22:33
问题 I saw a question about v8 Optimization which led me to play a bit with v8 Optimization. I've also seen bluebird post about v8 Optimization killers. According to v8 repo, optimization status codes are in multiplications of 2: 1,2,4 ,8 and so on (see OptimizationStatus enum ) However, the following code gave me strange status codes like 17 and 65, and only in these specific cases (see the last few lines of code). Any ideas about why this is happening? function adder(a, b) { return new Function(

Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)

≡放荡痞女 提交于 2019-12-09 04:03:43
问题 My website has been broken since Dreamhost upgraded their servers a couple of weeks ago. I have been tearing my hair out trying to get it fixed and made some progress but am stuck on what is hopefully the final issue. I'm using Rails 3.1.1 on Ruby 1.8.7 and get presented with a 'Ruby (Rack) application could not be started error' from PhusionPassenger. It states that it 'Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS: