Overte C++ Documentation
ScriptContext.h
1
//
2
// ScriptContext.h
3
// libraries/script-engine/src
4
//
5
// Created by Heather Anderson on 5/1/21.
6
// Copyright 2021 Vircadia contributors.
7
// Copyright 2023 Overte e.V.
8
//
9
// Distributed under the Apache License, Version 2.0.
10
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
11
// SPDX-License-Identifier: Apache-2.0
12
//
13
16
17
#ifndef hifi_ScriptContext_h
18
#define hifi_ScriptContext_h
19
20
#include <memory>
21
22
#include <QtCore/QString>
23
#include <QtCore/QStringList>
24
25
#include "ScriptValue.h"
26
27
class
ScriptContext
;
28
class
ScriptEngine
;
29
class
ScriptFunctionContext
;
30
using
ScriptContextPointer = std::shared_ptr<ScriptContext>;
31
using
ScriptFunctionContextPointer = std::shared_ptr<ScriptFunctionContext>;
32
using
ScriptEnginePointer = std::shared_ptr<ScriptEngine>;
33
35
class
ScriptFunctionContext
{
36
public
:
37
enum
FunctionType {
38
ScriptFunction = 0,
39
QtFunction = 1,
40
QtPropertyFunction = 2,
41
NativeFunction = 3,
42
};
43
44
public
:
45
virtual
QString fileName()
const
= 0;
46
virtual
QString functionName()
const
= 0;
47
virtual
FunctionType functionType()
const
= 0;
48
virtual
int
lineNumber()
const
= 0;
49
50
protected
:
51
~
ScriptFunctionContext
() {}
// prevent explicit deletion of base class
52
};
53
55
class
ScriptContext
{
56
public
:
57
virtual
int
argumentCount()
const
= 0;
58
virtual
ScriptValue
argument(
int
index)
const
= 0;
59
virtual
QStringList backtrace()
const
= 0;
60
61
// Name of the file in which message was generated. Empty string when no file name is available.
62
virtual
int
currentLineNumber()
const
= 0;
63
64
// Number of the line on which message was generated. -1 if there line number is not available.
65
virtual
QString currentFileName()
const
= 0;
66
67
virtual
ScriptValue
callee()
const
= 0;
68
virtual
ScriptEnginePointer engine()
const
= 0;
69
virtual
ScriptFunctionContextPointer functionContext()
const
= 0;
70
virtual
ScriptContextPointer parentContext()
const
= 0;
71
virtual
ScriptValue
thisObject()
const
= 0;
72
virtual
ScriptValue
throwError(
const
QString& text) = 0;
73
virtual
ScriptValue
throwValue(
const
ScriptValue
& value) = 0;
74
75
protected
:
76
~
ScriptContext
() {}
// prevent explicit deletion of base class
77
};
78
79
class
ScriptContextGuard {
80
public
:
81
ScriptContextGuard(
ScriptContext
* context);
82
~ScriptContextGuard();
83
84
private
:
85
ScriptContext
* _oldContext;
86
};
87
88
#endif
// hifi_ScriptContext_h
89
ScriptContext
[ScriptInterface] Provides an engine-independent interface for QScriptContext
Definition:
ScriptContext.h:55
ScriptEngine
Provides an engine-independent interface for a scripting engine.
Definition:
ScriptEngine.h:93
ScriptFunctionContext
[ScriptInterface] Provides an engine-independent interface for QScriptContextInfo
Definition:
ScriptContext.h:35
ScriptValue
[ScriptInterface] Provides an engine-independent interface for QScriptValue
Definition:
ScriptValue.h:40
libraries
script-engine
src
ScriptContext.h
Generated by
1.9.1