Fixed C++ function calls for V8

This commit is contained in:
ksuprynowicz 2022-10-15 19:43:05 +02:00
parent abfcbb7588
commit be3d1713a8
3 changed files with 6 additions and 4 deletions

View file

@ -13,7 +13,7 @@
#include "ScriptEngineLogging.h"
//V8TODO name is misleading, it's actually undefined
class ScriptValueProxyNull final : public ScriptValueProxy {
public:
virtual void release() override;

View file

@ -50,9 +50,9 @@ int ScriptContextV8Wrapper::argumentCount() const {
//Q_ASSERT(_functionCallbackInfo);A
// V8TODO
if (_functionCallbackInfo) {
return _functionCallbackInfo->kArgsLength;
return _functionCallbackInfo->Length();
} else if (_propertyCallbackInfo) {
return _propertyCallbackInfo->kArgsLength;
return 0;
} else {
return Q_METAMETHOD_INVOKE_MAX_ARGS;
}

View file

@ -1157,7 +1157,9 @@ ScriptValue ScriptEngineV8::newFunction(ScriptEngine::FunctionSignature fun, int
//V8TODO: this scriptContext needs to have FunctionCallbackInfo added
ScriptValue result = function(&scriptContext, scriptEngine);
ScriptValueV8Wrapper* unwrapped = ScriptValueV8Wrapper::unwrap(result);
info.GetReturnValue().Set(unwrapped->toV8Value().constGet());
if (unwrapped) {
info.GetReturnValue().Set(unwrapped->toV8Value().constGet());
}
};
//auto functionTemplate = v8::FunctionTemplate::New(_v8Isolate, v8FunctionCallback, v8::Local<v8::Value>(), v8::Local<v8::Signature>(), length);
//auto functionData = v8::Object::New(_v8Isolate);