'v8::Value::ToNumber': 已宣布弃用 [英] 'v8::Value::ToNumber': was declared deprecated

查看:57
本文介绍了'v8::Value::ToNumber': 已宣布弃用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试访问一个已知对象并将其属性之一作为 Number

I'm trying to access a known object and get one of its properties as a Number

不幸的是,下面的代码...

Unfortunately, the following code...

Isolate *isolate = args.GetIsolate();

Local<Object> opts = args[0]->ToObject();

Local<Number> mode = opts->Get(String::NewFromUtf8(isolate, "mode"))->ToNumber();

发出以下警告:

警告 C4996:v8::Value::ToNumber":已声明不推荐使用
....node-gyp\8.5.0\include\node\v8.h(9578):注意:参见'v8::Value::ToNumber'的声明

warning C4996: 'v8::Value::ToNumber': was declared deprecated
....node-gyp\8.5.0\include\node\v8.h(9578): note: see declaration of 'v8::Value::ToNumber'

在 v8.h 中,我注意到对 ToNumber 的评论:可能使用版本".我试图将它转换为 Maybe 但我还没有尝试正确编译.使用 Maybe 和获取 Number 对象的正确方法是什么?

In the v8.h I noticed the comment on ToNumber: "Use maybe version". I've attempted to convert it to a Maybe but I've not yet been able to get any attempt to compile correctly. What is the correct approach to using Maybe and getting the Number object?

推荐答案

看起来 v8.h 中的可能使用版本"注释让我走错了方向.弃用通知似乎适用于缺少隔离的方法重载.如果你通过了隔离……

Looks like the "Use maybe version" comment in the v8.h led me in the wrong direction. The deprecate notice seems to apply to the method-overload that is missing the isolate. If you pass the isolate...

->ToNumber(isolate);

它在没有警告的情况下工作.

it works without warning.

这篇关于'v8::Value::ToNumber': 已宣布弃用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