rbplusplus 0.1.1 → 0.8
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 +31 -15
- data/TODO +20 -0
- data/lib/rbplusplus/builders/base.rb +148 -8
- data/lib/rbplusplus/builders/class.rb +106 -31
- data/lib/rbplusplus/builders/enumeration.rb +40 -0
- data/lib/rbplusplus/builders/extension.rb +31 -6
- data/lib/rbplusplus/builders/module.rb +12 -6
- data/lib/rbplusplus/builders/types_manager.rb +93 -0
- data/lib/rbplusplus/extension.rb +69 -41
- data/lib/rbplusplus/module.rb +3 -1
- data/lib/rbplusplus/transformers/class.rb +67 -0
- data/lib/rbplusplus/transformers/constructor.rb +4 -0
- data/lib/rbplusplus/transformers/function.rb +27 -0
- data/lib/rbplusplus/transformers/method.rb +4 -0
- data/lib/rbplusplus/transformers/module.rb +71 -0
- data/lib/rbplusplus/transformers/node.rb +77 -0
- data/lib/rbplusplus/transformers/node_cache.rb +19 -0
- data/lib/rbplusplus/transformers/node_reference.rb +30 -0
- data/lib/rbplusplus/transformers/rbgccxml.rb +6 -0
- data/lib/rbplusplus/writers/extension.rb +33 -25
- data/lib/rbplusplus/writers/multiple_files_writer.rb +42 -2
- data/lib/rbplusplus/writers/single_file_writer.rb +5 -0
- data/lib/rbplusplus.rb +24 -0
- data/test/class_methods_test.rb +55 -0
- data/test/classes_test.rb +0 -25
- data/test/compiling_test.rb +30 -0
- data/test/constructors_test.rb +40 -0
- data/test/enumerations_test.rb +63 -0
- data/test/file_writers_test.rb +56 -4
- data/test/generated/extconf.rb +25 -5
- data/test/headers/class_methods.h +41 -0
- data/test/headers/complex_static_methods.h +25 -0
- data/test/headers/constructors.h +47 -0
- data/test/headers/enums.h +77 -0
- data/test/headers/external_mapping.h +16 -0
- data/test/headers/external_mapping_rice.h +20 -0
- data/test/headers/include/helper.h +1 -0
- data/test/headers/nested_struct.h +20 -0
- data/test/headers/overload.h +28 -0
- data/test/headers/subclass.h +42 -0
- data/test/headers/to_from_ruby.h +78 -0
- data/test/headers/to_from_ruby_source.cpp +22 -0
- data/test/headers/ugly_helper.h +18 -0
- data/test/headers/ugly_interface.h +115 -0
- data/test/headers/ugly_interface_ns.h +8 -0
- data/test/nested_test.rb +26 -0
- data/test/object_persistence_test.rb +44 -0
- data/test/overloading_test.rb +36 -0
- data/test/struct_test.rb +22 -0
- data/test/subclass_test.rb +31 -0
- data/test/test_helper.rb +5 -0
- data/test/to_from_ruby_test.rb +24 -0
- data/test/wrap_as_test.rb +114 -0
- metadata +43 -6
@@ -0,0 +1,114 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
|
3
|
+
context "Ugly interfaces cleaner" do
|
4
|
+
|
5
|
+
specify "should map functions detailed" do
|
6
|
+
node = nil
|
7
|
+
|
8
|
+
|
9
|
+
Extension.new "ui" do |e|
|
10
|
+
e.sources full_dir("headers/ugly_interface_ns.h"),
|
11
|
+
:includes => full_dir("headers/ugly_helper.h")
|
12
|
+
node = e.namespace("UI")
|
13
|
+
|
14
|
+
# test the no export option
|
15
|
+
node.functions("uiIgnore").ignore
|
16
|
+
|
17
|
+
# static method wrapping
|
18
|
+
node.functions("IlikeVectors").wrap_as("create_vector").calls("newInstanceButBetter")
|
19
|
+
|
20
|
+
e.module "UI" do |m|
|
21
|
+
m.module "Math" do |m_math|
|
22
|
+
#function wrapping
|
23
|
+
m_math.includes node.functions("uiAdd").wrap_as("add")
|
24
|
+
# Wrap_as changes the name of the node
|
25
|
+
node.functions("add").ignored?.should == false
|
26
|
+
node.functions("add").moved?.should == true
|
27
|
+
|
28
|
+
m_math.includes node.functions("ui_Subtract").wrap_as("subtract")
|
29
|
+
m_math.includes node.namespaces("DMath").functions("divide")
|
30
|
+
end
|
31
|
+
|
32
|
+
#class wrapping
|
33
|
+
vector = node.classes("C_UIVector").wrap_as("Vector")
|
34
|
+
vector.methods("x_").wrap_as("x")
|
35
|
+
vector.methods("set_x").wrap_as("x=")
|
36
|
+
|
37
|
+
# This is ignored because the C function Vector_y is not defined
|
38
|
+
vector.methods("y_").calls("Vector_y").ignore
|
39
|
+
vector.methods("y_").qualified_name.should == "Vector_y"
|
40
|
+
|
41
|
+
m.includes vector
|
42
|
+
|
43
|
+
#mapping stray functions to singleton methods
|
44
|
+
modder = node.namespaces("I_LEARN_C").classes("Modder").wrap_as("Modulus")
|
45
|
+
modder.includes node.namespaces("I_LEARN_C").functions("mod")
|
46
|
+
modder.includes node.namespaces("I_LEARN_C").functions("mod2").wrap_as("method_mod").as_instance_method
|
47
|
+
m.includes modder
|
48
|
+
|
49
|
+
nc = node.classes("NoConstructor")
|
50
|
+
nc.constructors.each { |c| c.ignore }
|
51
|
+
m.includes nc
|
52
|
+
|
53
|
+
m.includes node.classes("Outside")
|
54
|
+
node.classes("Outside").includes node.classes("Inside")
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
require 'ui'
|
59
|
+
|
60
|
+
should.raise NoMethodError do
|
61
|
+
ui_ignore()
|
62
|
+
end
|
63
|
+
|
64
|
+
should.raise NoMethodError do
|
65
|
+
ui_add(1,2)
|
66
|
+
end
|
67
|
+
|
68
|
+
should.not.raise NoMethodError do
|
69
|
+
UI::Math::add(1,2).should == 3
|
70
|
+
end
|
71
|
+
|
72
|
+
should.raise NoMethodError do
|
73
|
+
ui_subtract(2,1)
|
74
|
+
end
|
75
|
+
|
76
|
+
should.not.raise NoMethodError do
|
77
|
+
UI::Math::subtract(2,1).should == 1
|
78
|
+
end
|
79
|
+
|
80
|
+
should.raise NameError do
|
81
|
+
C_UIVector.new
|
82
|
+
end
|
83
|
+
|
84
|
+
should.not.raise NameError do
|
85
|
+
v = UI::Vector.new
|
86
|
+
v.x = 3
|
87
|
+
v.x.should == 3
|
88
|
+
end
|
89
|
+
|
90
|
+
should.raise NameError do
|
91
|
+
UI::DMath::divide(1.0,2.0)
|
92
|
+
end
|
93
|
+
|
94
|
+
should.not.raise NoMethodError do
|
95
|
+
UI::Modulus.mod(3,2).should == 1
|
96
|
+
end
|
97
|
+
|
98
|
+
should.raise TypeError do
|
99
|
+
UI::Modulus.new.method_mod(2)
|
100
|
+
end
|
101
|
+
|
102
|
+
should.not.raise NoMethodError do
|
103
|
+
UI::Math::divide(2,1).should == 2
|
104
|
+
end
|
105
|
+
|
106
|
+
should.raise TypeError do
|
107
|
+
UI::NoConstructor.new
|
108
|
+
end
|
109
|
+
|
110
|
+
should.not.raise NoMethodError do
|
111
|
+
UI::Outside::Inside.new
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbplusplus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: "0.8"
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Roelofs
|
@@ -9,26 +9,28 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-07-22 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rbgccxml
|
17
|
+
type: :runtime
|
17
18
|
version_requirement:
|
18
19
|
version_requirements: !ruby/object:Gem::Requirement
|
19
20
|
requirements:
|
20
21
|
- - "="
|
21
22
|
- !ruby/object:Gem::Version
|
22
|
-
version: 0.
|
23
|
+
version: "0.8"
|
23
24
|
version:
|
24
25
|
- !ruby/object:Gem::Dependency
|
25
26
|
name: rice
|
27
|
+
type: :runtime
|
26
28
|
version_requirement:
|
27
29
|
version_requirements: !ruby/object:Gem::Requirement
|
28
30
|
requirements:
|
29
|
-
- - "
|
31
|
+
- - ">="
|
30
32
|
- !ruby/object:Gem::Version
|
31
|
-
version: 1.0.
|
33
|
+
version: 1.0.2
|
32
34
|
version:
|
33
35
|
description: Rb++ combines the powerful query interface of rbgccxml and the Rice library to make Ruby wrapping extensions easier to write than ever.
|
34
36
|
email: jameskilton@gmail.com
|
@@ -43,11 +45,22 @@ files:
|
|
43
45
|
- Rakefile
|
44
46
|
- lib/rbplusplus/extension.rb
|
45
47
|
- lib/rbplusplus/module.rb
|
48
|
+
- lib/rbplusplus/builders/enumeration.rb
|
46
49
|
- lib/rbplusplus/builders/extension.rb
|
47
50
|
- lib/rbplusplus/builders/module.rb
|
51
|
+
- lib/rbplusplus/builders/types_manager.rb
|
48
52
|
- lib/rbplusplus/builders/base.rb
|
49
53
|
- lib/rbplusplus/builders/class.rb
|
50
54
|
- lib/rbplusplus/rbplusplus.rb
|
55
|
+
- lib/rbplusplus/transformers/function.rb
|
56
|
+
- lib/rbplusplus/transformers/node_cache.rb
|
57
|
+
- lib/rbplusplus/transformers/node.rb
|
58
|
+
- lib/rbplusplus/transformers/module.rb
|
59
|
+
- lib/rbplusplus/transformers/constructor.rb
|
60
|
+
- lib/rbplusplus/transformers/node_reference.rb
|
61
|
+
- lib/rbplusplus/transformers/method.rb
|
62
|
+
- lib/rbplusplus/transformers/class.rb
|
63
|
+
- lib/rbplusplus/transformers/rbgccxml.rb
|
51
64
|
- lib/rbplusplus/writers/extension.rb
|
52
65
|
- lib/rbplusplus/writers/base.rb
|
53
66
|
- lib/rbplusplus/writers/single_file_writer.rb
|
@@ -78,25 +91,49 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
78
91
|
requirements: []
|
79
92
|
|
80
93
|
rubyforge_project: rbplusplus
|
81
|
-
rubygems_version: 1.
|
94
|
+
rubygems_version: 1.2.0
|
82
95
|
signing_key:
|
83
96
|
specification_version: 2
|
84
97
|
summary: Ruby library to generate Rice wrapper code
|
85
98
|
test_files:
|
86
99
|
- test/classes_test.rb
|
87
100
|
- test/extension_test.rb
|
101
|
+
- test/nested_test.rb
|
102
|
+
- test/subclass_test.rb
|
103
|
+
- test/constructors_test.rb
|
104
|
+
- test/overloading_test.rb
|
105
|
+
- test/wrap_as_test.rb
|
106
|
+
- test/object_persistence_test.rb
|
88
107
|
- test/generated/extconf.rb
|
108
|
+
- test/class_methods_test.rb
|
89
109
|
- test/compiling_test.rb
|
110
|
+
- test/to_from_ruby_test.rb
|
111
|
+
- test/struct_test.rb
|
112
|
+
- test/enumerations_test.rb
|
90
113
|
- test/modules_test.rb
|
91
114
|
- test/functions_test.rb
|
92
115
|
- test/test_helper.rb
|
93
116
|
- test/file_writers_test.rb
|
94
117
|
- test/headers/Subtracter.hpp
|
118
|
+
- test/headers/complex_static_methods.h
|
119
|
+
- test/headers/ugly_interface.h
|
120
|
+
- test/headers/external_mapping.h
|
95
121
|
- test/headers/functions.h
|
122
|
+
- test/headers/to_from_ruby_source.cpp
|
96
123
|
- test/headers/empty.h
|
124
|
+
- test/headers/enums.h
|
125
|
+
- test/headers/ugly_interface_ns.h
|
126
|
+
- test/headers/nested_struct.h
|
127
|
+
- test/headers/subclass.h
|
97
128
|
- test/headers/requires_define.h
|
129
|
+
- test/headers/class_methods.h
|
130
|
+
- test/headers/ugly_helper.h
|
131
|
+
- test/headers/constructors.h
|
98
132
|
- test/headers/nested_classes.h
|
99
133
|
- test/headers/with_includes.h
|
134
|
+
- test/headers/to_from_ruby.h
|
135
|
+
- test/headers/external_mapping_rice.h
|
100
136
|
- test/headers/include
|
101
137
|
- test/headers/include/helper.h
|
138
|
+
- test/headers/overload.h
|
102
139
|
- test/headers/Adder.h
|