History

More fixes for V8

ksuprynowicz committed 3 years ago

Commit 97137c71 parent 2f9f78f9 files · +214 −72Browse files

Showing the changes to libraries/script-engine/src/v8/ScriptObjectV8Proxy.cpp (1 of 9 files). Show all

Unified · Split

libraries/script-engine/src/v8/ScriptObjectV8Proxy.cpp+13−5
@@ -657,6 +657,10 @@ void ScriptMethodV8Proxy::call(const v8::FunctionCallbackInfo<v8::Value>& argume · 656 unmodified lines
657 int bestMeta = 0;657 int bestMeta = 0;
658 int bestConversionPenaltyScore = 0;658 int bestConversionPenaltyScore = 0;
659 659
660 if(fullName() == "SettingsScriptingInterface::getValue") {
661 printf("SettingsScriptingInterface::getValue");
662 }
663
660 for (int i = 0; i < num_metas; i++) {664 for (int i = 0; i < num_metas; i++) {
661 const QMetaMethod& meta = _metas[i];665 const QMetaMethod& meta = _metas[i];
662 int methodNumArgs = meta.parameterCount();666 int methodNumArgs = meta.parameterCount();
@@ -783,21 +787,25 @@ void ScriptMethodV8Proxy::call(const v8::FunctionCallbackInfo<v8::Value>& argume · 120 unmodified lines
783 int methodArgTypeId = meta.parameterType(arg);787 int methodArgTypeId = meta.parameterType(arg);
784 Q_ASSERT(methodArgTypeId != QMetaType::UnknownType);788 Q_ASSERT(methodArgTypeId != QMetaType::UnknownType);
785 v8::Local<v8::Value> argVal = arguments[arg];789 v8::Local<v8::Value> argVal = arguments[arg];
786 if (methodArgTypeId != scriptValueTypeId && methodArgTypeId != QMetaType::QVariant) {790 if (methodArgTypeId != scriptValueTypeId) {
787 QVariant varArgVal;791 QVariant varArgVal;
788 if (!_engine->castValueToVariant(V8ScriptValue(isolate, argVal), varArgVal, methodArgTypeId)) {792 if (!_engine->castValueToVariant(V8ScriptValue(isolate, argVal), varArgVal, methodArgTypeId)) {
789 QByteArray methodTypeName = QMetaType(methodArgTypeId).name();793 QByteArray methodTypeName = QMetaType(methodArgTypeId).name();
790 QByteArray argTypeName = _engine->valueType(V8ScriptValue(isolate, argVal)).toLatin1();794 QByteArray argTypeName = _engine->valueType(V8ScriptValue(isolate, argVal)).toLatin1();
791 isolate->ThrowError(v8::String::NewFromUtf8(isolate, QString("Native call of %1 failed: Cannot convert parameter %2 from %3 to %4")795 QString errorMessage = QString("Native call of %1 failed: Cannot convert parameter %2 from %3 to %4")
792 .arg(fullName()).arg(arg+1).arg(argTypeName, methodTypeName).toStdString().c_str()).ToLocalChecked());796 .arg(fullName()).arg(arg+1).arg(argTypeName, methodTypeName);
797 qDebug(scriptengine) << errorMessage;
798 isolate->ThrowError(v8::String::NewFromUtf8(isolate, errorMessage.toStdString().c_str()).ToLocalChecked());
793 //context->throwError(V8ScriptContext::TypeError, QString("Native call of %1 failed: Cannot convert parameter %2 from %3 to %4")799 //context->throwError(V8ScriptContext::TypeError, QString("Native call of %1 failed: Cannot convert parameter %2 from %3 to %4")
794 // .arg(fullName()).arg(arg+1).arg(argTypeName, methodTypeName));800 // .arg(fullName()).arg(arg+1).arg(argTypeName, methodTypeName));
795 return;801 return;
796 }802 }
797 }803 }
798 }804 }
799 805 QString errorMessage = QString("Native call of %1 failed: could not locate an overload with the requested arguments").arg(fullName());
800 isolate->ThrowError(v8::String::NewFromUtf8(isolate, QString("Native call of %1 failed: could not locate an overload with the requested arguments").arg(fullName()).toStdString().c_str()).ToLocalChecked());806 qDebug(scriptengine) << errorMessage;
807 isolate->ThrowError(v8::String::NewFromUtf8(isolate, errorMessage.toStdString().c_str()).ToLocalChecked());
808 // V8TODO: it happens sometimes for some reason
801 Q_ASSERT(false); // really shouldn't have gotten here -- it didn't work before and it's working now?809 Q_ASSERT(false); // really shouldn't have gotten here -- it didn't work before and it's working now?
802 return;810 return;
803}811}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t