Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
flatpak-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
Marco Bubke
flatpak-qt-creator
Commits
a8bc5a4b
Commit
a8bc5a4b
authored
15 years ago
by
Roberto Raggi
Browse files
Options
Downloads
Patches
Plain Diff
Create bindings for the javascript soure elements.
parent
15ae1001
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/libs/qmljs/qmljsbind.cpp
+63
-2
63 additions, 2 deletions
src/libs/qmljs/qmljsbind.cpp
src/libs/qmljs/qmljsbind.h
+4
-0
4 additions, 0 deletions
src/libs/qmljs/qmljsbind.h
src/libs/qmljs/qmljslink.cpp
+0
-1
0 additions, 1 deletion
src/libs/qmljs/qmljslink.cpp
with
67 additions
and
3 deletions
src/libs/qmljs/qmljsbind.cpp
+
63
−
2
View file @
a8bc5a4b
...
...
@@ -120,6 +120,42 @@ public:
}
};
class
ProcessSourceElements
:
protected
AST
::
Visitor
{
Interpreter
::
Engine
*
_interp
;
public:
ProcessSourceElements
(
Interpreter
::
Engine
*
interp
)
:
_interp
(
interp
)
{
}
void
operator
()(
AST
::
Node
*
node
)
{
if
(
node
)
node
->
accept
(
this
);
}
protected
:
using
AST
::
Visitor
::
visit
;
virtual
bool
visit
(
FunctionDeclaration
*
ast
)
{
if
(
ast
->
name
)
_interp
->
globalObject
()
->
setProperty
(
ast
->
name
->
asString
(),
new
ASTFunctionValue
(
ast
,
_interp
));
return
false
;
}
virtual
bool
visit
(
VariableDeclaration
*
ast
)
{
if
(
ast
->
name
)
_interp
->
globalObject
()
->
setProperty
(
ast
->
name
->
asString
(),
_interp
->
undefinedValue
());
return
false
;
}
};
}
// end of anonymous namespace
Bind
::
Bind
(
Document
::
Ptr
doc
,
const
Snapshot
&
snapshot
,
Interpreter
::
Engine
*
interp
)
...
...
@@ -152,6 +188,11 @@ Bind::~Bind()
{
}
QStringList
Bind
::
includedScripts
()
const
{
return
_includedScripts
;
}
ObjectValue
*
Bind
::
switchObjectValue
(
ObjectValue
*
newObjectValue
)
{
ObjectValue
*
oldObjectValue
=
_currentObjectValue
;
...
...
@@ -177,10 +218,30 @@ ObjectValue *Bind::scopeChainAt(Document::Ptr currentDocument, const Snapshot &s
LinkImports
linkImports
;
Link
link
;
// link the import directives
linkImports
(
binds
);
// link the scripts
QStringList
includedScriptFiles
;
foreach
(
Bind
*
bind
,
binds
)
includedScriptFiles
+=
bind
->
includedScripts
();
includedScriptFiles
.
removeDuplicates
();
ProcessSourceElements
processSourceElements
(
interp
);
foreach
(
const
QString
&
scriptFile
,
includedScriptFiles
)
{
if
(
Document
::
Ptr
scriptDoc
=
snapshot
.
document
(
scriptFile
))
{
if
(
AST
::
Program
*
program
=
scriptDoc
->
jsProgram
())
{
processSourceElements
(
program
);
}
}
}
ObjectValue
*
scope
=
interp
->
globalObject
();
if
(
currentBind
)
scope
=
link
(
binds
,
currentBind
,
currentObject
);
qDeleteAll
(
binds
);
return
scope
;
...
...
@@ -222,8 +283,8 @@ void Bind::processScript(AST::UiQualifiedId *qualifiedId, AST::UiObjectInitializ
if
(
bindingName
==
QLatin1String
(
"source"
))
{
if
(
StringLiteral
*
literal
=
cast
<
StringLiteral
*>
(
expression
(
binding
)))
{
QFileInfo
fileInfo
(
QDir
(
_doc
->
path
()),
literal
->
value
->
asString
());
Document
::
Ptr
script
=
_snapshot
.
document
(
fileInfo
.
absoluteFilePath
()
)
;
// ### process the script
const
QString
scriptPath
=
fileInfo
.
absoluteFilePath
();
_includedScripts
.
append
(
scriptPath
);
}
}
}
else
if
(
UiSourceElement
*
binding
=
cast
<
UiSourceElement
*>
(
it
->
member
))
{
...
...
This diff is collapsed.
Click to expand it.
src/libs/qmljs/qmljsbind.h
+
4
−
0
View file @
a8bc5a4b
...
...
@@ -35,6 +35,7 @@
#include
<qmljs/qmljsinterpreter.h>
#include
<QtCore/QHash>
#include
<QtCore/QStringList>
namespace
QmlJS
{
...
...
@@ -49,6 +50,8 @@ protected:
public:
virtual
~
Bind
();
QStringList
includedScripts
()
const
;
// ### TODO: This methods should go. Bind each document after parsing, link later.
static
Interpreter
::
ObjectValue
*
scopeChainAt
(
Document
::
Ptr
currentDocument
,
const
Snapshot
&
snapshot
,
...
...
@@ -91,6 +94,7 @@ private:
QHash
<
AST
::
UiObjectDefinition
*
,
Interpreter
::
ObjectValue
*>
_qmlObjectDefinitions
;
QHash
<
AST
::
UiObjectBinding
*
,
Interpreter
::
ObjectValue
*>
_qmlObjectBindings
;
QStringList
_includedScripts
;
friend
class
LinkImports
;
friend
class
Link
;
...
...
This diff is collapsed.
Click to expand it.
src/libs/qmljs/qmljslink.cpp
+
0
−
1
View file @
a8bc5a4b
...
...
@@ -148,7 +148,6 @@ void LinkImports::operator()(const QList<Bind *> &binds)
ObjectValue
*
Link
::
operator
()(
const
QList
<
Bind
*>
&
binds
,
Bind
*
currentBind
,
UiObjectMember
*
currentObject
)
{
Q_UNUSED
(
binds
);
ObjectValue
*
scopeObject
;
if
(
UiObjectDefinition
*
definition
=
cast
<
UiObjectDefinition
*>
(
currentObject
))
scopeObject
=
currentBind
->
_qmlObjectDefinitions
.
value
(
definition
);
...
...
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