flok 0.0.36 → 0.0.38

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +1 -0
  3. data/app/drivers/chrome/build_context.rb +1 -1
  4. data/app/drivers/chrome/config.yml +10 -0
  5. data/app/drivers/chrome/pipe.rb +24 -1
  6. data/app/drivers/chrome/src/persist.js +29 -0
  7. data/app/drivers/chrome/src/sockio.js +3 -1
  8. data/app/drivers/chrome/src/vendor/store2.js +3 -0
  9. data/app/kern/callout.js +55 -0
  10. data/app/kern/controller.js +3 -0
  11. data/app/kern/crc32.js +22 -0
  12. data/app/kern/dispatch.js +16 -0
  13. data/app/kern/mod/event.js +3 -0
  14. data/app/kern/mod/persist.js +1 -0
  15. data/app/kern/mod/timer.js +5 -0
  16. data/app/kern/pagers/mem_pager.js +2 -0
  17. data/app/kern/pagers/sockio_pager.js +66 -0
  18. data/app/kern/pagers/spec0.js +35 -0
  19. data/app/kern/pagers/spec1.js +24 -0
  20. data/app/kern/pagers/spec2.js +31 -0
  21. data/app/kern/services/test.rb +7 -0
  22. data/app/kern/services/vm.rb +141 -0
  23. data/app/kern/spec_helper.js +5 -0
  24. data/bin/flok +27 -5
  25. data/docs/callout.md +8 -0
  26. data/docs/client_api.md +1 -1
  27. data/docs/compilation.md +14 -8
  28. data/docs/controllers.md +2 -1
  29. data/docs/datatypes.md +3 -1
  30. data/docs/environmentals.md +6 -0
  31. data/docs/interactive.md +6 -1
  32. data/docs/kernel_api.md +3 -0
  33. data/docs/mod/event.md +5 -1
  34. data/docs/mod/persist.md +14 -31
  35. data/docs/mod/timer.md +4 -2
  36. data/docs/project.md +16 -5
  37. data/docs/scheduling.md +1 -0
  38. data/docs/services.md +141 -56
  39. data/docs/services/vm.md +128 -0
  40. data/docs/services/vm/pagers.md +46 -0
  41. data/lib/flok/build.rb +11 -16
  42. data/lib/flok/platform.rb +29 -6
  43. data/lib/flok/project_template/app/scripts/script.js +3 -0
  44. data/lib/flok/project_template/app/services/service.rb +1 -0
  45. data/lib/flok/project_template/config/config.yml +1 -0
  46. data/lib/flok/project_template/config/platforms/chrome/config.yml +1 -0
  47. data/lib/flok/project_template/config/services.rb +1 -0
  48. data/lib/flok/service_compiler_templates/services.js.erb +78 -9
  49. data/lib/flok/services_compiler.rb +117 -20
  50. data/lib/flok/user_compiler.rb +14 -6
  51. data/lib/flok/user_compiler_templates/ctable.js.erb +10 -0
  52. data/lib/flok/version.rb +1 -1
  53. data/spec/env/etc.rb +1 -1
  54. data/spec/env/global.rb +2 -0
  55. data/spec/env/iface.rb +20 -4
  56. data/spec/env/kern.rb +8 -3
  57. data/spec/etc/cli_spec.rb +319 -165
  58. data/spec/etc/lib/assets/config.yml +3 -0
  59. data/spec/etc/lib/platform_spec.rb +14 -10
  60. data/spec/etc/lib/project_spec.rb +22 -0
  61. data/spec/etc/service_compiler/config0.rb +1 -0
  62. data/spec/etc/service_compiler/config1.rb +1 -0
  63. data/spec/etc/service_compiler/config2.rb +3 -0
  64. data/spec/etc/service_compiler/service0.rb +22 -6
  65. data/spec/etc/service_compiler/service1.rb +26 -0
  66. data/spec/etc/service_compiler/service_bad_type.rb +20 -0
  67. data/spec/etc/services_compiler_spec.rb +35 -16
  68. data/spec/etc/user_compiler/data.js +2 -0
  69. data/spec/etc/user_compiler_spec.rb +7 -1
  70. data/spec/iface/driver/persist_spec.rb +106 -0
  71. data/spec/iface/driver/pipe_spec.rb +5 -0
  72. data/spec/iface/kern/ping_spec.rb +4 -3
  73. data/spec/kern/assets/blank.rb +0 -0
  74. data/spec/kern/assets/service0.rb +24 -0
  75. data/spec/kern/assets/service1.rb +22 -0
  76. data/spec/kern/assets/service2.rb +27 -0
  77. data/spec/kern/assets/service_config0.rb +2 -0
  78. data/spec/kern/assets/service_config1.rb +2 -0
  79. data/spec/kern/assets/service_controller0.rb +13 -0
  80. data/spec/kern/assets/service_controller1.rb +32 -0
  81. data/spec/kern/assets/service_controller2.rb +38 -0
  82. data/spec/kern/assets/service_controller3.rb +38 -0
  83. data/spec/kern/assets/vm/config0.rb +2 -0
  84. data/spec/kern/assets/vm/config1.rb +12 -0
  85. data/spec/kern/assets/vm/config2.rb +12 -0
  86. data/spec/kern/assets/vm/config3.rb +12 -0
  87. data/spec/kern/assets/vm/controller0.rb +8 -0
  88. data/spec/kern/assets/vm/controller1.rb +18 -0
  89. data/spec/kern/assets/vm/controller2.rb +18 -0
  90. data/spec/kern/assets/vm/controller3.rb +20 -0
  91. data/spec/kern/assets/vm/controller4.rb +22 -0
  92. data/spec/kern/assets/vm/controller5.rb +22 -0
  93. data/spec/kern/assets/vm/controller6.rb +21 -0
  94. data/spec/kern/assets/vm/service0.rb +24 -0
  95. data/spec/kern/assets/vm/service_controller0.rb +7 -0
  96. data/spec/kern/callout_spec.rb +153 -0
  97. data/spec/kern/functions_spec.rb +29 -0
  98. data/spec/kern/service_controller_spec.rb +213 -0
  99. data/spec/kern/vm_service_spec.rb +195 -0
  100. metadata +98 -12
  101. data/app/kern/services/rest.rb +0 -310
  102. data/app/kern/services/timer.rb +0 -30
  103. data/docs/services/timer.md +0 -21
  104. data/spec/kern/assets/rest_service.rb +0 -20
  105. data/spec/kern/assets/timer_service.rb +0 -19
  106. data/spec/kern/timer_service_spec.rb +0 -40
