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
d4c5ccaf
Vérifiée
Valider
d4c5ccaf
rédigé
Il y a 4 ans
par
Kubat
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
SCRIPT: Get the methods working, meta methods not working for now...
parent
519ddcd9
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion
!9
Lua cpp expose
Modifications
2
Afficher les modifications d'espaces
En ligne
Côte à côte
Affichage de
2 fichiers modifiés
src/Lib/Script/CRTPLuaScriptObject.cc
+2
-2
2 ajouts, 2 suppressions
src/Lib/Script/CRTPLuaScriptObject.cc
src/Lib/Script/CRTPLuaScriptObject.hh
+11
-3
11 ajouts, 3 suppressions
src/Lib/Script/CRTPLuaScriptObject.hh
avec
13 ajouts
et
5 suppressions
src/Lib/Script/CRTPLuaScriptObject.cc
+
2
−
2
Voir le fichier @
d4c5ccaf
...
...
@@ -26,11 +26,11 @@ SampleObject::foo(lua_State *L) noexcept
LuaMethodTable
SampleObject
::
getMetaMethods
()
noexcept
{
return
{
LUA_DECL_
METHOD
(
SampleObject
,
foo
)
};
return
{
luaRegDefaultGC
,
LUA_DECL_
CREATE
(
SampleObject
)
};
}
LuaMethodTable
SampleObject
::
getMethods
()
noexcept
{
return
{
luaRegDefaultGC
};
return
{
LUA_DECL_METHOD
(
SampleObject
,
foo
)
};
}
Ce diff est replié.
Cliquez pour l'agrandir.
src/Lib/Script/CRTPLuaScriptObject.hh
+
11
−
3
Voir le fichier @
d4c5ccaf
...
...
@@ -4,11 +4,13 @@
#include
"lua.hpp"
#include
<vector>
#include
<cstdio>
namespace
Vivy
::
Script
{
// clang-format off
#define LUA_DECL_METHOD(class, name) luaL_Reg{ #name, class ::name }
#define LUA_DECL_CREATE(class) luaL_Reg{ "new", class ::CREATE }
#define LUA_DECL_SCRIPTABLE_CLASS(class) public CRTPLuaScriptObject<class>
#define LUA_SCRIPTABLE_CLASS(class) \
...
...
@@ -27,6 +29,7 @@ protected:
static
int
GC
(
lua_State
*
L
)
noexcept
{
const
Object
*
obj
=
reinterpret_cast
<
const
Object
*>
(
lua_topointer
(
L
,
1
));
puts
(
"CALL DESTRUCTOR"
);
obj
->~
Object
();
return
0
;
}
...
...
@@ -34,6 +37,7 @@ protected:
static
int
CREATE
(
lua_State
*
L
)
noexcept
{
Object
*
obj
=
reinterpret_cast
<
Object
*>
(
lua_newuserdata
(
L
,
sizeof
(
Object
)));
puts
(
"CALL CONSTRUCTOR"
);
new
(
obj
)
Object
;
luaL_getmetatable
(
L
,
Object
::
className
);
lua_setmetatable
(
L
,
-
2
);
...
...
@@ -44,8 +48,10 @@ protected:
{
luaL_checktype
(
L
,
index
,
LUA_TUSERDATA
);
Object
*
obj
=
reinterpret_cast
<
Object
*>
(
luaL_checkudata
(
L
,
index
,
Object
::
className
));
if
(
obj
==
nullptr
)
if
(
obj
==
nullptr
)
{
puts
(
"TYPE ERROR"
);
luaL_typeerror
(
L
,
index
,
Object
::
className
);
}
return
obj
;
}
...
...
@@ -72,6 +78,7 @@ public:
lua_settable
(
L
,
metatable
);
for
(
const
luaL_Reg
meta
:
Object
::
getMetaMethods
())
{
fprintf
(
stderr
,
"REGISTER %s
\n
"
,
meta
.
name
);
lua_pushstring
(
L
,
meta
.
name
);
lua_pushcfunction
(
L
,
meta
.
func
);
lua_settable
(
L
,
metatable
);
...
...
@@ -81,7 +88,8 @@ public:
}
// Fill the method table with specified methods
for
(
const
luaL_Reg
method
:
Object
::
getMetaMethods
())
{
for
(
const
luaL_Reg
method
:
Object
::
getMethods
())
{
fprintf
(
stderr
,
"REGISTER %s
\n
"
,
method
.
name
);
lua_pushstring
(
L
,
method
.
name
);
lua_pushcfunction
(
L
,
method
.
func
);
lua_settable
(
L
,
methodtable
);
...
...
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