esruby 0.0.9 → 0.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/lib/esruby/build.rb +7 -4
  4. data/resources/build_config.eruby +1 -0
  5. data/resources/cpp/main.cpp +14 -0
  6. data/resources/mruby/doc/guides/mrbgems.md +5 -0
  7. data/resources/mruby/include/mrbconf.h +3 -5
  8. data/resources/mruby/include/mruby/proc.h +2 -2
  9. data/resources/mruby/include/mruby.h +11 -4
  10. data/resources/mruby/lib/mruby/build/load_gems.rb +5 -3
  11. data/resources/mruby/lib/mruby/build.rb +23 -0
  12. data/resources/mruby/lib/mruby/gem.rb +12 -13
  13. data/resources/mruby/mrbgems/default.gembox +6 -0
  14. data/resources/mruby/mrbgems/mruby-compiler/core/codegen.c +7 -1
  15. data/resources/mruby/mrbgems/mruby-compiler/core/parse.y +31 -36
  16. data/resources/mruby/mrbgems/mruby-enum-ext/mrblib/enum.rb +33 -10
  17. data/resources/mruby/mrbgems/mruby-enum-ext/test/enum.rb +6 -0
  18. data/resources/mruby/mrbgems/mruby-enum-lazy/test/lazy.rb +1 -1
  19. data/resources/mruby/mrbgems/mruby-enumerator/mrblib/enumerator.rb +32 -17
  20. data/resources/mruby/mrbgems/mruby-enumerator/test/enumerator.rb +10 -0
  21. data/resources/mruby/mrbgems/mruby-fiber/src/fiber.c +3 -2
  22. data/resources/mruby/mrbgems/mruby-io/mrblib/io.rb +3 -2
  23. data/resources/mruby/mrbgems/mruby-io/src/file.c +15 -0
  24. data/resources/mruby/mrbgems/mruby-io/src/io.c +16 -8
  25. data/resources/mruby/mrbgems/mruby-io/test/file.rb +17 -1
  26. data/resources/mruby/mrbgems/mruby-io/test/io.rb +4 -0
  27. data/resources/mruby/mrbgems/mruby-pack/src/pack.c +16 -6
  28. data/resources/mruby/mrbgems/mruby-socket/mrbgem.rake +2 -2
  29. data/resources/mruby/mrbgems/mruby-socket/test/sockettest.c +42 -6
  30. data/resources/mruby/mrbgems/mruby-test/init_mrbtest.c +1 -0
  31. data/resources/mruby/mrbgems/mruby-test/mrbgem.rake +1 -0
  32. data/resources/mruby/mrbgems/mruby-time/src/time.c +22 -3
  33. data/resources/mruby/mrbgems/mruby-time/test/time.rb +4 -0
  34. data/resources/mruby/mrblib/array.rb +8 -9
  35. data/resources/mruby/mrblib/enum.rb +1 -1
  36. data/resources/mruby/src/array.c +1 -1
  37. data/resources/mruby/src/class.c +8 -2
  38. data/resources/mruby/src/error.c +2 -1
  39. data/resources/mruby/src/gc.c +1 -1
  40. data/resources/mruby/src/object.c +2 -2
  41. data/resources/mruby/src/string.c +8 -8
  42. data/resources/mruby/src/variable.c +41 -7
  43. data/resources/mruby/src/vm.c +5 -4
  44. data/resources/mruby/tasks/toolchains/visualcpp.rake +10 -9
  45. data/resources/mruby/test/t/string.rb +2 -1
  46. data/resources/project_template/config.rb +5 -0
  47. data/resources/rb/append.rb +3 -0
  48. metadata +3 -4
  49. data/resources/cpp/esruby.cpp +0 -51
  50. data/resources/cpp/esruby.hpp +0 -38
  51. data/resources/js/esruby.js +0 -17
@@ -55,14 +55,15 @@ MRuby::Toolchain.new(:visualcpp) do |conf, _params|
55
55
 
56
56
  conf.file_separator = '\\'
57
57
 
58
- if require 'open3'
59
- Open3.popen3 conf.cc.command do |_, _, e, _|
60
- if /Version (\d{2})\.\d{2}\.\d{5}/ =~ e.gets && $1.to_i <= 17
61
- m = "# VS2010/2012 support will be dropped after the next release! #"
62
- h = "#" * m.length
63
- puts h, m, h
64
- end
65
- end
66
- end
58
+ # Unreliable detection and will result in invalid encoding errors for localized versions of Visual C++
59
+ # if require 'open3'
60
+ # Open3.popen3 conf.cc.command do |_, _, e, _|
61
+ # if /Version (\d{2})\.\d{2}\.\d{5}/ =~ e.gets && $1.to_i <= 17
62
+ # m = "# VS2010/2012 support will be dropped after the next release! #"
63
+ # h = "#" * m.length
64
+ # puts h, m, h
65
+ # end
66
+ # end
67
+ # end
67
68
 
68
69
  end
@@ -20,6 +20,7 @@ assert('String#<=>', '15.2.10.5.1') do
20
20
  assert_equal 1, c
21
21
  assert_equal(-1, d)
22
22
  assert_equal 1, e