@@ -0,0 +1,7 @@
1
+ service :test do
2
+ global %{
3
+ function <%= @name %>_function(x) {
4
+ <%= @name %>_function_args = x;
5
+ }
6
+ }
7
+ end
@@ -0,0 +1,141 @@
1
+ service :vm do
2
+ global %{
3
+ //Cache contains a blank hash for each namespace
4
+ vm_cache = {
5
+ <% @options[:pagers].each do |p| %>
6
+ <%= p[:namespace] %>: {},
7
+ <% end %>
8
+ };
9
+
10
+ //Notification listeners, converts ns+key to an array of base pointers
11
+ vm_notify_map = {};
12
+
13
+ //Cache
14
+ function vm_cache_write(ns, key, value) {
15
+ vm_cache[ns][key] = value;
16
+ }
17
+
18
+ //Notification of a change
19
+ function vm_notify(ns, key) {
20
+ var a = vm_notify_map[ns];
21
+ if (a) {
22
+ var b = a[key];
23
+
24
+ if (b) {
25
+ for (var i = 0; i < b.length; ++i) {
26
+ <% @options[:pagers].each do |p| %>
27
+ if (ns === "<%= p[:namespace] %>") {
28
+ <%= p[:name] %>_read(ns, b[i], key);
29
+ }
30
+ <% end %>
31
+ }
32
+ }
33
+ }
34
+ }
35
+ }
36
+
37
+ on_wakeup %{
38
+ <% raise "No pagers given in options for vm" unless @options[:pagers] %>
39
+
40
+ <% if @debug %>
41
+ vm_did_wakeup = true;
42
+ <% end %>
43
+
44
+
45
+ //Call init functions
46
+ <% @options[:pagers].each do |p| %>
47
+ <%= p[:name] %>_init(<%= (p[:options] || {}).to_json %>);
48
+ <% end %>
49
+ }
50
+
51
+ on_sleep %{
52
+ }
53
+
54
+ on_connect %{
55
+ }
56
+
57
+ on_disconnect %{
58
+ }
59
+
60
+ on "read_sync", %{
61
+ <% raise "No pagers given in options for vm" unless @options[:pagers] %>
62
+
63
+ var cres = vm_cache[params.ns][params.key];
64
+ if (cres != undefined) {
65
+ int_event(bp, "read_res", {key: params.key, value: cres});
66
+ return;
67
+ }
68
+
69
+ <% @options[:pagers].each do |p| %>
70
+ if (params.ns === "<%= p[:namespace] %>") {
71
+ var res = <%= p[:name] %>_read_sync(params.ns, bp, params.key);
72
+ }
73
+ <% end %>
74
+ vm_read_sync_called = true;
75
+
76
+ int_event(bp, "read_sync_res", res);
77
+ }
78
+
79
+ on "read", %{
80
+ <% raise "No pagers given in options for vm" unless @options[:pagers] %>
81
+
82
+ var cres = vm_cache[params.ns][params.key];
83
+ if (cres != undefined) {
84
+ int_event(bp, "read_res", {key: params.key, value: cres});
85
+ }
86
+
87
+ <% @options[:pagers].each do |p| %>
88
+ if (params.ns === "<%= p[:namespace] %>") {
89
+ <%= p[:name] %>_read(params.ns, bp, params.key);
90
+ }
91
+ <% end %>
92
+ }
93
+
94
+ on "write", %{
95
+ <% raise "No pagers given in options for vm" unless @options[:pagers] %>
96
+
97
+ <% @options[:pagers].each do |p| %>
98
+ if (params.ns === "<%= p[:namespace] %>") {
99
+ <%= p[:name] %>_write(params.key, params.value);
100
+ }
101
+ <% end %>
102
+ }
103
+
104
+ on "watch", %{
105
+ <% raise "No pagers given in options for vm" unless @options[:pagers] %>
106
+
107
+ //Ensure map exists
108
+ ////////////////////////////////////////////////
109
+ var a = vm_notify_map[params.ns];
110
+ if (!a) {
111
+ a = {};
112
+ vm_notify_map[params.ns] = a;
113
+ }
114
+
115
+ var b = a[params.key];
116
+ if (!b) {
117
+ b = [];
118
+ a[params.key] = b;
119
+ }
120
+
121
+ b.push(bp)
122
+ ////////////////////////////////////////////////
123
+
124
+ <% @options[:pagers].each do |p| %>
125
+ if (params.ns === "<%= p[:namespace] %>") {
126
+ <%= p[:name] %>_watch(params.ns, params.key);
127
+ }
128
+ <% end %>
129
+ }
130
+
131
+ on "unwatch", %{
132
+ <% raise "No pagers given in options for vm" unless @options[:pagers] %>
133
+
134
+ <% @options[:pagers].each do |p| %>
135
+ if (params.ns === "<%= p[:namespace] %>") {
136
+ <%= p[:name] %>_unwatch(params.ns, params.key);
137
+ }
138
+ <% end %>
139
+ }
140
+
141
+ end
@@ -0,0 +1,5 @@
1
+ <% if @debug %>
2
+ <% if @defines['spec_test'] %>
3
+ //spec_helper_defines_spec_test
4
+ <% end %>
5
+ <% end %>
data/bin/flok CHANGED
@@ -23,7 +23,11 @@ class FlokCLI < Thor
23
23
  raise "$PLATFORM was not set" unless ENV['PLATFORM']
