rucy 0.1.44 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f7410bc5ab8edd7026da4603fecbadc7e628e42f63bb3a04550ba49eb0636661
4
- data.tar.gz: cc7d0f386395368b11c17ddc699094e5960e28426d8cf43f8141dd565e8e05b1
3
+ metadata.gz: 8e17e711a8ae802303c387e10b9718fc4399be80c87fbf25badd9b518d6f4a2b
4
+ data.tar.gz: f7ffb9c06acdf4ecb9e2e0011e956365d558f6509a6c158e00894bba2b4de052
5
5
  SHA512:
6
- metadata.gz: b8c79e0c29c9990821ed62e0093a43080addc6e4530a8b7066c73c4ee638d3632edd6b5f41578608b845613832cb5c3cef2ddf2b0fea766ed80fd30f4615c2c7
7
- data.tar.gz: a9040e5e82e59ef7b0b5b708bf4888dc1b6142f9c6e26f30da629a379345e13f9b09298804d29ea136f88353fb34fcd23e39c209eecf256225c237b020e34276
6
+ metadata.gz: 121368e5fa7d2246451dae710fc0eb993b700eb1842a36dd0ecf0243b92aaf0f1a278adbe30bf16176b3656bbba137b4e5cb1e5265b2746cf1d69ad85a658a3c
7
+ data.tar.gz: 6363492ca08f9a2a7c03b444263d3b6a723453205335ac4c831ab32a6e92a1d9b9f85e3ca7d49421e8384e82b40da26da1de29d72bd185996b938a7f817b3171
@@ -25,7 +25,7 @@ VALUE all_logs(VALUE self)
25
25
  {
26
26
  std::vector<Value> a;
27
27
  for (size_t i = 0; i < logs.size(); ++i) a.push_back(logs[i].c_str());
28
- return value(a.size(), &a[0]);
28
+ return array(&a[0], a.size());
29
29
  }
30
30
 
