100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > 六 v8引擎执行JS文件

六 v8引擎执行JS文件

时间:2023-04-23 07:47:18

相关推荐

六 v8引擎执行JS文件

这个环节比较简单,直接上代码了

main.cpp

// Copyright the V8 project authors. All rights reserved.// Use of this source code is governed by a BSD-style license that can be// found in the LICENSE file.#include <stdio.h>#include <stdlib.h>#include <string.h>#include "include/libplatform/libplatform.h"#include "include/v8.h"using namespace std;using namespace v8;const std::string fileName = "file.js";// Reads a file into a v8 string.MaybeLocal<String> ReadFile( Isolate* isolate, const string& name ) {FILE* file = fopen( name.c_str(), "rb" );if ( file == NULL ) return MaybeLocal<String>();fseek( file, 0, SEEK_END );size_t size = ftell( file );rewind( file );std::unique_ptr<char> chars( new char[size + 1] );chars.get()[size] = \;for ( size_t i = 0; i < size;) {

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。