Mercurial Hosting > luan
diff core/src/luan/LuanState.java @ 517:8dcf9e12446b
add Luan.on_luan_close()
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Wed, 27 May 2015 01:20:49 -0600 |
parents | e3b0846dc2ef |
children | 8a217fe5b4f3 |
line wrap: on
line diff
--- a/core/src/luan/LuanState.java Tue May 26 20:59:05 2015 -0600 +++ b/core/src/luan/LuanState.java Wed May 27 01:20:49 2015 -0600 @@ -13,6 +13,7 @@ final List<StackTraceElement> stackTrace = new ArrayList<StackTraceElement>(); private Map registry; + private final List<LuanFunction> onClose = new ArrayList<LuanFunction>(); protected LuanState() { registry = new HashMap(); @@ -32,6 +33,17 @@ return registry; } + public void onClose(LuanFunction fn) { + onClose.add(fn); + } + + public void close() throws LuanException { + for( LuanFunction fn : onClose ) { + call(fn); + } + onClose.clear(); + } + public static LuanState newInstance() { return LuanCompiler.newLuanState(); }