conyard 0.1.4 → 0.1.5

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.
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems' if RUBY_VERSION < '1.9'
4
+ require 'thor'
5
+ require 'erb'
6
+
7
+ $OLDDIR = Dir.pwd
8
+ Dir.chdir File.expand_path(File.join(File.dirname(__FILE__),'..'))
9
+
10
+ class VectorDispatcher < Thor
11
+
12
+ desc "generate NAME TYPE OUTFILE LOCALFILES GLOBALFILES", "Makes a new vector"
13
+ def generate(name, datatype, outfile, local_include_files, global_include_files)
14
+ @name = name or raise "Vector name cannot be nil"
15
+ @type = datatype or raise "Data type cannot be nil"
16
+ @outfile = File.expand_path(outfile) or raise "Outfile cannot be nil"
17
+ @guard = File.split(outfile).last.gsub(/\-/,'_').upcase
18
+ @include = File.split(@outfile).last
19
+ @local_include_files = local_include_files.match(/^nil$/) ? Array.new : local_include_files.split(/,\s*/)
20
+ @global_include_files = global_include_files.match(/^nil$/) ? Array.new : global_include_files.split(/,\s*/)
21
+
22
+ puts "Generating Vector:"
23
+ puts " name: #{@name}"
24
+ puts " type: #{@type}"
25
+ puts " file: #{@outfile}"
26
+ puts " local includes: #{@local_include_files}"
27
+ puts " global includes: #{@global_include_files}"
28
+
29
+ ofh=File.new(@outfile+".gen.h", "w")
30
+ ofh.write(ERB.new(File.read('lib/vector/vector.h.erb')).result(binding))
31
+ ofh.close
32
+
33
+ ofi=File.new(@outfile+".gen.c", "w")
34
+ ofi.write(ERB.new(File.read('lib/vector/vector.c.erb')).result(binding))
35
+ ofi.close
36
+ end
37
+
38
+ end
39
+
40
+ VectorDispatcher.start
@@ -6,7 +6,7 @@
6
6
  //! regenerated again. I would suggest putting re-implementations
7
7
  //! and/or extensions in another file.
8
8
 
9
- #include "<%= @outfile.pathmap("%f") %>.gen.h"
9
+ #include "<%= @include %>.gen.h"
10
10
 
11
11
  #ifdef __cplusplus
12
12
  extern "C" {
@@ -13,6 +13,13 @@
13
13
  #include <stdlib.h>
14
14
  #include <string.h>
15
15
 
16
+ <% @local_include_files.each do |includefile| %>
17
+ #include "<%= includefile %>"
18
+ <% end %>
19
+ <% @global_include_files.each do |includefile| %>
20
+ #include <<%= includefile %>>
21
+ <% end %>
22
+
16
23
  #ifdef __cplusplus
17
24
  extern "C" {
18
25
  #endif
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: conyard
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
4
+ hash: 17
5
+ prerelease:
5
6
  segments:
6
7
  - 0
7
8
  - 1
8
- - 4
9
- version: 0.1.4
9
+ - 5
10
+ version: 0.1.5
10
11
  platform: ruby
11
12
  authors:
12
13
  - Christopher Miller
@@ -14,16 +15,17 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2011-10-14 00:00:00 -06:00
18
- default_executable:
18
+ date: 2011-10-17 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
- name: rake
21
+ name: thor
22
22
  prerelease: false
23
23
  requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
24
25
  requirements:
25
26
  - - ">="
26
27
  - !ruby/object:Gem::Version
28
+ hash: 3
27
29
  segments:
28
30
  - 0
29
31
  version: "0"
@@ -32,20 +34,17 @@ dependencies:
32
34
  description: Conyard is a Ruby experiment in generating source code for use by C, C++, and Objective-C projects. It is designed to reduce the amount of typing (and therefore errors) introduced by sleep-deprived programmers.
33
35
  email: lordsauronthegreat@gmail.com
34
36
  executables:
35
- - conyard
37
+ - conyard-vector
36
38
  extensions: []
37
39
 
38
40
  extra_rdoc_files: []
39
41
 
40
42
  files:
41
- - structure-kits/vector/vector.c.erb
42
- - structure-kits/vector/vector.h.erb
43
- - structure-kits/vector/vector.rake
44
- - bin/conyard
45
- - Rakefile
43
+ - lib/vector/vector.c.erb
44
+ - lib/vector/vector.h.erb
45
+ - bin/conyard-vector
46
46
  - README.md
47
47
  - COPYING.md
48
- has_rdoc: true
49
48
  homepage: https://github.com/NSError/Conyard/wiki
50
49
  licenses: []
51
50
 
@@ -55,18 +54,22 @@ rdoc_options: []
55
54
  require_paths:
56
55
  - lib
57
56
  required_ruby_version: !ruby/object:Gem::Requirement
57
+ none: false
58
58
  requirements:
59
59
  - - ">="
60
60
  - !ruby/object:Gem::Version
61
+ hash: 57
61
62
  segments:
62
63
  - 1
63
64
  - 8
64
65
  - 7
65
66
  version: 1.8.7
66
67
  required_rubygems_version: !ruby/object:Gem::Requirement
68
+ none: false
67
69
  requirements:
68
70
  - - ">="
69
71
  - !ruby/object:Gem::Version
72
+ hash: 23
70
73
  segments:
71
74
  - 1
72
75
  - 3
@@ -75,7 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
75
78
  requirements: []
76
79
 
77
80
  rubyforge_project: conyard
78
- rubygems_version: 1.3.6
81
+ rubygems_version: 1.8.10
79
82
  signing_key:
80
83
  specification_version: 3
81
84
  summary: Generators for typing-intensive programming tasks.
data/Rakefile DELETED
@@ -1,25 +0,0 @@
1
- # Created on 10 October 2011.
2
- # Copyright 2011 Chris Miller. All rights reserved.
3
-
4
- require 'rubygems' if RUBY_VERSION < '1.9'
5
- require 'rake'
6
- require 'erb'
7
-
8
- $CC = 'clang'
9
- $CXX = 'clang++'
10
-
11
- CLEAN = FileList['.o']
12
-
13
- Dir.glob('**/*.rake').each { |r| import r }
14
-
15
- desc 'Runs a task using a file for arguments'
16
- task :run, :argfile do |t, args|
17
- argfile=args.argfile
18
- raise 'Dude, no argument? You jerk!' unless argfile
19
- config=File.read(File.expand_path(argfile))
20
- lines = Array.new
21
- config.each_line { |line| lines << line.strip }
22
- tn = lines[0]
23
- lines = lines[1 .. -1]
24
- Rake::Task[tn].invoke *lines
25
- end
data/bin/conyard DELETED
@@ -1,9 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'rubygems' if RUBY_VERSION < '1.9'
4
- require 'rake'
5
-
6
- $OLDDIR = Dir.pwd
7
- Dir.chdir File.expand_path(File.join(File.dirname(__FILE__),'..'))
8
-
9
- Rake.application.run
@@ -1,24 +0,0 @@
1
- def emit_vector name, datatype, outfile
2
- @name = name
3
- @type = datatype
4
- @outfile = File.expand_path outfile
5
- @guard = outfile.pathmap("%n").gsub(/\-/,'_').upcase
6
-
7
- headertmpl = 'structure-kits/vector/vector.h.erb'
8
- impltmpl = 'structure-kits/vector/vector.c.erb'
9
-
10
- ofh=File.new(@outfile+".gen.h", "w")
11
- ofh.write(ERB.new(File.read(headertmpl)).result)
12
- ofh.close
13
- ofi=File.new(@outfile+".gen.c", "w")
14
- ofi.write(ERB.new(File.read(impltmpl)).result)
15
- ofi.close
16
- end
17
-
18
- namespace :generate do
19
- desc "Creates a new fast, lean C vector implementation; useage is: rake vector[name, type, outfile]"
20
- task :vector, :name, :datatype, :outfile do |t, args|
21
- args.with_defaults(:name => 'int_vector', :datatype => 'int', :outfile => 'int_vector')
22
- emit_vector args.name, args.datatype, File.expand_path(File.join($OLDDIR,args.outfile))
23
- end
24
- end