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
896390fc
Vérifiée
Valider
896390fc
rédigé
5 août 2021
par
Kubat
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
SCRIPT: Update specification and lib
parent
6b6810e3
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
3
Afficher les modifications d'espaces
En ligne
Côte à côte
Affichage de
3 fichiers modifiés
rsc/lua/lib.lua
+47
-61
47 ajouts, 61 suppressions
rsc/lua/lib.lua
utils/lua/sample-spec.lua
+7
-7
7 ajouts, 7 suppressions
utils/lua/sample-spec.lua
utils/lua/sample-spec.spek
+6
-6
6 ajouts, 6 suppressions
utils/lua/sample-spec.spek
avec
60 ajouts
et
74 suppressions
rsc/lua/lib.lua
+
47
−
61
Voir le fichier @
896390fc
...
...
@@ -5,88 +5,74 @@
includes some exposed Vivy API things, enums and object to the user.
]]
function
getrometatable
(
tbl
,
tablename
)
local
errormsg
=
tablename
~=
nil
and
"attempt to update "
..
tablename
..
" table"
or
"attempt to update a read only table"
return
{
__index
=
tbl
,
__metatable
=
false
,
__newindex
=
function
(
t
,
k
,
v
)
error
(
errormsg
,
2
)
end
}
end
function
setrometatable
(
tbl
,
tblname
)
setmetatable
(
tbl
,
getrometatable
(
tbl
,
tblname
))
end
function
generalize
(
tbl
)
for
k
,
v
in
pairs
(
tbl
)
do
_G
[
k
]
=
v
end
end
-- Create an enum
function
enum
(
tbl
)
local
length
=
#
tbl
for
i
=
1
,
length
do
local
v
=
tbl
[
i
]
tbl
[
v
]
=
i
local
newval
=
v
..
"_"
..
i
tbl
[
v
]
=
newval
end
local
mt
=
{
__index
=
tbl
,
__newindex
=
function
(
t
,
k
,
v
)
error
(
"attempt to update an enum table"
,
2
)
end
}
setmetatable
(
tbl
,
mt
)
setrometatable
(
tbl
,
"an enum"
)
return
tbl
end
-- Check if a table contains a key
function
tableHasKey
(
tbl
,
key
)
return
tbl
[
key
]
~=
nil
end
-- Things used to iterate over with a job
-- Enums
Iterable
=
enum
{
"LINE"
,
"SYLLABE"
"SYLLABE"
,
}
-- Table: ReservedKeywords["keyword"] = "type"
local
ReservedKeywords
=
{
[
"Vivy"
]
=
"table"
StdType
=
enum
{
"NUMBER"
,
"COLOR"
,
"BOOLEAN"
,
}
-- Vivy global object construction
Vivy
=
{
-- Standard libraries
[
"math"
]
=
math
,
[
"string"
]
=
string
,
[
"utf8"
]
=
utf8
,
[
"table"
]
=
table
,
[
"print"
]
=
print
,
-- Custom things
[
"Iterable"
]
=
Iterable
,
}
os
=
nil
io
=
nil
debug
=
nil
Vivy
=
{
}
Version
=
{
MAJOR
=
0
,
MINOR
=
1
,
PATCH
=
0
,
LABEL
=
"alpha"
}
Vivy
[
"Fun"
]
=
FreeFunctions
()
version
=
{
[
"MAJOR"
]
=
0
,
[
"MINOR"
]
=
1
,
[
"PATCH"
]
=
0
,
[
"LABEL"
]
=
"alpha"
,
}
Vivy
[
"Version"
]
=
setmetatable
(
version
,
{
Vivy
[
"Version"
]
=
setmetatable
(
Version
,
{
__tostring
=
function
()
return
string.format
(
"%d.%d.%d-%s"
,
Vivy
.
Version
.
MAJOR
,
Vivy
.
Version
.
MINOR
,
Vivy
.
Version
.
PATCH
,
Vivy
.
Version
.
LABEL
)
Version
.
MAJOR
,
Version
.
MINOR
,
Version
.
PATCH
,
Version
.
LABEL
)
end
,
__index
=
Version
,
__metatable
=
false
,
__newindex
=
function
(
t
,
k
,
v
)
error
(
"attempt to update the version table"
,
2
)
end
})
-- In case we are able to do the _ENV <- Vivy one day...
Vivy
[
"Vivy"
]
=
Vivy
Vivy
=
setmetatable
(
Vivy
,
{
__newindex
=
function
(
t
,
k
,
v
)
error
(
"you can't set new keys in the Vivy table"
)
end
})
-- Hide everything from the user, appart some specific things he can do.
local
_ENV
=
setmetatable
(
Vivy
,
{
__newindex
=
function
(
t
,
k
,
v
)
-- Use the ReservedKeywords table here
if
(
tableHasKey
(
ReservedKeywords
,
k
))
then
error
(
"The keyword "
..
k
..
" is protected!"
)
else
rawset
(
t
,
k
,
v
)
end
end
})
-- Protect the content of Vivy, for now we are unable to protect the
-- Vivy keyword...
setrometatable
(
Vivy
)
generalize
(
Iterable
)
print
=
Vivy
.
Fun
.
print
Ce diff est replié.
Cliquez pour l'agrandir.
utils/lua/sample-spec.lua
+
7
−
7
Voir le fichier @
896390fc
-- vim: ft=lua
local
global
=
Vivy
:
global
{
}
local
module
=
Vivy
:
module
{
"sample-spec"
}
global
=
Vivy
:
global
{
}
module
=
Vivy
:
module
{
"sample-spec"
}
local
utils
=
module
:
import
{
"utils"
}
local
prettyPrint
=
module
:
import
{
"utils"
,
"prettyPrint"
}
utils
=
module
:
import
{
"utils"
}
prettyPrint
=
module
:
import
{
"utils"
,
"prettyPrint"
}
local
tripleCopySyl
=
module
:
export
{
"tripleCopySyl"
,
function
(
syl
)
tripleCopySyl
=
module
:
export
{
"tripleCopySyl"
,
function
(
syl
)
return
{
syl
:
copy
(),
syl
:
copy
(),
syl
:
copy
()
}
end
}
module
:
export
{
"printFoo"
,
function
()
prettyPrint
(
"Bar"
)
end
}
module
:
export
{
"retime_lines"
,
Iterable
.
LINE
,
function
(
opt
,
line
)
module
:
export
{
"retime_lines"
,
LINE
,
function
(
opt
,
line
)
line
.
start
+=
opt
.
preTime
line
.
finish
+=
opt
.
postTime
if
line
.
start
<=
0
then
line
.
start
=
0
end
...
...
@@ -19,7 +19,7 @@ module:export { "retime_lines", Iterable.LINE, function (opt, line)
return
line
end
}
module
:
export
{
"create_syllabes"
,
Iterable
.
SYLLABE
,
function
(
opt
,
syl
)
module
:
export
{
"create_syllabes"
,
SYLLABE
,
function
(
opt
,
syl
)
local
newSyls
=
tripleCopySyl
(
syl
)
newSyls
[
1
].
start
=
syl
.
line
.
start
newSyls
[
1
].
finish
=
syl
.
start
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
utils/lua/sample-spec.spek
+
6
−
6
Voir le fichier @
896390fc
-- vim: ft=lua
local
custom_opt
=
DeclareOption
{
option1
=
false
}
local
time_opt
=
DeclareOption
{
preTime
=
-
900
,
postTime
=
300
,
}
local
color_opt
=
DeclareOption
{
color1
=
Vivy
:
newColor
(
"#314159"
)
}
custom_opt
=
DeclareOption
{
option1
=
false
}
time_opt
=
DeclareOption
{
preTime
=
-
900
,
postTime
=
300
,
}
color_opt
=
DeclareOption
{
color1
=
Vivy
:
newColor
(
"#314159"
)
}
DeclareModule
{
name
=
"sample-spec"
,
...
...
@@ -17,8 +17,8 @@ DeclareModule {
ImportFunction
{
"utils"
,
"prettyPrint"
},
},
jobs
=
{
DeclareJob
{
name
=
"set_retime"
,
options
=
{
time_opt
}
},
DeclareJob
{
name
=
"demultiply_syllabes"
},
ImportJob
{
name
=
"color_after_read_3"
,
script
=
"utils"
,
options
=
{
color_opt
}
}
DeclareJob
{
"set_retime"
,
options
=
{
time_opt
}
},
DeclareJob
{
"demultiply_syllabes"
},
ImportJob
{
"utils"
,
"color_after_read_3"
,
options
=
{
color_opt
}
}
}
}
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