RubyInline 3.12.6 → 3.14.0

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: 7ba7b8737df8454f2428459aa7066082c3966cd52213ae62126489327ce614b9
4
- data.tar.gz: 77476279cc150dbfec24b72cfbee747af92f13489e6c46d44436deb06e095fa7
3
+ metadata.gz: 14e2dd1d335589d1f389ba716c031d8778d02d0b2c74e35ad981168dd7d0999d
4
+ data.tar.gz: 5b39db47e57df1e9494db491e778e121f0556b8827270ea6cbd63899c03f8f52
5
5
  SHA512:
6
- metadata.gz: eb1b824084189a44908e5896fba9acb9637c26c31a5944f0c3bd9fa986aae2986e30c05f4a1886672d8dc9a46b619a8b566d5051f8504a48365ddc96d85473fd
7
- data.tar.gz: 1c9184d49d7ecf30af622fa8a6b317ca84707524f810b6ee9eb675ceb68d419814116f85eb096ffca523634e7d9f4287e538de584eb2786684b1c05f298bcb0c
6
+ metadata.gz: 9cce3379d5f7876f9ed3f8736eb3ef90beeea58730fc9303c532efebaf629ea097481e06084a61ddb379319e599ca002385c458a8a183464a1f6199014f8c6b6
7
+ data.tar.gz: 1650103a7b18af47316fd0983baa3877a36776e71732ac1ffa71cf715fa86415a9bd1ad7584efc74378a2db52c287e6243cedae4cbf025224aaf09136381f67c
checksums.yaml.gz.sig CHANGED
Binary file
data/History.txt CHANGED
@@ -1,3 +1,25 @@
1
+ === 3.14.0 / 2023-06-28
2
+
3
+ * 3 minor enhancements:
4
+
5
+ * Changed File.write_with_backup to write the content and return renamed path.
6
+ * Dropped #inline ancient options processing code. 2005, yo.
7
+ * Preemptively require language extension if not defined yet.
8
+
9
+ * 1 bug fix:
10
+
11
+ * Declare Init_* to be (void) to prevent some compilers from complaining.
12
+
13
+ === 3.13.0 / 2023-01-31
14
+
15
+ * 1 minor enhancement:
16
+
17
+ * Error out if current ruby isn't configured for ENABLE_SHARED.
18
+
19
+ * 1 bug fix:
20
+
21
+ * Clean up examples. C++ warns about ANYARGS deprecation. Gonna have to sit with it for now.
22
+
1
23
  === 3.12.6 / 2022-05-23
2
24
 
3
25
  * 1 bug fix:
data/Rakefile CHANGED
@@ -16,6 +16,8 @@ Hoe.spec "RubyInline" do
16
16
  spec_extras[:requirements] =
17
17
  "A POSIX environment and a compiler for your language."
18
18
 
19
+ license "MIT"
20
+
19
21
  dependency "ZenTest", "~> 4.3" # for ZenTest mapping
20
22
  end
21
23
 
@@ -23,16 +25,17 @@ task :test => :clean
23
25
 
24
26
  desc "run all examples"
25
27
  task :examples do
