RubyInline 3.13.0 → 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: 6fb686fe259ea5574fa2a1f00e0a6d7dc4e1d8a7aa3c1ba44b5f2fd07951962c
4
- data.tar.gz: af619f2046cbbb045a242aa0b6292953e98cbb917244587e026d8a27e32fe9a5
3
+ metadata.gz: 14e2dd1d335589d1f389ba716c031d8778d02d0b2c74e35ad981168dd7d0999d
4
+ data.tar.gz: 5b39db47e57df1e9494db491e778e121f0556b8827270ea6cbd63899c03f8f52
5
5
  SHA512:
6
- metadata.gz: ab7bb820deb6412c42493a8efb50e60cdcb7d3bc5ce0c6f0918efeb253c6621f3b49eb9d325d90bc968ee9a98aa011346665a16785ad2a2f438e7eeddc894448
7
- data.tar.gz: f79d57058eef27a84ee713d108cff2acdb38b69a8a167825e673c773cc8a8cb20ad25b4c9b6af31574c16526d20870bf237eced0e0e35cd44da9ba373b16712b
6
+ metadata.gz: 9cce3379d5f7876f9ed3f8736eb3ef90beeea58730fc9303c532efebaf629ea097481e06084a61ddb379319e599ca002385c458a8a183464a1f6199014f8c6b6
7
+ data.tar.gz: 1650103a7b18af47316fd0983baa3877a36776e71732ac1ffa71cf715fa86415a9bd1ad7584efc74378a2db52c287e6243cedae4cbf025224aaf09136381f67c
checksums.yaml.gz.sig CHANGED
Binary file
data/History.txt CHANGED
@@ -1,3 +1,15 @@
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
+
1
13
  === 3.13.0 / 2023-01-31
2
14
 
3
15
  * 1 minor enhancement:
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
 
@@ -33,7 +35,7 @@ task :examples do
33
35
  end
34
36
 
35
37
  desc "run simple benchmarks"
36
- task :bench do
38
+ task :bench => [:clean, :isolate] do
37
39
  verbose(false) do
38
40
  ruby "-Ilib ./example.rb"
39
41
  ruby "-Ilib ./example.rb 1000000 12" # 12 is the bignum cutoff for factorial
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.13.0"
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
 
@@ -834,22 +831,9 @@ class Module
834
831
  def inline(lang = :C, options={})
835
832
  Inline.register self
836
833
 
837
- case options
838
- when TrueClass, FalseClass then
839
- warn "WAR\NING: 2nd argument to inline is now a hash, changing to {:testing=>#{options}}" unless options
840
- options = { :testing => options }
841
- when Hash
842
- options[:testing] ||= false
843
- else
844
- raise ArgumentError, "BLAH"
845
- end
834
+ require "inline/#{lang}" unless Inline.const_defined? lang
846
835
 
847
- builder_class = begin
848
- Inline.const_get(lang)
849
- rescue NameError
850
- require "inline/#{lang}"
851
- Inline.const_get(lang)
852
- end
836
+ builder_class = Inline.const_get lang
853
837
 
854
838
  builder = builder_class.new self
855
839
 
@@ -869,25 +853,24 @@ class File
869
853
  ##
870
854
  # Equivalent to +File::open+ with an associated block, but moves
871
855
  # any existing file with the same name to the side first.
856
+ # Returns renamed path or false if none.
872
857
 
873
- def self.write_with_backup(path) # returns true if file already existed
874
-
875
- # move previous version to the side if it exists
858
+ def self.write_with_backup(path, content)
876
859
  renamed = false
860
+
877
861
  if File.file? path then
862
+ renamed = "#{path}.old"
863
+
878
864
  begin
879
- File.rename path, path + ".old"
880
- renamed = true
881
- rescue SystemCallError
865
+ File.rename path, renamed
866
+ rescue SystemCallError # in case of race condition
882
867
  # do nothing
883
868
  end
884
869
  end
885
870
 
886
- File.open(path, "w") do |io|
887
- yield(io)
888
- end
871
+ File.write path, content
889
872
 
890
- return renamed
873
+ renamed
891
874
  end
892
875
  end # class File
893
876
 
@@ -901,7 +884,7 @@ class Dir
901
884
 
902
885
  def self.assert_secure(path)
903
886
  mode = File.stat(path).mode
904
- unless ((mode % 01000) & 0022) == 0 then
887
+ unless mode % 01000 & 0022 == 0 then
905
888
  if $TESTING then
906
889
  raise SecurityError, "Directory #{path} is insecure"
907
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.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.13.0
4
+ version: 3.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Davis
@@ -29,7 +29,7 @@ cert_chain:
29
29
  ROfWo9Uyp8ba/j9eVG14KkYRaLydAY1MNQk2yd3R5CGfeOpD1kttxjoypoUJ2dOG
30
30
  nsNBRuQJ1UfiCG97a6DNm+Fr
31
31
  -----END CERTIFICATE-----
32
- date: 2023-02-01 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
@@ -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.4.3
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
@@ -1,2 +1,3 @@
1
- �^�����AV?���������"I:YZHvp*������������J�=� �D� �–2A��F"��kS��H(9X��Ikt0M
2
- J��������N��Zu����x�T1LG�&�
1
+ X.(-�_w
2
+ G��x>��cQygYݲ���S�c��� ��^M}�HŨ"���zu ���R�k��q���@</G��ʹ���{�<�.��l�t�x�B�B�cN�ucV�<|f�m�Q,e4�U}�xJ���Qf|�
3
+ U����}�Z�Z�%�V5v*-J7J�N�P�Q\Q5���ö�Aj��ٰ��GXA\P