24
24
  platform = ENV['PLATFORM']
25
25
 
26
+ #Set the correct config.yml
27
+ ENV['FLOK_CONFIG'] = File.expand_path("./config/platforms/#{platform}/config.yml")
28
+
26
29
  #Create a products folder if it dosen't already exist
30
+ FileUtils.rm_r "./products" if File.directory? "./products"
27
31
  Dir.mkdir("./products") unless File.exists?("./products")
28
32
 
29
33
  #Go into the flok gem project
@@ -32,30 +36,48 @@ class FlokCLI < Thor
32
36
  #1. Use the rake task
33
37
  system('rake build:world')
34
38
 
35
- #2. Copy everything in the gems ./flok/products/$PLATFORM -> $PROJECT/products/$PLATFORM
39
+ #2. Copy everything in the gems ./flok/products/$PLATFORM -> $PROJECT/products/$PLATFORM and ./flok/app/kern/services/*.rb -> #$PROJECT/products/$PLATFORM/services
36
40
  FileUtils.cp_r "./products/#{platform}", local_products_path
41
+
42
+ #Copy built in services
43
+ Flok.src_glob("rb", "./app/kern/services", File.join(local_products_path, platform, "services/kern_services.rb"))
37
44
  end
38
45
 
39
46
  #3. Build the client's ./app/controllers/*.rb into './products/$PLATFORM/user_compiler.js'
40
47
  controller_glob_path = "#{local_products_path}/#{platform}/glob/controllers.rb"
41
48
  Flok.src_glob("rb", './app/controllers', controller_glob_path)
42
49
  user_compiler_js = Flok::UserCompiler.compile File.read(controller_glob_path)
50
+ services_config_js = File.read "./config/services.rb"
51
+ Flok.src_glob("rb", './app/services', File.join(local_products_path, platform, "./services/user_services.rb"))
52
+
53
+ #4. Move ./app/scripts/*.js into `./products/$PLATFORM/./glob/scripts.js`
54
+ Flok.src_glob("js", './app/scripts', File.join(local_products_path, platform, "./glob/scripts.js"))
43
55
 
56
+ #We are now inside the platform folder
44
57
  Dir.chdir File.join(local_products_path, platform) do
45
- #3. Put user_compiler_js in glob folder
58
+ #3. Put user_compiler_js in glob folder and services into ./services/user_services.rb
46
59
  File.write "glob/user_compiler.js", user_compiler_js
47
60
 
48
- #4. Move application.js to the glob folder
61
+ #4. The `./products/$PLATFORM/services/*.rb` file are globbed into `./products/$PLATFORM/services/combined_services.rb`
62
+ Flok.src_glob("rb", "./services/", "./services/combined_services.rb")
63
+
64
+ #5. The service configuration in `./config/services.rb` is read and run through `services_compiler` and files from `./products/$PLATFORM/services/combined_services.rb` and write to ./glob/services.js
65
+ services_js = Flok::ServicesCompiler.compile(File.read("./services/combined_services.rb"), services_config_js)
66
+ File.write "./glob/services.js", services_js
67
+
68
+ #6. Move application.js to the glob folder
49
69
  FileUtils.cp "application.js", "glob/application.js"
50
70
  FileUtils.rm "application.js"
51
71
 
52
- #5. Combine application.js and user_compiler.js.erb
72
+ #7. Combine application.js and user_compiler.js.erb and services.js and scripts.js
53
73
  File.open "glob/application_user.js.erb", "w" do |f|
54
74
  f.puts File.read("glob/application.js")
55
75
  f.puts File.read("glob/user_compiler.js")
76
+ f.puts File.read("glob/services.js")
77
+ f.puts File.read("glob/scripts.js")
56
78
  end
57
79
 
58
- #6. The `erb` files is then sent to `./products/$PLATFORM/glob/application_user.js` with the below `ERB` variables allowable.
80
+ #8. The `erb` files is then sent to `./products/$PLATFORM/glob/application_user.js` with the below `ERB` variables allowable.
59
81
  erb_src = File.read "glob/application_user.js.erb"
60
82
  renderr = ERB.new(erb_src)
61
83
  context = ERBUserApplicationContext.new()
data/docs/callout.md ADDED
@@ -0,0 +1,8 @@
1
+ #Callout - Kernel timer manager
2
+ The function `callout_wakeup()` embodies the time management functions of the kernel; this includes maintaining periodic
3
+ and interval timers and to send a custom event to the given port.
4
+
5
+ ##Registration
6
+ You may register for a timer event via `reg_timeout(ep, ename, ticks)`. This will wait `ticks` before firing.
7
+ To continually fire, you may use `reg_interval(ep, ename, ticks)` which will continue to fire every `ticks`. If `ep` is no longer in the `evt`, then
8
+ the entry will no longer exist.
data/docs/client_api.md CHANGED
@@ -4,7 +4,7 @@ Client API covers controller action event handlers.
4
4
  ### Controller MACROS
5
5
  * Embed(view_controller_name, spot_name, context) - Embed a view controller with the name `view_controller_name` inside the current view controller at the spot with a context
6
6
  * Goto(action_name) - Change actions
7
- * Request(service_name, info, event_cb_name) - Initiate a service. See [Services](./services.md) for more info.
7
+ * Request(service_insatnce_name, ename, params) Initiate a service. See [Services](./services.md) for more info.
8
8
  * Send(event_name, info) - Send a custom event on the main queue.
