rbplusplus 1.0 → 1.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 CHANGED
@@ -3,7 +3,7 @@ require 'rake/rdoctask'
3
3
  require 'rake/contrib/sshpublisher'
4
4
 
5
5
  PROJECT_NAME = "rb++"
6
- RBPLUSPLUS_VERSION = "1.0"
6
+ RBPLUSPLUS_VERSION = "1.0.1"
7
7
 
8
8
  task :default => :test
9
9
 
@@ -38,16 +38,18 @@ module RbPlusPlus
38
38
  [to_use || real_constructors].flatten.each do |constructor|
39
39
  next if do_not_wrap?(constructor)
40
40
 
41
- if constructor.attributes[:artificial]
42
- next if ignore_artificial || constructor.arguments.length == 1
43
- end
41
+ Logger.debug "Wrapping constructor: #{constructor.attributes["demangled"]}"
44
42
 
45
- if implicit_converter?(constructor)
46
- if constructor.implicit_casting?
47
- parent.add_child ImplicitCasterNode.new(constructor, self)
43
+ if constructor.attributes["artificial"]
44
+ if ignore_artificial && constructor.arguments.length == 1
45
+ Logger.debug "Not wrapping artificial constructor #{constructor.attributes["demangled"]}"
46
+ next
48
47
  end
48
+ end
49
49
 
50
- # We don't want to expose these constructors to Rice
50
+ if implicit_casting?(constructor)
51
+ Logger.debug "Wrapping implicit constructor #{constructor.to_cpp}"
52
+ parent.add_child ImplicitCasterNode.new(constructor, self)
51
53
  next
52
54
  end
53
55
 
@@ -60,9 +62,10 @@ module RbPlusPlus
60
62
  end
61
63
 
62
64
  # Is this constructor a converter constructor?
63
- def implicit_converter?(constructor)
64
- # Single argument
65
- constructor.arguments.length == 1 &&
65
+ def implicit_casting?(constructor)
66
+ constructor.implicit_casting? &&
67
+ # Only works on single argument constructors
68
+ constructor.arguments.length == 1 &&
66
69
  # We are wrapping the type converting from
67
70
  !do_not_wrap?(constructor.arguments[0].cpp_type.base_type)
68
71
  end
@@ -9,9 +9,9 @@ module RbGCCXML
9
9
  # They manage the conversion of one type to another. Rice handles this functionality
10
10
  # through a special method, define_implicit_cast<From, To>().
11
11
  #
12
- # Rb++ attempts to find all classes and constructors that fit this pattern
13
- # and write out the casting declarations as needed. In the cases where this is
14
- # functionality not wanted, use this method to turn off this casting check.
12
+ # Use this method to specify which constructors are meant to be used in implicit casting.
13
+ # This will mark the constructor as such and won't wrap it directly, but will build an
14
+ # appropriate define_implicit_cast<> call for the two types (class and argument)
15
15
  #
16
16
  # This method can be called per Constructor or per Class.
17
17
  def implicit_casting(state)
@@ -20,7 +20,7 @@ module RbGCCXML
20
20
 
21
21
  def implicit_casting? #:nodoc:
22
22
  if @implicit_casting.nil?
23
- @implicit_casting = true
23
+ @implicit_casting = false
24
24
  end
25
25
 
26
26
  @implicit_casting
@@ -1,6 +1,6 @@
1
1
  require 'test_helper'
2
2
 
3
- context "Director proxy generation" do
3
+ describe "Director proxy generation" do
4
4
 
5
5
  before(:all) do
6
6
  Extension.new "director" do |e|
