Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

globals #557

Closed
4 of 6 tasks
tehn opened this issue Sep 21, 2018 · 2 comments
Closed
4 of 6 tasks

globals #557

tehn opened this issue Sep 21, 2018 · 2 comments
Assignees
Labels

Comments

@tehn
Copy link
Member

tehn commented Sep 21, 2018

see #425

@pq
Copy link
Collaborator

pq commented Sep 21, 2018

disable overwriting system globals - see #436 (comment) @pq

on a little more investigation, i don't think disabling overwrites is possible without going more in the "sandbox scripts" direction (as explored in #426). alternatively, if the goal is more to limit the impact of overwriting globals, we could take an easier tack and piggy-back on what we're already doing in Script.clear and choose to additionally restore chosen globals to a good initial state.

for example,

norns/lua/script.lua

Lines 27 to 29 in dada0b7

-- reset midi callbacks
midi.add = norns.none
midi.remove = norns.none

resets midi callbacks. taking a similar approach we could restore tables like metro, midi, etc.

@tehn: do we have a sense for what globals we want to protect and what we want to preserve across scripts?

list of globals...

globals = { }
for k,v in pairs(_G) do table.insert(globals, k..' : '..tostring(v)) end
for _,v in ipairs(globals) do print(v) end

_G : table: 0x538b8
_VERSION : Lua 5.3
_reset_lvm : function: 0x1be28
assert : function: 0x76c2e7bc
audio_dir : /home/we/dust/audio/
audio_input_level : function: 0x1b1b4
audio_monitor_level : function: 0x1b114
audio_monitor_mono : function: 0x1a5b4
audio_monitor_off : function: 0x1a584
audio_monitor_on : function: 0x1a594
audio_monitor_stereo : function: 0x1a5a4
audio_output_level : function: 0x1b164
audio_pitch_off : function: 0x1a564
audio_pitch_on : function: 0x1a574
bit32 : table: 0x54898
clamped_value : 0.052140721099196
cleanup : function: 0x759a8
collectgarbage : function: 0x76c2e250
controlspec : table: 0x63a80
coroutine : table: 0x54418
data_dir : /home/we/dust/data/
debug : table: 0x55b98
dofile : function: 0x76c2e734
enc : function: 0x759a8
engine : table: 0x5fdc0
error : function: 0x76c2e1d0
fileselect : table: 0xef690
gain_hp : function: 0x1b5f8
gain_in : function: 0x1b590
get_time : function: 0x1a5c4
getmetatable : function: 0x76c2e6e4
globals : table: 0x97708
grid : table: 0xaf500
grid_all_led : function: 0x1bf94
grid_cols : function: 0x1be6c
grid_refresh : function: 0x1bf34
grid_rows : function: 0x1bed0
grid_set_led : function: 0x1c00c
hid : table: 0x664b0
home_dir : /home/we
init : function: 0x759a8
io : table: 0x55398
ipairs : function: 0x76c2e4b0
key : function: 0x759a8
line : network >
load : function: 0x76c2e53c
load_engine : function: 0x1b438
loadfile : function: 0x76c2e674
math : table: 0x56830
metro : table: 0xa3330
metro_set_time : function: 0x1b380
metro_start : function: 0x1a608
metro_stop : function: 0x1b3e8
midi : table: 0xb6188
midi_send : function: 0x1b488
mix : table: 0x6a020
next : function: 0x76c2e060
norns : table: 0x5aef0
os : table: 0x55128
osc : table: 0xee528
osc_send : function: 0x1aa84
osc_send_crone : function: 0x1a8d0
package : table: 0x53808
pairs : function: 0x76c2e490
params : table: 0xf2a78
paramset : table: 0x78fc8
pcall : function: 0x76c2d9a4
poll : table: 0x66260
print : function: 0x76c2dedc
rawequal : function: 0x76c2de9c
rawget : function: 0x76c2de04
rawlen : function: 0x76c2de44
rawset : function: 0x76c2ddb8
redraw : function: 0x759a8
report_engines : function: 0x1a8c0
request_poll_value : function: 0x1b21c
require : function: 0x544d8
restart_audio : function: 0x1a4a0
s : 249255
s_aa : function: 0x1bd3c
s_arc : function: 0x1b7a8
s_circle : function: 0xad858
s_clear : function: 0x1c1b4
s_close : function: 0x1c0b4
s_curve : function: 0x1b91c
s_curve_rel : function: 0x1b858
s_extents : function: 0x1b644
s_fill : function: 0x1c174
s_font_face : function: 0x1bddc
s_font_size : function: 0x1bd88
s_level : function: 0x1bcf0
s_line : function: 0x1bad0
s_line_cap : function: 0x1bc54
s_line_join : function: 0x1bc04
s_line_rel : function: 0x1b9e0
s_line_width : function: 0x1bca4
s_miter_limit : function: 0x1bbb8
s_move : function: 0x1bb44
s_move_rel : function: 0x1ba5c
s_rect : function: 0x1b70c
s_stroke : function: 0x1c134
s_text : function: 0x1b6bc
s_text_center : function: 0xac270
s_text_right : function: 0xac258
s_update : function: 0x1c0f4
screen : table: 0xac7b0
script_dir : /home/we/dust/scripts/
select : function: 0x76c2da48
send_command : function: 0x1a6d4
set_aux_fx_input_level : function: 0x1b018
set_aux_fx_input_pan : function: 0x1afbc
set_aux_fx_off : function: 0x1a4e4
set_aux_fx_on : function: 0x1a4f4
set_aux_fx_output_level : function: 0x1af78
set_aux_fx_param : function: 0x1aed4
set_aux_fx_return_level : function: 0x1af34
set_insert_fx_mix : function: 0x1ae90
set_insert_fx_off : function: 0x1a4c4
set_insert_fx_on : function: 0x1a4d4
set_insert_fx_param : function: 0x1ae30
set_poll_time : function: 0x1b26c
setmetatable : function: 0x76c2e334
sound_file_inspect : function: 0x1ada8
start_audio : function: 0x1a4b4
start_poll : function: 0x1c1f4
startup : function: 0x760a0
state : table: 0x666b0
stop_poll : function: 0x1b2d4
string : table: 0x539c0
tab : table: 0x57ef8
table : table: 0x54ee0
tape_new : function: 0x1b0c4
tape_open : function: 0x1b074
tape_pause : function: 0x1a514
tape_pause_rec : function: 0x1a544
tape_play : function: 0x1a524
tape_start_rec : functi
on: 0x1a554
tape_stop : function: 0x1a504
tape_stop_rec : function: 0x1a534
textentry : table: 0xdf838
tonumber : function: 0x76c2db18
tostring : function: 0x76c2da20
type : function: 0x76c2d94c
us : 1537564476
usleep : function: 0x1b328
utf8 : table: 0x57458
util : table: 0x6b748
wifi : table: 0xe5420
xpcall : function: 0x76c2d8bc

@pq
Copy link
Collaborator

pq commented Sep 21, 2018

@tehn: do we have a sense for what globals we want to protect and what we want to preserve across scripts?

this is related to the general cleanup task i guess. there may not actually be much left to protect / restore when norns is less leaky...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants