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.
- checksums.yaml +7 -0
- data/.gitignore +0 -1
- data/.travis.yml +8 -0
- data/README.md +2 -2
- data/Rakefile +0 -1
- data/ext/rubysl/dl/depend +46 -0
- data/ext/rubysl/dl/dl.c +742 -0
- data/ext/rubysl/dl/dl.def +59 -0
- data/ext/rubysl/dl/dl.h +313 -0
- data/ext/rubysl/dl/extconf.rb +193 -0
- data/ext/rubysl/dl/h2rb +500 -0
- data/ext/rubysl/dl/handle.c +215 -0
- data/ext/rubysl/dl/install.rb +49 -0
- data/ext/rubysl/dl/lib/dl/import.rb +225 -0
- data/ext/rubysl/dl/lib/dl/struct.rb +149 -0
- data/ext/rubysl/dl/lib/dl/types.rb +245 -0
- data/ext/rubysl/dl/lib/dl/win32.rb +25 -0
- data/ext/rubysl/dl/mkcall.rb +69 -0
- data/ext/rubysl/dl/mkcallback.rb +63 -0
- data/ext/rubysl/dl/mkcbtable.rb +25 -0
- data/ext/rubysl/dl/ptr.c +1062 -0
- data/ext/rubysl/dl/sample/c++sample.C +35 -0
- data/ext/rubysl/dl/sample/c++sample.rb +60 -0
- data/ext/rubysl/dl/sample/drives.rb +70 -0
- data/ext/rubysl/dl/sample/getch.rb +5 -0
- data/ext/rubysl/dl/sample/libc.rb +69 -0
- data/ext/rubysl/dl/sample/msgbox.rb +19 -0
- data/ext/rubysl/dl/sample/msgbox2.rb +18 -0
- data/ext/rubysl/dl/sample/stream.rb +87 -0
- data/ext/rubysl/dl/sym.c +993 -0
- data/ext/rubysl/dl/test/libtest.def +28 -0
- data/ext/rubysl/dl/test/test.c +247 -0
- data/ext/rubysl/dl/test/test.rb +306 -0
- data/ext/rubysl/dl/type.rb +115 -0
- data/lib/dl.rb +1 -0
- data/lib/rubysl/dl.rb +2 -0
- data/lib/rubysl/dl/version.rb +5 -0
- data/rubysl-dl.gemspec +20 -18
- metadata +109 -87
- data/lib/rubysl-dl.rb +0 -7
- data/lib/rubysl-dl/version.rb +0 -5
@@ -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
|
data/lib/dl.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "rubysl/dl"
|
data/lib/rubysl/dl.rb
ADDED
data/rubysl-dl.gemspec
CHANGED
@@ -1,22 +1,24 @@
|
|
1
|
-
#
|
2
|
-
require
|
1
|
+
# coding: utf-8
|
2
|
+
require './lib/rubysl/dl/version'
|
3
3
|
|
4
|
-
Gem::Specification.new do |
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
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
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
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
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
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
|
-
|
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
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
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
|
-
|
24
|
-
|
25
|
-
requirements:
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
26
24
|
- - ~>
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
|
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
|
-
|
38
|
-
|
39
|
-
none: false
|
40
|
-
requirements:
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
41
31
|
- - ~>
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
|
44
|
-
segments:
|
45
|
-
- 10
|
46
|
-
- 0
|
47
|
-
version: "10.0"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
48
34
|
type: :development
|
49
|
-
|
50
|
-
|
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
|
-
|
54
|
-
|
55
|
-
|
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
|
-
|
59
|
-
segments:
|
60
|
-
- 1
|
61
|
-
- 5
|
62
|
-
version: "1.5"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.0'
|
63
62
|
type: :development
|
64
|
-
|
65
|
-
|
66
|
-
|
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
|
-
|
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
|
-
-
|
81
|
-
-
|
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
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
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:
|
136
|
+
rubygems_version: 2.0.7
|
113
137
|
signing_key:
|
114
|
-
specification_version:
|
115
|
-
summary: Ruby
|
138
|
+
specification_version: 4
|
139
|
+
summary: Ruby standard library dl.
|
116
140
|
test_files: []
|
117
|
-
|
118
|
-
has_rdoc:
|
data/lib/rubysl-dl.rb
DELETED