RubyInline 3.4.0 → 3.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,13 @@
1
+ *** 3.5.0 / 2005-10-15
2
+
3
+ + 4 minor enhancements
4
+ + Switched to install for Makefile.
5
+ + Lots of minor cleanup.
6
+ + Added add_to_init to extend init methods. Great hack!
7
+ + Added 2 demo files used in the rubyconf 2005 presentation.
8
+ + 1 bug fix
9
+ + Fixed example in README.txt. OOPS!
10
+
1
11
  *** 3.4.0 / 2005-07-13
2
12
 
3
13
  + 2 minor enhancement
data/Makefile CHANGED
@@ -30,17 +30,12 @@ bench:
30
30
  @$(RUBY) -I. ./example.rb 2 2> /dev/null
31
31
 
32
32
  install:
33
- echo "installing inline.rb in $(RUBYLIB)"
34
- cp -f inline.rb $(RUBYLIB)
35
- cp -f inline_package $(PREFIX)/bin
36
- chmod 755 $(PREFIX)/bin/inline_package
37
- echo Installed
33
+ install -m 0444 inline.rb $(RUBYLIB)
34
+ install -m 0555 inline_package $(PREFIX)/bin
38
35
 
39
36
  uninstall:
40
- echo "Removing inline.rb from $(RUBYLIB)"
41
- rm $(RUBYLIB)/inline.rb
37
+ rm -f $(RUBYLIB)/inline.rb
42
38
  rm -f $(PREFIX)/bin/inline_package
43
- echo Removed
44
39
 
45
40
  clean:
46
41
  rm -rf *~ doc ~/.ruby_inline
data/Manifest.txt CHANGED
@@ -2,6 +2,8 @@ History.txt
2
2
  Makefile
3
3
  Manifest.txt
4
4
  README.txt
5
+ demo/fastmath.rb
6
+ demo/hello.rb
5
7
  example.rb
6
8
  example2.rb
7
9
  inline.gemspec
data/README.txt CHANGED
@@ -32,31 +32,31 @@ compiler (read: windows)!
32
32
 
33
33
  require "inline"
34
34
  class MyTest
35
- inline_c "
36
- long factorial(int max) {
37
- int i=max, result=1;
38
- while (i >= 2) { result *= i--; }
39
- return result;
40
- }"
35
+ inline do |builder|
36
+ builder.c "
37
+ long factorial(int max) {
38
+ int i=max, result=1;
39
+ while (i >= 2) { result *= i--; }
40
+ return result;
41
+ }"
41
42
  end
42
43
  t = MyTest.new()
43
44
  factorial_5 = t.factorial(5)
44
45
 
45
46
  ** SYNOPSYS (C++):
46
47
 
47
- $INLINE_FLAGS = " -x c++ "
48
- $INLINE_LIBS = " -lstdc++ "
49
- require "inline"
48
+ require 'inline'
50
49
  class MyTest
51
- inline_c "
52
- #include <iostream>
53
- static
54
- VALUE
55
- hello(int i) {
56
- while (i-- > 0) {
57
- std::cout << \"hello\" << std::endl;
58
- }
59
- }"
50
+ inline(:C) do |builder|
51
+ builder.include '<iostream>'
52
+ builder.add_compile_flags '-x c++', '-lstdc++'
53
+ builder.c '
54
+ void hello(int i) {
55
+ while (i-- > 0) {
56
+ std::cout << "hello" << std::endl;
57
+ }
58
+ }'
59
+ end
60
60
  end
61
61
  t = MyTest.new()
62
62
  t.hello(3)
@@ -95,7 +95,7 @@ compiler (read: windows)!
95
95
 
96
96
  ** REQUIREMENTS:
97
97
 
98
- + Ruby - 1.6.7 & 1.8.2 has been used on FreeBSD 4.6+ and MacOSX.
98
+ + Ruby - 1.8.2 has been used on FreeBSD 4.6+ and MacOSX.
99
99
  + POSIX compliant system (ie pretty much any UNIX, or Cygwin on MS platforms).
100
100
  + A C/C++ compiler (the same one that compiled your ruby interpreter).