31
31
  /*
@@ -15,7 +15,7 @@ jobs:
15
15
  ruby-version: 3.2
16
16
 
17
17
  - name: checkout
18
- uses: actions/checkout@v2
18
+ uses: actions/checkout@v4
19
19
 
20
20
  - name: setup gems
21
21
  run: bundle install
@@ -15,7 +15,7 @@ jobs:
15
15
  ruby-version: 3.2
16
16
 
17
17
  - name: checkout
18
- uses: actions/checkout@v2
18
+ uses: actions/checkout@v4
19
19
  with:
20
20
  fetch-depth: 0
21
21
  token: ${{ secrets.PAT }}
@@ -16,7 +16,7 @@ jobs:
16
16
  ruby-version: 3.2
17
17
 
18
18
  - name: checkout
19
- uses: actions/checkout@v2
19
+ uses: actions/checkout@v4
20
20
 
21
21
  - name: setup gems
22
22
  run: bundle install
@@ -24,5 +24,11 @@ jobs:
24
24
  - name: setup dependencies
25
25
  run: "ruby -I.github/workflows -rutils -e 'setup_dependencies'"
26
26
 
27
+ - name: lib
28
+ run: bundle exec rake lib
29
+
30
+ - name: ext
31
+ run: bundle exec rake ext
32
+
27
33
  - name: test
28
34
  run: bundle exec rake test
data/ChangeLog.md CHANGED
@@ -1,6 +1,19 @@
1
1
  # rucy ChangeLog
2
2
 
3
3
 
4
+ ## [v0.2.1] - 2024-07-05
5
+
6
+ - Value() can take encoding parameter
7
+ - value(size, values) -> array(values, size)
8
+ - Update workflows for test
9
+ - Update to actions/checkout@v4
10
+
11
+
12
+ ## [v0.2] - 2024-03-14
13
+
14
+ - Change the super class for exception class from RuntimeError to StandardError
15
+
16
+
4
17
  ## [v0.1.44] - 2024-02-07
5
18
 
6
19
  - Update dependencies
data/Gemfile.lock CHANGED
@@ -9,7 +9,7 @@ GEM
9
9
 
10
10
  PLATFORMS
11
11
  arm64-darwin-21
12
- x86_64-darwin-20
12
+ arm64-darwin-22
13
13
 
14
14
  DEPENDENCIES
15
15
  rake
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.44
1
+ 0.2.1
data/ext/rucy/tester.cpp CHANGED
@@ -25,7 +25,7 @@ RUCY_DEF0(all_logs)
25
25
  {
26
26
  std::vector<Value> a;
27
27
  for (size_t i = 0; i < logs.size(); ++i) a.push_back(logs[i].c_str());
28
- return value(a.size(), &a[0]);
28
+ return array(&a[0], a.size());
29
29
  }
30
30
  RUCY_END
31
31
 
@@ -446,8 +446,9 @@ namespace Rucy
446
446
  template <typename T> inline T* get_type_ptr (Value obj, Value klass = nil())
447
447
  {
448
448
  if (!klass.is_nil()) check_class(obj, klass);
449
- T* p = NULL;
450
- Data_Get_Struct(obj.value(), T, p);
449
+ RubyValue o = obj.value();
450
+ T* p = NULL;
451
+ Data_Get_Struct(o, T, p);
451
452
  return p;
452
453
  }
453
454
 
data/include/rucy/ruby.h CHANGED
@@ -7,6 +7,7 @@
7
7
  #pragma clang diagnostic push
8
8
  #pragma clang diagnostic ignored "-Wundef"
9
9
  #include <ruby.h>
10
+ #include <ruby/encoding.h>
10
11
  #pragma clang diagnostic pop
11
12
 
12
13
 
data/include/rucy/rucy.h CHANGED
@@ -18,7 +18,7 @@ namespace Rucy
18
18
  // module Rucy
19
19
 
20
20
  Class native_error_class ();
21
- // class Rucy::NativeError < RuntimeError
21
+ // class Rucy::NativeError < StandardError
22
22
 
23
23
  Class invalid_state_error_class ();
24
24
  // class Rucy::InvalidStateError < Rucy::NativeError
@@ -29,9 +29,9 @@ namespace Rucy
29
29
 
30
30
  Value (double n);
31
31
 
32
- Value (const char* s);
32
+ Value (const char* s, rb_encoding* encoding = NULL);
33
33
 
34
- Value (const char* s, size_t len);
34
+ Value (const char* s, size_t len, rb_encoding* encoding = NULL);
35
35
 
36
36
  Value (size_t size, const Value* array);
37
37
 
@@ -243,11 +243,11 @@ namespace Rucy
243
243
 
244
244
  Value value (double n);
245
245
 
246
- Value value (const char* s);
246
+ Value value (const char* s, rb_encoding* encoding = NULL);
247
247
 
248
- Value value (const char* s, size_t len);
248
+ Value value (const char* s, size_t len, rb_encoding* encoding = NULL);
249
249
 
250
- Value value (size_t size, const Value* array);
250
+ Value array (const Value* values, size_t size);
251
251
  % (1..16).each do |n|
252
252
 
253
253
  Value array (<%= params(n, ', ') {|i| "Value v#{i}"} %>);
data/rucy.gemspec CHANGED
@@ -25,7 +25,7 @@ Gem::Specification.new do |s|
25
25
  s.platform = Gem::Platform::RUBY
26
26
  s.required_ruby_version = '>= 3.0.0'
27
27
 
28
- s.add_runtime_dependency 'xot', '~> 0.1.42'
28
+ s.add_runtime_dependency 'xot', '~> 0.2.1'
29
29
 
30
30
  s.files = `git ls-files`.split $/
31
31
  s.executables = s.files.grep(%r{^bin/}) {|f| File.basename f}
data/src/exception.cpp CHANGED
@@ -3,9 +3,6 @@
3
3
 
4
4
 
5
5
  #include <typeinfo>
6
- #ifdef WIN32
7
- #include <windows.h>
8
- #endif
9
6
  #include <xot/exception.h>
10
7
  #include "rucy/ruby.h"
11
8
  #include "rucy/rucy.h"
@@ -136,28 +133,7 @@ namespace Rucy
136
133
  system_error (const char* file, int line, const char* format, ...)
137
134
  {
138
135
  XOT_STRINGF(format, s);
139
-
140
- #ifdef WIN32
141
- DWORD lasterror = GetLastError();
142
- if (lasterror != 0)
143
- {
144
- LPVOID msg = NULL;
145
- DWORD flags =
146
- FORMAT_MESSAGE_ALLOCATE_BUFFER |
147
- FORMAT_MESSAGE_FROM_SYSTEM |
148
- FORMAT_MESSAGE_IGNORE_INSERTS;
149
- if (FormatMessageA(
150
- flags, NULL, lasterror, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
151
- (LPSTR) &msg, 0, NULL))
152
- {
153
- Xot::String m = (LPCSTR) msg;
154
- if (!m.empty()) s += ": " + m;
155
- }
156
- LocalFree(msg);
157
- }
158
- #endif
159
-
160
- raise(system_error_class(), Xot::error_text(file, line, s));
136
+ raise(system_error_class(), Xot::system_error_text(file, line, s));
161
137
  }
162
138
 
163
139
 
data/src/rucy.cpp CHANGED
@@ -35,7 +35,7 @@ namespace Rucy
35
35
  native_error_class ()
36
36
  {
37
37
  static Class c =
38
- rucy_module().define_class("NativeError", rb_eRuntimeError);
38
+ rucy_module().define_class("NativeError", rb_eStandardError);
39
39
  return c;
40
40
  }
41
41
 
data/src/value.cpp.erb CHANGED
@@ -2,7 +2,6 @@
2
2
  #include "rucy/value.h"
3
3
 
4
4
 
5
- #include <ruby/encoding.h>
6
5
  #include "rucy/function.h"
7
6
  #include "rucy/exception.h"
8
7
  #include "rucy/debug.h"
@@ -56,28 +55,28 @@ namespace Rucy
56
55
  }
57
56
 
58
57
  static VALUE
59
- str_new (const char* s)
58
+ str_new (const char* s, rb_encoding* encoding)
60
59
  {
61
- rb_encoding* e = rb_default_internal_encoding();
60
+ rb_encoding* e = encoding ? encoding : rb_default_internal_encoding();
62
61
  return e ? rb_enc_str_new_cstr(s, e) : rb_str_new_cstr(s);
63
62
  }
64
63
 
65
64
  static VALUE
66
- str_new (const char* s, size_t len)
65
+ str_new (const char* s, size_t len, rb_encoding* encoding)
67
66
  {
68
- rb_encoding* e = rb_default_internal_encoding();
67
+ rb_encoding* e = encoding ? encoding : rb_default_internal_encoding();
69
68
  return e ? rb_enc_str_new(s, len, e) : rb_str_new(s, len);
70
69
  }
71
70
 
72
- Value::Value (const char* s)
73
- : val(s ? str_new(s) : Qnil)
71
+ Value::Value (const char* s, rb_encoding* encoding)
72
+ : val(s ? str_new(s, encoding) : Qnil)
74
73
  {
75
74
  if (!s)
76
75
  argument_error(__FILE__, __LINE__);
77
76
  }
78
77
 
79
- Value::Value (const char* s, size_t len)
80
- : val(s ? str_new(s, len) : Qnil)
78
+ Value::Value (const char* s, size_t len, rb_encoding* encoding)
79
+ : val(s ? str_new(s, len, encoding) : Qnil)
81
80
  {
82
81
  if (!s)
83
82
  argument_error(__FILE__, __LINE__);
@@ -613,21 +612,21 @@ namespace Rucy
613
612
  }
614
613
 
615
614
  Value
616
- value (const char* s)
615
+ value (const char* s, rb_encoding* encoding)
617
616
  {
618
- return Value(s);
617
+ return Value(s, encoding);
619
618
  }
620
619
 
621
620
  Value
622
- value (const char* s, size_t len)
621
+ value (const char* s, size_t len, rb_encoding* encoding)
623
622
  {
624
- return Value(s, len);
623
+ return Value(s, len, encoding);
625
624
  }
626
625
 
627
626
  Value
628
- value (size_t size, const Value* array)
627
+ array (const Value* values, size_t size)
629
628
  {
630
- return Value(size, array);
629
+ return Value(size, values);
631
630
  }
632
631
  % (1..16).each do |n|
633
632
 
@@ -635,7 +634,7 @@ namespace Rucy
635
634
  array (<%= params(n, ', ') {|i| "Value v#{i}"} %>)
636
635
  {
637
636
  Value tmp[] = {<%= params(n, ', ') {|i| "v#{i}"} %>};
638
- return value(<%= n %>, tmp);
637
+ return array(tmp, <%= n %>);
639
638
  }
640
639
  % end
641
640
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rucy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.44
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - xordog
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-06 00:00:00.000000000 Z
11
+ date: 2024-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xot
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.1.42
19
+ version: 0.2.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.1.42
26
+ version: 0.2.1
27
27
  description: This library helps you to develop Ruby Extension by C++.
28
28
  email: xordog@gmail.com
29
29
  executables: