mirror of
https://github.com/lubosz/overte.git
synced 2025-04-07 15:22:09 +02:00
Fixed build warnings
This commit is contained in:
parent
1550049b0c
commit
3f1a7605a5
6 changed files with 53 additions and 26 deletions
|
@ -546,9 +546,13 @@ void ScriptEngineV8::registerGlobalObject(const QString& name, QObject* object)
|
|||
if (!v8GlobalObject->Get(getContext(), v8Name).IsEmpty()) {
|
||||
if (object) {
|
||||
V8ScriptValue value = ScriptObjectV8Proxy::newQObject(this, object, ScriptEngine::QtOwnership);
|
||||
v8GlobalObject->Set(getContext(), v8Name, value.get());
|
||||
if(!v8GlobalObject->Set(getContext(), v8Name, value.get()).FromMaybe(false)) {
|
||||
Q_ASSERT(false);
|
||||
}
|
||||
} else {
|
||||
v8GlobalObject->Set(getContext(), v8Name, v8::Null(_v8Isolate));
|
||||
if(!v8GlobalObject->Set(getContext(), v8Name, v8::Null(_v8Isolate)).FromMaybe(false)) {
|
||||
Q_ASSERT(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
//}
|
||||
|
@ -785,7 +789,7 @@ ScriptValue ScriptEngineV8::evaluateInClosure(const ScriptValue& _closure,
|
|||
}
|
||||
|
||||
const V8ScriptValue& closure = unwrappedClosure->toV8Value();
|
||||
const V8ScriptProgram& program = unwrappedProgram->toV8Value();
|
||||
//const V8ScriptProgram& program = unwrappedProgram->toV8Value();
|
||||
if (!closure.constGet()->IsObject()) {
|
||||
_evaluatingCounter--;
|
||||
qDebug(scriptengine) << "Unwrapped closure is not an object";
|
||||
|
@ -795,7 +799,9 @@ ScriptValue ScriptEngineV8::evaluateInClosure(const ScriptValue& _closure,
|
|||
closureObject = v8::Local<v8::Object>::Cast(closure.constGet());
|
||||
qDebug() << "Closure object members:" << scriptValueDebugListMembersV8(closure);
|
||||
v8::Local<v8::Object> testObject = v8::Object::New(_v8Isolate);
|
||||
testObject->Set(getContext(), v8::String::NewFromUtf8(_v8Isolate, "test_value").ToLocalChecked(), closureObject);
|
||||
if(!testObject->Set(getContext(), v8::String::NewFromUtf8(_v8Isolate, "test_value").ToLocalChecked(), closureObject).FromMaybe(false)) {
|
||||
Q_ASSERT(false);
|
||||
}
|
||||
qDebug() << "Test object members:" << scriptValueDebugListMembersV8(V8ScriptValue(_v8Isolate, testObject));
|
||||
|
||||
if (!closureObject->Get(closure.constGetContext(), v8::String::NewFromUtf8(_v8Isolate, "global").ToLocalChecked())
|
||||
|
@ -831,7 +837,7 @@ ScriptValue ScriptEngineV8::evaluateInClosure(const ScriptValue& _closure,
|
|||
// It might cause trouble
|
||||
{
|
||||
v8::Context::Scope contextScope(closureContext);
|
||||
const V8ScriptValue& closure = unwrappedClosure->toV8Value();
|
||||
//const V8ScriptValue& closure = unwrappedClosure->toV8Value();
|
||||
if (!unwrappedProgram->compile()) {
|
||||
qDebug(scriptengine) << "Can't compile script for evaluating in closure";
|
||||
Q_ASSERT(false);
|
||||
|
@ -868,15 +874,19 @@ ScriptValue ScriptEngineV8::evaluateInClosure(const ScriptValue& _closure,
|
|||
v8::TryCatch tryCatch(getIsolate());
|
||||
// Since V8 cannot use arbitrary object as global object, objects from main global need to be copied to closure's global object
|
||||
auto oldGlobalMemberNames = oldContext->Global()->GetPropertyNames(oldContext).ToLocalChecked();
|
||||
for (int i = 0; i < oldGlobalMemberNames->Length(); i++) {
|
||||
for (size_t i = 0; i < oldGlobalMemberNames->Length(); i++) {
|
||||
auto name = oldGlobalMemberNames->Get(closureContext, i).ToLocalChecked();
|
||||
closureContext->Global()->Set(closureContext, name, oldContext->Global()->Get(oldContext, name).ToLocalChecked());
|
||||
if(!closureContext->Global()->Set(closureContext, name, oldContext->Global()->Get(oldContext, name).ToLocalChecked()).FromMaybe(false)) {
|
||||
Q_ASSERT(false);
|
||||
}
|
||||
}
|
||||
// Objects from closure need to be copied to global object too
|
||||
auto closureMemberNames = closureObject->GetPropertyNames(closureContext).ToLocalChecked();
|
||||
for (int i = 0; i < closureMemberNames->Length(); i++) {
|
||||
for (size_t i = 0; i < closureMemberNames->Length(); i++) {
|
||||
auto name = closureMemberNames->Get(closureContext, i).ToLocalChecked();
|
||||
closureContext->Global()->Set(closureContext, name, closureObject->Get(closureContext, name).ToLocalChecked());
|
||||
if(!closureContext->Global()->Set(closureContext, name, closureObject->Get(closureContext, name).ToLocalChecked()).FromMaybe(false)) {
|
||||
Q_ASSERT(false);
|
||||
}
|
||||
}
|
||||
// List members of closure global object
|
||||
QString membersString("");
|
||||
|
@ -1483,16 +1493,19 @@ ScriptValue ScriptEngineV8::uncaughtException() const {
|
|||
//V8TODO
|
||||
//V8ScriptValue result = QScriptEngine::uncaughtException();
|
||||
//return ScriptValue(new ScriptValueV8Wrapper(const_cast<ScriptEngineV8*>(this), std::move(result)));
|
||||
return ScriptValue();
|
||||
}
|
||||
|
||||
QStringList ScriptEngineV8::uncaughtExceptionBacktrace() const {
|
||||
//V8TODO
|
||||
//return QScriptEngine::uncaughtExceptionBacktrace();
|
||||
return QStringList();
|
||||
}
|
||||
|
||||
int ScriptEngineV8::uncaughtExceptionLineNumber() const {
|
||||
//V8TODO
|
||||
//return QScriptEngine::uncaughtExceptionLineNumber();
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool ScriptEngineV8::raiseException(const ScriptValue& exception) {
|
||||
|
|
|
@ -50,14 +50,14 @@ void ScriptEngineV8::registerCustomType(int type,
|
|||
|
||||
Q_DECLARE_METATYPE(ScriptValue);
|
||||
|
||||
static V8ScriptValue ScriptValueToV8ScriptValue(ScriptEngineV8* engine, const ScriptValue& src) {
|
||||
/*static V8ScriptValue ScriptValueToV8ScriptValue(ScriptEngineV8* engine, const ScriptValue& src) {
|
||||
return ScriptValueV8Wrapper::fullUnwrap(static_cast<ScriptEngineV8*>(engine), src);
|
||||
}
|
||||
}*/
|
||||
|
||||
static void ScriptValueFromV8ScriptValue(ScriptEngineV8* engine, const V8ScriptValue& src, ScriptValue& dest) {
|
||||
/*static void ScriptValueFromV8ScriptValue(ScriptEngineV8* engine, const V8ScriptValue& src, ScriptValue& dest) {
|
||||
//ScriptEngineV8* engine = static_cast<ScriptEngineV8*>(src.engine());
|
||||
dest = ScriptValue(new ScriptValueV8Wrapper(engine, src));
|
||||
}
|
||||
}*/
|
||||
|
||||
static ScriptValue StringListToScriptValue(ScriptEngine* engine, const QStringList& src) {
|
||||
int len = src.length();
|
||||
|
|
|
@ -32,7 +32,7 @@ Q_DECLARE_METATYPE(QSharedPointer<ScriptVariantV8Proxy>)
|
|||
// Value of internal field with index 0 when object contains ScriptObjectV8Proxy pointer in internal field 1
|
||||
static const void *internalPointsToQObjectProxy = (void *)0x13370000;
|
||||
static const void *internalPointsToQVariantProxy = (void *)0x13371000;
|
||||
static const void *internalPointsToSignalProxy = (void *)0x13372000;
|
||||
//static const void *internalPointsToSignalProxy = (void *)0x13372000;
|
||||
static const void *internalPointsToMethodProxy = (void *)0x13373000;
|
||||
|
||||
// Used strictly to replace the "this" object value for property access. May expand to a full context element
|
||||
|
@ -328,7 +328,7 @@ QString ScriptObjectV8Proxy::name() const {
|
|||
ScriptObjectV8Proxy::QueryFlags ScriptObjectV8Proxy::queryProperty(const V8ScriptValue& object, const V8ScriptString& name, QueryFlags flags, uint* id) {
|
||||
v8::HandleScope handleScope(_engine->getIsolate());
|
||||
// V8TODO: this might be inefficient when there's large number of properties
|
||||
v8::Local<v8::Context> context = _engine->getContext();
|
||||
//v8::Local<v8::Context> context = _engine->getContext();
|
||||
v8::String::Utf8Value nameStr(_engine->getIsolate(), name.constGet());
|
||||
|
||||
// check for methods
|
||||
|
@ -473,7 +473,7 @@ V8ScriptValue ScriptObjectV8Proxy::property(const V8ScriptValue& object, const V
|
|||
qDebug(scriptengine) << "Method with QMetaType::UnknownType " << metaObject->className() << " " << (*iter).name();
|
||||
}
|
||||
} //V8TODO: is new method created during every call? It needs to be cached instead
|
||||
bool isMethodDefined = false;
|
||||
//bool isMethodDefined = false;
|
||||
v8::Local<v8::Value> property;
|
||||
if(_v8Object.Get(_engine->getIsolate())->GetInternalField(2).As<v8::Object>()->Get(_engine->getContext(), name.constGet()).ToLocal(&property)) {
|
||||
if (!property->IsUndefined()) {
|
||||
|
@ -1140,14 +1140,24 @@ void ScriptSignalV8Proxy::connect(ScriptValue arg0, ScriptValue arg1) {
|
|||
bool foundIt = false;
|
||||
for (int idx = 0; idx < length && !foundIt; ++idx) {
|
||||
v8::Local<v8::Value> entry = destArray->Get(destFunctionContext, idx).ToLocalChecked();
|
||||
newArray->Set(destFunctionContext, idx, entry);
|
||||
if (!newArray->Set(destFunctionContext, idx, entry).FromMaybe(false)) {
|
||||
Q_ASSERT(false);
|
||||
}
|
||||
}
|
||||
if (!newArray->Set(destFunctionContext, length, v8ThisObject.get()).FromMaybe(false)) {
|
||||
Q_ASSERT(false);
|
||||
}
|
||||
if (!destFunction->Set(destFunctionContext, destDataName, newArray).FromMaybe(false)) {
|
||||
Q_ASSERT(false);
|
||||
}
|
||||
newArray->Set(destFunctionContext, length, v8ThisObject.get());
|
||||
destFunction->Set(destFunctionContext, destDataName, newArray);
|
||||
} else {
|
||||
v8::Local<v8::Array> newArray = v8::Array::New(isolate, 1);
|
||||
newArray->Set(destFunctionContext, 0, v8ThisObject.get());
|
||||
destFunction->Set(destFunctionContext, destDataName, newArray);
|
||||
if (!newArray->Set(destFunctionContext, 0, v8ThisObject.get()).FromMaybe(false)) {
|
||||
Q_ASSERT(false);
|
||||
}
|
||||
if (destFunction->Set(destFunctionContext, destDataName, newArray).FromMaybe(false)) {
|
||||
Q_ASSERT(false);
|
||||
}
|
||||
}
|
||||
/*{
|
||||
V8ScriptValueList args;
|
||||
|
@ -1245,12 +1255,16 @@ void ScriptSignalV8Proxy::disconnect(ScriptValue arg0, ScriptValue arg1) {
|
|||
//args << idx << 1;
|
||||
//destData.property("splice").call(destData, args);
|
||||
} else {
|
||||
newArray->Set(destFunctionContext, newIndex, entry);
|
||||
if (!newArray->Set(destFunctionContext, newIndex, entry).FromMaybe(false)) {
|
||||
Q_ASSERT(false);
|
||||
}
|
||||
newIndex++;
|
||||
}
|
||||
}
|
||||
Q_ASSERT(foundIt);
|
||||
destFunction->Set(destFunctionContext, destDataName, newArray);
|
||||
if (!destFunction->Set(destFunctionContext, destDataName, newArray).FromMaybe(false)) {
|
||||
Q_ASSERT(false);
|
||||
}
|
||||
} else {
|
||||
Q_ASSERT(false);
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ bool ScriptProgramV8Wrapper::compile() {
|
|||
int errorLineNumber = 0;
|
||||
QString errorMessage = "";
|
||||
QString errorBacktrace = "";
|
||||
ScriptSyntaxCheckResult::State state;
|
||||
//ScriptSyntaxCheckResult::State state;
|
||||
v8::TryCatch tryCatch(isolate);
|
||||
v8::ScriptOrigin scriptOrigin(isolate, v8::String::NewFromUtf8(isolate, _url.toStdString().c_str()).ToLocalChecked());
|
||||
v8::Local<v8::Script> script;
|
||||
|
|
|
@ -77,7 +77,7 @@ V8ScriptValue V8ScriptValueIterator::value() {
|
|||
ScriptValue::PropertyFlags ScriptValueIteratorV8Wrapper::flags() const {
|
||||
//V8TODO
|
||||
//return (ScriptValue::PropertyFlags)(int)_value.flags();
|
||||
return (ScriptValue::PropertyFlags)(0);
|
||||
return ScriptValue::PropertyFlags();
|
||||
}
|
||||
|
||||
bool ScriptValueIteratorV8Wrapper::hasNext() const {
|
||||
|
|
|
@ -534,7 +534,7 @@ bool ScriptValueV8Wrapper::isBool() const {
|
|||
}
|
||||
|
||||
bool ScriptValueV8Wrapper::isError() const {
|
||||
auto isolate = _engine->getIsolate();
|
||||
//auto isolate = _engine->getIsolate();
|
||||
// Q_ASSERT(isolate->IsCurrent());
|
||||
// v8::HandleScope handleScope(isolate);
|
||||
// v8::Context::Scope contextScope(_engine->getContext());
|
||||
|
|
Loading…
Reference in a new issue