rubysl-dl 0.0.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,115 @@
1
+ # example:
2
+ # DLTYPE[INT][:rb2c]["arg0"] => "NUM2INT(arg0)"
3
+ # DLTYPE[DOUBLE][:c2rb]["r"] => "rb_float_new(r)"
4
+
5
+ DLTYPE = {
6
+ VOID = 0x00 => {
7
+ :name => 'VOID',
8
+ :rb2c => nil,
9
+ :c2rb => nil,
10
+ :ctype => "void",
11
+ :stmem => "v",
12
+ :sym => true,
13
+ :cb => true,
14
+ },
15
+ CHAR = 0x01 => {
16
+ :name => 'CHAR',
17
+ :rb2c => proc{|x| "NUM2CHR(#{x})"},
18
+ :c2rb => proc{|x| "CHR2FIX(#{x})"},
19
+ :ctype => "char",
20
+ :stmem => "c",
21
+ :sym => false,
22
+ :cb => false,
23
+ },
24
+ SHORT = 0x02 => {
25
+ :name => 'SHORT',
26
+ :rb2c => proc{|x| "FIX2INT(#{x})"},
27
+ :c2rb => proc{|x| "INT2FIX(#{x})"},
28
+ :ctype => "short",
29
+ :stmem => "h",
30
+ :sym => false,
31
+ :cb => false,
32
+ },
33
+ INT = 0x03 => {
34
+ :name => 'INT',
35
+ :rb2c => proc{|x| "NUM2INT(#{x})"},
36
+ :c2rb => proc{|x| "INT2NUM(#{x})"},
37
+ :ctype => "int",
38
+ :stmem => "i",
39
+ :sym => true,
40
+ :cb => false,
41
+ },
42
+ LONG = 0x04 => {
43
+ :name => 'LONG',
44
+ :rb2c => proc{|x| "NUM2INT(#{x})"},
45
+ :c2rb => proc{|x| "INT2NUM(#{x})"},
46
+ :ctype => "long",
47
+ :stmem => "l",
48
+ :sym => true,
49
+ :cb => true,
50
+ },
51
+ FLOAT = 0x05 => {
52
+ :name => 'FLOAT',
53
+ :rb2c => proc{|x| "(float)(RFLOAT(#{x})->value)"},
54
+ :c2rb => proc{|x| "rb_float_new((double)#{x})"},
55
+ :ctype => "float",
56
+ :stmem => "f",
57
+ :sym => false,
58
+ :cb => false,
59
+ },
60
+ DOUBLE = 0x06 => {
61
+ :name => 'DOUBLE',
62
+ :rb2c => proc{|x| "RFLOAT(#{x})->value"},
63
+ :c2rb => proc{|x| "rb_float_new(#{x})"},
64
+ :ctype => "double",
65
+ :stmem => "d",
66
+ :sym => true,
67
+ :cb => true,
68
+ },
69
+ VOIDP = 0x07 => {
70
+ :name => 'VOIDP',
71
+ :rb2c => proc{|x| "rb_dlptr2cptr(#{x})"},
72
+ :c2rb => proc{|x| "rb_dlptr_new(#{x},sizeof(void*),0)"},
73
+ :ctype => "void *",
74
+ :stmem => "p",
75
+ :sym => true,
76
+ :cb => true,
77
+ },
78
+ }
79
+
80
+ def tpush(t, x)
81
+ (t << 3)|x
82
+ end
83
+
84
+ def tget(t, i)
85
+ (t & (0x07 << (i * 3))) >> (i * 3)
86
+ end
87
+
88
+ def types2num(types)
89
+ res = 0x00
90
+ r = types.reverse
91
+ r.each{|t|
92
+ res = tpush(res,t)
93
+ }
94
+ res
95
+ end
96
+
97
+ def num2types(num)
98
+ ts = []
99
+ i = 0
100
+ t = tget(num,i)
101
+ while( (t != VOID && i > 0) || (i == 0) )
102
+ ts.push(DLTYPE[t][:ctype])
103
+ i += 1
104
+ t = tget(num,i)
105
+ end
106
+ ts
107
+ end
108
+
109
+ def types2ctypes(types)
110
+ res = []
111
+ types.each{|t|
112
+ res.push(DLTYPE[t][:ctype])
113
+ }
114
+ res
115
+ end
@@ -0,0 +1 @@
1
+ require "rubysl/dl"
@@ -0,0 +1,2 @@
1
+ require "dl/dl"
2
+ require "rubysl/dl/version"
@@ -0,0 +1,5 @@
1
+ module RubySL
2
+ module DL
3
+ VERSION = "1.0.0"
4
+ end
5
+ end
@@ -1,22 +1,24 @@
1
- # -*- encoding: utf-8 -*-
2
- require File.expand_path('../lib/rubysl-dl/version', __FILE__)
1
+ # coding: utf-8
2
+ require './lib/rubysl/dl/version'
3
3
 
4
- Gem::Specification.new do |gem|
5
- gem.authors = ["Brian Shirai"]
6
- gem.email = ["brixen@gmail.com"]
7
- gem.description = %q{Ruby Standard Library - dl}
8
- gem.summary = %q{Ruby Standard Library - dl}
9
- gem.homepage = ""
4
+ Gem::Specification.new do |spec|
5
+ spec.name = "rubysl-dl"
6
+ spec.version = RubySL::DL::VERSION
7
+ spec.authors = ["Brian Shirai"]
8
+ spec.email = ["brixen@gmail.com"]
9
+ spec.description = %q{Ruby standard library dl.}
10
+ spec.summary = %q{Ruby standard library dl.}
11
+ spec.homepage = "https://github.com/rubysl/rubysl-dl"
12
+ spec.license = "BSD"
10
13
 
11
- gem.files = `git ls-files`.split($\)
12
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
- gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
- gem.name = "rubysl-dl"
15
- gem.require_paths = ["lib"]
16
- gem.version = RubySL::Dl::VERSION
14
+ spec.files = `git ls-files`.split($/)
15
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
16
+ spec.extensions = ["ext/rubysl/dl/extconf.rb"]
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
17
19
 
18
- gem.add_runtime_dependency "redcard", "~> 1.0"
19
-
20
- gem.add_development_dependency "rake", "~> 10.0"
21
- gem.add_development_dependency "mspec", "~> 1.5"
20
+ spec.add_development_dependency "bundler", "~> 1.3"
21
+ spec.add_development_dependency "rake", "~> 10.0"
22
+ spec.add_development_dependency "mspec", "~> 1.5"
23
+ spec.add_development_dependency "rubysl-prettyprint", "~> 1.0"
22
24
  end
metadata CHANGED
@@ -1,118 +1,140 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: rubysl-dl
3
- version: !ruby/object:Gem::Version
4
- hash: 856480538658449761
5
- prerelease:
6
- segments:
7
- - 0
8
- - 0
9
- - 1
10
- version: 0.0.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - Brian Shirai
14
8
  autorequire:
15
9
  bindir: bin
16
10
  cert_chain: []
17
-
18
- date: 2013-04-15 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
21
- name: redcard
11
+ date: 2013-12-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
22
21
  prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
- none: false
25
- requirements:
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
26
24
  - - ~>
27
- - !ruby/object:Gem::Version
28
- hash: 4428665182548103036
29
- segments:
30
- - 1
31
- - 0
32
- version: "1.0"
33
- type: :runtime
34
- version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
36
28
  name: rake
37
- prerelease: false
38
- requirement: &id002 !ruby/object:Gem::Requirement
39
- none: false
40
- requirements:
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
41
31
  - - ~>
42
- - !ruby/object:Gem::Version
43
- hash: 1510892033553700768
44
- segments:
45
- - 10
46
- - 0
47
- version: "10.0"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
48
34
  type: :development
49
- version_requirements: *id002
50
- - !ruby/object:Gem::Dependency
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
51
42
  name: mspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.5'
48
+ type: :development
52
49
  prerelease: false
53
- requirement: &id003 !ruby/object:Gem::Requirement
54
- none: false
55
- requirements:
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.5'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubysl-prettyprint
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
56
59
  - - ~>
57
- - !ruby/object:Gem::Version
58
- hash: 1660815245844205030
59
- segments:
60
- - 1
61
- - 5
62
- version: "1.5"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.0'
63
62
  type: :development
64
- version_requirements: *id003
65
- description: Ruby Standard Library - dl
66
- email:
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '1.0'
69
+ description: Ruby standard library dl.
70
+ email:
67
71
  - brixen@gmail.com
68
72
  executables: []
69
-
70
- extensions: []
71
-
73
+ extensions:
74
+ - ext/rubysl/dl/extconf.rb
72
75
  extra_rdoc_files: []
73
-
74
- files:
76
+ files:
75
77
  - .gitignore
78
+ - .travis.yml
76
79
  - Gemfile
77
80
  - LICENSE
78
81
  - README.md
79
82
  - Rakefile
80
- - lib/rubysl-dl.rb
81
- - lib/rubysl-dl/version.rb
83
+ - ext/rubysl/dl/depend
84
+ - ext/rubysl/dl/dl.c
85
+ - ext/rubysl/dl/dl.def
86
+ - ext/rubysl/dl/dl.h
87
+ - ext/rubysl/dl/extconf.rb
88
+ - ext/rubysl/dl/h2rb
89
+ - ext/rubysl/dl/handle.c
90
+ - ext/rubysl/dl/install.rb
91
+ - ext/rubysl/dl/lib/dl/import.rb
92
+ - ext/rubysl/dl/lib/dl/struct.rb
93
+ - ext/rubysl/dl/lib/dl/types.rb
94
+ - ext/rubysl/dl/lib/dl/win32.rb
95
+ - ext/rubysl/dl/mkcall.rb
96
+ - ext/rubysl/dl/mkcallback.rb
97
+ - ext/rubysl/dl/mkcbtable.rb
98
+ - ext/rubysl/dl/ptr.c
99
+ - ext/rubysl/dl/sample/c++sample.C
100
+ - ext/rubysl/dl/sample/c++sample.rb
101
+ - ext/rubysl/dl/sample/drives.rb
102
+ - ext/rubysl/dl/sample/getch.rb
103
+ - ext/rubysl/dl/sample/libc.rb
104
+ - ext/rubysl/dl/sample/msgbox.rb
105
+ - ext/rubysl/dl/sample/msgbox2.rb
106
+ - ext/rubysl/dl/sample/stream.rb
107
+ - ext/rubysl/dl/sym.c
108
+ - ext/rubysl/dl/test/libtest.def
109
+ - ext/rubysl/dl/test/test.c
110
+ - ext/rubysl/dl/test/test.rb
111
+ - ext/rubysl/dl/type.rb
112
+ - lib/dl.rb
113
+ - lib/rubysl/dl.rb
114
+ - lib/rubysl/dl/version.rb
82
115
  - rubysl-dl.gemspec
83
- homepage: ""
84
- licenses: []
85
-
116
+ homepage: https://github.com/rubysl/rubysl-dl
117
+ licenses:
118
+ - BSD
119
+ metadata: {}
86
120
  post_install_message:
87
121
  rdoc_options: []
88
-
89
- require_paths:
122
+ require_paths:
90
123
  - lib
91
- required_ruby_version: !ruby/object:Gem::Requirement
92
- none: false
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- hash: 2002549777813010636
97
- segments:
98
- - 0
99
- version: "0"
100
- required_rubygems_version: !ruby/object:Gem::Requirement
101
- none: false
102
- requirements:
103
- - - ">="
104
- - !ruby/object:Gem::Version
105
- hash: 2002549777813010636
106
- segments:
107
- - 0
108
- version: "0"
124
+ required_ruby_version: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - '>='
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ required_rubygems_version: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
109
134
  requirements: []
110
-
111
135
  rubyforge_project:
112
- rubygems_version: 1.8.25
136
+ rubygems_version: 2.0.7
113
137
  signing_key:
114
- specification_version: 3
115
- summary: Ruby Standard Library - dl
138
+ specification_version: 4
139
+ summary: Ruby standard library dl.
116
140
  test_files: []
117
-
118
- has_rdoc:
@@ -1,7 +0,0 @@
1
- require "rubysl-dl/version"
2
-
3
- module RubySL
4
- module Dl
5
- # Your code goes here...
6
- end
7
- end
@@ -1,5 +0,0 @@
1
- module RubySL
2
- module Dl
3
- VERSION = "0.0.1"
4
- end
5
- end