Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
qt-creator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tobias Hunger
qt-creator
Commits
98474002
Commit
98474002
authored
15 years ago
by
Roberto Raggi
Browse files
Options
Downloads
Patches
Plain Diff
Store all the object-based values in the QML/JS interpreter.
parent
280a99b6
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/libs/qmljs/qmljsinterpreter.cpp
+13
-28
13 additions, 28 deletions
src/libs/qmljs/qmljsinterpreter.cpp
src/libs/qmljs/qmljsinterpreter.h
+3
-4
3 additions, 4 deletions
src/libs/qmljs/qmljsinterpreter.h
with
16 additions
and
32 deletions
src/libs/qmljs/qmljsinterpreter.cpp
+
13
−
28
View file @
98474002
...
...
@@ -127,7 +127,6 @@ public:
MetaFunction
(
const
QMetaMethod
&
method
,
Engine
*
engine
)
:
FunctionValue
(
engine
),
_method
(
method
)
{
engine
->
registerObject
(
this
);
}
virtual
const
Value
*
returnValue
()
const
...
...
@@ -748,8 +747,11 @@ bool MemberProcessor::processGeneratedSlot(const QString &, const Value *)
}
ObjectValue
::
ObjectValue
(
Engine
*
engine
)
:
_engine
(
engine
),
_prototype
(
0
),
_scope
(
0
)
:
_engine
(
engine
),
_prototype
(
0
),
_scope
(
0
)
{
engine
->
registerObject
(
this
);
}
ObjectValue
::~
ObjectValue
()
...
...
@@ -869,9 +871,8 @@ const Value *ObjectValue::lookupMember(const QString &name) const
return
0
;
}
Activation
::
Activation
(
Engine
*
engine
)
:
ObjectValue
(
engine
),
_thisObject
(
0
),
Activation
::
Activation
()
:
_thisObject
(
0
),
_calledAsFunction
(
true
)
{
}
...
...
@@ -931,7 +932,7 @@ FunctionValue::~FunctionValue()
const
Value
*
FunctionValue
::
construct
(
const
ValueList
&
actuals
)
const
{
Activation
activation
(
engine
());
// ### FIXME: create on the heap
Activation
activation
;
activation
.
setCalledAsConstructor
(
true
);
activation
.
setThisObject
(
engine
()
->
newObject
());
activation
.
setArguments
(
actuals
);
...
...
@@ -940,7 +941,7 @@ const Value *FunctionValue::construct(const ValueList &actuals) const
const
Value
*
FunctionValue
::
call
(
const
ValueList
&
actuals
)
const
{
Activation
activation
(
engine
());
// ### FIXME: create on the heap
Activation
activation
;
activation
.
setCalledAsFunction
(
true
);
activation
.
setThisObject
(
engine
()
->
globalObject
());
// ### FIXME: it should be `null'
activation
.
setArguments
(
actuals
);
...
...
@@ -949,7 +950,7 @@ const Value *FunctionValue::call(const ValueList &actuals) const
const
Value
*
FunctionValue
::
call
(
const
ObjectValue
*
thisObject
,
const
ValueList
&
actuals
)
const
{
Activation
activation
(
engine
());
// ### FIXME: create on the heap
Activation
activation
;
activation
.
setCalledAsFunction
(
true
);
activation
.
setThisObject
(
const_cast
<
ObjectValue
*>
(
thisObject
));
// ### FIXME: remove the const_cast
activation
.
setArguments
(
actuals
);
...
...
@@ -1316,10 +1317,7 @@ Engine::Engine()
Engine
::~
Engine
()
{
QList
<
ObjectValue
*>::
iterator
it
=
_objects
.
begin
();
for
(;
it
!=
_objects
.
end
();
++
it
)
delete
*
it
;
qDeleteAll
(
_registeredObjects
);
}
const
NullValue
*
Engine
::
nullValue
()
const
...
...
@@ -1361,14 +1359,13 @@ ObjectValue *Engine::newObject(const ObjectValue *prototype)
{
ObjectValue
*
object
=
new
ObjectValue
(
this
);
object
->
setPrototype
(
prototype
);
_objects
.
push_back
(
object
);
return
object
;
}
Function
*
Engine
::
newFunction
()
{
Function
*
Engine
::
newFunction
()
{
Function
*
function
=
new
Function
(
this
);
function
->
setPrototype
(
functionPrototype
());
_objects
.
push_back
(
function
);
return
function
;
}
...
...
@@ -1464,7 +1461,7 @@ const ObjectValue *Engine::mathObject() const
void
Engine
::
registerObject
(
ObjectValue
*
object
)
{
_
o
bjects
.
append
(
object
);
_
registeredO
bjects
.
append
(
object
);
}
const
Value
*
Engine
::
convertToBoolean
(
const
Value
*
value
)
...
...
@@ -1527,42 +1524,34 @@ void Engine::initializePrototypes()
// set up the default Object prototype
_objectCtor
=
new
ObjectCtor
(
this
);
_objectCtor
->
setPrototype
(
_functionPrototype
);
_objects
.
push_back
(
_objectCtor
);
_objectCtor
->
setProperty
(
"prototype"
,
_objectPrototype
);
_functionCtor
=
new
FunctionCtor
(
this
);
_functionCtor
->
setPrototype
(
_functionPrototype
);
_objects
.
push_back
(
_functionCtor
);
_functionCtor
->
setProperty
(
"prototype"
,
_functionPrototype
);
_arrayCtor
=
new
ArrayCtor
(
this
);
_arrayCtor
->
setPrototype
(
_functionPrototype
);
_objects
.
push_back
(
_arrayCtor
);
_arrayCtor
->
setProperty
(
"prototype"
,
_arrayPrototype
);
_stringCtor
=
new
StringCtor
(
this
);
_stringCtor
->
setPrototype
(
_functionPrototype
);
_objects
.
push_back
(
_stringCtor
);
_stringCtor
->
setProperty
(
"prototype"
,
_stringPrototype
);
_booleanCtor
=
new
BooleanCtor
(
this
);
_booleanCtor
->
setPrototype
(
_functionPrototype
);
_objects
.
push_back
(
_booleanCtor
);
_booleanCtor
->
setProperty
(
"prototype"
,
_booleanPrototype
);
_numberCtor
=
new
NumberCtor
(
this
);
_numberCtor
->
setPrototype
(
_functionPrototype
);
_objects
.
push_back
(
_numberCtor
);
_numberCtor
->
setProperty
(
"prototype"
,
_numberPrototype
);
_dateCtor
=
new
DateCtor
(
this
);
_dateCtor
->
setPrototype
(
_functionPrototype
);
_objects
.
push_back
(
_dateCtor
);
_dateCtor
->
setProperty
(
"prototype"
,
_datePrototype
);
_regexpCtor
=
new
RegExpCtor
(
this
);
_regexpCtor
->
setPrototype
(
_functionPrototype
);
_objects
.
push_back
(
_regexpCtor
);
_regexpCtor
->
setProperty
(
"prototype"
,
_regexpPrototype
);
addFunction
(
_objectCtor
,
"getPrototypeOf"
,
1
);
...
...
@@ -1764,7 +1753,6 @@ void Engine::initializePrototypes()
#ifndef NO_DECLARATIVE_BACKEND
_qmlKeysObject
=
new
QmlAttachedKeys
(
this
);
_globalObject
->
setProperty
(
"Keys"
,
_qmlKeysObject
);
// ### attach it to the current scope, and not to the global object
registerObject
(
_qmlKeysObject
);
#endif
}
...
...
@@ -1795,11 +1783,9 @@ QmlObjectValue *Engine::newQmlObject(const QString &name, const QString &prefix,
{
if
(
name
==
QLatin1String
(
"QmlGraphicsAnchors"
))
{
QmlObjectValue
*
object
=
new
QmlObjectValue
(
&
QmlGraphicsAnchors
::
staticMetaObject
,
QLatin1String
(
"Anchors"
),
-
1
,
-
1
,
this
);
_objects
.
append
(
object
);
return
object
;
}
else
if
(
name
==
QLatin1String
(
"QmlGraphicsPen"
))
{
QmlObjectValue
*
object
=
new
QmlObjectValue
(
&
QmlGraphicsPen
::
staticMetaObject
,
QLatin1String
(
"Pen"
),
-
1
,
-
1
,
this
);
_objects
.
append
(
object
);
return
object
;
}
else
if
(
name
==
QLatin1String
(
"QmlGraphicsScaleGrid"
))
{
QmlObjectValue
*
object
=
new
QmlObjectValue
(
&
QObject
::
staticMetaObject
,
QLatin1String
(
"ScaleGrid"
),
-
1
,
-
1
,
this
);
...
...
@@ -1817,7 +1803,6 @@ QmlObjectValue *Engine::newQmlObject(const QString &name, const QString &prefix,
const
QString
typeName
=
qmlType
->
qmlTypeName
();
const
QString
strippedTypeName
=
typeName
.
mid
(
typeName
.
lastIndexOf
(
'/'
)
+
1
);
QmlObjectValue
*
object
=
new
QmlObjectValue
(
qmlType
->
metaObject
(),
strippedTypeName
,
majorVersion
,
minorVersion
,
this
);
_objects
.
append
(
object
);
return
object
;
}
...
...
This diff is collapsed.
Click to expand it.
src/libs/qmljs/qmljsinterpreter.h
+
3
−
4
View file @
98474002
...
...
@@ -281,10 +281,10 @@ private:
#endif // !NO_DECLARATIVE_BACKEND
class
QMLJS_EXPORT
Activation
:
public
ObjectValue
class
QMLJS_EXPORT
Activation
{
public:
Activation
(
Engine
*
engine
);
Activation
();
virtual
~
Activation
();
bool
calledAsConstructor
()
const
;
...
...
@@ -514,7 +514,6 @@ public:
const
MetaTypeSystem
&
metaTypeSystem
()
const
{
return
_metaTypeSystem
;
}
private
:
void
initializePrototypes
();
...
...
@@ -551,7 +550,7 @@ private:
NumberValue
_numberValue
;
BooleanValue
_booleanValue
;
StringValue
_stringValue
;
QList
<
ObjectValue
*>
_
o
bjects
;
QList
<
ObjectValue
*>
_
registeredO
bjects
;
ConvertToNumber
_convertToNumber
;
ConvertToString
_convertToString
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment