Removed script engine lambda

This commit is contained in:
ksuprynowicz 2023-05-01 20:12:51 +02:00
parent 5050cc9a4e
commit 30f4608c25
2 changed files with 0 additions and 101 deletions

View file

@ -52,7 +52,6 @@
#include "ScriptObjectV8Proxy.h"
#include "ScriptProgramV8Wrapper.h"
#include "ScriptValueV8Wrapper.h"
#include "V8Lambda.h"
#include "ScriptEngineLoggingV8.h"
static const int MAX_DEBUG_VALUE_LENGTH { 80 };
@ -149,63 +148,6 @@ ScriptValue ScriptEngineV8::checkScriptSyntax(ScriptProgramPointer program) {
return undefinedValue();
}
// Lambda
/*ScriptValue ScriptEngineV8::newLambdaFunction(std::function<V8ScriptValue(V8ScriptContext*, ScriptEngineV8*)> operation,
const V8ScriptValue& data,
const ValueOwnership& ownership) {
v8::HandleScope handleScope(_v8Isolate);
v8::Context::Scope contextScope(getContext());
auto lambda = new Lambda(this, operation, data);
auto object = newQObject(lambda, ownership);
//V8TODO - I'm not sure if this works
auto call = object.property("call");
call.setPrototype(object); // context->callee().prototype() === Lambda QObject
call.setData(ScriptValue(new ScriptValueV8Wrapper(this, data))); // context->callee().data() will === data param
return call;
}*/
QString Lambda::toString() const {
v8::Locker locker(_engine->getIsolate());
v8::Isolate::Scope isolateScope(_engine->getIsolate());
v8::HandleScope handleScope(_engine->getIsolate());
v8::Context::Scope contextScope(_engine->getContext());
v8::Local<v8::String> string;
QString qString("");
if (_data.constGet()->ToString(_engine->getContext()).ToLocal(&string)) {
v8::String::Utf8Value utf8Value(_engine->getIsolate(), string);
qString = QString(*utf8Value);
}
//V8TODO it was data.isValid() originally
//I have no idea what happens here
return QString("[Lambda%1]").arg((!_data.constGet()->IsNullOrUndefined()) ? " " + qString : qString);
}
Lambda::~Lambda() {
#ifdef DEBUG_JS_LAMBDA_FUNCS
qCDebug(scriptengine_v8) << "~Lambda"
<< "this" << this;
#endif
}
Lambda::Lambda(ScriptEngineV8* engine,
std::function<V8ScriptValue(ScriptEngineV8*)> operation,
V8ScriptValue data) :
_engine(engine),
_operation(operation), _data(data) {
#ifdef DEBUG_JS_LAMBDA_FUNCS
qCDebug(scriptengine_v8) << "Lambda" << data.toString();
#endif
}
V8ScriptValue Lambda::call() {
if (!_engine->IS_THREADSAFE_INVOCATION(__FUNCTION__)) {
return V8ScriptValue(_engine, v8::Null(_engine->getIsolate()));
}
// V8TODO: it needs to be done in entirely different way for V8
Q_ASSERT(false);
//return _operation(_engine->getContext(), _engine);
//return V8ScriptValue(_engine->getIsolate(), v8::Null(_engine->getIsolate()));
//return operation(static_cast<QScriptEngine*>(engine)->currentContext(), engine);
}
#ifdef DEBUG_JS
void ScriptEngineV8::_debugDump(const QString& header, const V8ScriptValue& object, const QString& footer) {
// V8TODO

View file

@ -1,43 +0,0 @@
//
// V8Lambda.h
// split from ScriptEngineV8.h
// libraries/script-engine/src/qtscript
//
// Created by Brad Hefta-Gaub on 12/14/13.
// Modified for V8 by dr Karol Suprynowicz on 2022/10/08
// Copyright 2013 High Fidelity, Inc.
// Copyright 2020 Vircadia contributors.
// Copyright 2022-2023 Overte e.V.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// SPDX-License-Identifier: Apache-2.0
//
#ifndef hifi_V8Lambda_h
#define hifi_V8Lambda_h
#include "ScriptEngineV8.h"
#include "V8Types.h"
// Lambda helps create callable V8ScriptValues out of std::functions:
// (just meant for use from within the script engine itself)
// V8TODO: this looks like it can be safely removed?
class Lambda : public QObject {
Q_OBJECT
public:
Lambda(ScriptEngineV8* engine,
std::function<V8ScriptValue(ScriptEngineV8* engine)> operation,
V8ScriptValue data);
~Lambda();
public slots:
V8ScriptValue call();
QString toString() const;
private:
ScriptEngineV8* _engine;
std::function<V8ScriptValue(ScriptEngineV8* engine)> _operation;
V8ScriptValue _data;
};
#endif