9
9
  * Raise(event_name, info) - Will send an event to the parent view controller (and it will bubble up, following `event_gw` which is set in `Embed` as the parent controller
10
10
  * Lower(spot_name, event_name, info) - Send an event to a particular spot
data/docs/compilation.md CHANGED
@@ -13,14 +13,12 @@ as necessary.*
13
13
  1. `rake build` is run inside `./app/drivers/$PLATFORM` with the environmental variables set to BUILD_PATH=`./produts/$PLATFORM/driver` (and folder
14
14
  2. All js files in `./app/kern/config/*.js` are globbed togeather and sent to `./products/$PLATFORM/glob/1kern_config.js`
15
15
  3. All js files in `./app/kern/*.js` are globbed togeather and sent to `./products/$PLATFORM/glob/2kern.pre_macro.js`
16
- 4. All rb files inside `./app/kern/services/` are globbed into `./products/$PLATFORM/glob/kern_services.rb`
17
- 5. `./products/$PLATFORM/glob/kern_serivces.rb` is processed via `Flok::Services` and then exported as `./products/$PLATFORM/glob/kern_services.pre_macro.js`
18
- 6. All js files in `./products/$PLATFORM/glob/2kern.pre_macro.js` are run through `./app/kern/macro.rb's macro_process` and then sent to ./products/$PLATFORM/glob/2kern.js
19
- 7. All js files in `./products/$PLATFORM/glob/kern_services.pre_macro.js` are run through `./app/kern/macro.rb's macro_process` and then sent to ./products/$PLATFORM/glob/kern_services.js
20
- 8. All js files are globbed from `./products/$PLATFORM/glob` and combined into `./products/$PLATFORM/glob/application.js.erb`
21
- 9. Auto-generated code is placed at the end (like PLATFORM global)
22
- 10. The module specific code in `./kern/mod/.*js` are added when the name of the file (without the js part) is mentioned in the `./app/drivers/$PLATFORM/config.yml` `mods` section and appended to `glob/application.js.erb`
23
- 11. The compiled `glob/application.js.erb` file is run through the ERB compiler and formed into `application.js`
16
+ 4. All js files in `./app/kern/pagers/*.js` are globbed togeather and sent to `./products/$PLATFORM/glob/3kern.pre_macro.js`
17
+ 5. All js files in `./products/$PLATFORM/glob/{2,3}kern.pre_macro.js` are run through `./app/kern/macro.rb's macro_process` and then sent to `./products/$PLATFORM/glob/{2,3}kern.js`
18
+ 6. All js files are globbed from `./products/$PLATFORM/glob` and combined into `./products/$PLATFORM/glob/application.js.erb`
19
+ 7. Auto-generated code is placed at the end (like PLATFORM global)
20
+ 8. The module specific code in `./kern/mod/.*js` are added when the name of the file (without the js part) is mentioned in the `./app/drivers/$PLATFORM/config.yml` `mods` section and appended to `glob/application.js.erb`
21
+ 9. The compiled `glob/application.js.erb` file is run through the ERB compiler and formed into `application.js`
24
22
 
25
23
  ##Erb variables
26
24
  All kernel source files support embedded ERB code like `<% if DEBUG %>Code<% end %>`. These files include:
@@ -32,6 +30,7 @@ All kernel source files support embedded ERB code like `<% if DEBUG %>Code<% end
32
30
  * `@debug` - Set to `true` when FLOK_ENV=DEBUG
33
31
  * `@release` - Set to `true` FLOK_ENV=RELEASE
34
32
  * `@mods` - The set of modules supported by this platform and build configuration
33
+ * `@defines` - A hash that contains things under the `defines` section in a `config.yml`. Each item in the hash is `true`
35
34
 
36
35
  ```js
37
36
  //Example JS code for debug / release mode
@@ -40,4 +39,11 @@ All kernel source files support embedded ERB code like `<% if DEBUG %>Code<% end
40
39
  <% else %>
41
40
  //JS code for not debug mode
42
41
  <% end %>
42
+
43
+ <% if @defines['spec_test'] %>
44
+ //spec_helper_defines_spec_test
45
+ <% end %>
43
46
  ```
47
+
48
+ ####Spec Helpers
49
+ The file contained in the kernel `./app/kern/spec_helper.js` is used to test things like variable setting from `config.yml`
data/docs/controllers.md CHANGED
@@ -23,7 +23,8 @@ Let's write a `fuc` controller that has 2 tabs and a content area. The view is i
23
23
 
24
24
  ```ruby
25
25
  controller "tab_controller" do
26
- spaces "content"
26
+ spots "content"
27
+ services "my_service" #See docs on services for what this means
27
28
 
28
29
  #You can also define macros for shared action traits
29
30
  macro "my_macro" do
data/docs/datatypes.md CHANGED
@@ -11,7 +11,9 @@ ctable_entry {
11
11
  root_view, //A constant string of the name of the view this controller sets as it's root view.
12
12
  actions, //A dictionary [String:action_info] that corresponds to a dictionary of action_info object's based on the action's name.
13
13
  spots, //An array fo spot names for this controller
14
- name //The name of the controller, useful for certain lookup operations, this is also the ctable key
14
+ name, //The name of the controller, useful for certain lookup operations, this is also the ctable key
15
+ __init__, //A function that is called when this controller is created. Signals service connection
16
+ __dealloc__ //A function that is called when this controller is destroyed via parent controller switching actions in Goto. Signals services d/c
15
17
  }
16
18
  ```
17
19
 
@@ -0,0 +1,6 @@
1
+ #Environmentals
2
+
3
+ Various environmental variables effect both the build, spec, and interface systems. These environmentals include:
4
+ * `PLATFORM` - The current platform (driver stack) to use. E.g. `chrome`
5
+ * `FLOK_ENV` - Are we in `debug` or `release`
6
+ * `FLOK_CONFIG` - Absolute location of the config.yml, this config.yml must be usable for the the current `PLATFORM`
data/docs/interactive.md CHANGED
@@ -8,7 +8,6 @@
8
8
  * `cd ./; rake pipe:server PLATFORM=$PLATFORM`
9
9
 
10
10
  ###What $stdout and $stdin does for pipes
11
-
12
11
  * Server
13
12
  - `$stdin` => `int_dispatch`
14
13
  - `if_dispatch` => `$stdout`
@@ -17,6 +16,12 @@
17
16
  - `int_dispatch` => `$stdout`
18
17
 
19
18
  All communication *coming* from `$stdin` and *going* to `$stdout` is in un-escaped JSON formatting that follows the conventions mentioned in [Messaging](./messaging.md).
19
+ If the driver `$stdin` receives the string `RESTART\n` by itself on a single line, then it should restart itself and then next reply should be
20
+ `RESTART OK\n`
21
+ it is fully restarted. All data should be destroyed except for things explicitly synchronously flushed like the `persist` module. When this pipe is
22
+ opened, it is expected that no local data is retained; the only way to retain data is through explicit restarts. All data writes should be flushed
23
+ (fsynced) when the pipe is restarted so that no data writes are lost. Some specs expect that setting data will be fsynced when it calls restart (which
24
+ is immediately after the set)
20
25
 
21
26
  The test suites assume particular behavior of the pipes. Please review [./spec/env/iface.rb](../spec/env/iface.rb) for the method named `pipe_suite` for the proper behavior.
22
27
 
data/docs/kernel_api.md CHANGED
@@ -9,6 +9,9 @@
9
9
  * `tel_exists(tp)` - Returns true or false depending on whether there is a telepointer that matches
10
10
  instead.
11
11
 
12
+ ##CRC32
13
+ * `crc32(seed, str)` - Will calculate a CRC32 based on a seed and a string
14
+
12
15
  ##Events
13
16
  * `reg_evt(ep, f)` - Register a function to be called when an event is processed by `int_event`. The function will receive `(ep, event_name, info)`.
14
17
 
data/docs/mod/event.md CHANGED
@@ -4,11 +4,15 @@
4
4
  `if_event(ep, event_name, event)` - Receive an event at some object located at `ep`. This is a platform defined opaque pointer.
5
5
 
6
6
  ### Interrupts
7
- `int_event(ep, event_name, event)` - Send an event back to *Flok* through an event. The `ep` in this case is dependent on the sub-system. Dispatching is provided through the `evt` (event vector table). On the flok kernel, using, `reg_ivt` and `dereg_ivt` will determine what happens post int_event. If `ep` is no longer valid, the event in ignored.
7
+ `int_event(ep, event_name, event)` - Send an event back to *Flok* through an event. The `ep` in this case is dependent on the sub-system. Dispatching is provided through the `evt` (event vector table). On the flok kernel, using, `reg_evt` and `dereg_evt` will determine what happens post int_event. If `ep` is no longer valid, the event in ignored. Returns `false` if the destination does not exist and `true` otherwise.
8
8
  For example, the `vc` (view controller) subsystem will receive any events sent when the `ep` is an opaque pointer to a
9
9
  ./app/driver/$PLATFORM/config.yml`)
10
10
  file is used to compile only the modules into the flok kernel that the driver supports.rface controller from `ui`.
11
11
 
12
+ ### Helper function
13
+ `reg_evt(ep, f)` - Register a function to be called when `ep` is sent a message, function looks like function f(ep, ename, info)
14
+ `dereg_evt(ep)` - Disable notifications to a function
15
+
12
16
  ### Kernel spec related
13
17
  * `spec_event_handler(ep, event_name, event)` - This function should send the message `spec_event_handler_res(ep, event_name, event)` if called
14
18
  * `int_spec_event_dereg` - This function should de-register 3848392 from being an event
data/docs/mod/persist.md CHANGED
@@ -1,36 +1,19 @@
1
1
  #Persist (persist.js)
2
- Persistance management. Storage of data, etc. Loosely based on redis. Refer to [redios.io](http://redis.io/commands) for more detailed
3
- descriptions.
2
+ Persistance management. Loosely based on redis.
4
3
 
5
- ###Messages
6
- `if_per_hdel key field [field...]` - Delete one or more hash fields
7
- `if_per_hmget key field [field...]` - Get the value of multiple fields
4
+ ###Driver messages
5
+ `if_per_set(ns, key, value)` - Set a key and value
6
+ `if_per_get(s, ns, key)` - Get a key's value, a message `int_get_res` will be sent back
7
+ `if_per_del(ns, key)` - Delete a particular key
8
+ `if_per_del_ns(ns)` - Delete an entire namespace
8
9
 
9
- ###Spec related
10
- `if_ui_spec_init` - Setup anything necessary for the spec tests, this may include adding prototype views to your hierarchy, etc.
11
- `if_ui_spec_views_at_spot(p)` - Sends a packet back that contains a listing of all the view pointers inside of a spot. If 0 is passed, the view pointers are from the root node. `[N(vp*), "spec", vp*]`
12
- `if_ui_spec_view_exists(vp)` - Checks whether or not a view still exists `[1, "spec", true]`
13
- `if_ui_spec_view_is_visible(vp)` - Checks whether or not a view is visible `[1, "spec", true]`
10
+ ###TODO driver messages
11
+ `if_per_set_f(ns, key, tp)` - Tell the driver to dereference the telepointer and to save it to disk.
14
12
 
15
- #####You must be able to accept the following prototypes names:
16
- `spec_blank` - A blank view with no spots
17
- `spec_one_spot` - "A blank view with with one spot named `content` that takes up the entire view"
18
- `spec_two_spot` - "A blank view with with one spot named `a` and one spot named `b`.
13
+ For race conditions, e.g, an asynchronous set is followed by a synchronous get, it is undefined as to what that behavior that will be.
14
+ It is expected that the kernel should manage the write-back cache and that the driver should not attempt a write back cache unless
15
+ it is convenient to do so.
19
16
 
20
- ------
21
-
22
- ## Overview
23
-
24
- This driver controls two things called a **view** and a **spot**.
25
-
26
- 1. **View** - A **view** holds your content.
27
- 2. **Spot** - Views can have blank **Spot**s where other views can be placed.
28
-
29
- ## Examples
30
- Here is an example for the `chrome` driver of a live view built from two views.
31
- ![](../images/view_and_spot.png)
32
-
33
-
34
-
35
- ###A note on free
36
- If `free` is called on a view, that view is always already detached. If a *view* receives `free`, that *view* must call `free` on all of it's children before itself.
17
+ ###Kernel interrupts
18
+ `int_per_get_res(s, res)` - A response retrieved from `if_per_get` that contains the session key and result dictionary. If the key
19
+ does not exist, null is returned.
data/docs/mod/timer.md CHANGED
@@ -1,8 +1,10 @@
1
1
  #Timer (timer.js)
2
2
 
3
3
  ###Functions
4
-
5
- `if_timer_init(tps)` - Initiate a timer that calls `int_timer` N `tps` (ticsk per second)
4
+ `if_timer_init(tps)` - Initiate a timer that calls `int_timer` N `tps` (ticsk per second). This is always called via the cpu scheduling class (3)
6
5
 
7
6
  ###Interrupts
8
7
  `int_timer` - Called by the device at the rate described in `tps`. This function lives inside the `timer` service's initialization portion.
8
+
9
+ ###Callout
10
+ The kernel's `int_timer` function gets sent to `callout_wakeup()` located in `callout.js`.
data/docs/project.md CHANGED
@@ -11,21 +11,32 @@ You create and build projects via the `flok` command. You must set the `$FLOK_EN
11
11
  ###Folder structure
12
12
  * `app/`
13
13
  * `controllers/` - All your controllers live here as `rb` files.
14
+ * `services/` - Service `rb` files
15
+ * `scripts/` - Scripts are ordinary javascript files that are merged with the main kernel.
14
16
  * `products/` - Autogenerated when you build
15
17
  * `$PLATFORM/` - A folder named after the platform you selected
16
18
  * `application_user.js` - The source for the flok application_user. Includes your application code statically linked
17
19
  * `drivers/` - Contains the driver code needed to implement the driver side interface
20
+ * `config/` - The configuration files
21
+ * `services.rb` - A list of service instances that are statically compiled into the kernel. See [Services](./services.md) for details.
22
+ * `platforms/$PLATFORM/` - Platform dependent build options
23
+ * `config.yml` - Copied from the platform's config.yml folder in the kernel `./app/drivers/$PLATFORM/config.yml`. This is used when running
24
+ `flok build`
18
25
 
19
26
  ###application_user.js
20
27
  `application_user.js` is equivalent to the application_user build `application.js` except that it contains the users controllers statically linked (appended in *js*).
21
28
 
22
29
  ###User build process
23
30
  1. The gem is build via `build:world` using the platform given in build.
24
- 2. All files generated by the gem kernel and associated driver for the platform are placed in the project ./products/$PLATFORM
25
- 3. The controllers in `./app/controllers/*.rb` are run through the `user_compiler` in `./lib/flok/user_compiler.rb` and then saved to the projects `./products/$PLATFORM/glob/user_compiler.js`
26
- 4. `./products/$PLATFORM/application.js` is moved to `./products/$PLATFORM/glob/application.js`
27
- 5. The local project `./products/$PLATFORM/glob/application.js` and `./products/$PLATFORM/glob/user_compiler.js` are merged into `./products/$PLATFORM/glob/application_user.js.erb`.
28
- 6. The `erb` files is then sent to `./products/$PLATFORM/glob/application_user.js` with the below `ERB` variables allowable.
31
+ 2. Copy everything in the gems ./flok/products/$PLATFORM -> $PROJECT/products/$PLATFORM and ./flok/app/kern/services/*.rb -> $PROJECT/products/$PLATFORM/services/kern_services.rb
32
+ 3. The controllers in `./app/controllers/*.rb` are run through the `user_compiler` in `./lib/flok/user_compiler.rb` and then saved to the projects
33
+ `./products/$PLATFORM/glob/user_compiler.js` and the `./app/services/*.rb` are globbed into `./products/$PLATFORM/services/user_services.rb`
34
+ 4. The `./products/$PLATFORM/services/*.rb` file are globbed into `./products/$PLATFORM/services/combined_services.rb`
35
+ 5. The service configuration in `./config/services.rb` is read and run through `services_compiler` and files from
36
+ `./products/$PLATFORM/services/combined_services.rb`. The output of this file is moved to `./products/$PLATFORM/glob/services.js`
37
+ 6. `./products/$PLATFORM/application.js` is moved to `./products/$PLATFORM/glob/application.js`
38
+ 7. The local project `./products/$PLATFORM/glob/application.js` and `./products/$PLATFORM/glob/user_compiler.js` and `./products/$PLATFORM/glob/services.js` and `./products/$PLATFORM/glob/scripts.js` are merged into `./products/$PLATFORM/glob/application_user.js.erb`.
39
+ 8. The `erb` files is then sent to `./products/$PLATFORM/glob/application_user.js` with the below `ERB` variables allowable.
29
40
 
30
41
  ####Supported variables
31
42
  * `@debug` - Set to `true` when FLOK_ENV=DEBUG