@@ -55,53 +55,6 @@ namespace implicit_cast {
55
55
  bool isRight(Degree* degree) {
56
56
  return degree->valueDegrees() == 90;
57
57
  }
58
-
59
- /**
60
- * Classes to show how to turn off the implicit casting
61
- */
62
- class Explicit
63
- {
64
- public:
65
- Explicit(float v) {
66
- value = v;
67
- }
68
-
69
- Explicit(const Degree &d) {
70
- value = d.valueDegrees();
71
- }
72
-
73
- Explicit(const Radian &r) {
74
- value = r.valueDegrees();
75
- }
76
-
77
- float value;
78
- };
79
-
80
- float explicitValue(Explicit e) {
81
- return e.value;
82
- }
83
-
84
- class NotImplicit
85
- {
86
- public:
87
- NotImplicit(float v, int a) {
88
- value = v * a;
89
- }
90
-
91
- NotImplicit(const Degree &d) {
92
- value = d.valueDegrees();
93
- }
94
-
95
- NotImplicit(const Radian &r) {
96
- value = r.valueDegrees();
97
- }
98
-
99
- float value;
100
- };
101
-
102
- float notImplicitValue(NotImplicit i) {
103
- return i.value;
104
- }
105
58
  }
106
59
 
107
60
  #endif
@@ -10,11 +10,10 @@ describe "Specify types to allow implicit casting" do
10
10
  node = e.namespace "implicit_cast"
11
11
 
12
12
  # Can flag individual constructors
13
- node.classes("Explicit").constructors.
14
- find(:arguments => ["const Radian&"]).implicit_casting(false)
13
+ node.classes("Degree").constructors.find(:arguments => ["const Radian&"]).implicit_casting(true)
15
14
 
16
15
  # Or flag the class as a whole
17
- node.classes("NotImplicit").implicit_casting(false)
16
+ node.classes("Radian").implicit_casting(true)
18
17
  end
19
18
 
20
19
  require 'implicit_cast'
@@ -37,31 +36,5 @@ describe "Specify types to allow implicit casting" do
37
36
  is_right(Degree.new(90)).should be_true
38
37
  is_right(Radian.new(2.0)).should be_false
39
38
  end
40
-
41
- specify "can turn off implicit cast wrapping for a given constructor" do
42
- lambda do
43
- explicit_value(Radian.new(60.0))
44
- end.should raise_error
45
-
46
- lambda do
47
- e = Explicit.new(14.0)
48
- explicit_value(e).should be_close(14.0, 0.001)
49
- end.should_not raise_error
50
- end
51
-
52
- specify "can turn off implicit casting for an entire class" do
53
- n = NotImplicit.new(10.0, 3)
54
-
55
- not_implicit_value(n).should be_close(30.0, 0.001)
56
-
57
- lambda do
58
- not_implicit_value(Degree.new(15.0))
59
- end.should raise_error
60
-
61
- lambda do
62
- not_implicit_value(Radian.new(1.0))
63
- end.should raise_error
64
- end
65
-
66
39
  end
67
40
 
data/test/modules_test.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'test_helper'
2
2
 
3
- context "Extension with modules" do
3
+ describe "Extension with modules" do
4
4
 
5
5
  before(:all) do
6
6
  Extension.new "modules" do |e|
data/test/nested_test.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'test_helper'
2
2
 
3
- context "Wrapping Classes within classes" do
3
+ describe "Wrapping Classes within classes" do
4
4
  before(:all) do
5
5
  Extension.new "nested" do |e|
6
6
  e.sources full_dir("headers/nested_classes.h")
@@ -1,6 +1,6 @@
1
1
  require 'test_helper'
2
2
 
3
- context "Extension with class hierachies" do
3
+ describe "Extension with class hierachies" do
4
4
 
5
5
  specify "should make super classes methods available" do
6
6
  Extension.new "subclass" do |e|
@@ -1,6 +1,6 @@
1
1
  require 'test_helper'
2
2
 
3
- context "Properly build known required to_ruby and from_ruby methods" do
3
+ describe "Properly build known required to_ruby and from_ruby methods" do
4
4
 
5
5
  specify "should build for const & types as needed" do
6
6
  Extension.new "to_from_ruby" do |e|
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbplusplus
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- version: "1.0"
9
+ - 1
10
+ version: 1.0.1
10
11
  platform: ruby
11
12
  authors:
12
13
  - Jason Roelofs
@@ -14,7 +15,7 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-08-30 00:00:00 -04:00
18
+ date: 2010-10-26 00:00:00 -04:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency