rbplusplus 0.1
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.
- data/Rakefile +78 -0
- data/TODO +25 -0
- data/lib/inflections.rb +53 -0
- data/lib/inflector.rb +285 -0
- data/lib/jamis.rb +589 -0
- data/lib/rbplusplus.rb +31 -0
- data/lib/rbplusplus/builders/base.rb +116 -0
- data/lib/rbplusplus/builders/class.rb +62 -0
- data/lib/rbplusplus/builders/extension.rb +48 -0
- data/lib/rbplusplus/builders/module.rb +67 -0
- data/lib/rbplusplus/extension.rb +183 -0
- data/lib/rbplusplus/module.rb +56 -0
- data/lib/rbplusplus/rbplusplus.rb +3 -0
- data/lib/rbplusplus/writers/base.rb +25 -0
- data/lib/rbplusplus/writers/extension.rb +37 -0
- data/lib/rbplusplus/writers/multiple_files_writer.rb +84 -0
- data/lib/rbplusplus/writers/single_file_writer.rb +37 -0
- data/test/classes_test.rb +67 -0
- data/test/compiling_test.rb +85 -0
- data/test/extension_test.rb +38 -0
- data/test/file_writers_test.rb +68 -0
- data/test/functions_test.rb +26 -0
- data/test/headers/Adder.h +26 -0
- data/test/headers/Subtracter.hpp +20 -0
- data/test/headers/empty.h +3 -0
- data/test/headers/functions.h +19 -0
- data/test/headers/include/helper.h +8 -0
- data/test/headers/nested_classes.h +20 -0
- data/test/headers/with_includes.h +14 -0
- data/test/modules_test.rb +67 -0
- data/test/test_helper.rb +19 -0
- metadata +91 -0
@@ -0,0 +1,26 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
|
3
|
+
context "Extension with globally available functions" do
|
4
|
+
|
5
|
+
specify "should make functions available" do
|
6
|
+
Extension.new "functions" do |e|
|
7
|
+
e.sources full_dir("headers/functions.h")
|
8
|
+
e.namespace "functions"
|
9
|
+
end
|
10
|
+
|
11
|
+
require 'functions'
|
12
|
+
|
13
|
+
should.not.raise NameError do
|
14
|
+
test1
|
15
|
+
end
|
16
|
+
|
17
|
+
should.not.raise NameError do
|
18
|
+
assert_in_delta 1.0, test2(2.0), 0.001
|
19
|
+
end
|
20
|
+
|
21
|
+
should.not.raise NameError do
|
22
|
+
test3(2, 4.2).should == 2
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
#ifndef __ADDER_H__
|
2
|
+
#define __ADDER_H__
|
3
|
+
|
4
|
+
#include <string>
|
5
|
+
using namespace std;
|
6
|
+
|
7
|
+
namespace classes {
|
8
|
+
class Adder {
|
9
|
+
public:
|
10
|
+
Adder() { }
|
11
|
+
|
12
|
+
static int doAdding(int a, int b, int c, int d, int e) {
|
13
|
+
return a + b + c + d + e;
|
14
|
+
}
|
15
|
+
|
16
|
+
int addIntegers(int a, int b) { return a + b; }
|
17
|
+
|
18
|
+
float addFloats(float a, float b) { return a + b; }
|
19
|
+
|
20
|
+
string addStrings(string a, string b) { return a + b; }
|
21
|
+
|
22
|
+
string getClassName() { return "Adder"; }
|
23
|
+
};
|
24
|
+
}
|
25
|
+
|
26
|
+
#endif
|
@@ -0,0 +1,20 @@
|
|
1
|
+
#ifndef __SUBTRACTER_H__
|
2
|
+
#define __SUBTRACTER_H__
|
3
|
+
|
4
|
+
#include <string>
|
5
|
+
using namespace std;
|
6
|
+
|
7
|
+
namespace subtracter {
|
8
|
+
class Subtracter {
|
9
|
+
public:
|
10
|
+
Subtracter() { }
|
11
|
+
|
12
|
+
int subIntegers(int a, int b) { return a - b; }
|
13
|
+
|
14
|
+
float subFloats(float a, float b) { return a - b; }
|
15
|
+
|
16
|
+
string getClassName() { return "Subtracter"; }
|
17
|
+
};
|
18
|
+
}
|
19
|
+
|
20
|
+
#endif
|
@@ -0,0 +1,19 @@
|
|
1
|
+
/**
|
2
|
+
* This header file is for testing free (top) level function
|
3
|
+
* parsing and querying
|
4
|
+
*/
|
5
|
+
|
6
|
+
#ifndef __FUNCTIONS__H__
|
7
|
+
#define __FUNCTIONS__H__
|
8
|
+
|
9
|
+
namespace functions {
|
10
|
+
|
11
|
+
void test1() { }
|
12
|
+
|
13
|
+
float test2(int arg1) { return 1.0; }
|
14
|
+
|
15
|
+
int test3(int arg1, float arg2) { return arg1; }
|
16
|
+
|
17
|
+
}
|
18
|
+
|
19
|
+
#endif
|
@@ -0,0 +1,20 @@
|
|
1
|
+
#ifndef __NESTED_CLASSES_H__
|
2
|
+
#define __NESTED_CLASSES_H__
|
3
|
+
|
4
|
+
namespace classes {
|
5
|
+
class TestClass {
|
6
|
+
public:
|
7
|
+
TestClass() { }
|
8
|
+
|
9
|
+
class InnerClass {
|
10
|
+
public:
|
11
|
+
InnerClass() {}
|
12
|
+
class Inner2 {
|
13
|
+
public:
|
14
|
+
Inner2() {}
|
15
|
+
};
|
16
|
+
};
|
17
|
+
};
|
18
|
+
}
|
19
|
+
|
20
|
+
#endif
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
|
3
|
+
context "Extension with modules" do
|
4
|
+
|
5
|
+
def setup
|
6
|
+
if !defined?(@@modules_built)
|
7
|
+
super
|
8
|
+
@@modules_built = true
|
9
|
+
Extension.new "modules" do |e|
|
10
|
+
e.sources [
|
11
|
+
full_dir("headers/Adder.h"),
|
12
|
+
full_dir("headers/functions.h"),
|
13
|
+
full_dir("headers/Subtracter.hpp")
|
14
|
+
]
|
15
|
+
|
16
|
+
# e.writer_mode :single
|
17
|
+
|
18
|
+
e.module "Empty" do |m|
|
19
|
+
end
|
20
|
+
|
21
|
+
# Can use without a block
|
22
|
+
wrapper = e.module "Wrapper"
|
23
|
+
wrapper.namespace "classes"
|
24
|
+
|
25
|
+
e.module "Functions" do |m|
|
26
|
+
m.namespace "functions"
|
27
|
+
end
|
28
|
+
|
29
|
+
e.module "Nested" do |m|
|
30
|
+
m.module "Nested" do |n|
|
31
|
+
n.module "Inner" do |inner|
|
32
|
+
inner.namespace "subtracter"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
require 'modules'
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
specify "should be able to generate a module definition" do
|
44
|
+
assert defined?(Empty)
|
45
|
+
Empty.class.should == Module
|
46
|
+
end
|
47
|
+
|
48
|
+
specify "should wrap up C++ classes under the namespace as requested" do
|
49
|
+
assert !defined?(Adder)
|
50
|
+
assert defined?(Wrapper::Adder)
|
51
|
+
a = Wrapper::Adder.new
|
52
|
+
a.get_class_name.should == "Adder"
|
53
|
+
end
|
54
|
+
|
55
|
+
specify "should wrap up C++ functions in the module" do
|
56
|
+
assert defined?(Functions)
|
57
|
+
Functions::test2(2).should.be.close 1.0, 0.001
|
58
|
+
Functions::test3(4, 6).should == 4
|
59
|
+
end
|
60
|
+
|
61
|
+
specify "should be able to nest modules and related definitions" do
|
62
|
+
assert !defined?(Subtracter)
|
63
|
+
assert defined?(Nested::Nested::Inner::Subtracter)
|
64
|
+
s = Nested::Nested::Inner::Subtracter.new
|
65
|
+
s.get_class_name.should == "Subtracter"
|
66
|
+
end
|
67
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
$: << File.expand_path(File.dirname(__FILE__) + "/../lib")
|
2
|
+
$:.unshift File.expand_path(File.dirname(__FILE__) + "/generated")
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
require 'test/spec'
|
6
|
+
require 'rbplusplus'
|
7
|
+
|
8
|
+
include RbPlusPlus
|
9
|
+
|
10
|
+
class Test::Unit::TestCase
|
11
|
+
|
12
|
+
def full_dir(path)
|
13
|
+
File.expand_path(File.join(File.dirname(__FILE__), path))
|
14
|
+
end
|
15
|
+
|
16
|
+
def setup
|
17
|
+
`rm -rf #{full_dir('generated')}/*`
|
18
|
+
end
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rbplusplus
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: "0.1"
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jason Roelofs
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-05-04 00:00:00 -04:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rbgccxml
|
17
|
+
version_requirement:
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - "="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: "0.1"
|
23
|
+
version:
|
24
|
+
description: Rb++ combines the powerful query interface of rbgccxml and the Rice library to make Ruby wrapping extensions easier to write than ever.
|
25
|
+
email: jameskilton@gmail.com
|
26
|
+
executables: []
|
27
|
+
|
28
|
+
extensions: []
|
29
|
+
|
30
|
+
extra_rdoc_files: []
|
31
|
+
|
32
|
+
files:
|
33
|
+
- TODO
|
34
|
+
- Rakefile
|
35
|
+
- lib/rbplusplus/extension.rb
|
36
|
+
- lib/rbplusplus/module.rb
|
37
|
+
- lib/rbplusplus/builders/extension.rb
|
38
|
+
- lib/rbplusplus/builders/module.rb
|
39
|
+
- lib/rbplusplus/builders/base.rb
|
40
|
+
- lib/rbplusplus/builders/class.rb
|
41
|
+
- lib/rbplusplus/rbplusplus.rb
|
42
|
+
- lib/rbplusplus/writers/extension.rb
|
43
|
+
- lib/rbplusplus/writers/base.rb
|
44
|
+
- lib/rbplusplus/writers/single_file_writer.rb
|
45
|
+
- lib/rbplusplus/writers/multiple_files_writer.rb
|
46
|
+
- lib/jamis.rb
|
47
|
+
- lib/inflector.rb
|
48
|
+
- lib/inflections.rb
|
49
|
+
- lib/rbplusplus.rb
|
50
|
+
has_rdoc: false
|
51
|
+
homepage: http://rbplusplus.rubyforge.org/rbplusplus
|
52
|
+
post_install_message:
|
53
|
+
rdoc_options: []
|
54
|
+
|
55
|
+
require_paths:
|
56
|
+
- lib
|
57
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: "0"
|
62
|
+
version:
|
63
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: "0"
|
68
|
+
version:
|
69
|
+
requirements: []
|
70
|
+
|
71
|
+
rubyforge_project: rbplusplus
|
72
|
+
rubygems_version: 1.1.1
|
73
|
+
signing_key:
|
74
|
+
specification_version: 2
|
75
|
+
summary: Ruby library to generate Rice wrapper code
|
76
|
+
test_files:
|
77
|
+
- test/classes_test.rb
|
78
|
+
- test/extension_test.rb
|
79
|
+
- test/compiling_test.rb
|
80
|
+
- test/modules_test.rb
|
81
|
+
- test/functions_test.rb
|
82
|
+
- test/test_helper.rb
|
83
|
+
- test/file_writers_test.rb
|
84
|
+
- test/headers/Subtracter.hpp
|
85
|
+
- test/headers/functions.h
|
86
|
+
- test/headers/empty.h
|
87
|
+
- test/headers/nested_classes.h
|
88
|
+
- test/headers/with_includes.h
|
89
|
+
- test/headers/include
|
90
|
+
- test/headers/include/helper.h
|
91
|
+
- test/headers/Adder.h
|