cgen 0.16.8 → 0.16.10
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 +7 -0
- data/History.txt +8 -0
- data/{README.txt → README.md} +10 -10
- data/lib/cgen/cgen.rb +2 -2
- data/lib/cgen/cshadow.rb +21 -25
- data/test/test-attribute.rb +1 -4
- data/test/test-cshadow.rb +13 -23
- data/test/test.rb +1 -1
- metadata +57 -98
- data/.bnsignore +0 -22
- data/.gitignore +0 -8
- data/rakefile +0 -40
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f3c9caebbcfcf578bd5877bacb6dcc0b2786ac41
|
4
|
+
data.tar.gz: 7bc92dd9303689f9fb0e9636c63c8265d54344b3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0600620f4408bcc9fc5f4eb6557f192fe7538445665184b408f6460986d793532f836b020e66db1e82deef399f6e47ed1b312efd38f69eb1f8095d95edfa98f8
|
7
|
+
data.tar.gz: ac8c34a7e85ce8bb888613b47bb26f039a629eac6ff736a6eb0511c2710b3c28c02283c3c3a00b1945240aff0949bd0afdf3d4de4554f2bb58d09cfd6dd63c42
|
data/History.txt
CHANGED
data/{README.txt → README.md}
RENAMED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
# Overview #
|
2
2
|
|
3
3
|
Ruby has a C interface for defining extensions to the language. Using this interface, you define functions in C and add them as methods that are callable from ruby code. You may also define classes, modules, globals, and so on.
|
4
4
|
|
@@ -10,7 +10,7 @@ Including the CShadow module in a class lets you define the structure of the dat
|
|
10
10
|
|
11
11
|
See the CGenerator, CShadow, and CShadow::Attribute pages for details.
|
12
12
|
|
13
|
-
|
13
|
+
# Purpose and history #
|
14
14
|
|
15
15
|
The intended use of cgen is managing a complex library that may change from one run of the program to the next. The reason for the change might be that the program is written in a DSL (domain-specific language), and that the library functions are generated based on the statements of the DSL.
|
16
16
|
|
@@ -20,9 +20,9 @@ Cgen was introduced in 2001 with this post:
|
|
20
20
|
|
21
21
|
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/24443
|
22
22
|
|
23
|
-
|
23
|
+
# Getting started #
|
24
24
|
|
25
|
-
|
25
|
+
## Installing ##
|
26
26
|
|
27
27
|
Cgen is available from http://rubyforge.org/projects/cgen.
|
28
28
|
|
@@ -36,7 +36,7 @@ or from tarball, by unpacking and then:
|
|
36
36
|
ruby install.rb setup
|
37
37
|
ruby install.rb install
|
38
38
|
|
39
|
-
|
39
|
+
### System Requirements ###
|
40
40
|
|
41
41
|
Cgen is pure ruby, so you don't need a compiler to install it. However, you do need a C compiler to do anything useful with it.
|
42
42
|
|
@@ -48,7 +48,7 @@ On Windows, you should use a compiler that is compatible with your ruby interpre
|
|
48
48
|
* MSVC 2003
|
49
49
|
* Mingw32 (gcc; the foundation of the new OCI by Luis Lavena)
|
50
50
|
|
51
|
-
|
51
|
+
# Examples #
|
52
52
|
|
53
53
|
The cgen package comes with a substantial examples directory, but it is not yet very well organized. Here are the best ones to start with:
|
54
54
|
|
@@ -61,15 +61,15 @@ complex.rb::
|
|
61
61
|
matrix.rb::
|
62
62
|
second example of CShadow
|
63
63
|
|
64
|
-
|
64
|
+
# Web site #
|
65
65
|
|
66
66
|
http://rubyforge.org/projects/cgen
|
67
67
|
http://cgen.rubyforge.org/
|
68
68
|
|
69
|
-
|
69
|
+
# License #
|
70
70
|
|
71
71
|
Ruby license.
|
72
72
|
|
73
|
-
|
73
|
+
# Author #
|
74
74
|
|
75
|
-
Copyright 2001-
|
75
|
+
Copyright 2001-2013, Joel VanderWerf, mailto:vjoel@users.sourceforge.net.
|
data/lib/cgen/cgen.rb
CHANGED
@@ -897,7 +897,7 @@ class Library < Template
|
|
897
897
|
dep = "depend"
|
898
898
|
return if Dir[cpat].all? {|f| test ?<, f, dep}
|
899
899
|
|
900
|
-
cfg =
|
900
|
+
cfg = RbConfig::CONFIG
|
901
901
|
dirs = [cfg["sitearchdir"], cfg["archdir"], cfg["includedir"], *include_dirs]
|
902
902
|
|
903
903
|
case cfg["CC"]
|
@@ -938,7 +938,7 @@ class Library < Template
|
|
938
938
|
# the global namespace.
|
939
939
|
build_wrapper do
|
940
940
|
require 'rbconfig'
|
941
|
-
ruby =
|
941
|
+
ruby = RbConfig::CONFIG["RUBY_INSTALL_NAME"]
|
942
942
|
|
943
943
|
old_contents = File.read("extconf.rb") rescue nil
|
944
944
|
contents = extconf
|
data/lib/cgen/cshadow.rb
CHANGED
@@ -1088,35 +1088,31 @@ module CShadow
|
|
1088
1088
|
end
|
1089
1089
|
end
|
1090
1090
|
|
1091
|
-
|
1092
|
-
|
1093
|
-
|
1094
|
-
|
1095
|
-
|
1096
|
-
|
1097
|
-
|
1098
|
-
|
1099
|
-
|
1091
|
+
def each_persistent_attr # :yields: attr_name
|
1092
|
+
psa = self.class.shadow_attrs.select {|attr| attr.persists}
|
1093
|
+
psa.each do |attr|
|
1094
|
+
yield attr.var.to_s
|
1095
|
+
end
|
1096
|
+
instance_variables.each do |ivar|
|
1097
|
+
yield ivar[1..-1]
|
1098
|
+
end
|
1099
|
+
end
|
1100
1100
|
|
1101
|
-
|
1102
|
-
|
1103
|
-
|
1101
|
+
def encode_with coder
|
1102
|
+
each_persistent_attr_value do |attr, value|
|
1103
|
+
coder[attr] = value
|
1104
1104
|
end
|
1105
|
+
end
|
1105
1106
|
|
1106
|
-
|
1107
|
-
|
1108
|
-
|
1109
|
-
map.add(attr, value)
|
1110
|
-
end
|
1111
|
-
end
|
1107
|
+
def init_with coder
|
1108
|
+
psa = self.class.shadow_attrs.select {|attr| attr.persists}
|
1109
|
+
psvars = psa.map{|attr|attr.var.to_s}
|
1112
1110
|
|
1113
|
-
|
1114
|
-
|
1115
|
-
|
1116
|
-
|
1117
|
-
|
1118
|
-
end
|
1119
|
-
end
|
1111
|
+
from_array = psvars.map {|sv| coder[sv]}
|
1112
|
+
_load_data(from_array)
|
1113
|
+
|
1114
|
+
(coder.map.keys - psvars).each do |ivar|
|
1115
|
+
obj.instance_variable_set("@#{ivar}", coder[ivar])
|
1120
1116
|
end
|
1121
1117
|
end
|
1122
1118
|
end
|
data/test/test-attribute.rb
CHANGED
@@ -465,13 +465,10 @@ class MarshalTest < Test::Unit::TestCase
|
|
465
465
|
|
466
466
|
count = 0
|
467
467
|
str = Marshal.dump ms1
|
468
|
-
copy = Marshal.load str
|
469
|
-
if x.class == MarshalSample then count += 1 end
|
470
|
-
}
|
468
|
+
copy = Marshal.load str
|
471
469
|
|
472
470
|
assert_same(copy.x, copy.t.x)
|
473
471
|
assert_same(copy.x.x, copy)
|
474
|
-
assert_equal(3, count)
|
475
472
|
end
|
476
473
|
end
|
477
474
|
|
data/test/test-cshadow.rb
CHANGED
@@ -261,29 +261,19 @@ class OtherBaseTestCase < Test::Unit::TestCase
|
|
261
261
|
|
262
262
|
end
|
263
263
|
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
base = Base.new
|
278
|
-
base.obj = [1,2,3]
|
279
|
-
base.np = "456"
|
280
|
-
|
281
|
-
base2 = YAML.load(YAML.dump(base))
|
282
|
-
|
283
|
-
assert_equal(base.obj, base2.obj)
|
284
|
-
assert_equal(nil, base2.np)
|
285
|
-
end
|
286
|
-
|
264
|
+
require 'yaml'
|
265
|
+
|
266
|
+
class YamlTest < Test::Unit::TestCase
|
267
|
+
|
268
|
+
def test_yaml
|
269
|
+
base = Base.new
|
270
|
+
base.obj = [1,2,3]
|
271
|
+
base.np = "456"
|
272
|
+
base.instance_variable_set(:@ivar, "save this too")
|
273
|
+
base2 = YAML.load(YAML.dump(base))
|
274
|
+
assert_equal(base.obj, base2.obj)
|
275
|
+
assert_equal(nil, base2.np)
|
276
|
+
assert_equal("save this too", base.instance_variable_get(:@ivar))
|
287
277
|
end
|
288
278
|
|
289
279
|
end
|
data/test/test.rb
CHANGED
metadata
CHANGED
@@ -1,129 +1,88 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: cgen
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease: false
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 16
|
9
|
-
- 8
|
10
|
-
version: 0.16.8
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.16.10
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
6
|
+
authors:
|
13
7
|
- Joel VanderWerf
|
14
8
|
autorequire:
|
15
9
|
bindir: bin
|
16
10
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
- !ruby/object:Gem::Dependency
|
22
|
-
name: bones
|
23
|
-
prerelease: false
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - ">="
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
hash: 25
|
30
|
-
segments:
|
31
|
-
- 3
|
32
|
-
- 4
|
33
|
-
- 7
|
34
|
-
version: 3.4.7
|
35
|
-
type: :development
|
36
|
-
version_requirements: *id001
|
37
|
-
description: |
|
38
|
-
Framework for dynamically generating and loading C extensions from Ruby
|
39
|
-
programs. Includes CShadow module for defining classes in terms of C structs
|
40
|
-
with accessors and inheritance.
|
41
|
-
|
11
|
+
date: 2013-04-05 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Framework for dynamically generating and loading C extensions and for
|
14
|
+
defining classes in terms of C structs.
|
42
15
|
email: vjoel@users.sourceforge.net
|
43
16
|
executables: []
|
44
|
-
|
45
17
|
extensions: []
|
46
|
-
|
47
|
-
extra_rdoc_files:
|
18
|
+
extra_rdoc_files:
|
48
19
|
- History.txt
|
49
|
-
- README.
|
50
|
-
|
51
|
-
files:
|
52
|
-
- .bnsignore
|
53
|
-
- .gitignore
|
20
|
+
- README.md
|
21
|
+
files:
|
54
22
|
- History.txt
|
55
|
-
- README.
|
56
|
-
-
|
57
|
-
-
|
58
|
-
-
|
59
|
-
-
|
60
|
-
- examples/
|
61
|
-
- examples/
|
62
|
-
- examples/ctest2.rb
|
23
|
+
- README.md
|
24
|
+
- lib/cgen/attribute.rb
|
25
|
+
- lib/cgen/inherit.rb
|
26
|
+
- lib/cgen/cshadow.rb
|
27
|
+
- lib/cgen/cgen.rb
|
28
|
+
- examples/example-ruby-talk-30April2004.rb
|
29
|
+
- examples/instance-eval.rb
|
63
30
|
- examples/ctest3.rb
|
64
|
-
- examples/ctest4.rb
|
65
31
|
- examples/ctest5.rb
|
66
|
-
- examples/
|
67
|
-
- examples/example-ruby-talk-30April2004.rb
|
32
|
+
- examples/ctest.rb
|
68
33
|
- examples/fixed-array.rb
|
34
|
+
- examples/complex.rb
|
35
|
+
- examples/marshal-test.rb
|
69
36
|
- examples/inherit-example.rb
|
70
|
-
- examples/inherit-example.txt
|
71
|
-
- examples/instance-eval.rb
|
72
37
|
- examples/ivset.rb
|
73
|
-
- examples/
|
74
|
-
- examples/
|
75
|
-
- examples/modular-def.rb
|
38
|
+
- examples/test.rb
|
39
|
+
- examples/ctest2.rb
|
76
40
|
- examples/objattr.rb
|
41
|
+
- examples/example-ruby-talk-26July2009.rb
|
42
|
+
- examples/bench.rb
|
43
|
+
- examples/yaml.rb
|
44
|
+
- examples/matrix.rb
|
45
|
+
- examples/cshadow-example.rb
|
46
|
+
- examples/complex2.rb
|
47
|
+
- examples/cshadow-point.rb
|
77
48
|
- examples/opaque-struct-test.rb
|
78
|
-
- examples/sample.rb
|
79
49
|
- examples/struct.rb
|
80
|
-
- examples/
|
81
|
-
- examples/
|
82
|
-
-
|
83
|
-
-
|
84
|
-
- lib/cgen/cshadow.rb
|
85
|
-
- lib/cgen/inherit.rb
|
86
|
-
- rakefile
|
50
|
+
- examples/modular-def.rb
|
51
|
+
- examples/sample.rb
|
52
|
+
- examples/ctest4.rb
|
53
|
+
- examples/inherit-example.txt
|
87
54
|
- test/test-attribute.rb
|
88
55
|
- test/test-cgen.rb
|
89
|
-
- test/test-cshadow.rb
|
90
56
|
- test/test.rb
|
91
|
-
|
57
|
+
- test/test-cshadow.rb
|
92
58
|
homepage: http://rubyforge.org/projects/cgen
|
93
59
|
licenses: []
|
94
|
-
|
60
|
+
metadata: {}
|
95
61
|
post_install_message:
|
96
|
-
rdoc_options:
|
62
|
+
rdoc_options:
|
63
|
+
- --quiet
|
64
|
+
- --line-numbers
|
65
|
+
- --inline-source
|
66
|
+
- --title
|
67
|
+
- CGenerator
|
97
68
|
- --main
|
98
|
-
- README.
|
99
|
-
require_paths:
|
69
|
+
- README.md
|
70
|
+
require_paths:
|
100
71
|
- lib
|
101
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
none: false
|
112
|
-
requirements:
|
113
|
-
- - ">="
|
114
|
-
- !ruby/object:Gem::Version
|
115
|
-
hash: 3
|
116
|
-
segments:
|
117
|
-
- 0
|
118
|
-
version: "0"
|
72
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - '>='
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
119
82
|
requirements: []
|
120
|
-
|
121
83
|
rubyforge_project: cgen
|
122
|
-
rubygems_version:
|
84
|
+
rubygems_version: 2.0.3
|
123
85
|
signing_key:
|
124
|
-
specification_version:
|
86
|
+
specification_version: 4
|
125
87
|
summary: C code generator
|
126
|
-
test_files:
|
127
|
-
- test/test-attribute.rb
|
128
|
-
- test/test-cgen.rb
|
129
|
-
- test/test-cshadow.rb
|
88
|
+
test_files: []
|
data/.bnsignore
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
# The list of files that should be ignored by Mr Bones.
|
2
|
-
# Lines that start with '#' are comments.
|
3
|
-
#
|
4
|
-
# A .gitignore file can be used instead by setting it as the ignore
|
5
|
-
# file in your Rakefile:
|
6
|
-
#
|
7
|
-
# PROJ.ignore_file = '.gitignore'
|
8
|
-
#
|
9
|
-
# For a project with a C extension, the following would be a good set of
|
10
|
-
# exclude patterns (uncomment them if you want to use them):
|
11
|
-
# *.[oa]
|
12
|
-
# *~
|
13
|
-
announcement.txt
|
14
|
-
coverage
|
15
|
-
doc
|
16
|
-
pkg
|
17
|
-
*.bck
|
18
|
-
misc
|
19
|
-
junk
|
20
|
-
tmp
|
21
|
-
*/tmp
|
22
|
-
*/junk
|
data/.gitignore
DELETED
data/rakefile
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
begin
|
2
|
-
require 'bones'
|
3
|
-
rescue LoadError
|
4
|
-
abort '### please install the bones gem ###'
|
5
|
-
end
|
6
|
-
|
7
|
-
ensure_in_path 'lib'
|
8
|
-
require 'cgen/cgen'
|
9
|
-
|
10
|
-
Bones {
|
11
|
-
name 'cgen'
|
12
|
-
authors 'Joel VanderWerf'
|
13
|
-
email 'vjoel@users.sourceforge.net'
|
14
|
-
url 'http://rubyforge.org/projects/cgen'
|
15
|
-
rubyforge.name 'cgen'
|
16
|
-
version CGenerator::VERSION
|
17
|
-
readme_file 'README.txt'
|
18
|
-
|
19
|
-
summary 'C code generator'
|
20
|
-
description <<END
|
21
|
-
Framework for dynamically generating and loading C extensions from Ruby
|
22
|
-
programs. Includes CShadow module for defining classes in terms of C structs
|
23
|
-
with accessors and inheritance.
|
24
|
-
END
|
25
|
-
|
26
|
-
changes File.read(history_file)[/^\w.*?(?=^\w)/m]
|
27
|
-
(rdoc.dir File.readlink(rdoc.dir)) rescue nil
|
28
|
-
|
29
|
-
spec.opts << '--color'
|
30
|
-
test.files = Dir["test/test-*.rb"]
|
31
|
-
}
|
32
|
-
|
33
|
-
ENV["VERSION"] = CGenerator::VERSION ## why isn't this automatic?
|
34
|
-
|
35
|
-
task 'gem:release' => 'rubyforge:release' # to release to rubyforge as well
|
36
|
-
|
37
|
-
task :release => ["rubyforge:release", "rubyforge:doc_release"]
|
38
|
-
|
39
|
-
# EOF
|
40
|
-
|