Skip to content

Commit 1d2b14d

Browse files
committed
Fix module methods for Gl module.
No longer uses GlEnums/GlCommands modules. GL functions are now wrapped so that they can be overridden if need be. This will probably be necessary just to ruby-ify some bits of the API.
1 parent 07b2540 commit 1d2b14d

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

gen_from_xml.rb

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ def generate_binding_impl(document)
189189
|io|
190190

191191
io.puts <<-EOS
192-
module GlEnums
192+
module Gl
193193
EOS
194194

195195
filtered_enums.select { |name, enum| enum.alias.nil? }.each {
@@ -213,7 +213,7 @@ module GlEnums
213213
io.puts " #{name.ljust(enum_name_length)} = #{enum.alias}"
214214
}
215215

216-
io.puts 'end # module GlEnums'
216+
io.puts 'end # module Gl'
217217
}
218218

219219
File.open("lib/opengl/#{prefix}_commands.rb", 'w') {
@@ -223,7 +223,7 @@ module GlEnums
223223
require 'fiddle'
224224
require 'opengl/gl_sym'
225225
226-
module GlCommands
226+
module Gl
227227
EOS
228228

229229
filtered_commands.each {
@@ -237,18 +237,19 @@ module GlCommands
237237
param_string = cmd.parameters.map { |p| "#{p.name}_" }.join(', ')
238238
io.puts <<-EOS
239239
240-
def #{name}(#{param_string})
240+
def self.#{name}__(#{param_string})
241241
if @@#{name}.nil?
242-
sym = load_gl_sym__('#{name}')
242+
sym = GlSym.load_gl_sym__('#{name}')
243243
@@#{name} = Fiddle::Function.new(sym, [#{
244-
cmd.parameters.map { |p| fiddle_type(p) }.join(', ') }], [#{ fiddle_type(cmd.type) }])
244+
cmd.parameters.map { |p| fiddle_type(p) }.join(', ') }], #{ fiddle_type(cmd.type) })
245245
end
246246
@@#{name}.call(#{param_string})
247247
end
248+
define_singleton_method(:'#{name}', method(:'#{name}__'))
248249
EOS
249250
}
250251

251-
io.puts 'end # module GlCommands'
252+
io.puts 'end # module Gl'
252253
}
253254
end
254255

lib/opengl.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,4 @@
44
require 'opengl/gl_commands'
55

66
module Gl
7-
include GlEnums
8-
include GlCommands
97
end

0 commit comments

Comments
 (0)