RubyInline 3.12.6 → 3.14.0
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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/History.txt +22 -0
- data/Rakefile +6 -3
- data/example.rb +5 -5
- data/example2.rb +2 -0
- data/lib/inline.rb +25 -36
- data/test/test_inline.rb +1 -1
- data/tutorial/example1.rb +3 -3
- data/tutorial/example2.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +13 -13
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 14e2dd1d335589d1f389ba716c031d8778d02d0b2c74e35ad981168dd7d0999d
|
4
|
+
data.tar.gz: 5b39db47e57df1e9494db491e778e121f0556b8827270ea6cbd63899c03f8f52
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
-
|
58
|
+
max.times do
|
59
59
|
# do nothing
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
63
|
x.report("c") do
|
64
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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.
|
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 =
|
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
|
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
|
-
|
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 =
|
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)
|
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,
|
874
|
-
|
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.
|
881
|
-
yield(io)
|
882
|
-
end
|
871
|
+
File.write path, content
|
883
872
|
|
884
|
-
|
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
|
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
|
-
|
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
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.
|
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
|
-
|
13
|
+
MIIDPjCCAiagAwIBAgIBBzANBgkqhkiG9w0BAQsFADBFMRMwEQYDVQQDDApyeWFu
|
14
14
|
ZC1ydWJ5MRkwFwYKCZImiZPyLGQBGRYJemVuc3BpZGVyMRMwEQYKCZImiZPyLGQB
|
15
|
-
|
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
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
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:
|
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: '
|
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: '
|
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.
|
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
|