ctable = { <% @controllers.each do |c| %> <%= c.name %>: { __init__: function(__base__) { //Call service on_connect <% c._services.each do |s| %> <%= s %>_on_connect(__base__); <% end %> //Register this controller for every single interval timer *now* <% actions_for_controller(c.name).each do |a| %> <% a.every_handlers.each do |e| %> reg_interval(__base__, "<%= e[:name] %>", <%= e[:ticks] %>); <% end %> <% end %> //Controller information, includes action, etc. (controller_info) var __info__ = tel_deref(__base__); //The 'context' which is user-defined var context = __info__.context; //Call global on entry <%= c._on_entry %> }, __dealloc__: function(__base__) { var __info__ = tel_deref(__base__); //Recursively call dealloc var embeds = __info__.embeds; while (true) { for (var i = 0; i < embeds.length; ++i) { for (var x = 0; x < embeds[i].length; ++x) { tel_deref(embeds[i][x]).cte.__dealloc__(embeds[i][x]); } } if (__info__.stack.length > 0) { var slice = __info__.stack.pop(); embeds = slice.embeds; } else { break; } } <% c._services.each do |s| %> <%= s %>_on_disconnect(__base__); <% end %> dereg_evt(__base__); tel_del(__base__); }, name: '<%= c.name %>', root_view: '<%= c.name %>', spots: <%= c.spots.to_json %>, actions: { <% actions_for_controller(c.name).each do |a| %> <%= a.name %>: { on_entry: function(__base__) { //Controller information, includes action, etc. (controller_info) var __info__ = tel_deref(__base__); //The 'context' which is user-defined var context = __info__.context; <%= a.on_entry_src.strip %> }, handlers: { <% a.ons.each do |e| %> <%= e[:name] %>: function(__base__, params) { var __info__ = tel_deref(__base__); var context = __info__.context; var current_action = __info__.action; <%= e[:src] %> }, <% end %> <% a.every_handlers.each do |e| %> "<%= e[:name] %>": function(__base__, ename, info) { var __info__ = tel_deref(__base__); var context = __info__.context; <%= e[:src] %> }, <% end %> }, }, <% end %> }, }, <% end %> }