gosu 0.10.1 → 0.10.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7aedd1fe70ab438f78ea2412e96323a9713f5d58
4
- data.tar.gz: 34533d20906d49c8b6928be119c43494d4253146
3
+ metadata.gz: c46dd6699c9130c8434d29c5959a5e6a3cee98e1
4
+ data.tar.gz: bd9ecfb8eeff6d3cf7a9575faeca1d0c86ef68e2
5
5
  SHA512:
6
- metadata.gz: 4bd7363b574bfa87aa0a777f90badb769f2c7391a6d9cee1dfd8edbefe706b3e9c4737b81aa189a30a56430e1216da4fa449f57f41ec8a1f9cd0676e5217f44f
7
- data.tar.gz: b7e43cb2de077d7f8ce07556f8eb1e14b523ca7a599bb0342c62fdf76913c097b7342ec141d87ef56b63f6af4d60d1dc49282cf78449083af26c16e6b72c07ad
6
+ metadata.gz: 262068eafcea756f964eb25f5247f44f98d07389c9b9695dc202d060a4207fffd507bf4366e07caff61c3d36f6568a19457e6a494df372c2a1cb722044fd5233
7
+ data.tar.gz: a6d61afe0a41de71c3c8faa782884549b3a02a880aff70d8fbb35c5d7fa6f71509bfa4407840e03adb1677d543e50649d12c50494c1a85db6ee816272c01f3b4
@@ -8,6 +8,10 @@
8
8
  * interface file instead.
9
9
  * ----------------------------------------------------------------------------- */
10
10
 
11
+ // This file was afterwards patched using the following instructions:
12
+ // http://sourceforge.net/tracker/index.php?func=detail&aid=2034216&group_id=1645&atid=101645
13
+ // (Many thanks to Kevin Burge for that.)
14
+
11
15
  #define SWIGRUBY
12
16
  #define SWIG_DIRECTORS
13
17
 
