rucy 0.2 → 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: fb34f5678ae8965c0f500a75bbffc6a2ccc988d3426a1f70add9632272ae107a
4
- data.tar.gz: 8678ed1c6c5b28980519f7723e0760857d26c7f80d1d92a57c3ff9ebc387e883
3
+ metadata.gz: 8e17e711a8ae802303c387e10b9718fc4399be80c87fbf25badd9b518d6f4a2b
4
+ data.tar.gz: f7ffb9c06acdf4ecb9e2e0011e956365d558f6509a6c158e00894bba2b4de052
5
5
  SHA512:
6
- metadata.gz: e16469de93f4c589f13670c9d5c3866b7ca6966913519239f4e860df6672c132589e33e41da5b5859455bbc2050644b826f1710b752be0af3e682fdea2524ed9
7
- data.tar.gz: a5e4a00964aa69286955e0d92c25a28faa2cfff02b165a69d8c1ab08dcacf1a3cb2fb5622c4698ddbfb3af0b84275d558f85d86d7c0e6b2f4c033c17b153f892
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,14 @@
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
+
4
12
  ## [v0.2] - 2024-03-14
5
13
 
6
14
  - Change the super class for exception class from RuntimeError to StandardError
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.2
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
 
@@ -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.2'
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/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.2'
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-03-13 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.2'
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.2'
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: