Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cedlemo/rtruckboris
A native Ruby extension for the truckboris library
https://github.com/cedlemo/rtruckboris
Last synced: 14 days 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 (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2015-11-02T18:12:05.000Z (about 9 years ago)
- Last Synced: 2024-10-04T22:16:00.289Z (about 1 month 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 rubyrequire 'rtruckboris'
parser = Rtruckboris::HeaderParser.new("a_file.h", ["/usr/include"])
parser.parsefunctions = 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
endfunctions.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