101
101
  + test::unit for running tests ( http://testunit.talbott.ws/ ).
data/demo/fastmath.rb ADDED
@@ -0,0 +1,27 @@
1
+
2
+ begin require 'rubygems' rescue LoadError end
3
+ require 'inline'
4
+
5
+ class FastMath
6
+ def factorial(n)
7
+ f = 1
8
+ n.downto(2) { |x| f *= x }
9
+ return f
10
+ end
11
+ inline do |builder|
12
+ builder.c "
13
+ long factorial_c(int max) {
14
+ int i=max, result=1;
15
+ while (i >= 2) { result *= i--; }
16
+ return result;
17
+ }"
18
+ end
19
+ end
20
+
21
+ math = FastMath.new
22
+
23
+ if ARGV.empty? then
24
+ 30000.times do math.factorial(20); end
25
+ else
26
+ 30000.times do math.factorial_c(20); end
27
+ end
data/demo/hello.rb ADDED
@@ -0,0 +1,13 @@
1
+ #!/usr/local/bin/ruby -w
2
+
3
+ begin require 'rubygems' rescue LoadError end
4
+ require 'inline'
5
+
6
+ class Hello
7
+ inline do |builder|
8
+ builder.include "<stdio.h>"
9
+ builder.c 'void hello() { puts("hello world"); }'
10
+ end
11
+ end
12
+
13
+ Hello.new.hello
data/example.rb CHANGED
@@ -12,8 +12,6 @@ class MyTest
12
12
  end
13
13
 
14
14
  inline do |builder|
15
- builder.include "<math.h>"
16
-
17
15
  builder.c "
18
16
  long factorial_c(int max) {
19
17
  int i=max, result=1;
data/inline.rb CHANGED
@@ -51,7 +51,7 @@ class CompilationError < RuntimeError; end
51
51
  # the current namespace.
52
52
 
53
53
  module Inline
54
- VERSION = '3.4.0'
54
+ VERSION = '3.5.0'
55
55
 
56
56
  $stderr.puts "RubyInline v #{VERSION}" if $DEBUG
57
57
 
@@ -276,6 +276,7 @@ module Inline
276
276
  @sig = {}
277
277
  @flags = []
278
278
  @libs = []
279
+ @init_extra = []
279
280
  end
280
281
 
281
282
  ##
@@ -337,6 +338,9 @@ module Inline
337
338
  end
338
339
  io.puts "(VALUE(*)(ANYARGS))#{name}, #{arity});"
339
340
  end
341
+
342
+ io.puts @init_extra.join("\n") unless @init_extra.empty?
343
+
340
344
  io.puts
341
345
  io.puts " }"
342
346
  io.puts "#ifdef __cplusplus"
@@ -386,7 +390,7 @@ module Inline
386
390
  cmd += ' -L/usr/local/lib -lruby.dll'
387
391
  end
388
392
 
389
- cmd += " 2> /dev/null" if $TESTING
393
+ cmd += " 2> /dev/null" if $TESTING and not $DEBUG
390
394
 
391
395
  $stderr.puts "Building #{so_name} with '#{cmd}'" if $DEBUG
392
396
  `#{cmd}`
@@ -420,6 +424,13 @@ module Inline
420
424
  @libs.push(*flags)
421
425
  end
422
426
 
427
+ ##
428
+ # Adds custom content to the end of the init function.
429
+
430
+ def add_to_init(*src)
431
+ @init_extra.push(*src)
432
+ end
433
+
423
434
  ##
424
435
  # Registers C type-casts +r2c+ and +c2r+ for +type+.
425
436
 
data/test_inline.rb CHANGED
@@ -248,7 +248,7 @@ class TestC < InlineTestCase
248
248
  result = builder.generate src, expand_types
249
249
  end
250
250
  result.gsub!(/\# line \d+/, '# line N')
251
- expected = '# line N "./test_inline.rb"' + "\n" + expected
251
+ expected = "# line N \"#{$0}\"\n" + expected
252
252
  assert_equal(expected, result)
253
253
  end
254
254
 
@@ -462,7 +462,7 @@ puts(s); return rb_str_new2(s)}"
462
462
  result = builder.c "int add(int a, int b) { return a + b; }"
463
463
  end
464
464
 
465
- expected = "# line N \"./test_inline.rb\"\nstatic VALUE add(VALUE self, VALUE _a, VALUE _b) {\n int a = FIX2INT(_a);\n int b = FIX2INT(_b);\n return INT2FIX(a + b); }"
465
+ expected = "# line N \"#{$0}\"\nstatic VALUE add(VALUE self, VALUE _a, VALUE _b) {\n int a = FIX2INT(_a);\n int b = FIX2INT(_b);\n return INT2FIX(a + b); }"
466
466
 
467
467
  result.gsub!(/\# line \d+/, '# line N')
468
468
 
@@ -479,7 +479,7 @@ puts(s); return rb_str_new2(s)}"
479
479
  end
480
480
 
481
481
  result.gsub!(/\# line \d+/, '# line N')
482
- expected = "# line N \"./test_inline.rb\"\n" + src
482
+ expected = "# line N \"#{$0}\"\n" + src
483
483
 
484
484
  assert_equal expected, result
485
485
  assert_equal [expected], builder.src
metadata CHANGED
@@ -1,54 +1,58 @@
1
- --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.8.10.1
1
+ !ruby/object:Gem::Specification
2
+ rubygems_version: 0.8.11.1
3
3
  specification_version: 1
4
4
  name: RubyInline
5
5
  version: !ruby/object:Gem::Version
6
- version: 3.4.0
7
- date: 2005-07-13
6
+ version: 3.5.0
7
+ date: 2005-10-16 00:00:00 -07:00
8
8
  summary: Multi-language extension coding within ruby.
9
9
  require_paths:
10
- - "."
10
+ - .
11
11
  email: ryand-ruby@zenspider.com
12
12
  homepage: http://www.zenspider.com/ZSS/Products/RubyInline/
13
13
  rubyforge_project: rubyinline
14
- description: "Ruby Inline is an analog to Perl's Inline::C. Out of the box, it allows you to
15
- embed C/++ external module code in your ruby script directly. By writing simple
16
- builder classes, you can teach how to cope with new languages (fortran, perl,
17
- whatever). The code is compiled and run on the fly when needed."
14
+ description: Ruby Inline is an analog to Perl's Inline::C. Out of the box, it allows you to embed C/++ external module code in your ruby script directly. By writing simple builder classes, you can teach how to cope with new languages (fortran, perl, whatever). The code is compiled and run on the fly when needed.
18
15
  autorequire: inline
19
16
  default_executable:
20
- bindir: "."
17
+ bindir: .
21
18
  has_rdoc: false
22
19
  required_ruby_version: !ruby/object:Gem::Version::Requirement
23
20
  requirements:
24
- -
25
- - ">"
26
- - !ruby/object:Gem::Version
27
- version: 0.0.0
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
28
24
  version:
29
25
  platform: ruby
26
+ signing_key:
27
+ cert_chain:
30
28
  authors:
31
- - Ryan Davis
29
+ - Ryan Davis
32
30
  files:
33
- - History.txt
34
- - Makefile
35
- - Manifest.txt
36
- - README.txt
37
- - example.rb
38
- - example2.rb
39
- - inline.gemspec
40
- - inline.rb
41
- - inline_package
42
- - test_inline.rb
43
- - tutorial/example1.rb
44
- - tutorial/example2.rb
31
+ - History.txt
32
+ - Makefile
33
+ - Manifest.txt
34
+ - README.txt
35
+ - demo/fastmath.rb
36
+ - demo/hello.rb
37
+ - example.rb
38
+ - example2.rb
39
+ - inline.gemspec
40
+ - inline.rb
41
+ - inline_package
42
+ - test_inline.rb
43
+ - tutorial/example1.rb
44
+ - tutorial/example2.rb
45
45
  test_files:
46
- - test_inline.rb
46
+ - test_inline.rb
47
47
  rdoc_options: []
48
+
48
49
  extra_rdoc_files: []
50
+
49
51
  executables:
50
- - inline_package
52
+ - inline_package
51
53
  extensions: []
54
+
52
55
  requirements:
53
- - A POSIX environment and a compiler for your language.
54
- dependencies: []
56
+ - A POSIX environment and a compiler for your language.
57
+ dependencies: []
58
+