https://github.com/cedlemo/rtruckboris
A native Ruby extension for the truckboris library
https://github.com/cedlemo/rtruckboris
Last synced: about 1 year ago
JSON representation
A native Ruby extension for the truckboris library
- Host: GitHub
- URL: https://github.com/cedlemo/rtruckboris
- Owner: cedlemo
- Created: 2014-11-08T18:06:59.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2015-11-02T18:12:05.000Z (over 10 years ago)
- Last Synced: 2025-02-06T06:24:15.032Z (over 1 year ago)
- Language: C++
- Size: 578 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Rtruckboris: Ruby bindings for the truckboris library
With rtruckboris, you can easily parse C headers files in pure Ruby.
```ruby
#!/usr/bin/env ruby
require 'rtruckboris'
parser = Rtruckboris::HeaderParser.new("a_file.h", ["/usr/include"])
parser.parse
functions = parser.functions
puts "Functions number : #{functions.size}"
functions.each do |f|
puts "Name : #{f.name}"
puts "Return : #{f.return.name}"
params = f.parameters
puts "\t #{params.size.to_s} parameters :"
params.each do |p|
puts "\t\t#{p.type.name} #{p.name}"
if(!p.type.is_canonical)
puts "\t\t\t#{p.type.canonical_type.name}"
end
end
end
functions.each do |f|
puts f.raw(parser.source_manager,parser.lang_opts)
end
```
## Resolve dependencies and Install
### Dependencies
rtruckboris is a ruby extension for the truckboris library so you need to install
it (https://github.com/cedlemo/truckboris) and its dependencies (LLVM and Clang >= 3.4 to 3.8).
You will need to install :
* Ruby
* Rake-compiler
* swig
### Install
When this is done, clone this repository with:
git clone https://github.com/cedlemo/rtruckboris
First (re)generate the extension source code via swig with:
rake swig
Then create the gem for your platform:
gem build rtruckboris.gemspec
You can now install the rtruckboris gem with:
gem install rtruckboris-x.x.x.gem
### Usage
a lot of examples can be found in the test lib. I use those files when I test
truckboris functionnalities you have two ways to try them:
#### Without installing rtuckboris
rake swig
rake compile
Then you can use each files in the directory (be sure to be in this directory
in order to launch those files.
### After installing rtruckboris as a gem
Just modify the require line:
require File.dirname(__FILE__) + "/../lib/rtruckboris/rtruckboris"
with
require 'rtruckboris'
Cedlemo