Skip to content
GitLab
Explorer
Connexion
Navigation principale
Rechercher ou aller à…
Projet
Vivy
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Wiki
Wiki externe
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Compilation
Pipelines
Jobs
Planifications de pipeline
Artéfacts
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté GitLab
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
Elliu
Vivy
Validations
f50f5665
Vérifiée
Valider
f50f5665
rédigé
5 août 2021
par
Kubat
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
SCRIPT: Load the lib.lua and module.lua at the end of the LuaContext creation
parent
b693b8f3
Branches
Branches contenant la validation
Aucune étiquette associée trouvée
1 requête de fusion
!16
Add a way to execute a Lua file with Vivy in a click-click way
Modifications
2
Afficher les modifications d'espaces
En ligne
Côte à côte
Affichage de
2 fichiers modifiés
src/Lib/Script/LuaContext.cc
+13
-6
13 ajouts, 6 suppressions
src/Lib/Script/LuaContext.cc
src/Lib/Script/LuaContext.hh
+1
-0
1 ajout, 0 suppression
src/Lib/Script/LuaContext.hh
avec
14 ajouts
et
6 suppressions
src/Lib/Script/LuaContext.cc
+
13
−
6
Voir le fichier @
f50f5665
...
...
@@ -16,9 +16,6 @@ LuaContext::LuaContext(ScriptStore::LoggerType &out, ScriptStore::LoggerType &er
,
streamErr
(
err
)
{
luaL_openlibs
(
L
);
QFile
libVivy
(
":lua/lib.lua"
);
if
(
!
libVivy
.
open
(
QIODevice
::
ReadOnly
|
QIODevice
::
Text
))
qFatal
(
"Failed to find packaged libVivy (:lia/lib.lua)"
);
// Register this context
contextList
.
emplace
(
L
,
this
);
...
...
@@ -31,7 +28,8 @@ LuaContext::LuaContext(ScriptStore::LoggerType &out, ScriptStore::LoggerType &er
ModuleDeclaration
::
Register
(
L
);
// Load the lib
loadString
(
libVivy
.
readAll
().
toStdString
().
c_str
());
loadPackagedFile
(
":lua/lib.lua"
);
loadPackagedFile
(
":lua/module.lua"
);
}
LuaContext
::~
LuaContext
()
noexcept
...
...
@@ -40,6 +38,15 @@ LuaContext::~LuaContext() noexcept
contextList
.
erase
(
L
);
// Unregister the context
}
void
LuaContext
::
loadPackagedFile
(
const
QString
&
url
)
noexcept
{
QFile
libVivy
(
url
);
if
(
!
libVivy
.
open
(
QIODevice
::
ReadOnly
|
QIODevice
::
Text
))
qFatal
(
"FATA -> failed to find packaged Vivy file %s"
,
url
.
toStdString
().
c_str
());
loadString
(
libVivy
.
readAll
().
toStdString
().
c_str
());
}
LuaContext
*
LuaContext
::
getContext
(
const
lua_State
*
const
state
)
noexcept
{
...
...
@@ -79,7 +86,7 @@ LuaContext::Code
LuaContext
::
loadString
(
const
char
*
str
)
noexcept
{
if
(
luaL_loadstring
(
L
,
str
)
!=
LUA_OK
)
{
err
(
this
)
<<
"Error loading string
\n
"
;
err
(
this
)
<<
"Error loading string
: "
<<
getLastError
().
toStdString
()
<<
"
\n
"
;
return
Code
::
Error
;
}
return
exec
();
...
...
@@ -89,7 +96,7 @@ LuaContext::Code
LuaContext
::
loadFile
(
const
char
*
file
)
noexcept
{
if
(
luaL_loadfile
(
L
,
file
)
!=
LUA_OK
)
{
err
(
this
)
<<
"Error loading file "
<<
file
<<
"
\n
"
;
err
(
this
)
<<
"Error loading file "
<<
file
<<
": "
<<
getLastError
().
toStdString
()
<<
"
\n
"
;
return
Code
::
Error
;
}
return
exec
();
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
src/Lib/Script/LuaContext.hh
+
1
−
0
Voir le fichier @
f50f5665
...
...
@@ -48,6 +48,7 @@ private:
Code
loadString
(
const
char
*
)
noexcept
;
Code
loadFile
(
const
char
*
)
noexcept
;
void
loadPackagedFile
(
const
QString
&
)
noexcept
;
// Swap the env, needed before executing a user script!
void
swapEnv
()
noexcept
;
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter