gosu 0.7.20 → 0.7.21
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/Gosu/Audio.hpp +1 -0
- data/Gosu/Color.hpp +5 -0
- data/Gosu/Font.hpp +5 -0
- data/Gosu/Graphics.hpp +12 -0
- data/Gosu/GraphicsBase.hpp +4 -3
- data/Gosu/ImageData.hpp +1 -0
- data/Gosu/Input.hpp +1 -0
- data/Gosu/Platform.hpp +8 -0
- data/Gosu/Text.hpp +17 -7
- data/Gosu/Version.hpp +2 -2
- data/Gosu/Window.hpp +4 -4
- data/GosuImpl/Audio/AudioSDL.cpp +4 -0
- data/GosuImpl/Graphics/BitmapPNG.cpp +7 -6
- data/GosuImpl/Graphics/Common.hpp +28 -0
- data/GosuImpl/Graphics/DrawOp.hpp +31 -6
- data/GosuImpl/Graphics/Font.cpp +63 -34
- data/GosuImpl/Graphics/FormattedString.hpp +248 -0
- data/GosuImpl/Graphics/Graphics.cpp +39 -7
- data/GosuImpl/Graphics/LargeImageData.cpp +10 -0
- data/GosuImpl/Graphics/LargeImageData.hpp +2 -0
- data/GosuImpl/Graphics/Macro.hpp +5 -0
- data/GosuImpl/Graphics/TexChunk.cpp +10 -5
- data/GosuImpl/Graphics/TexChunk.hpp +4 -2
- data/GosuImpl/Graphics/Text.cpp +118 -57
- data/GosuImpl/Graphics/TextTouch.mm +49 -17
- data/GosuImpl/Graphics/TextUnix.cpp +1 -2
- data/GosuImpl/Graphics/TextWin.cpp +2 -3
- data/GosuImpl/Graphics/Texture.cpp +33 -2
- data/GosuImpl/Graphics/Texture.hpp +3 -1
- data/GosuImpl/Graphics/Transform.cpp +59 -0
- data/GosuImpl/RubyGosu.swg +46 -4
- data/GosuImpl/RubyGosu_wrap.cxx +822 -157
- data/GosuImpl/Utility.cpp +1 -0
- data/GosuImpl/WindowWin.cpp +8 -8
- data/examples/CptnRuby.rb +27 -28
- data/lib/gosu.rb +1 -1
- data/linux/extconf.rb +2 -2
- metadata +21 -6
- data/GosuImpl/RubyGosu_wrap.cxx.rej +0 -187
data/GosuImpl/Utility.cpp
CHANGED
data/GosuImpl/WindowWin.cpp
CHANGED
|
@@ -245,16 +245,16 @@ Gosu::Window::Window(unsigned width, unsigned height, bool fullscreen,
|
|
|
245
245
|
if (GetLastError() != 0)
|
|
246
246
|
Win::throwLastError("setting the window's GWLP_USERDATA pointer");
|
|
247
247
|
|
|
248
|
-
// Windowed: Create window large enough to display stuff
|
|
249
|
-
// This is a pretty brutal heuristic I guess.
|
|
250
|
-
|
|
248
|
+
// Windowed: Create window large enough to display stuff
|
|
249
|
+
// This is a pretty brutal heuristic I guess.
|
|
250
|
+
|
|
251
251
|
if (!fullscreen)
|
|
252
252
|
{
|
|
253
|
-
double factor = std::min(0.9 * screenWidth() / width,
|
|
254
|
-
0.8 * screenHeight() / height);
|
|
255
|
-
|
|
256
|
-
if (factor < 1)
|
|
257
|
-
width *= factor, height *= factor;
|
|
253
|
+
double factor = std::min(0.9 * screenWidth() / width,
|
|
254
|
+
0.8 * screenHeight() / height);
|
|
255
|
+
|
|
256
|
+
if (factor < 1)
|
|
257
|
+
width *= factor, height *= factor;
|
|
258
258
|
}
|
|
259
259
|
|
|
260
260
|
// Determine the size the window needs to have.
|
data/examples/CptnRuby.rb
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# Shows how to
|
|
4
4
|
# * implement jumping/gravity
|
|
5
|
-
# * implement scrolling
|
|
5
|
+
# * implement scrolling using Window#translate
|
|
6
6
|
# * implement a simple tile-based map
|
|
7
7
|
# * load levels from primitive text files
|
|
8
8
|
|
|
@@ -25,14 +25,15 @@
|
|
|
25
25
|
# ...Enemies, a more sophisticated object system, weapons, title and credits
|
|
26
26
|
# screens...
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
require '../lib/gosu'
|
|
29
|
+
# begin
|
|
30
|
+
# # In case you use Gosu via rubygems.
|
|
31
|
+
# require 'rubygems'
|
|
32
|
+
# rescue LoadError
|
|
33
|
+
# # In case you don't.
|
|
34
|
+
# end
|
|
35
|
+
#
|
|
36
|
+
# require 'gosu'
|
|
36
37
|
include Gosu
|
|
37
38
|
|
|
38
39
|
module Tiles
|
|
@@ -48,10 +49,9 @@ class CollectibleGem
|
|
|
48
49
|
@x, @y = x, y
|
|
49
50
|
end
|
|
50
51
|
|
|
51
|
-
def draw
|
|
52
|
+
def draw
|
|
52
53
|
# Draw, slowly rotating
|
|
53
|
-
@image.draw_rot(@x
|
|
54
|
-
25 * Math.sin(milliseconds / 133.7))
|
|
54
|
+
@image.draw_rot(@x, @y, 0, 25 * Math.sin(milliseconds / 133.7))
|
|
55
55
|
end
|
|
56
56
|
end
|
|
57
57
|
|
|
@@ -72,7 +72,7 @@ class CptnRuby
|
|
|
72
72
|
@cur_image = @standing
|
|
73
73
|
end
|
|
74
74
|
|
|
75
|
-
def draw
|
|
75
|
+
def draw
|
|
76
76
|
# Flip vertically when facing to the left.
|
|
77
77
|
if @dir == :left then
|
|
78
78
|
offs_x = -25
|
|
@@ -81,7 +81,7 @@ class CptnRuby
|
|
|
81
81
|
offs_x = 25
|
|
82
82
|
factor = -1.0
|
|
83
83
|
end
|
|
84
|
-
@cur_image.draw(@x
|
|
84
|
+
@cur_image.draw(@x + offs_x, @y - 49, 0, factor, 1.0)
|
|
85
85
|
end
|
|
86
86
|
|
|
87
87
|
# Could the object be placed at x + offs_x/y + offs_y without being stuck?
|
|
@@ -146,7 +146,6 @@ class Map
|
|
|
146
146
|
def initialize(window, filename)
|
|
147
147
|
# Load 60x60 tiles, 5px overlap in all four directions.
|
|
148
148
|
@tileset = Image.load_tiles(window, "media/CptnRuby Tileset.png", 60, 60, true)
|
|
149
|
-
@sky = Image.new(window, "media/Space.png", true)
|
|
150
149
|
|
|
151
150
|
gem_img = Image.new(window, "media/CptnRuby Gem.png", false)
|
|
152
151
|
@gems = []
|
|
@@ -171,11 +170,7 @@ class Map
|
|
|
171
170
|
end
|
|
172
171
|
end
|
|
173
172
|
|
|
174
|
-
def draw
|
|
175
|
-
# Sigh, stars!
|
|
176
|
-
@sky.draw(0, 0, 0)
|
|
177
|
-
|
|
178
|
-
|
|
173
|
+
def draw
|
|
179
174
|
# Very primitive drawing function:
|
|
180
175
|
# Draws all the tiles, some off-screen, some on-screen.
|
|
181
176
|
@height.times do |y|
|
|
@@ -184,11 +179,11 @@ class Map
|
|
|
184
179
|
if tile
|
|
185
180
|
# Draw the tile with an offset (tile images have some overlap)
|
|
186
181
|
# Scrolling is implemented here just as in the game objects.
|
|
187
|
-
@tileset[tile].draw(x * 50 -
|
|
182
|
+
@tileset[tile].draw(x * 50 - 5, y * 50 - 5, 0)
|
|
188
183
|
end
|
|
189
184
|
end
|
|
190
185
|
end
|
|
191
|
-
@gems.each { |c| c.draw
|
|
186
|
+
@gems.each { |c| c.draw }
|
|
192
187
|
end
|
|
193
188
|
|
|
194
189
|
# Solid at a given pixel position?
|
|
@@ -203,10 +198,11 @@ class Game < Window
|
|
|
203
198
|
def initialize
|
|
204
199
|
super(640, 480, false)
|
|
205
200
|
self.caption = "Cptn. Ruby"
|
|
201
|
+
@sky = Image.new(self, "media/Space.png", true)
|
|
206
202
|
@map = Map.new(self, "media/CptnRuby Map.txt")
|
|
207
203
|
@cptn = CptnRuby.new(self, 400, 100)
|
|
208
|
-
#
|
|
209
|
-
@
|
|
204
|
+
# The scrolling position is stored as top left corner of the screen.
|
|
205
|
+
@camera_x = @camera_y = 0
|
|
210
206
|
end
|
|
211
207
|
def update
|
|
212
208
|
move_x = 0
|
|
@@ -215,12 +211,15 @@ class Game < Window
|
|
|
215
211
|
@cptn.update(move_x)
|
|
216
212
|
@cptn.collect_gems(@map.gems)
|
|
217
213
|
# Scrolling follows player
|
|
218
|
-
@
|
|
219
|
-
@
|
|
214
|
+
@camera_x = [[@cptn.x - 320, 0].max, @map.width * 50 - 640].min
|
|
215
|
+
@camera_y = [[@cptn.y - 240, 0].max, @map.height * 50 - 480].min
|
|
220
216
|
end
|
|
221
217
|
def draw
|
|
222
|
-
@
|
|
223
|
-
|
|
218
|
+
@sky.draw 0, 0, 0
|
|
219
|
+
translate(-@camera_x, -@camera_y) do
|
|
220
|
+
@map.draw
|
|
221
|
+
@cptn.draw
|
|
222
|
+
end
|
|
224
223
|
end
|
|
225
224
|
def button_down(id)
|
|
226
225
|
if id == KbUp then @cptn.try_to_jump end
|
data/lib/gosu.rb
CHANGED
|
@@ -9,7 +9,7 @@ begin
|
|
|
9
9
|
require "#{File.dirname(__FILE__)}/gosu.for_#{version}.#{Config::CONFIG['DLEXT']}"
|
|
10
10
|
require "#{File.dirname(__FILE__)}/gosu/swig_patches.rb"
|
|
11
11
|
rescue LoadError => e
|
|
12
|
-
require "#{File.dirname(__FILE__)}/gosu
|
|
12
|
+
require "#{File.dirname(__FILE__)}/gosu.#{Config::CONFIG['DLEXT']}"
|
|
13
13
|
require "#{File.dirname(__FILE__)}/gosu/swig_patches.rb"
|
|
14
14
|
end
|
|
15
15
|
|
data/linux/extconf.rb
CHANGED
|
@@ -20,7 +20,7 @@ SOURCE_FILES =
|
|
|
20
20
|
Graphics/RotFlip.cpp Graphics/BlockAllocator.cpp
|
|
21
21
|
Graphics/Texture.cpp Graphics/LargeImageData.cpp
|
|
22
22
|
Graphics/BitmapPNG.cpp Graphics/Font.cpp Graphics/BitmapBMP.cpp
|
|
23
|
-
Graphics/TextUnix.cpp Graphics/Text.cpp
|
|
23
|
+
Graphics/TextUnix.cpp Graphics/Text.cpp Graphics/Transform.cpp
|
|
24
24
|
Graphics/BitmapColorKey.cpp DirectoriesUnix.cpp
|
|
25
25
|
Audio/AudioSDL.cpp RubyGosu_wrap.cxx)
|
|
26
26
|
|
|
@@ -32,7 +32,7 @@ SOURCE_FILES.each { |file| `cp ../GosuImpl/#{file} #{File.basename(file)}` }
|
|
|
32
32
|
|
|
33
33
|
# Symlink our pretty gosu.so into ../lib
|
|
34
34
|
# FIXME gosu.rb should just look in the right place
|
|
35
|
-
`ln -s ../linux/gosu.so ../lib/gosu.
|
|
35
|
+
`ln -s ../linux/gosu.so ../lib/gosu.so`
|
|
36
36
|
|
|
37
37
|
sdl_config = with_config("sdl-config", "sdl-config")
|
|
38
38
|
pango_config = "pkg-config pangoft2" # FIXME should probably use with_config
|
metadata
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: gosu
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
|
|
4
|
+
hash: 41
|
|
5
|
+
prerelease: false
|
|
6
|
+
segments:
|
|
7
|
+
- 0
|
|
8
|
+
- 7
|
|
9
|
+
- 21
|
|
10
|
+
version: 0.7.21
|
|
5
11
|
platform: ruby
|
|
6
12
|
authors:
|
|
7
13
|
- Julian Raschke
|
|
@@ -10,7 +16,7 @@ autorequire:
|
|
|
10
16
|
bindir: bin
|
|
11
17
|
cert_chain: []
|
|
12
18
|
|
|
13
|
-
date: 2010-
|
|
19
|
+
date: 2010-06-13 00:00:00 +08:00
|
|
14
20
|
default_executable:
|
|
15
21
|
dependencies: []
|
|
16
22
|
|
|
@@ -105,6 +111,7 @@ files:
|
|
|
105
111
|
- GosuImpl/Graphics/Common.hpp
|
|
106
112
|
- GosuImpl/Graphics/DrawOp.hpp
|
|
107
113
|
- GosuImpl/Graphics/Font.cpp
|
|
114
|
+
- GosuImpl/Graphics/FormattedString.hpp
|
|
108
115
|
- GosuImpl/Graphics/GosuView.hpp
|
|
109
116
|
- GosuImpl/Graphics/GosuView.mm
|
|
110
117
|
- GosuImpl/Graphics/Graphics.cpp
|
|
@@ -123,6 +130,7 @@ files:
|
|
|
123
130
|
- GosuImpl/Graphics/Texture.cpp
|
|
124
131
|
- GosuImpl/Graphics/Texture.hpp
|
|
125
132
|
- GosuImpl/Graphics/TextWin.cpp
|
|
133
|
+
- GosuImpl/Graphics/Transform.cpp
|
|
126
134
|
- GosuImpl/Iconv.hpp
|
|
127
135
|
- GosuImpl/InputMac.mm
|
|
128
136
|
- GosuImpl/InputTouch.mm
|
|
@@ -135,7 +143,6 @@ files:
|
|
|
135
143
|
- GosuImpl/RubyGosu_DllMain.cxx
|
|
136
144
|
- GosuImpl/RubyGosu_SWIG_GC_PATCH.patch
|
|
137
145
|
- GosuImpl/RubyGosu_wrap.cxx
|
|
138
|
-
- GosuImpl/RubyGosu_wrap.cxx.rej
|
|
139
146
|
- GosuImpl/RubyGosu_wrap.h
|
|
140
147
|
- GosuImpl/RubyGosuStub.mm
|
|
141
148
|
- GosuImpl/Sockets/CommSocket.cpp
|
|
@@ -168,17 +175,25 @@ rdoc_options: []
|
|
|
168
175
|
require_paths:
|
|
169
176
|
- lib
|
|
170
177
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
178
|
+
none: false
|
|
171
179
|
requirements:
|
|
172
180
|
- - ">="
|
|
173
181
|
- !ruby/object:Gem::Version
|
|
182
|
+
hash: 51
|
|
183
|
+
segments:
|
|
184
|
+
- 1
|
|
185
|
+
- 8
|
|
186
|
+
- 2
|
|
174
187
|
version: 1.8.2
|
|
175
|
-
version:
|
|
176
188
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
189
|
+
none: false
|
|
177
190
|
requirements:
|
|
178
191
|
- - ">="
|
|
179
192
|
- !ruby/object:Gem::Version
|
|
193
|
+
hash: 3
|
|
194
|
+
segments:
|
|
195
|
+
- 0
|
|
180
196
|
version: "0"
|
|
181
|
-
version:
|
|
182
197
|
requirements:
|
|
183
198
|
- g++
|
|
184
199
|
- pkg-config
|
|
@@ -191,7 +206,7 @@ requirements:
|
|
|
191
206
|
g++ pkg-config ruby-dev xorg-dev libsdl-mixer1.2-dev libgl1-mesa-dev libpango1.0-dev
|
|
192
207
|
)
|
|
193
208
|
rubyforge_project:
|
|
194
|
-
rubygems_version: 1.3.
|
|
209
|
+
rubygems_version: 1.3.7
|
|
195
210
|
signing_key:
|
|
196
211
|
specification_version: 3
|
|
197
212
|
summary: 2D game development library.
|
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
***************
|
|
2
|
-
*** 8,13 ****
|
|
3
|
-
* interface file instead.
|
|
4
|
-
* ----------------------------------------------------------------------------- */
|
|
5
|
-
|
|
6
|
-
#define SWIGRUBY
|
|
7
|
-
#define SWIG_DIRECTORS
|
|
8
|
-
|
|
9
|
-
--- 8,17 ----
|
|
10
|
-
* interface file instead.
|
|
11
|
-
* ----------------------------------------------------------------------------- */
|
|
12
|
-
|
|
13
|
-
+ // This file was afterwards patched using the following instructions:
|
|
14
|
-
+ // http://sourceforge.net/tracker/index.php?func=detail&aid=2034216&group_id=1645&atid=101645
|
|
15
|
-
+ // (Many thanks to Kevin Burge for that.)
|
|
16
|
-
+
|
|
17
|
-
#define SWIGRUBY
|
|
18
|
-
#define SWIG_DIRECTORS
|
|
19
|
-
|
|
20
|
-
***************
|
|
21
|
-
*** 855,860 ****
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
#include <ruby.h>
|
|
25
|
-
|
|
26
|
-
/* Remove global macros defined in Ruby's win32.h */
|
|
27
|
-
#ifdef write
|
|
28
|
-
--- 859,865 ----
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
#include <ruby.h>
|
|
32
|
-
+ #include <map>
|
|
33
|
-
|
|
34
|
-
/* Remove global macros defined in Ruby's win32.h */
|
|
35
|
-
#ifdef write
|
|
36
|
-
***************
|
|
37
|
-
*** 1183,1189 ****
|
|
38
|
-
/* Global Ruby hash table to store Trackings from C/C++
|
|
39
|
-
structs to Ruby Objects.
|
|
40
|
-
*/
|
|
41
|
-
- static VALUE swig_ruby_trackings = Qnil;
|
|
42
|
-
|
|
43
|
-
/* Global variable that stores a reference to the ruby
|
|
44
|
-
hash table delete function. */
|
|
45
|
-
--- 1188,1194 ----
|
|
46
|
-
/* Global Ruby hash table to store Trackings from C/C++
|
|
47
|
-
structs to Ruby Objects.
|
|
48
|
-
*/
|
|
49
|
-
+ static std::map<void*, VALUE> swig_ruby_trackings;
|
|
50
|
-
|
|
51
|
-
/* Global variable that stores a reference to the ruby
|
|
52
|
-
hash table delete function. */
|
|
53
|
-
***************
|
|
54
|
-
*** 1200,1233 ****
|
|
55
|
-
This is done to allow multiple DSOs to share the same
|
|
56
|
-
tracking table.
|
|
57
|
-
*/
|
|
58
|
-
- ID trackings_id = rb_intern( "@__trackings__" );
|
|
59
|
-
VALUE verbose = rb_gv_get("VERBOSE");
|
|
60
|
-
rb_gv_set("VERBOSE", Qfalse);
|
|
61
|
-
- swig_ruby_trackings = rb_ivar_get( _mSWIG, trackings_id );
|
|
62
|
-
rb_gv_set("VERBOSE", verbose);
|
|
63
|
-
|
|
64
|
-
/* No, it hasn't. Create one ourselves */
|
|
65
|
-
- if ( swig_ruby_trackings == Qnil )
|
|
66
|
-
- {
|
|
67
|
-
- swig_ruby_trackings = rb_hash_new();
|
|
68
|
-
- rb_ivar_set( _mSWIG, trackings_id, swig_ruby_trackings );
|
|
69
|
-
- }
|
|
70
|
-
|
|
71
|
-
/* Now store a reference to the hash table delete function
|
|
72
|
-
so that we only have to look it up once.*/
|
|
73
|
-
swig_ruby_hash_delete = rb_intern("delete");
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
- /* Get a Ruby number to reference a pointer */
|
|
77
|
-
- SWIGRUNTIME VALUE SWIG_RubyPtrToReference(void* ptr) {
|
|
78
|
-
- /* We cast the pointer to an unsigned long
|
|
79
|
-
- and then store a reference to it using
|
|
80
|
-
- a Ruby number object. */
|
|
81
|
-
-
|
|
82
|
-
- /* Convert the pointer to a Ruby number */
|
|
83
|
-
- return SWIG2NUM(ptr);
|
|
84
|
-
- }
|
|
85
|
-
-
|
|
86
|
-
/* Get a Ruby number to reference an object */
|
|
87
|
-
SWIGRUNTIME VALUE SWIG_RubyObjectToReference(VALUE object) {
|
|
88
|
-
/* We cast the object to an unsigned long
|
|
89
|
-
--- 1205,1222 ----
|
|
90
|
-
This is done to allow multiple DSOs to share the same
|
|
91
|
-
tracking table.
|
|
92
|
-
*/
|
|
93
|
-
VALUE verbose = rb_gv_get("VERBOSE");
|
|
94
|
-
rb_gv_set("VERBOSE", Qfalse);
|
|
95
|
-
rb_gv_set("VERBOSE", verbose);
|
|
96
|
-
|
|
97
|
-
/* No, it hasn't. Create one ourselves */
|
|
98
|
-
+ swig_ruby_trackings.clear();
|
|
99
|
-
|
|
100
|
-
/* Now store a reference to the hash table delete function
|
|
101
|
-
so that we only have to look it up once.*/
|
|
102
|
-
swig_ruby_hash_delete = rb_intern("delete");
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/* Get a Ruby number to reference an object */
|
|
106
|
-
SWIGRUNTIME VALUE SWIG_RubyObjectToReference(VALUE object) {
|
|
107
|
-
/* We cast the object to an unsigned long
|
|
108
|
-
***************
|
|
109
|
-
*** 1249,1287 ****
|
|
110
|
-
|
|
111
|
-
/* Add a Tracking from a C/C++ struct to a Ruby object */
|
|
112
|
-
SWIGRUNTIME void SWIG_RubyAddTracking(void* ptr, VALUE object) {
|
|
113
|
-
- /* In a Ruby hash table we store the pointer and
|
|
114
|
-
- the associated Ruby object. The trick here is
|
|
115
|
-
- that we cannot store the Ruby object directly - if
|
|
116
|
-
- we do then it cannot be garbage collected. So
|
|
117
|
-
- instead we typecast it as a unsigned long and
|
|
118
|
-
- convert it to a Ruby number object.*/
|
|
119
|
-
-
|
|
120
|
-
- /* Get a reference to the pointer as a Ruby number */
|
|
121
|
-
- VALUE key = SWIG_RubyPtrToReference(ptr);
|
|
122
|
-
-
|
|
123
|
-
- /* Get a reference to the Ruby object as a Ruby number */
|
|
124
|
-
- VALUE value = SWIG_RubyObjectToReference(object);
|
|
125
|
-
-
|
|
126
|
-
/* Store the mapping to the global hash table. */
|
|
127
|
-
- rb_hash_aset(swig_ruby_trackings, key, value);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/* Get the Ruby object that owns the specified C/C++ struct */
|
|
131
|
-
SWIGRUNTIME VALUE SWIG_RubyInstanceFor(void* ptr) {
|
|
132
|
-
- /* Get a reference to the pointer as a Ruby number */
|
|
133
|
-
- VALUE key = SWIG_RubyPtrToReference(ptr);
|
|
134
|
-
-
|
|
135
|
-
- /* Now lookup the value stored in the global hash table */
|
|
136
|
-
- VALUE value = rb_hash_aref(swig_ruby_trackings, key);
|
|
137
|
-
-
|
|
138
|
-
- if (value == Qnil) {
|
|
139
|
-
- /* No object exists - return nil. */
|
|
140
|
-
return Qnil;
|
|
141
|
-
- }
|
|
142
|
-
- else {
|
|
143
|
-
- /* Convert this value to Ruby object */
|
|
144
|
-
- return SWIG_RubyReferenceToObject(value);
|
|
145
|
-
- }
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
/* Remove a Tracking from a C/C++ struct to a Ruby object. It
|
|
149
|
-
--- 1238,1253 ----
|
|
150
|
-
|
|
151
|
-
/* Add a Tracking from a C/C++ struct to a Ruby object */
|
|
152
|
-
SWIGRUNTIME void SWIG_RubyAddTracking(void* ptr, VALUE object) {
|
|
153
|
-
/* Store the mapping to the global hash table. */
|
|
154
|
-
+ swig_ruby_trackings[ptr] = object;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
/* Get the Ruby object that owns the specified C/C++ struct */
|
|
158
|
-
SWIGRUNTIME VALUE SWIG_RubyInstanceFor(void* ptr) {
|
|
159
|
-
+ if (swig_ruby_trackings.count(ptr) == 0)
|
|
160
|
-
return Qnil;
|
|
161
|
-
+ else
|
|
162
|
-
+ return swig_ruby_trackings[ptr];
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/* Remove a Tracking from a C/C++ struct to a Ruby object. It
|
|
166
|
-
***************
|
|
167
|
-
*** 1289,1300 ****
|
|
168
|
-
since the same memory address may be reused later to create
|
|
169
|
-
a new object. */
|
|
170
|
-
SWIGRUNTIME void SWIG_RubyRemoveTracking(void* ptr) {
|
|
171
|
-
- /* Get a reference to the pointer as a Ruby number */
|
|
172
|
-
- VALUE key = SWIG_RubyPtrToReference(ptr);
|
|
173
|
-
-
|
|
174
|
-
- /* Delete the object from the hash table by calling Ruby's
|
|
175
|
-
- do this we need to call the Hash.delete method.*/
|
|
176
|
-
- rb_funcall(swig_ruby_trackings, swig_ruby_hash_delete, 1, key);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
/* This is a helper method that unlinks a Ruby object from its
|
|
180
|
-
--- 1255,1261 ----
|
|
181
|
-
since the same memory address may be reused later to create
|
|
182
|
-
a new object. */
|
|
183
|
-
SWIGRUNTIME void SWIG_RubyRemoveTracking(void* ptr) {
|
|
184
|
-
+ swig_ruby_trackings.erase(ptr);
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
/* This is a helper method that unlinks a Ruby object from its
|