rubber-generate 0.0.16 → 0.0.17
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/rubber-generate +5 -2
- data/lib/rubber/codegen/gcrefpool.rb +1 -1
- data/lib/rubber/mkextconf.rb +28 -6
- data/lib/rubber/scanner.rb +4 -6
- data/lib/rubber/struct.rb +20 -19
- data/lib/rubber/version.rb +6 -0
- metadata +44 -58
data/bin/rubber-generate
CHANGED
@@ -8,7 +8,6 @@ end
|
|
8
8
|
|
9
9
|
require 'fileutils'
|
10
10
|
require 'rbconfig'
|
11
|
-
require 'ftools'
|
12
11
|
|
13
12
|
dir = File.dirname(File.expand_path(file))
|
14
13
|
$:.unshift(dir)
|
@@ -23,7 +22,11 @@ require 'optparse'
|
|
23
22
|
require 'ostruct'
|
24
23
|
|
25
24
|
Args = OpenStruct.new
|
26
|
-
|
25
|
+
if Object.const_defined?('RbConfig')
|
26
|
+
Args.build_dir = RbConfig::CONFIG['sitearch']
|
27
|
+
else
|
28
|
+
Args.build_dir = Config::CONFIG['sitearch']
|
29
|
+
end
|
27
30
|
Args.configure = false
|
28
31
|
Args.build = false
|
29
32
|
Args.install = false
|
data/lib/rubber/mkextconf.rb
CHANGED
@@ -1,12 +1,16 @@
|
|
1
1
|
|
2
2
|
module Rubber
|
3
3
|
def generate_extconf(scanner, io)
|
4
|
-
io
|
4
|
+
io.write <<-EOMK
|
5
5
|
require 'mkmf'
|
6
|
-
|
6
|
+
use_gems = false
|
7
7
|
begin
|
8
8
|
require 'mkmf-gnome2'
|
9
9
|
rescue LoadError
|
10
|
+
use_gems = true
|
11
|
+
end
|
12
|
+
|
13
|
+
if use_gems or Object.const_defined?('Gem')
|
10
14
|
require 'rubygems'
|
11
15
|
gem 'glib2'
|
12
16
|
require 'mkmf-gnome2'
|
@@ -16,13 +20,31 @@ rescue LoadError
|
|
16
20
|
end
|
17
21
|
end
|
18
22
|
end
|
23
|
+
EOMK
|
19
24
|
|
20
|
-
|
25
|
+
io.write <<-EOMK
|
26
|
+
# Look for headers in {gem_root}/ext/{package}
|
27
|
+
if use_gems
|
28
|
+
%w[
|
21
29
|
EOMK
|
30
|
+
io << " glib2" if scanner.options.glib
|
31
|
+
io << " gdk_pixbuf2 atk gtk2" if scanner.options.gtk
|
32
|
+
io.write <<-EOX
|
33
|
+
].each do |package|
|
34
|
+
require package
|
35
|
+
$CFLAGS += " -I"+Gem.loaded_specs[package].full_gem_path+"/ext/"+package
|
36
|
+
end
|
37
|
+
end
|
38
|
+
EOX
|
22
39
|
|
23
|
-
|
24
|
-
|
25
|
-
|
40
|
+
io.write <<-EOY
|
41
|
+
if RbConfig::CONFIG.has_key?('rubyhdrdir')
|
42
|
+
$CFLAGS += " -I" + RbConfig::CONFIG['rubyhdrdir']+'/ruby'
|
43
|
+
end
|
44
|
+
|
45
|
+
$CFLAGS += " -I."
|
46
|
+
have_func("rb_errinfo")
|
47
|
+
EOY
|
26
48
|
|
27
49
|
if scanner.inc_dirs
|
28
50
|
io.puts "$CFLAGS += "+scanner.inc_dirs.collect { |i| " '-I#{i}'"}.join().inspect
|
data/lib/rubber/scanner.rb
CHANGED
@@ -1,9 +1,6 @@
|
|
1
1
|
require 'rubber/struct'
|
2
|
+
require 'rubber/version'
|
2
3
|
module Rubber
|
3
|
-
VERSION = [0,0,16]
|
4
|
-
def VERSION.to_s
|
5
|
-
self.map{|i|i.to_s}.join('.')
|
6
|
-
end
|
7
4
|
class ScanState
|
8
5
|
define_members(:in_code, :in_class, :in_func, :braces)
|
9
6
|
end
|
@@ -140,7 +137,7 @@ def _scan(fp)
|
|
140
137
|
@incs << @str[1].strip
|
141
138
|
elsif @str.skip(/%option +([a-z]+)=(yes|no)\n/) # Option
|
142
139
|
case @str[1]
|
143
|
-
when 'glib','gtk','gnu'
|
140
|
+
when 'glib', 'gtk', 'gnu'
|
144
141
|
@options[@str[1]] = (@str[2] == 'yes')
|
145
142
|
else
|
146
143
|
syntax_error "Unknown option #{@str[1]}"
|
@@ -411,7 +408,8 @@ EOADD
|
|
411
408
|
unless name
|
412
409
|
name = @str.scan(/[-\[\]<>~=+|&]{1,3}/)
|
413
410
|
end
|
414
|
-
|
411
|
+
oname = name
|
412
|
+
name = prename.to_s + oname
|
415
413
|
#p [prename, oname, name]
|
416
414
|
@str.skip(/\s*/)
|
417
415
|
args = scan_args().collect { |i| C_Param.new(i) }
|
data/lib/rubber/struct.rb
CHANGED
@@ -8,24 +8,24 @@ def define_member(name, value=nil)
|
|
8
8
|
end
|
9
9
|
end
|
10
10
|
def define_members(*ids)
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
members = []
|
12
|
+
ids.each do |id|
|
13
|
+
if id.kind_of?(Hash)
|
14
14
|
STDERR.puts("WARNING: Hash passed to define_members has size > 1 in #{caller.join("\n")}\n`#{to_s}.new(...)' will not work as expected (non-predictable member order)") if id.size > 1
|
15
15
|
id.each do |name,value|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
end
|
16
|
+
define_member(name,value)
|
17
|
+
raise "Duplicate definition of member `#{name}'" if members.include?(name.to_s)
|
18
|
+
members.push(name.to_s)
|
19
|
+
end
|
20
|
+
elsif id.kind_of?(Symbol)
|
21
|
+
define_member(id)
|
22
|
+
raise "Duplicate definition of member `#{id}'" if members.include?(id.to_s)
|
23
|
+
members.push(id.to_s)
|
24
|
+
else
|
25
|
+
raise "Neither a Hash nor a Symbol - `#{id}'"
|
27
26
|
end
|
28
|
-
|
27
|
+
end
|
28
|
+
code = <<-EOS
|
29
29
|
def initialize(*ids);
|
30
30
|
members.each_index { |i| __send__((members[i]+'=').intern, i < ids.size ? ids[i] : __send__(members[i].intern)) };
|
31
31
|
if respond_to?(:init)
|
@@ -42,11 +42,12 @@ def define_members(*ids)
|
|
42
42
|
def members(); #{members.inspect}; end
|
43
43
|
def kind_of?(klass); return true if klass == Struct; super(klass); end
|
44
44
|
def to_a(); [#{members.join(', ')}]; end
|
45
|
-
def [](id); id=id.intern if id.kind_of?(String); case id; #{i=-1;members.collect{|name| "when :#{name},#{i+=1}; @#{name};"}} else raise 'Unknown member - '+id.to_s; end; end
|
46
|
-
def []=(id,value); id=id.intern if id.kind_of?(String); case id; #{i=-1;members.collect{|name| "when :#{name},#{i+=1}; @#{name}=value;"}} else raise 'Unknown member - '+id.to_s; end; end
|
45
|
+
def [](id); id=id.intern if id.kind_of?(String); case id; #{i=-1;members.collect{|name| "when :#{name},#{i+=1}; @#{name};"}.join("\n")} else raise 'Unknown member - '+id.to_s; end; end
|
46
|
+
def []=(id,value); id=id.intern if id.kind_of?(String); case id; #{i=-1;members.collect{|name| "when :#{name},#{i+=1}; @#{name}=value;"}.join("\n")} else raise 'Unknown member - '+id.to_s; end; end
|
47
47
|
def length; #{members.size}; end
|
48
48
|
alias_method(:size, :length)
|
49
49
|
alias_method(:values, :to_a)
|
50
|
-
|
51
|
-
|
50
|
+
EOS
|
51
|
+
module_eval code
|
52
|
+
end
|
52
53
|
end
|
metadata
CHANGED
@@ -1,92 +1,78 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubber-generate
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.17
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 16
|
10
|
-
version: 0.0.16
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Geoff Youngs
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
date: 2011-10-26 00:00:00 +01:00
|
19
|
-
default_executable:
|
12
|
+
date: 2012-11-16 00:00:00.000000000 Z
|
20
13
|
dependencies: []
|
21
|
-
|
22
|
-
|
14
|
+
description: ! " rubber-c-binder allows a rubyish means of generating bindings
|
15
|
+
for C libraries,\n including (but not limited to) GObject based libraries.\n\n
|
16
|
+
\ It allows C code to be written in the context of a ruby style class/method layout\n
|
17
|
+
\ and eases type checking and conversion between Ruby & C datatypes.\n"
|
23
18
|
email: g@intersect-uk.co.uk
|
24
|
-
executables:
|
19
|
+
executables:
|
25
20
|
- rubber-generate
|
26
21
|
extensions: []
|
27
|
-
|
28
|
-
extra_rdoc_files:
|
22
|
+
extra_rdoc_files:
|
29
23
|
- README.textile
|
30
|
-
files:
|
24
|
+
files:
|
31
25
|
- bin/rubber-generate
|
32
|
-
- lib/rubber/
|
33
|
-
- lib/rubber/codegen.rb
|
34
|
-
- lib/rubber/scanner.rb
|
35
|
-
- lib/rubber/struct.rb
|
36
|
-
- lib/rubber/mkextconf.rb
|
37
|
-
- lib/rubber/codegen/function.rb
|
38
|
-
- lib/rubber/codegen/array.rb
|
26
|
+
- lib/rubber/codegen/param.rb
|
39
27
|
- lib/rubber/codegen/ginterface.rb
|
40
|
-
- lib/rubber/codegen/class.rb
|
41
|
-
- lib/rubber/codegen/gboxed.rb
|
42
|
-
- lib/rubber/codegen/float.rb
|
43
|
-
- lib/rubber/codegen/module.rb
|
44
|
-
- lib/rubber/codegen/enum.rb
|
45
|
-
- lib/rubber/codegen/integer.rb
|
46
28
|
- lib/rubber/codegen/genum.rb
|
47
|
-
- lib/rubber/codegen/struct.rb
|
48
|
-
- lib/rubber/codegen/param.rb
|
49
|
-
- lib/rubber/codegen/flags.rb
|
50
29
|
- lib/rubber/codegen/gflags.rb
|
51
|
-
- lib/rubber/codegen/
|
30
|
+
- lib/rubber/codegen/flags.rb
|
52
31
|
- lib/rubber/codegen/string.rb
|
32
|
+
- lib/rubber/codegen/struct.rb
|
33
|
+
- lib/rubber/codegen/module.rb
|
53
34
|
- lib/rubber/codegen/gcrefpool.rb
|
35
|
+
- lib/rubber/codegen/function.rb
|
36
|
+
- lib/rubber/codegen/gboxed.rb
|
37
|
+
- lib/rubber/codegen/integer.rb
|
38
|
+
- lib/rubber/codegen/gobject.rb
|
39
|
+
- lib/rubber/codegen/class.rb
|
40
|
+
- lib/rubber/codegen/enum.rb
|
41
|
+
- lib/rubber/codegen/array.rb
|
42
|
+
- lib/rubber/codegen/float.rb
|
43
|
+
- lib/rubber/autord.rb
|
44
|
+
- lib/rubber/struct.rb
|
45
|
+
- lib/rubber/version.rb
|
46
|
+
- lib/rubber/mkextconf.rb
|
47
|
+
- lib/rubber/codegen.rb
|
54
48
|
- lib/rubber/types.rb
|
49
|
+
- lib/rubber/scanner.rb
|
55
50
|
- README.textile
|
56
51
|
- example/vte.cr
|
57
|
-
has_rdoc: true
|
58
52
|
homepage: http://github.com/geoffyoungs/rubber-generate
|
59
53
|
licenses: []
|
60
|
-
|
61
54
|
post_install_message:
|
62
55
|
rdoc_options: []
|
63
|
-
|
64
|
-
require_paths:
|
56
|
+
require_paths:
|
65
57
|
- lib
|
66
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
58
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
67
59
|
none: false
|
68
|
-
requirements:
|
69
|
-
- -
|
70
|
-
- !ruby/object:Gem::Version
|
71
|
-
|
72
|
-
|
73
|
-
- 0
|
74
|
-
version: "0"
|
75
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ! '>='
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
65
|
none: false
|
77
|
-
requirements:
|
78
|
-
- -
|
79
|
-
- !ruby/object:Gem::Version
|
80
|
-
|
81
|
-
segments:
|
82
|
-
- 0
|
83
|
-
version: "0"
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
84
70
|
requirements: []
|
85
|
-
|
86
71
|
rubyforge_project:
|
87
|
-
rubygems_version: 1.
|
72
|
+
rubygems_version: 1.8.24
|
88
73
|
signing_key:
|
89
74
|
specification_version: 3
|
90
75
|
summary: Template language for generating Ruby bindings for C libraries
|
91
|
-
test_files:
|
76
|
+
test_files:
|
92
77
|
- example/vte.cr
|
78
|
+
has_rdoc:
|