在 Chromium 嵌入式框架中将 CefRefPtr<CefV8Value> 转换为 int

Convert CefRefPtr<CefV8Value> into int in Chromium Embedded Framework

我正在尝试扩展 Chromium 嵌入式框架附带的 cefsimple 应用程序以包含 V8 处理程序。到目前为止,我编写的代码看起来像这样;

bool SimpleHandler::Execute(const CefString& name,
            CefRefPtr<CefV8Value> object,
            const CefV8ValueList& arguments,
            CefRefPtr<CefV8Value>& retval,
            CefString& exception) {
    int argn = arguments.size();
    if (name == "serial_connect" && (argn == 4 || argn == 1))
    {
        if (connection.isOpen())
            connection.~Serial();
        connection = NULL;
        if (argn == 1)
        {
            int port = (arguments[0]); // convert to int?
        }
        else
        {

        }
    }
    else if (name == "serial_send" && argn >= 1)
    {

    }
    else if (name == "serial_recieve")
    {

    }
    else
        return false;
    return true;
}

我无法将处理程序返回的通用值对象转换为我可以在计算中使用的 cpp int。我找到了函数 CefV8Value::GetIntValue();,但我不知道如何使用它。

尝试调用 object->GetIntValue()

原因是 CefRefPtr 是一个持有 CefV8Value 引用的对象,所以你需要箭头运算符来访问它指向的底层 CefV8Value 对象