@@ -870,6 +874,7 @@ SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) {
870
874
 
871
875
 
872
876
  #include <ruby.h>
877
+ #include <map>
873
878
 
874
879
  /* Ruby 1.9.1 has a "memoisation optimisation" when compiling with GCC which
875
880
  * breaks using rb_intern as an lvalue, as SWIG does. We work around this
@@ -1210,7 +1215,7 @@ extern "C" {
1210
1215
  /* Global Ruby hash table to store Trackings from C/C++
1211
1216
  structs to Ruby Objects.
1212
1217
  */
1213
- static VALUE swig_ruby_trackings = Qnil;
1218
+ static std::map<void*, VALUE> swig_ruby_trackings;
1214
1219
 
1215
1220
  /* Global variable that stores a reference to the ruby
1216
1221
  hash table delete function. */
@@ -1227,34 +1232,18 @@ SWIGRUNTIME void SWIG_RubyInitializeTrackings(void) {
1227
1232
  This is done to allow multiple DSOs to share the same
1228
1233
  tracking table.
1229
1234
  */
1230
- ID trackings_id = rb_intern( "@__trackings__" );
1231
1235
  VALUE verbose = rb_gv_get("VERBOSE");
1232
1236
  rb_gv_set("VERBOSE", Qfalse);
1233
- swig_ruby_trackings = rb_ivar_get( _mSWIG, trackings_id );
1234
1237
  rb_gv_set("VERBOSE", verbose);
1235
1238
 
1236
1239
  /* No, it hasn't. Create one ourselves */
1237
- if ( swig_ruby_trackings == Qnil )
1238
- {
1239
- swig_ruby_trackings = rb_hash_new();
1240
- rb_ivar_set( _mSWIG, trackings_id, swig_ruby_trackings );
1241
- }
1240
+ swig_ruby_trackings.clear();
1242
1241
 
1243
1242
  /* Now store a reference to the hash table delete function
1244
1243
  so that we only have to look it up once.*/
1245
1244
  swig_ruby_hash_delete = rb_intern("delete");
1246
1245
  }
1247
1246
 
1248
- /* Get a Ruby number to reference a pointer */
1249
- SWIGRUNTIME VALUE SWIG_RubyPtrToReference(void* ptr) {
1250
- /* We cast the pointer to an unsigned long
1251
- and then store a reference to it using
1252
- a Ruby number object. */
1253
-
1254
- /* Convert the pointer to a Ruby number */
1255
- return SWIG2NUM(ptr);
1256
- }
1257
-
1258
1247
  /* Get a Ruby number to reference an object */
1259
1248
  SWIGRUNTIME VALUE SWIG_RubyObjectToReference(VALUE object) {
1260
1249
  /* We cast the object to an unsigned long
@@ -1276,39 +1265,16 @@ SWIGRUNTIME VALUE SWIG_RubyReferenceToObject(VALUE reference) {
1276
1265
 
1277
1266
  /* Add a Tracking from a C/C++ struct to a Ruby object */
1278
1267
  SWIGRUNTIME void SWIG_RubyAddTracking(void* ptr, VALUE object) {
1279
- /* In a Ruby hash table we store the pointer and
1280
- the associated Ruby object. The trick here is
1281
- that we cannot store the Ruby object directly - if
1282
- we do then it cannot be garbage collected. So
1283
- instead we typecast it as a unsigned long and
1284
- convert it to a Ruby number object.*/
1285
-
1286
- /* Get a reference to the pointer as a Ruby number */
1287
- VALUE key = SWIG_RubyPtrToReference(ptr);
1288
-
1289
- /* Get a reference to the Ruby object as a Ruby number */
1290
- VALUE value = SWIG_RubyObjectToReference(object);
1291
-
1292
1268
  /* Store the mapping to the global hash table. */
1293
- rb_hash_aset(swig_ruby_trackings, key, value);
1269
+ swig_ruby_trackings[ptr] = object;
1294
1270
  }
1295
1271
 
1296
1272
  /* Get the Ruby object that owns the specified C/C++ struct */
1297
1273
  SWIGRUNTIME VALUE SWIG_RubyInstanceFor(void* ptr) {
1298
- /* Get a reference to the pointer as a Ruby number */
1299
- VALUE key = SWIG_RubyPtrToReference(ptr);
1300
-
1301
- /* Now lookup the value stored in the global hash table */
1302
- VALUE value = rb_hash_aref(swig_ruby_trackings, key);
1303
-
1304
- if (value == Qnil) {
1305
- /* No object exists - return nil. */
1274
+ if (swig_ruby_trackings.count(ptr) == 0)
1306
1275
  return Qnil;
1307
- }
1308
- else {
1309
- /* Convert this value to Ruby object */
1310
- return SWIG_RubyReferenceToObject(value);
1311
- }
1276
+ else
1277
+ return swig_ruby_trackings[ptr];
1312
1278
  }
1313
1279
 
1314
1280
  /* Remove a Tracking from a C/C++ struct to a Ruby object. It
@@ -1316,12 +1282,7 @@ SWIGRUNTIME VALUE SWIG_RubyInstanceFor(void* ptr) {
1316
1282
  since the same memory address may be reused later to create
1317
1283
  a new object. */
1318
1284
  SWIGRUNTIME void SWIG_RubyRemoveTracking(void* ptr) {
1319
- /* Get a reference to the pointer as a Ruby number */
1320
- VALUE key = SWIG_RubyPtrToReference(ptr);
1321
-
1322
- /* Delete the object from the hash table by calling Ruby's
1323
- do this we need to call the Hash.delete method.*/
1324
- rb_funcall(swig_ruby_trackings, swig_ruby_hash_delete, 1, key);
1285
+ swig_ruby_trackings.erase(ptr);
1325
1286
  }
1326
1287
 
1327
1288
  /* This is a helper method that unlinks a Ruby object from its
@@ -3111,14 +3072,14 @@ SwigDirector_Window::~SwigDirector_Window() {
3111
3072
  void SwigDirector_Window::update() {
3112
3073
  VALUE result;
3113
3074
 
3114
- result = rb_funcall(swig_get_self(), rb_intern("update"), 0, NULL);
3075
+ result = rb_funcall(swig_get_self(), rb_intern("protected_update"), 0, NULL);
3115
3076
  }
3116
3077
 
3117
3078
 
3118
3079
  void SwigDirector_Window::draw() {
3119
3080
  VALUE result;
3120
3081
 
3121
- result = rb_funcall(swig_get_self(), rb_intern("draw"), 0, NULL);
3082
+ result = rb_funcall(swig_get_self(), rb_intern("protected_draw_2"), 0, NULL);
3122
3083
  }
3123
3084
 
3124
3085
 
@@ -3126,7 +3087,7 @@ bool SwigDirector_Window::needsRedraw() const {
3126
3087
  bool c_result ;
3127
3088
  VALUE result;
3128
3089
 
3129
- result = rb_funcall(swig_get_self(), rb_intern("needs_redraw?"), 0, NULL);
3090
+ result = rb_funcall(swig_get_self(), rb_intern("protected_needs_redraw?"), 0, NULL);
3130
3091
  bool swig_val;
3131
3092
  int swig_res = SWIG_AsVal_bool(result, &swig_val);
3132
3093
  if (!SWIG_IsOK(swig_res)) {
@@ -3141,7 +3102,7 @@ bool SwigDirector_Window::needsCursor() const {
3141
3102
  bool c_result ;
3142
3103
  VALUE result;
3143
3104
 
3144
- result = rb_funcall(swig_get_self(), rb_intern("needs_cursor?"), 0, NULL);
3105
+ result = rb_funcall(swig_get_self(), rb_intern("protected_needs_cursor?"), 0, NULL);
3145
3106
  bool swig_val;
3146
3107
  int swig_res = SWIG_AsVal_bool(result, &swig_val);
3147
3108
  if (!SWIG_IsOK(swig_res)) {
@@ -3155,7 +3116,7 @@ bool SwigDirector_Window::needsCursor() const {
3155
3116
  void SwigDirector_Window::loseFocus() {
3156
3117
  VALUE result;
3157
3118
 
3158
- result = rb_funcall(swig_get_self(), rb_intern("lose_focus"), 0, NULL);
3119
+ result = rb_funcall(swig_get_self(), rb_intern("protected_lose_focus"), 0, NULL);
3159
3120
  }
3160
3121
 
3161
3122
 
@@ -3176,7 +3137,7 @@ void SwigDirector_Window::buttonDown(Gosu::Button arg0) {
3176
3137
  else
3177
3138
  obj0 = LONG2NUM((&arg0)->id());
3178
3139
  }
3179
- result = rb_funcall(swig_get_self(), rb_intern("button_down"), 1,obj0);
3140
+ result = rb_funcall(swig_get_self(), rb_intern("protected_button_down"), 1,obj0);
3180
3141
  }
3181
3142
 
3182
3143
 
@@ -3190,7 +3151,7 @@ void SwigDirector_Window::buttonUp(Gosu::Button arg0) {
3190
3151
  else
3191
3152
  obj0 = LONG2NUM((&arg0)->id());
3192
3153
  }
3193
- result = rb_funcall(swig_get_self(), rb_intern("button_up"), 1,obj0);
3154
+ result = rb_funcall(swig_get_self(), rb_intern("protected_button_up"), 1,obj0);
3194
3155
  }
3195
3156
 
3196
3157
 
@@ -11144,8 +11105,8 @@ SWIGEXPORT void Init_gosu(void) {
11144
11105
  SWIG_RubyInitializeTrackings();
11145
11106
  rb_define_const(mGosu, "MAJOR_VERSION", SWIG_From_int(static_cast< int >(0)));
11146
11107
  rb_define_const(mGosu, "MINOR_VERSION", SWIG_From_int(static_cast< int >(10)));
11147
- rb_define_const(mGosu, "POINT_VERSION", SWIG_From_int(static_cast< int >(0)));
11148
- rb_define_const(mGosu, "VERSION", SWIG_FromCharPtr("0.10.0"));
11108
+ rb_define_const(mGosu, "POINT_VERSION", SWIG_From_int(static_cast< int >(1)));
11109
+ rb_define_const(mGosu, "VERSION", SWIG_FromCharPtr("0.10.1"));
11149
11110
  rb_define_const(mGosu, "GOSU_COPYRIGHT_NOTICE", SWIG_FromCharPtr("This software uses the following third-party libraries:\n\nGosu, http://www.libgosu.org, MIT License, http://opensource.org/licenses/MIT\nSDL 2, http://www.libsdl.org, MIT License, http://opensource.org/licenses/MIT\nlibsndfile, http://www.mega-nerd.com/libsndfile, GNU LGPL 3, http://www.gnu.org/copyleft/lesser.html\nOpenAL Soft, http://kcat.strangesoft.net/openal.html, GNU LGPL 2, http://www.gnu.org/licenses/old-licenses/lgpl-2.0.html\n"));
11150
11111
  rb_define_module_function(mGosu, "milliseconds", VALUEFUNC(_wrap_milliseconds), -1);
11151
11112
  rb_define_module_function(mGosu, "random", VALUEFUNC(_wrap_random), -1);
@@ -1,19 +1,19 @@
1
- require 'rbconfig'
2
-
3
- if RUBY_PLATFORM =~ /mswin$|mingw32|mingw64|win32\-|\-win32/ then
4
- binary_path = File.dirname(__FILE__)
5
- # 64-bit builds of Windows use "x64-mingw32" as RUBY_PLATFORM
6
- binary_path += '64' if RUBY_PLATFORM =~ /^x64-/
7
-
8
- # Add this gem to the PATH on Windows so that bundled DLLs can be found.
9
- ENV['PATH'] = "#{binary_path};#{ENV['PATH']}"
10
-
11
- # Add the correct directory
12
- RUBY_VERSION =~ /(\d+.\d+)/
13
- $LOAD_PATH.unshift "#{binary_path}/#{$1}"
14
- end
15
-
16
- require "gosu.#{RbConfig::CONFIG['DLEXT']}"
17
-
18
- require "gosu/swig_patches"
19
- require "gosu/patches"
1
+ require 'rbconfig'
2
+
3
+ if RUBY_PLATFORM =~ /mswin$|mingw32|mingw64|win32\-|\-win32/ then
4
+ binary_path = File.dirname(__FILE__)
5
+ # 64-bit builds of Windows use "x64-mingw32" as RUBY_PLATFORM
6
+ binary_path += '64' if RUBY_PLATFORM =~ /^x64-/
7
+
8
+ # Add this gem to the PATH on Windows so that bundled DLLs can be found.
9
+ ENV['PATH'] = "#{binary_path};#{ENV['PATH']}"
10
+
11
+ # Add the correct directory
12
+ RUBY_VERSION =~ /(\d+.\d+)/
13
+ $LOAD_PATH.unshift "#{binary_path}/#{$1}"
14
+ end
15
+
16
+ require "gosu.#{RbConfig::CONFIG['DLEXT']}"
17
+
18
+ require "gosu/swig_patches"
19
+ require "gosu/patches"
@@ -1,117 +1,117 @@
1
- # Extend Numeric with simple angle conversion methods,
2
- # for easier integration with Chipmunk.
3
- class ::Numeric
4
- def degrees_to_radians
5
- self * Math::PI / 180.0
6
- end
7
-
8
- def radians_to_degrees
9
- self * 180.0 / Math::PI
10
- end
11
-
12
- def gosu_to_radians
13
- (self - 90) * Math::PI / 180.0
14
- end
15
-
16
- def radians_to_gosu
17
- self * 180.0 / Math::PI + 90
18
- end
19
- end
20
-
21
- # Backwards compatibility:
22
- # Import constants into Gosu::Button.
23
- module Gosu::Button
24
- Gosu.constants.each { |c| const_set(c, Gosu.const_get(c)) }
25
- end
26
-
27
- # Backwards compatibility:
28
- # The old version of from_text has been deprecated in Gosu 0.9.
29
- class Gosu::Image
30
- class << self
31
- alias from_text_without_window from_text
32
- end
33
-
34
- def self.from_text(*args)
35
- if args.size == 4
36
- from_text_without_window(args[1], args[3], :font => args[2])
37
- elsif args.size == 7
38
- from_text_without_window(args[1], args[3], :font => args[2],
39
- :spacing => args[4], :width => args[5], :align => args[6])
40
- else
41
- from_text_without_window(*args)
42
- end
43
- end
44
- end
45
-
46
- # Backwards compatibility:
47
- # Passing a Window Sample#initialize has been deprecated in Gosu 0.7.17.
48
- class Gosu::Sample
49
- alias initialize_without_window initialize
50
-
51
- def initialize(*args)
52
- args.shift if args.first.is_a? Gosu::Window
53
- initialize_without_window(*args)
54
- end
55
- end
56
-
57
- # Backwards compatibility:
58
- # Passing a Window to Song#initialize has been deprecated in Gosu 0.7.17.
59
- class Gosu::Song
60
- alias initialize_without_window initialize
61
-
62
- def initialize(*args)
63
- args.shift if args.first.is_a? Gosu::Window
64
- initialize_without_window(*args)
65
- end
66
- end
67
-
68
- # Color constants.
69
- # This is cleaner than having SWIG define them.
70
- module Gosu
71
- class ImmutableColor < Color
72
- private :alpha=, :red=, :green=, :blue=, :hue=, :saturation=, :value=
73
- end
74
-
75
- class Color
76
- NONE = Gosu::ImmutableColor.new(0x00_000000)
77
- BLACK = Gosu::ImmutableColor.new(0xff_000000)
78
- GRAY = Gosu::ImmutableColor.new(0xff_808080)
79
- WHITE = Gosu::ImmutableColor.new(0xff_ffffff)
80
- AQUA = Gosu::ImmutableColor.new(0xff_00ffff)
81
- RED = Gosu::ImmutableColor.new(0xff_ff0000)
82
- GREEN = Gosu::ImmutableColor.new(0xff_00ff00)
83
- BLUE = Gosu::ImmutableColor.new(0xff_0000ff)
84
- YELLOW = Gosu::ImmutableColor.new(0xff_ffff00)
85
- FUCHSIA = Gosu::ImmutableColor.new(0xff_ff00ff)
86
- CYAN = Gosu::ImmutableColor.new(0xff_00ffff)
87
- end
88
- end
89
-
90
- class Gosu::Window
91
- # Backwards compatibility:
92
- # Class methods that have been turned into module methods.
93
- def self.button_id_to_char(id)
94
- Gosu.button_id_to_char(id)
95
- end
96
-
97
- def self.char_to_button_id(ch)
98
- Gosu.char_to_button_id(ch)
99
- end
100
-
101
- # Backwards compatibility:
102
- # Instance methods taht have been turned into module methods.
103
- %w(draw_line draw_triangle draw_quad
104
- flush gl clip_to record
105
- transform translate rotate scale
106
- button_id_to_char char_to_button_id button_down?).each do |method|
107
- define_method method.to_sym do |*args, &block|
108
- Gosu.send method, *args, &block
109
- end
110
- end
111
- end
112
-
113
- # Release OpenAL resources during Ruby's shutdown, not Gosu's.
114
- at_exit do
115
- Gosu::Song.current_song.stop if Gosu::Song.current_song
116
- Gosu::_release_all_openal_resources
117
- end
1
+ # Extend Numeric with simple angle conversion methods,
2
+ # for easier integration with Chipmunk.
3
+ class ::Numeric
4
+ def degrees_to_radians
5
+ self * Math::PI / 180.0
6
+ end
7
+
8
+ def radians_to_degrees
9
+ self * 180.0 / Math::PI
10
+ end
11
+
12
+ def gosu_to_radians
13
+ (self - 90) * Math::PI / 180.0
14
+ end
15
+
16
+ def radians_to_gosu
17
+ self * 180.0 / Math::PI + 90
18
+ end
19
+ end
20
+
21
+ # Backwards compatibility:
22
+ # Import constants into Gosu::Button.
23
+ module Gosu::Button
24
+ Gosu.constants.each { |c| const_set(c, Gosu.const_get(c)) }
25
+ end
26
+
27
+ # Backwards compatibility:
28
+ # The old version of from_text has been deprecated in Gosu 0.9.
29
+ class Gosu::Image
30
+ class << self
31
+ alias from_text_without_window from_text
32
+ end
33
+
34
+ def self.from_text(*args)
35
+ if args.size == 4
36
+ from_text_without_window(args[1], args[3], :font => args[2])
37
+ elsif args.size == 7
38
+ from_text_without_window(args[1], args[3], :font => args[2],
39
+ :spacing => args[4], :width => args[5], :align => args[6])
40
+ else
41
+ from_text_without_window(*args)
42
+ end
43
+ end
44
+ end
45
+
46
+ # Backwards compatibility:
47
+ # Passing a Window Sample#initialize has been deprecated in Gosu 0.7.17.
48
+ class Gosu::Sample
49
+ alias initialize_without_window initialize
50
+
51
+ def initialize(*args)
52
+ args.shift if args.first.is_a? Gosu::Window
53
+ initialize_without_window(*args)
54
+ end
55
+ end
56
+
57
+ # Backwards compatibility:
58
+ # Passing a Window to Song#initialize has been deprecated in Gosu 0.7.17.
59
+ class Gosu::Song
60
+ alias initialize_without_window initialize
61
+
62
+ def initialize(*args)
63
+ args.shift if args.first.is_a? Gosu::Window
64
+ initialize_without_window(*args)
65
+ end
66
+ end
67
+
68
+ # Color constants.
69
+ # This is cleaner than having SWIG define them.
70
+ module Gosu
71
+ class ImmutableColor < Color
72
+ private :alpha=, :red=, :green=, :blue=, :hue=, :saturation=, :value=
73
+ end
74
+
75
+ class Color
76
+ NONE = Gosu::ImmutableColor.new(0x00_000000)
77
+ BLACK = Gosu::ImmutableColor.new(0xff_000000)
78
+ GRAY = Gosu::ImmutableColor.new(0xff_808080)
79
+ WHITE = Gosu::ImmutableColor.new(0xff_ffffff)
80
+ AQUA = Gosu::ImmutableColor.new(0xff_00ffff)
81
+ RED = Gosu::ImmutableColor.new(0xff_ff0000)
82
+ GREEN = Gosu::ImmutableColor.new(0xff_00ff00)
83
+ BLUE = Gosu::ImmutableColor.new(0xff_0000ff)
84
+ YELLOW = Gosu::ImmutableColor.new(0xff_ffff00)
85
+ FUCHSIA = Gosu::ImmutableColor.new(0xff_ff00ff)
86
+ CYAN = Gosu::ImmutableColor.new(0xff_00ffff)
87
+ end
88
+ end
89
+
90
+ class Gosu::Window
91
+ # Backwards compatibility:
92
+ # Class methods that have been turned into module methods.
93
+ def self.button_id_to_char(id)
94
+ Gosu.button_id_to_char(id)
95
+ end
96
+
97
+ def self.char_to_button_id(ch)
98
+ Gosu.char_to_button_id(ch)
99
+ end
100
+
101
+ # Backwards compatibility:
102
+ # Instance methods taht have been turned into module methods.
103
+ %w(draw_line draw_triangle draw_quad
104
+ flush gl clip_to record
105
+ transform translate rotate scale
106
+ button_id_to_char char_to_button_id button_down?).each do |method|
107
+ define_method method.to_sym do |*args, &block|
108
+ Gosu.send method, *args, &block
109
+ end
110
+ end
111
+ end
112
+
113
+ # Release OpenAL resources during Ruby's shutdown, not Gosu's.
114
+ at_exit do
115
+ Gosu::Song.current_song.stop if Gosu::Song.current_song
116
+ Gosu::_release_all_openal_resources
117
+ end
@@ -1,10 +1,10 @@
1
- warn "gosu/preview.rb has been removed in Gosu 0.9.0, and Gosu itself \n" +
2
- "provides a similar interface to what preview.rb used to offer.\n" +
3
- "Notable differences:\n" +
4
- "• no global $window variable\n" +
5
- "• no global Gosu.mouse_x and Gosu.mouse_y functions\n" +
6
- "• Image#initialize et.al. use an options hash now\n" +
7
- "If you cannot update your code base right now, you should require \n" +
8
- "Gosu 0.8.x in your Gemfile: gem 'gosu', '~> 0.8.0'";
9
-
10
- require 'gosu'
1
+ warn "gosu/preview.rb has been removed in Gosu 0.9.0, and Gosu itself \n" +
2
+ "provides a similar interface to what preview.rb used to offer.\n" +
3
+ "Notable differences:\n" +
4
+ "• no global $window variable\n" +
5
+ "• no global Gosu.mouse_x and Gosu.mouse_y functions\n" +
6
+ "• Image#initialize et.al. use an options hash now\n" +
7
+ "If you cannot update your code base right now, you should require \n" +
8
+ "Gosu 0.8.x in your Gemfile: gem 'gosu', '~> 0.8.0'";
9
+
10
+ require 'gosu'
@@ -1,11 +1,11 @@
1
- # Replace the load path
2
- $LOAD_PATH.clear
3
- $LOAD_PATH << File.dirname(__FILE__)[0..-6]
4
- $LOAD_PATH << $LOAD_PATH[0] + '/lib'
5
- # Ruby portions of Gosu
6
- require 'gosu/patches'
7
- require 'gosu/swig_patches'
8
- # Let the application know it is being run from the Mac app wrapper.
9
- OSX_EXECUTABLE = true
10
- # Main application
11
- require 'Main'
1
+ # Replace the load path
2
+ $LOAD_PATH.clear
3
+ $LOAD_PATH << File.dirname(__FILE__)[0..-6]
4
+ $LOAD_PATH << $LOAD_PATH[0] + '/lib'
5
+ # Ruby portions of Gosu
6
+ require 'gosu/patches'
7
+ require 'gosu/swig_patches'
8
+ # Let the application know it is being run from the Mac app wrapper.
9
+ OSX_EXECUTABLE = true
10
+ # Main application
11
+ require 'Main'
@@ -1,70 +1,70 @@
1
- # SWIG workarounds
2
- # These are offloaded into a separate file because rb_eval_string() is weird on Ruby 1.8.
3
-
4
- # Exceptions in Window callbacks often get lost, this is especially annoying in draw/update.
5
- # It is not clear whether this is a SWIG issue or if some stack frame is not exception
6
- # compatible, but I just call protected_update etc. in the Ruby wrapper so I can add this
7
- # custom debugging help:
8
- class Gosu::Window
9
- alias initialize_without_hash initialize
10
-
11
- def initialize width, height, *args
12
- if args.empty? or args.first.is_a? Hash then
13
- options = args.first || {}
14
- fullscreen = options[:fullscreen]
15
- update_interval = options[:update_interval]
16
- else
17
- fullscreen, update_interval = *args
18
- end
19
- initialize_without_hash width, height, !!fullscreen, update_interval || 16.666666
20
- end
21
-
22
- %w(update draw needs_redraw? needs_cursor?
23
- lose_focus button_down button_up).each do |callback|
24
- define_method "protected_#{callback}" do |*args|
25
- begin
26
- # If there has been an exception, don't do anything as to not make matters worse.
27
- # Conveniently turn the return value into a boolean result (for needs_cursor? etc).
28
- defined?(@_exception) ? false : !!send(callback, *args)
29
- rescue Exception => e
30
- # Exit the message loop naturally, then re-throw
31
- @_exception = e
32
- close
33
- end
34
- end
35
- end
36
-
37
- def protected_draw_2
38
- protected_draw
39
- $gosu_gl_blocks_2 = $gosu_gl_blocks
40
- $gosu_gl_blocks = nil
41
- end
42
-
43
- alias show_internal show
44
- def show
45
- show_internal
46
- # Try to format the message nicely, without any useless patching that we are
47
- # doing here.
48
- if defined? @_exception then
49
- if @_exception.backtrace.is_a? Array and not @_exception.backtrace.frozen? then
50
- @_exception.backtrace.reject! { |line| line.include? 'lib/gosu/swig_patches.rb' }
51
- end
52
- raise @_exception
53
- end
54
- end
55
- end
56
-
57
- module Gosu
58
- # Keep a reference to these blocks that is only cleared after Window#draw.
59
- # Otherwise, the GC might free these blocks while Gosu is still rendering.
60
- def self.gl(*args, &block)
61
- $gosu_gl_blocks ||= []
62
- $gosu_gl_blocks << block
63
- unsafe_gl(*args, &block)
64
- end
65
- end
66
-
67
- # SWIG won't let me rename my method to '[]='.
68
- class Gosu::Font
69
- alias []= set_image
70
- end
1
+ # SWIG workarounds
2
+ # These are offloaded into a separate file because rb_eval_string() is weird on Ruby 1.8.
3
+
4
+ # Exceptions in Window callbacks often get lost, this is especially annoying in draw/update.
5
+ # It is not clear whether this is a SWIG issue or if some stack frame is not exception
6
+ # compatible, but I just call protected_update etc. in the Ruby wrapper so I can add this
7
+ # custom debugging help:
8
+ class Gosu::Window
9
+ alias initialize_without_hash initialize
10
+
11
+ def initialize width, height, *args
12
+ if args.empty? or args.first.is_a? Hash then
13
+ options = args.first || {}
14
+ fullscreen = options[:fullscreen]
15
+ update_interval = options[:update_interval]
16
+ else
17
+ fullscreen, update_interval = *args
18
+ end
19
+ initialize_without_hash width, height, !!fullscreen, update_interval || 16.666666
20
+ end
21
+
22
+ %w(update draw needs_redraw? needs_cursor?
23
+ lose_focus button_down button_up).each do |callback|
24
+ define_method "protected_#{callback}" do |*args|
25
+ begin
26
+ # If there has been an exception, don't do anything as to not make matters worse.
27
+ # Conveniently turn the return value into a boolean result (for needs_cursor? etc).
28
+ defined?(@_exception) ? false : !!send(callback, *args)
29
+ rescue Exception => e
30
+ # Exit the message loop naturally, then re-throw
31
+ @_exception = e
32
+ close
33
+ end
34
+ end
35
+ end
36
+
37
+ def protected_draw_2
38
+ protected_draw
39
+ $gosu_gl_blocks_2 = $gosu_gl_blocks
40
+ $gosu_gl_blocks = nil
41
+ end
42
+
43
+ alias show_internal show
44
+ def show
45
+ show_internal
46
+ # Try to format the message nicely, without any useless patching that we are
47
+ # doing here.
48
+ if defined? @_exception then
49
+ if @_exception.backtrace.is_a? Array and not @_exception.backtrace.frozen? then
50
+ @_exception.backtrace.reject! { |line| line.include? 'lib/gosu/swig_patches.rb' }
51
+ end
52
+ raise @_exception
53
+ end
54
+ end
55
+ end
56
+
57
+ module Gosu
58
+ # Keep a reference to these blocks that is only cleared after Window#draw.
59
+ # Otherwise, the GC might free these blocks while Gosu is still rendering.
60
+ def self.gl(*args, &block)
61
+ $gosu_gl_blocks ||= []
62
+ $gosu_gl_blocks << block
63
+ unsafe_gl(*args, &block)
64
+ end
65
+ end
66
+
67
+ # SWIG won't let me rename my method to '[]='.
68
+ class Gosu::Font
69
+ alias []= set_image
70
+ end
@@ -1,89 +1,89 @@
1
- require 'gosu/preview'
2
-
3
- module Gosu
4
- module Zen
5
-
6
- @@window_args = [800, 600, {}]
7
- @@options = {}
8
-
9
- def window width, height, options = nil
10
- if $window.nil?
11
- @@window_args[0] = width
12
- @@window_args[1] = height
13
- @@window_args[2].merge! options if options
14
- else
15
- raise "window size can only be set before the window is created"
16
- end
17
- end
18
-
19
- def set what, value
20
- if $window.nil?
21
- @@options[what.to_sym] = value
22
- else
23
- $window.send "#{what}=", value
24
- end
25
- end
26
-
27
- def init &body
28
- ZenWindow.send :define_method, :init, &body
29
- end
30
-
31
- def button_down id = nil, &body
32
- m = id ? "button_down_#{id}" : :button_down_other
33
- ZenWindow.send :define_method, m, &body
34
- end
35
-
36
- def button_up id = nil, &body
37
- m = id ? "button_up_#{id}" : :button_up_other
38
- ZenWindow.send :define_method, m, &body
39
- end
40
-
41
- def update &body
42
- ZenWindow.send :define_method, :update, &body
43
- end
44
-
45
- def draw &body
46
- ZenWindow.send :define_method, :draw, &body
47
- end
48
-
49
- def run!
50
- window = ZenWindow.new *@@window_args
51
- @@options.each do |opt, value|
52
- window.send "#{opt}=", value
53
- end
54
- window.show
55
- end
56
-
57
- def Zen.included mod
58
- at_exit { run! unless $! }
59
- end
60
-
61
- end
62
-
63
- class ZenWindow < Window
64
- def initialize *args
65
- super
66
- init
67
- end
68
-
69
- def init
70
- end
71
-
72
- def button_down id
73
- m = :"button_down_#{id}"
74
- respond_to?(m) ? send(m) : button_down_other(id)
75
- end
76
-
77
- def button_up id
78
- m = :"button_up_#{id}"
79
- respond_to?(m) ? send(m) : button_up_other(id)
80
- end
81
-
82
- def button_down_other id
83
- end
84
-
85
- def button_up_other id
86
- end
87
-
88
- end
89
- end
1
+ require 'gosu/preview'
2
+
3
+ module Gosu
4
+ module Zen
5
+
6
+ @@window_args = [800, 600, {}]
7
+ @@options = {}
8
+
9
+ def window width, height, options = nil
10
+ if $window.nil?
11
+ @@window_args[0] = width
12
+ @@window_args[1] = height
13
+ @@window_args[2].merge! options if options
14
+ else
15
+ raise "window size can only be set before the window is created"
16
+ end
17
+ end
18
+
19
+ def set what, value
20
+ if $window.nil?
21
+ @@options[what.to_sym] = value
22
+ else
23
+ $window.send "#{what}=", value
24
+ end
25
+ end
26
+
27
+ def init &body
28
+ ZenWindow.send :define_method, :init, &body
29
+ end
30
+
31
+ def button_down id = nil, &body
32
+ m = id ? "button_down_#{id}" : :button_down_other
33
+ ZenWindow.send :define_method, m, &body
34
+ end
35
+
36
+ def button_up id = nil, &body
37
+ m = id ? "button_up_#{id}" : :button_up_other
38
+ ZenWindow.send :define_method, m, &body
39
+ end
40
+
41
+ def update &body
42
+ ZenWindow.send :define_method, :update, &body
43
+ end
44
+
45
+ def draw &body
46
+ ZenWindow.send :define_method, :draw, &body
47
+ end
48
+
49
+ def run!
50
+ window = ZenWindow.new *@@window_args
51
+ @@options.each do |opt, value|
52
+ window.send "#{opt}=", value
53
+ end
54
+ window.show
55
+ end
56
+
57
+ def Zen.included mod
58
+ at_exit { run! unless $! }
59
+ end
60
+
61
+ end
62
+
63
+ class ZenWindow < Window
64
+ def initialize *args
65
+ super
66
+ init
67
+ end
68
+
69
+ def init
70
+ end
71
+
72
+ def button_down id
73
+ m = :"button_down_#{id}"
74
+ respond_to?(m) ? send(m) : button_down_other(id)
75
+ end
76
+
77
+ def button_up id
78
+ m = :"button_up_#{id}"
79
+ respond_to?(m) ? send(m) : button_up_other(id)
80
+ end
81
+
82
+ def button_down_other id
83
+ end
84
+
85
+ def button_up_other id
86
+ end
87
+
88
+ end
89
+ end
@@ -42,7 +42,7 @@ namespace Gosu
42
42
  CREATE_STUB(sf_close, int,
43
43
  (SNDFILE *sndfile),
44
44
  (sndfile))
45
- CREATE_STUB(sf_read_short, sf_count_t,
45
+ CREATE_STUB(sf_readf_short, sf_count_t,
46
46
  (SNDFILE *sndfile, short *ptr, sf_count_t items),
47
47
  (sndfile, ptr, items))
48
48
  CREATE_STUB(sf_seek, sf_count_t,
@@ -65,7 +65,12 @@ namespace Gosu
65
65
  case SEEK_SET: self->reader.setPosition(offset); break;
66
66
  case SEEK_CUR: self->reader.seek(offset); break;
67
67
  case SEEK_END: self->reader.setPosition(self->buffer.size() - offset); break;
68
- };
68
+ }
69
+
70
+ if (self->reader.position() > self->buffer.size()) {
71
+ self->reader.setPosition(self->buffer.size());
72
+ }
73
+
69
74
  return 0;
70
75
  }
71
76
 
@@ -145,8 +150,8 @@ namespace Gosu
145
150
 
146
151
  std::size_t readData(void* dest, std::size_t length)
147
152
  {
148
- int itemSize = 2 * info.channels;
149
- return sf_read_short(file, (short*)dest, length / itemSize) * itemSize;
153
+ int frameSize = sizeof(short) * info.channels;
154
+ return sf_readf_short(file, (short*)dest, length / frameSize) * frameSize;
150
155
  }
151
156
 
152
157
  void rewind()
@@ -3,6 +3,9 @@
3
3
  #include <Gosu/IO.hpp>
4
4
  #include <Gosu/Utility.hpp>
5
5
 
6
+ #include <cstring>
7
+ #include <stdexcept>
8
+
6
9
  #define STB_IMAGE_IMPLEMENTATION
7
10
  #define STBI_NO_STDIO
8
11
  #define STBI_NO_LINEAR
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gosu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.1
4
+ version: 0.10.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Raschke