26
- %w(example.rb example2.rb
28
+ %w(example.rb
29
+ example2.rb
27
30
  tutorial/example1.rb
28
31
  tutorial/example2.rb).each do |e|
29
32
  rm_rf '~/.ruby_inline'
30
- ruby "-Ilib -w #{e}"
33
+ ruby "-Ilib -I#{Hoe.include_dirs.first} -w #{e}"
31
34
  end
32
35
  end
33
36
 
34
37
  desc "run simple benchmarks"
35
- task :bench do
38
+ task :bench => [:clean, :isolate] do
36
39
  verbose(false) do
37
40
  ruby "-Ilib ./example.rb"
38
41
  ruby "-Ilib ./example.rb 1000000 12" # 12 is the bignum cutoff for factorial
data/example.rb CHANGED
@@ -55,31 +55,31 @@ end
55
55
  puts "# of iterations = #{max}, n = #{n}"
56
56
  Benchmark::bm(20) do |x|
57
57
  x.report("null_time") do
58
- for i in 0..max do
58
+ max.times do
59
59
  # do nothing
60
60
  end
61
61
  end
62
62
 
63
63
  x.report("c") do
64
- for i in 0..max do
64
+ max.times do
65
65
  validate(t.factorial_c(n), m)
66
66
  end
67
67
  end
68
68
 
69
69
  x.report("c-raw") do
70
- for i in 0..max do
70
+ max.times do
71
71
  validate(t.factorial_c_raw(n), m)
72
72
  end
73
73
  end
74
74
 
75
75
  x.report("c-alias") do
76
- for i in 0..max do
76
+ max.times do
77
77
  validate(t.factorial_alias(n), m)
78
78
  end
79
79
  end
80
80
 
81
81
  x.report("pure ruby") do
82
- for i in 0..max do
82
+ max.times do
83
83
  validate(t.factorial(n), m)
84
84
  end
85
85
  end
data/example2.rb CHANGED
@@ -10,11 +10,13 @@ require 'inline'
10
10
  class MyTest
11
11
 
12
12
  inline do |builder|
13
+ builder.include_ruby_last
13
14
 
14
15
  builder.add_compile_flags %q(-x c++)
15
16
  builder.add_link_flags %q(-lstdc++)
16
17
 
17
18
  builder.include "<iostream>"
19
+ builder.include '"ruby/version.h"'
18
20
 
19
21
  builder.c "
20
22
  static
data/lib/inline.rb CHANGED
@@ -65,7 +65,7 @@ class CompilationError < RuntimeError; end
65
65
  # the current namespace.
66
66
 
67
67
  module Inline
68
- VERSION = "3.12.6"
68
+ VERSION = "3.14.0"
69
69
 
70
70
  WINDOZE = /mswin|mingw/ =~ RUBY_PLATFORM
71
71
  DEV_NULL = (WINDOZE ? 'nul' : '/dev/null')
@@ -74,12 +74,12 @@ module Inline
74
74
 
75
75
  warn "RubyInline v #{VERSION}" if $DEBUG
76
76
 
77
- def self.register cls
77
+ def self.register cls # for hoe/inline
78
78
  registered_inline_classes << cls
79
79
  registered_inline_classes.uniq!
80
80
  end
81
81
 
82
- def self.registered_inline_classes
82
+ def self.registered_inline_classes # for hoe/inline
83
83
  @@registered_inline_classes ||= []
84
84
  end
85
85
 
@@ -326,7 +326,7 @@ module Inline
326
326
  ext << "extern \"C\" {"
327
327
  ext << "#endif"
328
328
  ext << " __declspec(dllexport)" if WINDOZE
329
- ext << " void Init_#{module_name}() {"
329
+ ext << " void Init_#{module_name}(void) {"
330
330
  ext << " VALUE c = rb_cObject;"
331
331
 
332
332
  # TODO: use rb_class2path
@@ -449,7 +449,7 @@ module Inline
449
449
  @struct_name
450
450
 
451
451
  c <<-C
452
- VALUE #{method}() {
452
+ VALUE #{method}(void) {
453
453
  #{@struct_name} *pointer;
454
454
 
455
455
  Data_Get_Struct(self, #{@struct_name}, pointer);
@@ -535,14 +535,11 @@ VALUE #{method}_equals(VALUE value) {
535
535
  end
536
536
 
537
537
  src_name = "#{Inline.directory}/#{module_name}.c"
538
- old_src_name = "#{src_name}.old"
539
- should_compare = File.write_with_backup(src_name) do |io|
540
- io.puts generate_ext
541
- end
538
+ old_src_name = File.write_with_backup src_name, generate_ext
542
539
 
543
540
  # recompile only if the files are different
544
541
  recompile = true
545
- if so_exists and should_compare and
542
+ if so_exists and old_src_name and
546
543
  FileUtils.compare_file(old_src_name, src_name) then
547
544
  recompile = false
548
545
 
@@ -554,6 +551,9 @@ VALUE #{method}_equals(VALUE value) {
554
551
  end
555
552
 
556
553
  if recompile then
554
+ unless RbConfig::CONFIG["ENABLE_SHARED"] == "yes" then
555
+ raise "this ruby isn't configured for dynamic linking"
556
+ end
557
557
 
558
558
  hdrdir = %w(srcdir includedir archdir rubyhdrdir).map { |name|
559
559
  RbConfig::CONFIG[name]
@@ -562,6 +562,9 @@ VALUE #{method}_equals(VALUE value) {
562
562
  } or abort "ERROR: Can't find header dir for ruby. Exiting..."
563
563
 
564
564
  flags = @flags.join(' ')
565
+
566
+ @libs << RbConfig::CONFIG['LIBRUBYARG_SHARED']
567
+
565
568
  libs = @libs.join(' ')
566
569
 
567
570
  config_hdrdir = if RbConfig::CONFIG['rubyarchhdrdir'] then
@@ -828,22 +831,9 @@ class Module
828
831
  def inline(lang = :C, options={})
829
832
  Inline.register self
830
833
 
831
- case options
832
- when TrueClass, FalseClass then
833
- warn "WAR\NING: 2nd argument to inline is now a hash, changing to {:testing=>#{options}}" unless options
834
- options = { :testing => options }
835
- when Hash
836
- options[:testing] ||= false
837
- else
838
- raise ArgumentError, "BLAH"
839
- end
834
+ require "inline/#{lang}" unless Inline.const_defined? lang
840
835
 
841
- builder_class = begin
842
- Inline.const_get(lang)
843
- rescue NameError
844
- require "inline/#{lang}"
845
- Inline.const_get(lang)
846
- end
836
+ builder_class = Inline.const_get lang
847
837
 
848
838
  builder = builder_class.new self
849
839
 
@@ -863,25 +853,24 @@ class File
863
853
  ##
864
854
  # Equivalent to +File::open+ with an associated block, but moves
865
855
  # any existing file with the same name to the side first.
856
+ # Returns renamed path or false if none.
866
857
 
867
- def self.write_with_backup(path) # returns true if file already existed
868
-
869
- # move previous version to the side if it exists
858
+ def self.write_with_backup(path, content)
870
859
  renamed = false
860
+
871
861
  if File.file? path then
862
+ renamed = "#{path}.old"
863
+
872
864
  begin
873
- File.rename path, path + ".old"
874
- renamed = true
875
- rescue SystemCallError
865
+ File.rename path, renamed
866
+ rescue SystemCallError # in case of race condition
876
867
  # do nothing
877
868
  end
878
869
  end
879
870
 
880
- File.open(path, "w") do |io|
881
- yield(io)
882
- end
871
+ File.write path, content
883
872
 
884
- return renamed
873
+ renamed
885
874
  end
886
875
  end # class File
887
876
 
@@ -895,7 +884,7 @@ class Dir
895
884
 
896
885
  def self.assert_secure(path)
897
886
  mode = File.stat(path).mode
898
- unless ((mode % 01000) & 0022) == 0 then
887
+ unless mode % 01000 & 0022 == 0 then
899
888
  if $TESTING then
900
889
  raise SecurityError, "Directory #{path} is insecure"
901
890
  else
data/test/test_inline.rb CHANGED
@@ -769,7 +769,7 @@ static VALUE my_method(VALUE self) {
769
769
  #ifdef __cplusplus
770
770
  extern \"C\" {
771
771
  #endif#{windoze}
772
- void Init_Inline_TestInline__TestC_3ab8c09639e499394bb1f0a0194a839f() {
772
+ void Init_Inline_TestInline__TestC_3ab8c09639e499394bb1f0a0194a839f(void) {
773
773
  VALUE c = rb_cObject;
774
774
  c = rb_const_get(c, rb_intern("TestInline"));
775
775
  c = rb_const_get(c, rb_intern("TestC"));
data/tutorial/example1.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  # We started out with some code that averaged a ton of numbers in a
4
4
  # bunch of arrays. Once we finally lost our patience with the average
5
5
  # running time of the code, we decided to profile and optimize it
6
- # using RubyInline.
6
+ # using RubyInline.
7
7
 
8
8
  class Array
9
9
 
@@ -20,7 +20,7 @@ max_size = (ARGV.shift || 100_000).to_i
20
20
  a = (1..max_size).to_a
21
21
 
22
22
  1.upto(max_loop) do
23
- avg = a.average
23
+ a.average
24
24
  $stderr.print "."
25
25
  end
26
26
  $stderr.puts ""
@@ -34,7 +34,7 @@ $stderr.puts ""
34
34
 
35
35
  # & time ruby ./example1.rb 5 100000
36
36
  # .....
37
- #
37
+ #
38
38
  # real 0m4.580s
39
39
  # user 0m3.310s
40
40
  # sys 0m0.090s
data/tutorial/example2.rb CHANGED
@@ -27,7 +27,7 @@ max_size = (ARGV.shift || 100_000).to_i
27
27
  a = (1..max_size).to_a
28
28
 
29
29
  1.upto(max_loop) do
30
- avg = a.average
30
+ a.average
31
31
  $stderr.print "."
32
32
  end
33
33
  $stderr.puts ""
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: RubyInline
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.12.6
4
+ version: 3.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Davis
@@ -10,9 +10,9 @@ bindir: bin
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
- MIIDPjCCAiagAwIBAgIBBjANBgkqhkiG9w0BAQsFADBFMRMwEQYDVQQDDApyeWFu
13
+ MIIDPjCCAiagAwIBAgIBBzANBgkqhkiG9w0BAQsFADBFMRMwEQYDVQQDDApyeWFu
14
14
  ZC1ydWJ5MRkwFwYKCZImiZPyLGQBGRYJemVuc3BpZGVyMRMwEQYKCZImiZPyLGQB
15
- GRYDY29tMB4XDTIxMTIyMzIzMTkwNFoXDTIyMTIyMzIzMTkwNFowRTETMBEGA1UE
15
+ GRYDY29tMB4XDTIzMDEwMTA3NTExN1oXDTI0MDEwMTA3NTExN1owRTETMBEGA1UE
16
16
  AwwKcnlhbmQtcnVieTEZMBcGCgmSJomT8ixkARkWCXplbnNwaWRlcjETMBEGCgmS
17
17
  JomT8ixkARkWA2NvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALda
18
18
  b9DCgK+627gPJkB6XfjZ1itoOQvpqH1EXScSaba9/S2VF22VYQbXU1xQXL/WzCkx
@@ -22,14 +22,14 @@ cert_chain:
22
22
  qhtV7HJxNKuPj/JFH0D2cswvzznE/a5FOYO68g+YCuFi5L8wZuuM8zzdwjrWHqSV
23
23
  gBEfoTEGr7Zii72cx+sCAwEAAaM5MDcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAw
24
24
  HQYDVR0OBBYEFEfFe9md/r/tj/Wmwpy+MI8d9k/hMA0GCSqGSIb3DQEBCwUAA4IB
25
- AQCKB5jfsuSnKb+t/Wrh3UpdkmX7TrEsjVmERC0pPqzQ5GQJgmEXDD7oMgaKXaAq
26
- x2m+KSZDrqk7c8uho5OX6YMqg4KdxehfSLqqTZGoeV78qwf/jpPQZKTf+W9gUSJh
27
- zsWpo4K50MP+QtdSbKXZwjAafpQ8hK0MnnZ/aeCsW9ov5vdXpYbf3dpg6ADXRGE7
28
- lQY2y1tJ5/chqu6h7dQmnm2ABUqx9O+JcN9hbCYoA5i/EeubUEtFIh2w3SpO6YfB
29
- JFmxn4h9YO/pVdB962BdBNNDia0kgIjI3ENnkLq0dKpYU3+F3KhEuTksLO0L6X/V
30
- YsuyUzsMz6GQA4khyaMgKNSD
25
+ AQAkg3y+PBnBAPWdxxITm5sPHqdWQgSyCpRA20o4LTuWr8BWhSXBkfQNa7cY6fOn
26
+ xyM34VPzBFbExv6XOGDfOMFBVaYTHuN9peC/5/umL7kLl+nflXzL2QA7K6LYj5Bg
27
+ sM574Onr0dZDM6Vn69bzQ7rBIFDfK/OhlPzqKZad4nsdcsVH8ODCiT+ATMIZyz5K
28
+ WCnNtqlyiWXI8tdTpahDgcUwfcN/oN7v4K8iU5IbLJX6HQ5DKgmKjfb6XyMth16k
29
+ ROfWo9Uyp8ba/j9eVG14KkYRaLydAY1MNQk2yd3R5CGfeOpD1kttxjoypoUJ2dOG
30
+ nsNBRuQJ1UfiCG97a6DNm+Fr
31
31
  -----END CERTIFICATE-----
32
- date: 2022-05-23 00:00:00.000000000 Z
32
+ date: 2023-06-28 00:00:00.000000000 Z
33
33
  dependencies:
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: ZenTest
@@ -71,14 +71,14 @@ dependencies:
71
71
  requirements:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
- version: '3.23'
74
+ version: '4.0'
75
75
  type: :development
76
76
  prerelease: false
77
77
  version_requirements: !ruby/object:Gem::Requirement
78
78
  requirements:
79
79
  - - "~>"
80
80
  - !ruby/object:Gem::Version
81
- version: '3.23'
81
+ version: '4.0'
82
82
  description: |-
83
83
  Inline allows you to write foreign code within your ruby code. It
84
84
  automatically determines if the code in question has changed and
@@ -133,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
133
133
  version: '0'
134
134
  requirements:
135
135
  - A POSIX environment and a compiler for your language.
136
- rubygems_version: 3.3.12
136
+ rubygems_version: 3.4.10
137
137
  signing_key:
138
138
  specification_version: 4
139
139
  summary: Inline allows you to write foreign code within your ruby code
metadata.gz.sig CHANGED
Binary file