mcpp 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,3 @@
1
+ pkg/*
2
+ *.gem
3
+ .bundle
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (C) 2011 by Michael Dungan, mpd@jesters-court.net
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
@@ -0,0 +1,45 @@
1
+ Mcpp
2
+ ====
3
+
4
+ A gem to wrap the libmcpp C preprocessor.
5
+
6
+ Mcpp itself can be found at http://mccp.sourceforge.net
7
+
8
+ Installation
9
+ ============
10
+
11
+ 1. Install [mcpp](http://mccp.sourceforge.net) as a shared library.
12
+ 1. `gem install mcpp`
13
+
14
+ [ffi](https://github.com/ffi/ffi) is a requirement, but should be installed
15
+ automatically by this gem if not already installed.
16
+
17
+ Use
18
+ ===
19
+
20
+ Mcpp is a very simple wrapper that exposes a single method, `preprocess`,
21
+ that expects 0 or more arguments that correspond to the arguments that
22
+ you would pass to mcpp if running it on the command line.
23
+
24
+ The examples are hopefully more enlightening than the previous paragraph was.
25
+
26
+ The actual arguments that can be passed are identical to those used by the
27
+ command line program, and are enumerated in the mcpp man page, or online at
28
+ http://mcpp.svn.sourceforge.net/viewvc/mcpp/trunk/doc/mcpp-manual.html
29
+
30
+ Examples
31
+ --------
32
+
33
+ require 'mccp'
34
+
35
+ # Read from stdin, write to stdout
36
+ Mcpp.preprocess
37
+
38
+ # Read from a file, write to stdout
39
+ Mcpp.preprocess '/path/to/file.c'
40
+
41
+ # Read from a file, write to another file
42
+ Mcpp.preprocess '/path/to/infile.c', '/path/to/outfile'
43
+
44
+ # More arguments
45
+ Mcpp.preprocess '-DSOME_DEFINE', '-N', '-P', '-eutf8', 'relative/path/to/infile.c', 'path/to/outfile.cpp'
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,32 @@
1
+ require 'ffi'
2
+
3
+ module Mcpp
4
+ extend FFI::Library
5
+ ffi_lib "libmcpp"
6
+
7
+ # The documentation for this function doesn't even seem to be included
8
+ # with the distribution, but can be found online in a document called
9
+ # "mcpp-porting.html". One version was found at the time of writing at
10
+ # http://mcpp.svn.sourceforge.net/viewvc/mcpp/trunk/doc/mcpp-porting.html
11
+ #
12
+ # An example of how to use mcpp_lib_main() from C can be found at
13
+ # http://mcpp.sourcearchive.com/documentation/2.6.2/testmain_8c-source.html
14
+ attach_function :mcpp_lib_main, [:int, :pointer], :int
15
+
16
+ def self.preprocess(*args)
17
+ strptrs = []
18
+ strptrs << FFI::MemoryPointer.from_string("Ruby!") # placeholder for argv[0]
19
+ args.each do |a|
20
+ strptrs << FFI::MemoryPointer.from_string(a.to_s)
21
+ end
22
+ strptrs << nil
23
+
24
+ # Now load all the pointers into a native memory block
25
+ argv = FFI::MemoryPointer.new(:pointer, strptrs.length)
26
+ strptrs.each_with_index do |p, i|
27
+ argv[i].put_pointer(0, p)
28
+ end
29
+
30
+ mcpp_lib_main(strptrs.length - 1, argv)
31
+ end
32
+ end
@@ -0,0 +1,3 @@
1
+ module Mcpp
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "mcpp/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "mcpp"
7
+ s.version = Mcpp::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Michael Dungan"]
10
+ s.email = ["mpd@jesters-court.net"]
11
+ s.homepage = ""
12
+ s.summary = %q{Ruby wrapper for libmcpp C preprocessor}
13
+ s.description = %q{A Ruby wrapper for a library build of the mcpp C preprocessor. http://mccp.sourceforge.net}
14
+
15
+ s.rubyforge_project = "mcpp"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ # s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ # s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+ s.add_dependency 'ffi'
22
+ end
metadata ADDED
@@ -0,0 +1,83 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mcpp
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - Michael Dungan
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2011-01-05 00:00:00 -08:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: ffi
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 0
30
+ version: "0"
31
+ type: :runtime
32
+ version_requirements: *id001
33
+ description: A Ruby wrapper for a library build of the mcpp C preprocessor. http://mccp.sourceforge.net
34
+ email:
35
+ - mpd@jesters-court.net
36
+ executables: []
37
+
38
+ extensions: []
39
+
40
+ extra_rdoc_files: []
41
+
42
+ files:
43
+ - .gitignore
44
+ - LICENSE
45
+ - README.md
46
+ - Rakefile
47
+ - lib/mcpp.rb
48
+ - lib/mcpp/version.rb
49
+ - mcpp.gemspec
50
+ has_rdoc: true
51
+ homepage: ""
52
+ licenses: []
53
+
54
+ post_install_message:
55
+ rdoc_options: []
56
+
57
+ require_paths:
58
+ - lib
59
+ required_ruby_version: !ruby/object:Gem::Requirement
60
+ none: false
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ segments:
65
+ - 0
66
+ version: "0"
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
68
+ none: false
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ segments:
73
+ - 0
74
+ version: "0"
75
+ requirements: []
76
+
77
+ rubyforge_project: mcpp
78
+ rubygems_version: 1.3.7
79
+ signing_key:
80
+ specification_version: 3
81
+ summary: Ruby wrapper for libmcpp C preprocessor
82
+ test_files: []
83
+