23
+ assert_nil 'a' <=> 1024
23
24
  end
24
25
 
25
26
  assert('String#==', '15.2.10.5.2') do
@@ -685,7 +686,7 @@ assert('String#inspect', '15.2.10.5.46') do
685
686
  ("\1" * 100).inspect
686
687
  end
687
688
 
688
- assert_equal "\"\\000\"", "\0".inspect
689
+ assert_equal "\"\\x00\"", "\0".inspect
689
690
  end
690
691
 
691
692
  # Not ISO specified
@@ -28,5 +28,10 @@ ESRuby::Build.new do |conf|
28
28
 
29
29
  # JavaScript calling interface
30
30
  # conf.add_gem 'gems/esruby-bind'
31
+
32
+ # for now you will need to download the gem
33
+ # https://github.com/robfors/esruby-esruby
34
+ # and add it here
35
+ conf.add_gem 'gems/esruby-esruby'
31
36
 
32
37
  end
@@ -0,0 +1,3 @@
1
+ #ESRuby.eval = Proc.new do |code|
2
+ #eval(code)
3
+ #end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: esruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rob Fors
@@ -42,9 +42,7 @@ files:
42
42
  - lib/esruby/gem.rb
43
43
  - lib/esruby/gem/specification.rb
44
44
  - resources/build_config.eruby
45
- - resources/cpp/esruby.cpp
46
- - resources/cpp/esruby.hpp
47
- - resources/js/esruby.js
45
+ - resources/cpp/main.cpp
48
46
  - resources/mruby/AUTHORS
49
47
  - resources/mruby/CONTRIBUTING.md
50
48
  - resources/mruby/LEGAL
@@ -421,6 +419,7 @@ files:
421
419
  - resources/project_template/app/app.rb
422
420
  - resources/project_template/config.rb
423
421
  - resources/project_template/www/index.html
422
+ - resources/rb/append.rb
424
423
  homepage: https://github.com/robfors/esruby
425
424
  licenses:
426
425
  - MIT
@@ -1,51 +0,0 @@
1
- #include "esruby.hpp"
2
-
3
- mrb_state* ESRuby::_mrb = nullptr;
4
-
5
- void ESRuby::start()
6
- {
7
- if (_mrb)
8
- {
9
- printf("Error: ESRuby already started\n");
10
- throw std::runtime_error("Error: ESRuby already started");
11
- }
12
- _mrb = mrb_open();
13
- if (!_mrb)
14
- {
15
- printf("error opening new mrb state\n");
16
- throw std::runtime_error("error opening new mrb state");
17
- }
18
- mrb_load_irep(_mrb, app);
19
- // print error if any
20
- if (_mrb->exc)
21
- {
22
- mrb_p(_mrb, mrb_obj_value(_mrb->exc));
23
- _mrb->exc = 0;
24
- throw std::runtime_error("ruby error encountered");
25
- }
26
- }
27
-
28
- void ESRuby::stop()
29
- {
30
- if (!_mrb)
31
- {
32
- printf("Error: ESRuby not active\n");
33
- throw std::runtime_error("Error: ESRuby not active");
34
- }
35
- mrb_close(_mrb);
36
- // print error if any
37
- if (_mrb->exc)
38
- {
39
- mrb_p(_mrb, mrb_obj_value(_mrb->exc));
40
- _mrb->exc = 0;
41
- throw std::runtime_error("ruby error encountered");
42
- }
43
- }
44
-
45
- EMSCRIPTEN_BINDINGS(esruby)
46
- {
47
- emscripten::class_<ESRuby>("ESRuby")
48
- .class_function("start", &ESRuby::start)
49
- .class_function("stop", &ESRuby::stop)
50
- ;
51
- }
@@ -1,38 +0,0 @@
1
- #ifndef _ESRUBY_HPP_
2
- #define _ESRUBY_HPP_
3
-
4
- #include <emscripten.h>
5
- #include <emscripten/bind.h>
6
- #include <emscripten/val.h>
7
- #include <stdio.h>
8
- #include <math.h>
9
- #include <mruby.h>
10
- #include <mruby/array.h>
11
- #include <mruby/class.h>
12
- #include <mruby/data.h>
13
- #include <mruby/proc.h>
14
- #include <mruby/string.h>
15
- #include <mruby/value.h>
16
- #include <mruby/variable.h>
17
- #include <mruby.h>
18
- #include <mruby/irep.h>
19
-
20
-
21
- extern const uint8_t app[];
22
-
23
-
24
- class ESRuby
25
- {
26
-
27
- public:
28
-
29
- static void start();
30
- static void stop();
31
-
32
- private:
33
-
34
- static mrb_state* _mrb;
35
-
36
- };
37
-
38
- #endif
@@ -1,17 +0,0 @@
1
- class ESRuby
2
- {
3
-
4
- static start()
5
- {
6
- Module.ESRuby.start();
7
- }
8
-
9
- static stop()
10
- {
11
- Module.ESRuby.stop();
12
- }
13
-
14
- }
15
-
16
- window.addEventListener("load", ESRuby.start);
17
- window.addEventListener("unload", ESRuby.stop);