'v8::Value::ToNumber': was declared deprecated

陌路散爱 提交于 2021-01-28 10:23:40

问题


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();

is giving the following warning:

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'

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?


回答1:


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.



来源:https://stackoverflow.com/questions/46807777/v8valuetonumber-was-declared-deprecated

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!