I'm on the early stages to create a CEF-based piece of software that already loads HTML and performs ExecuteJavaScript() and implements JS Extensions.
Now I want to implement accessors for my JS objects and I've created a class in a .cpp file with same exact code defined in CEF JS documentation:
- Code: Select all
class MyV8Accessor : public CefV8Accessor {
public:
MyV8Accessor() {}
virtual bool Get(const CefString& name,
const CefRefPtr<CefV8Value> object,
CefRefPtr<CefV8Value>& retval,
CefString& exception) OVERRIDE {
if (name == "myval") {
// Return the value.
retval = CefV8Value::CreateString(myval_);
return true;
}
// Value does not exist.
return false;
}
virtual bool Set(const CefString& name,
const CefRefPtr<CefV8Value> object,
const CefRefPtr<CefV8Value> value,
CefString& exception) OVERRIDE {
if (name == "myval") {
if (value.IsString()) {
// Store the value.
myval_ = value.GetStringValue();
} else {
// Throw an exception.
exception = "Invalid value type";
}
return true;
}
// Value does not exist.
return false;
}
// Variable used for storing the value.
CefString myval_;
// Provide the reference counting implementation for this class.
IMPLEMENT_REFCOUNTING(MyV8Accessor);
};
I've prepended this code with #include "include/cef_v8.h".
I'm having two compiling errors (GCC). It seems CefV8Value cannot reach its member functions:
- Code: Select all
CefAccesor.cpp:28:17: error: 'CefRefPtr<CefV8Value>' {aka 'const class scoped_refptr<CefV8Value>'} has no member named 'IsString'
28 | if (value.IsString()) {
| ^~~~~~~~
CefAccesor.cpp:30:24: error: 'CefRefPtr<CefV8Value>' {aka 'const class scoped_refptr<CefV8Value>'} has no member named 'GetStringValue'
30 | myval_ = value.GetStringValue();
|
I'm know I'm missing some obvious stuff I'm be able to solve.
Thanks for your help in advance.