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
bc9b385d
Vérifiée
Valider
bc9b385d
rédigé
6 août 2021
par
Kubat
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
SCRIPT: Begin implementation of declaration script classes
parent
d633e0fe
Aucune branche associée trouvée
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/CRTPLuaScriptObject.cc
+14
-3
14 ajouts, 3 suppressions
src/Lib/Script/CRTPLuaScriptObject.cc
src/Lib/Script/CRTPLuaScriptObject.hh
+13
-15
13 ajouts, 15 suppressions
src/Lib/Script/CRTPLuaScriptObject.hh
avec
27 ajouts
et
18 suppressions
src/Lib/Script/CRTPLuaScriptObject.cc
+
14
−
3
Voir le fichier @
bc9b385d
...
...
@@ -93,12 +93,17 @@ OptionDeclaration::addOptionContent(lua_State *) noexcept
// JobDeclaration
JobDeclaration
::
JobDeclaration
(
lua_State
*
)
noexcept
{}
JobDeclaration
::~
JobDeclaration
()
noexcept
{}
int
JobDeclaration
::
setName
(
lua_State
*
)
noexcept
JobDeclaration
::
setName
(
lua_State
*
L
)
noexcept
{
std
::
size_t
len
=
0
;
auto
*
const
context
=
LuaContext
::
getContext
(
L
);
JobDeclaration
*
const
job
=
JobDeclaration
::
CHECK
(
L
,
1
);
const
char
*
cStrName
=
luaL_checklstring
(
L
,
2
,
&
len
);
job
->
name
=
std
::
string_view
(
cStrName
,
len
);
err
(
context
)
<<
"Set name of job to "
<<
job
->
name
<<
"
\n
"
;
return
0
;
}
...
...
@@ -109,8 +114,14 @@ JobDeclaration::setOptions(lua_State *) noexcept
}
int
JobDeclaration
::
setImportFromScript
(
lua_State
*
)
noexcept
JobDeclaration
::
setImportFromScript
(
lua_State
*
L
)
noexcept
{
std
::
size_t
len
=
0
;
auto
*
const
context
=
LuaContext
::
getContext
(
L
);
JobDeclaration
*
const
job
=
JobDeclaration
::
CHECK
(
L
,
1
);
const
char
*
cStrName
=
luaL_checklstring
(
L
,
2
,
&
len
);
job
->
parentScript
=
std
::
string_view
(
cStrName
,
len
);
err
(
context
)
<<
"Set the name of the parent script to "
<<
job
->
parentScript
<<
"
\n
"
;
return
0
;
}
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
src/Lib/Script/CRTPLuaScriptObject.hh
+
13
−
15
Voir le fichier @
bc9b385d
...
...
@@ -30,7 +30,7 @@ template <class Object> class CRTPLuaScriptObject {
protected:
static
int
GC
(
lua_State
*
L
)
noexcept
{
const
Object
*
obj
=
reinterpret_cast
<
const
Object
*>
(
lua_topointer
(
L
,
1
));
const
Object
*
const
obj
=
reinterpret_cast
<
const
Object
*>
(
lua_topointer
(
L
,
1
));
auto
*
context
=
LuaContext
::
getContext
(
L
);
err
(
context
)
<<
"Call destructor for "
<<
Object
::
className
<<
"
\n
"
;
obj
->~
Object
();
...
...
@@ -39,28 +39,22 @@ protected:
static
int
CREATE
(
lua_State
*
L
)
noexcept
{
Object
*
obj
=
reinterpret_cast
<
Object
*>
(
lua_newuserdata
(
L
,
sizeof
(
Object
)));
lua_settop
(
L
,
0
);
Object
*
const
obj
=
reinterpret_cast
<
Object
*>
(
lua_newuserdata
(
L
,
sizeof
(
Object
)));
new
(
obj
)
Object
(
L
);
luaL_getmetatable
(
L
,
Object
::
className
);
lua_setmetatable
(
L
,
-
2
);
lua_setmetatable
(
L
,
1
);
return
1
;
}
static
inline
constexpr
luaL_Reg
luaRegDefaultGC
=
{
"__gc"
,
GC
};
public
:
static
Object
*
CHECK
(
lua_State
*
L
,
int
index
)
noexcept
{
luaL_checktype
(
L
,
index
,
LUA_TUSERDATA
);
auto
*
context
=
LuaContext
::
getContext
(
L
);
Object
*
obj
=
reinterpret_cast
<
Object
*>
(
luaL_checkudata
(
L
,
index
,
Object
::
className
));
if
(
obj
==
nullptr
)
{
err
(
context
)
<<
"Type error, userdata is not of class "
<<
Object
::
className
<<
"
\n
"
;
luaL_typeerror
(
L
,
index
,
Object
::
className
);
}
return
obj
;
return
reinterpret_cast
<
Object
*>
(
luaL_checkudata
(
L
,
index
,
Object
::
className
));
}
static
inline
constexpr
luaL_Reg
luaRegDefaultGC
=
{
"__gc"
,
GC
};
public
:
static
void
Register
(
lua_State
*
L
)
noexcept
{
auto
*
context
=
LuaContext
::
getContext
(
L
);
...
...
@@ -125,6 +119,10 @@ script_class (JobDeclaration) {
static
int
setOptions
(
lua_State
*
)
noexcept
;
static
int
setImportFromScript
(
lua_State
*
)
noexcept
;
std
::
string
name
{};
std
::
string
parentScript
{};
std
::
vector
<
OptionDeclaration
*>
options
{};
method_list
metaMethods
=
{
luaRegDefaultGC
,
LUA_DECL_CREATE
(
JobDeclaration
)
};
method_list
methods
=
{
LUA_DECL_METHOD
(
JobDeclaration
,
setName
),
LUA_DECL_METHOD
(
JobDeclaration
,
setOptions
),
...
...
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