rubber-generate 0.0.13 → 0.0.15

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,6 +6,7 @@ else
6
6
  file = __FILE__
7
7
  end
8
8
 
9
+ require 'fileutils'
9
10
  require 'rbconfig'
10
11
  require 'ftools'
11
12
 
@@ -3,6 +3,7 @@ require 'rubber/codegen/enum'
3
3
  module Rubber
4
4
 
5
5
  class C_GEnum < C_Enum
6
+ attr_accessor :define_on_self
6
7
  define_members :name, :g_type, :prefix, :parent
7
8
  def init()
8
9
  ($custom_maps[name] ||= {})["VALUE"] = "GENUM2RVAL(%%, #{g_type})"
@@ -11,12 +12,14 @@ class C_GEnum < C_Enum
11
12
  def code(io)
12
13
  end
13
14
  def declare(io)
15
+ io.puts " VALUE #{cname} = Qnil;"
14
16
  end
15
17
  include RegisterChildren
16
18
  def default_cname
17
- "enum"+name
19
+ "genum"+name
18
20
  end
19
- def get_root(); is_root? ? self : parent.get_root; end; def is_root?()
21
+ def get_root(); is_root? ? self : parent.get_root; end;
22
+ def is_root?()
20
23
  not parent.respond_to?(:fullname)
21
24
  end
22
25
  def doc_rd(io)
@@ -24,9 +27,14 @@ class C_GEnum < C_Enum
24
27
  io.puts "=#{'=' * depth} enum #{fullname}"
25
28
  end
26
29
  def register(io, already_defined=false)
27
- io.puts " G_DEF_CLASS(#{g_type}, #{name.inspect}, #{get_root.cname});"
28
- io.puts " G_DEF_CONSTANTS(#{parent.cname}, #{g_type}, #{prefix.inspect});"
29
- # strip = args.first.length - splits.first.length
30
+ io.puts " #{cname} = G_DEF_CLASS(#{g_type}, #{name.inspect}, #{get_root.cname});"
31
+ if @define_on_self
32
+ io.puts " G_DEF_CONSTANTS(#{cname}, #{g_type}, #{prefix.inspect});"
33
+ else
34
+ io.puts " G_DEF_CONSTANTS(#{parent.cname}, #{g_type}, #{prefix.inspect});"
35
+ end
36
+ #io.puts " G_DEF_CONSTANTS(#{cname}, #{g_type}, #{prefix.inspect});"
37
+ # strip = args.first.length - splits.first.length
30
38
  end
31
39
  end
32
40
 
@@ -1,9 +1,27 @@
1
1
 
2
2
  module Rubber
3
3
  def generate_extconf(scanner, io)
4
- if true
5
- io.puts "require 'mkmf'"
6
- io.puts "require 'mkmf-gnome2'" if scanner.pkgs
4
+ io << <<-EOMK
5
+ require 'mkmf'
6
+
7
+ begin
8
+ require 'mkmf-gnome2'
9
+ rescue LoadError
10
+ require 'rubygems'
11
+ gem 'glib2'
12
+ require 'mkmf-gnome2'
13
+ %w[rbglib.h rbgtk.h rbpango.h rbatk.h].each do |header|
14
+ Gem.find_files(header).each do |f|
15
+ $CFLAGS += " '-I\#{File.dirname(f)}'"
16
+ end
17
+ end
18
+ end
19
+
20
+ have_func("rb_errinfo")
21
+ EOMK
22
+
23
+ #io.puts "require 'mkmf'"
24
+ #io.puts "require 'mkmf-gnome2'" if scanner.pkgs
7
25
  #io.puts "$defs ||= []"
8
26
 
9
27
  if scanner.inc_dirs
@@ -89,7 +107,6 @@ rescue Interrupt
89
107
  end
90
108
 
91
109
  EOB
92
- end
93
110
  end
94
111
  module_function :generate_extconf
95
112
  end
@@ -1,6 +1,6 @@
1
1
  require 'rubber/struct'
2
2
  module Rubber
3
- VERSION = [0,0,13]
3
+ VERSION = [0,0,15]
4
4
  def VERSION.to_s
5
5
  self.map{|i|i.to_s}.join('.')
6
6
  end
@@ -269,14 +269,17 @@ def _scan(fp)
269
269
  @str.skip(/\s+/)
270
270
  g_type = @str.scan(/[A-Z][_0-9A-Z]*/)
271
271
  @str.skip(/\s+/)
272
- prefix = @str.scan(/[A-Z][_0-9A-Z]*/)
272
+ prefix = @str.scan(/(prefix=)?[A-Z][_0-9A-Z]*/i).to_s.sub(/^prefix=/i,'')
273
+ @str.skip(/\s*/)
274
+ define_on_self = @str.scan(/define_on_self/)
273
275
  @str.skip(/\s*;/)
274
276
  if what == "gflags"
275
- stack.last.classes.push(C_GFlags.new(name, g_type, prefix, stack.last))
277
+ obj = C_GFlags.new(name, g_type, prefix, stack.last)
276
278
  else
277
- stack.last.classes.push(C_GEnum.new(name, g_type, prefix, stack.last))
278
- end
279
-
279
+ obj = C_GEnum.new(name, g_type, prefix, stack.last)
280
+ obj.define_on_self = !! define_on_self;
281
+ end
282
+ stack.last.classes.push(obj)
280
283
  elsif state.in_func == false and @str.skip(/(gobject|ginterface|gboxed)(?= )/x) # Class defn
281
284
  type=@str[1]
282
285
  @str.skip(/\s+/)
@@ -373,7 +376,7 @@ def _scan(fp)
373
376
  @class.post_func= @str[1] if @class.respond_to?(:post_func)
374
377
  elsif @str.skip(/def(?=\s+)/x) # Function defn
375
378
  @str.skip(/\s+/)
376
- if @str.scan(/([a-zA-Z_* ]+):/)
379
+ if @str.scan(/([a-zA-Z_* 0-9]+):/)
377
380
  returntype = @str[1]
378
381
  elsif @str.skip(/(GS?List)[{]([^}]+)[}]:/)
379
382
  container = @str[1]
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubber-generate
3
3
  version: !ruby/object:Gem::Version
4
- hash: 5
5
- prerelease: false
4
+ hash: 1
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 13
10
- version: 0.0.13
9
+ - 15
10
+ version: 0.0.15
11
11
  platform: ruby
12
12
  authors:
13
13
  - Geoff Youngs
@@ -15,8 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-05-05 00:00:00 +01:00
19
- default_executable:
18
+ date: 2011-10-18 00:00:00 Z
20
19
  dependencies: []
21
20
 
22
21
  description: " rubber-c-binder allows a rubyish means of generating bindings for C libraries,\n including (but not limited to) GObject based libraries.\n\n It allows C code to be written in the context of a ruby style class/method layout\n and eases type checking and conversion between Ruby & C datatypes.\n"
@@ -29,32 +28,31 @@ extra_rdoc_files:
29
28
  - README.textile
30
29
  files:
31
30
  - bin/rubber-generate
32
- - lib/rubber/mkextconf.rb
33
- - lib/rubber/codegen/enum.rb
34
- - lib/rubber/codegen/gobject.rb
35
- - lib/rubber/codegen/gcrefpool.rb
36
- - lib/rubber/codegen/class.rb
31
+ - lib/rubber/codegen/param.rb
32
+ - lib/rubber/codegen/ginterface.rb
37
33
  - lib/rubber/codegen/genum.rb
38
- - lib/rubber/codegen/gboxed.rb
39
- - lib/rubber/codegen/function.rb
40
- - lib/rubber/codegen/module.rb
41
- - lib/rubber/codegen/float.rb
42
- - lib/rubber/codegen/flags.rb
43
- - lib/rubber/codegen/array.rb
44
34
  - lib/rubber/codegen/gflags.rb
45
- - lib/rubber/codegen/struct.rb
35
+ - lib/rubber/codegen/flags.rb
46
36
  - lib/rubber/codegen/string.rb
47
- - lib/rubber/codegen/ginterface.rb
48
- - lib/rubber/codegen/param.rb
37
+ - lib/rubber/codegen/struct.rb
38
+ - lib/rubber/codegen/module.rb
39
+ - lib/rubber/codegen/gcrefpool.rb
40
+ - lib/rubber/codegen/function.rb
41
+ - lib/rubber/codegen/gboxed.rb
49
42
  - lib/rubber/codegen/integer.rb
43
+ - lib/rubber/codegen/gobject.rb
44
+ - lib/rubber/codegen/class.rb
45
+ - lib/rubber/codegen/enum.rb
46
+ - lib/rubber/codegen/array.rb
47
+ - lib/rubber/codegen/float.rb
50
48
  - lib/rubber/autord.rb
51
- - lib/rubber/types.rb
52
- - lib/rubber/codegen.rb
53
49
  - lib/rubber/struct.rb
50
+ - lib/rubber/mkextconf.rb
51
+ - lib/rubber/codegen.rb
52
+ - lib/rubber/types.rb
54
53
  - lib/rubber/scanner.rb
55
54
  - README.textile
56
55
  - example/vte.cr
57
- has_rdoc: true
58
56
  homepage: http://github.com/geoffyoungs/rubber-generate
59
57
  licenses: []
60
58
 
@@ -84,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
84
82
  requirements: []
85
83
 
86
84
  rubyforge_project:
87
- rubygems_version: 1.3.7
85
+ rubygems_version: 1.8.10
88
86
  signing_key:
89
87
  specification_version: 3
90
88
  summary: Template language for generating Ruby bindings for C libraries