mirror of
https://github.com/SFML/SFML.git
synced 2024-12-01 15:51:04 +08:00
new directory structure for ruby binding should compile and link fine under windows
git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1797 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
parent
8675cb364c
commit
e63a8fe442
@ -11,54 +11,62 @@ include Rake
|
|||||||
# Configurable section
|
# Configurable section
|
||||||
RUBYSFML_VERSION = "2.0"
|
RUBYSFML_VERSION = "2.0"
|
||||||
SO_SRCS = {'audio' => FileList.new('sfml-audio/audio/*.cpp'),
|
SO_SRCS = {'audio' => FileList.new('sfml-audio/audio/*.cpp'),
|
||||||
'graphics' => FileList.new('sfml-graphics/graphics/*.cpp'),
|
'graphics' => FileList.new('sfml-graphics/graphics/*.cpp'),
|
||||||
'window' => FileList.new('sfml-window/window/*.cpp'),
|
'window' => FileList.new('sfml-window/window/*.cpp'),
|
||||||
'system' => FileList.new('sfml-system/system/*.cpp'),
|
'system' => FileList.new('sfml-system/system/*.cpp'),
|
||||||
'all' => FileList.new('sfml-all/all/*.cpp') }
|
'all' => FileList.new('sfml-all/all/*.cpp') }
|
||||||
|
OTHER_SRCS = FileList.new('shared/*.cpp')
|
||||||
OBJDIR = 'obj'
|
OBJDIR = 'obj'
|
||||||
SODIR = 'sfml'
|
SODIR = 'sfml'
|
||||||
|
|
||||||
spec = Gem::Specification.new do |s|
|
spec = Gem::Specification.new do |s|
|
||||||
s.platform = Gem::Platform::CURRENT
|
s.platform = Gem::Platform::CURRENT
|
||||||
s.name = "rbSFML"
|
s.name = "rbSFML"
|
||||||
s.version = RUBYSFML_VERSION
|
s.version = RUBYSFML_VERSION
|
||||||
s.authors = ["Henrik Valter Vogelius Hansson", 'Brandon Whitehead']
|
s.authors = ["Henrik Valter Vogelius Hansson", 'Brandon Whitehead']
|
||||||
s.email = "groogy@groogy.se"
|
s.email = "groogy@groogy.se"
|
||||||
s.homepage = 'http://sfml-dev.org'
|
s.homepage = 'http://sfml-dev.org'
|
||||||
s.summary = "Ruby bindings for SFML 2.0"
|
s.summary = "Ruby bindings for SFML 2.0"
|
||||||
s.has_rdoc = true
|
s.has_rdoc = true
|
||||||
s.requirements << 'none'
|
s.requirements << 'none'
|
||||||
s.require_path = ''
|
s.require_path = ''
|
||||||
s.files = FileList.new do |fl|
|
s.files = FileList.new do |fl|
|
||||||
fl.include("sfml-audio/audio/*.cpp", "sfml-audio/audio/*.hpp")
|
fl.include("sfml-audio/audio/*.cpp", "sfml-audio/audio/*.hpp")
|
||||||
fl.include("sfml-graphics/graphics/*.cpp", "sfml-graphics/graphics/*.hpp")
|
fl.include("sfml-graphics/graphics/*.cpp", "sfml-graphics/graphics/*.hpp")
|
||||||
fl.include("sfml-window/window/*.cpp", "sfml-window/window/*.hpp")
|
fl.include("sfml-window/window/*.cpp", "sfml-window/window/*.hpp")
|
||||||
fl.include("sfml-system/system/*.cpp", "sfml-system/system/*.hpp")
|
fl.include("sfml-system/system/*.cpp", "sfml-system/system/*.hpp")
|
||||||
fl.include("sfml-all/all/*.cpp", "sfml-all/all/*.hpp")
|
fl.include("sfml-all/all/*.cpp", "sfml-all/all/*.hpp")
|
||||||
end
|
end
|
||||||
s.extensions = ["Rakefile"]
|
s.extensions = ["Rakefile"]
|
||||||
s.description = <<-EOF
|
s.description = <<-EOF
|
||||||
rbSFML are bindings for the SFML library version 2.0 for Ruby.
|
rbSFML are bindings for the SFML library version 2.0 for Ruby.
|
||||||
SFML or Simple Fast Multimedia library is is a free multimedia C++ API
|
SFML or Simple Fast Multimedia library is is a free multimedia C++ API
|
||||||
that provides you low and high level access to graphics, input, audio, etc.
|
that provides you low and high level access to graphics, input, audio, etc.
|
||||||
EOF
|
EOF
|
||||||
s.extra_rdoc_files = FileList.new do |fl|
|
s.extra_rdoc_files = FileList.new do |fl|
|
||||||
fl.include "doc/*.rdoc"
|
fl.include "doc/*.rdoc"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
verbose(false)
|
verbose(false)
|
||||||
|
|
||||||
# Do not touch
|
# Do not touch
|
||||||
SO_OBJS = {}
|
SO_OBJS = {}
|
||||||
SO_SRCS.each do |file, list|
|
SO_SRCS.each do |file, list|
|
||||||
SO_OBJS[file] = list.collect { |fn| File.join("#{OBJDIR}/#{file}", File.basename(fn).ext('o')) }
|
SO_OBJS[file] = list.collect { |fn| File.join("#{OBJDIR}/#{file}", File.basename(fn).ext('o')) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
OTHER_OBJS = OTHER_SRCS.collect {|fn| File.join("#{OBJDIR}/shared/#{file}", File.basename(fn).ext('o')) }
|
||||||
|
|
||||||
SO_LIBS = []
|
SO_LIBS = []
|
||||||
SO_SRCS.each_key {|file| SO_LIBS << "#{SODIR}/#{file}.so"}
|
SO_SRCS.each_key {|file| SO_LIBS << "#{SODIR}/#{file}.so"}
|
||||||
|
SO_SRCS.each_key {|dir| CLEAN.include("#{OBJDIR}/#{dir}")}
|
||||||
SO_OBJS.each_value {|list| CLEAN.include(list)}
|
SO_OBJS.each_value {|list| CLEAN.include(list)}
|
||||||
|
CLEAN.include(OTHER_OBJS)
|
||||||
|
CLEAN.include("#{OBJDIR}/shared")
|
||||||
|
CLEAN.include(OBJDIR)
|
||||||
|
|
||||||
SO_LIBS.each {|so_file| CLOBBER.include(so_file)}
|
SO_LIBS.each {|so_file| CLOBBER.include(so_file)}
|
||||||
CLOBBER.include(OBJDIR, SODIR)
|
CLOBBER.include(SODIR)
|
||||||
|
|
||||||
|
|
||||||
# Sets the default task to build
|
# Sets the default task to build
|
||||||
@ -74,11 +82,11 @@ desc "Uninstalls the generated files"
|
|||||||
task :uninstall
|
task :uninstall
|
||||||
|
|
||||||
task :clean do
|
task :clean do
|
||||||
puts "Cleaning out temporary generated files"
|
puts "Cleaning out temporary generated files"
|
||||||
end
|
end
|
||||||
|
|
||||||
task :clobber do
|
task :clobber do
|
||||||
puts "Cleaning out all generated files"
|
puts "Cleaning out all generated files"
|
||||||
end
|
end
|
||||||
|
|
||||||
task :rebuild => [:clobber, :build] do
|
task :rebuild => [:clobber, :build] do
|
||||||
@ -89,18 +97,19 @@ Rake::GemPackageTask.new(spec) do |pkg|
|
|||||||
end
|
end
|
||||||
|
|
||||||
RDoc::Task.new do |rd|
|
RDoc::Task.new do |rd|
|
||||||
rd.title = "RSFML #{RUBYSFML_VERSION} Documentation"
|
rd.title = "RSFML #{RUBYSFML_VERSION} Documentation"
|
||||||
rd.rdoc_files.include(SO_SRCS.values)
|
rd.rdoc_files.include(SO_SRCS.values)
|
||||||
rd.options << '--line-numbers' << '--quiet' << '--all'
|
rd.options << '--line-numbers' << '--quiet' << '--all'
|
||||||
rd.rdoc_dir = "doc"
|
rd.rdoc_dir = "doc"
|
||||||
end
|
end
|
||||||
|
|
||||||
CFLAGS = CONFIG['CFLAGS']
|
CFLAGS = CONFIG['CFLAGS']
|
||||||
CC = CONFIG['CC']
|
CC = CONFIG['CC']
|
||||||
INSTALL = CONFIG['INSTALL_PROGRAM']
|
# CONFIG['INSTALL_PROGRAM']
|
||||||
|
INSTALL = "install"
|
||||||
LOCATION = CONFIG['sitearchdir'] + '/sfml'
|
LOCATION = CONFIG['sitearchdir'] + '/sfml'
|
||||||
|
|
||||||
RUBYSFML_INC = "sfml-system/system"
|
RUBYSFML_INC = "shared"
|
||||||
SFML_INC = ENV.key?('SFML_INCLUDE') ? ENV['SFML_INCLUDE'] : '../../include'
|
SFML_INC = ENV.key?('SFML_INCLUDE') ? ENV['SFML_INCLUDE'] : '../../include'
|
||||||
SFML_LIB = ENV.key?('SFML_LIB') ? ENV['SFML_LIB'] : '../../lib'
|
SFML_LIB = ENV.key?('SFML_LIB') ? ENV['SFML_LIB'] : '../../lib'
|
||||||
SFML_LIBS = '-lsfml-audio -lsfml-graphics -lsfml-window -lsfml-system'
|
SFML_LIBS = '-lsfml-audio -lsfml-graphics -lsfml-window -lsfml-system'
|
||||||
@ -108,60 +117,78 @@ RUBY_INC = CONFIG['rubyhdrdir']
|
|||||||
RUBY_LIB = (CONFIG['ENABLE_SHARED'] == 'yes' ? CONFIG['LIBRUBYARG_SHARED'] : CONFIG['LIBRUBYARG_STATIC']) + ' ' + CONFIG['SOLIBS']
|
RUBY_LIB = (CONFIG['ENABLE_SHARED'] == 'yes' ? CONFIG['LIBRUBYARG_SHARED'] : CONFIG['LIBRUBYARG_STATIC']) + ' ' + CONFIG['SOLIBS']
|
||||||
RUBY_LIB_PATH = CONFIG['libdir']
|
RUBY_LIB_PATH = CONFIG['libdir']
|
||||||
LINK = CONFIG['LDSHAREDXX']
|
LINK = CONFIG['LDSHAREDXX']
|
||||||
|
# Windows screws up this variable...
|
||||||
LINK.sub!("$(if $(filter-out -g -g0,#{CONFIG["debugflags"]}),,-s)", '')
|
LINK.sub!("$(if $(filter-out -g -g0,#{CONFIG["debugflags"]}),,-s)", '')
|
||||||
LINK_FLAGS = CONFIG['DLDFLAGS'] + " " + CONFIG['LDFLAGS']
|
LINK_FLAGS = CONFIG['DLDFLAGS'] + " " + CONFIG['LDFLAGS']
|
||||||
LINK_FLAGS.sub!("$(DEFFILE)", "")
|
LINK_FLAGS.sub!("$(DEFFILE)", "")
|
||||||
|
|
||||||
SO_SRCS.each_key {|dir| directory "#{OBJDIR}/#{dir}"}
|
SO_SRCS.each_key {|dir| directory "#{OBJDIR}/#{dir}"}
|
||||||
|
directory "#{OBJDIR}/shared"
|
||||||
directory SODIR
|
directory SODIR
|
||||||
directory LOCATION
|
directory LOCATION
|
||||||
|
|
||||||
|
OTHER_SRCS.each do |srcfile|
|
||||||
|
objdir = "#{OBJDIR}/shared"
|
||||||
|
objfile = File.join(objdir, File.basename(srcfile).ext('o'))
|
||||||
|
file objfile => [srcfile, objdir] do
|
||||||
|
puts "Compiling #{File.basename(srcfile)}"
|
||||||
|
sh "#{CC} #{CFLAGS} -c #{srcfile} -o #{objfile} -I#{SFML_INC} -I#{RUBY_INC} -I#{RUBY_INC}/#{CONFIG['arch']} -I#{RUBYSFML_INC}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
task :shared => OTHER_OBJS
|
||||||
|
|
||||||
SO_SRCS.each do |so_file, list|
|
SO_SRCS.each do |so_file, list|
|
||||||
begin
|
begin
|
||||||
list.each do |srcfile|
|
list.each do |srcfile|
|
||||||
objdir = "#{OBJDIR}/#{so_file}"
|
objdir = "#{OBJDIR}/#{so_file}"
|
||||||
objfile = File.join(objdir, File.basename(srcfile).ext('o'))
|
objfile = File.join(objdir, File.basename(srcfile).ext('o'))
|
||||||
file objfile => [srcfile, objdir] do
|
file objfile => [srcfile, objdir] do
|
||||||
puts "Compiling #{File.basename(srcfile)}"
|
puts "Compiling #{File.basename(srcfile)}"
|
||||||
sh "#{CC} #{CFLAGS} -c #{srcfile} -o #{objfile} -I#{SFML_INC} -I#{RUBY_INC} -I#{RUBY_INC}/#{CONFIG['arch']} -I#{RUBYSFML_INC}"
|
sh "#{CC} #{CFLAGS} -c #{srcfile} -o #{objfile} -I#{SFML_INC} -I#{RUBY_INC} -I#{RUBY_INC}/#{CONFIG['arch']} -I#{RUBYSFML_INC}"
|
||||||
#p "#{CC} #{CFLAGS} -c #{srcfile} -o #{objfile} -I#{SFML_INC} -I#{RUBY_INC} -I#{RUBY_INC}/#{CONFIG['arch']} -I#{RUBYSFML_INC}"
|
#p "#{CC} #{CFLAGS} -c #{srcfile} -o #{objfile} -I#{SFML_INC} -I#{RUBY_INC} -I#{RUBY_INC}/#{CONFIG['arch']} -I#{RUBYSFML_INC}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
rescue
|
rescue
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
SO_OBJS.each do |so_file, objs|
|
SO_OBJS.each do |so_file, objs|
|
||||||
begin
|
begin
|
||||||
file "#{SODIR}/#{so_file}.so" => [*objs, SODIR] do
|
prestep = "pre#{so_file}".to_sym
|
||||||
puts "Linking files to create #{so_file}.so"
|
task prestep do
|
||||||
#p "#{LINK} -o #{SODIR}/#{so_file}.so #{objs} -L. -L#{SFML_LIB} -L#{RUBY_LIB_PATH} #{LINK_FLAGS} #{RUBY_LIB} #{SFML_LIBS}"
|
puts "Creating #{so_file}.so"
|
||||||
sh "#{LINK} -o #{SODIR}/#{so_file}.so #{objs} -L. -L#{SFML_LIB} -L#{RUBY_LIB_PATH} #{LINK_FLAGS} #{RUBY_LIB} #{SFML_LIBS}"
|
end
|
||||||
end
|
file "#{SODIR}/#{so_file}.so" => [prestep, :shared, SODIR, *objs] do
|
||||||
rescue
|
puts "Linking files to create #{so_file}.so"
|
||||||
end
|
#p "#{LINK} -o #{SODIR}/#{so_file}.so #{objs} -L. -L#{SFML_LIB} -L#{RUBY_LIB_PATH} #{LINK_FLAGS} #{RUBY_LIB} #{SFML_LIBS}"
|
||||||
|
sh "#{LINK} -o #{SODIR}/#{so_file}.so #{objs} #{OTHER_OBJS} -L. -L#{SFML_LIB} -L#{RUBY_LIB_PATH} #{LINK_FLAGS} #{RUBY_LIB} #{SFML_LIBS}"
|
||||||
|
end
|
||||||
|
rescue
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
task :install => [:build, LOCATION] do
|
task :install => [:build, LOCATION] do
|
||||||
puts "Installing library"
|
puts "Installing library to #{LOCATION}"
|
||||||
begin
|
begin
|
||||||
SO_SRCS.each_key do |so_file|
|
SO_SRCS.each_key do |so_file|
|
||||||
sh "#{INSTALL} #{SODIR}/#{so_file}.so #{LOCATION}"
|
sh "#{INSTALL} #{SODIR}/#{so_file}.so #{LOCATION}"
|
||||||
end
|
end
|
||||||
rescue
|
rescue Exception=>e
|
||||||
end
|
p e
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
task :uninstall do
|
task :uninstall do
|
||||||
puts "Uninstalling library"
|
puts "Uninstalling library to #{LOCATION}"
|
||||||
begin
|
begin
|
||||||
SO_SRCS.each_key do |so_file|
|
SO_SRCS.each_key do |so_file|
|
||||||
sh "rm -f #{LOCATION}/#{so_file}.so"
|
sh "rm -f #{LOCATION}/#{so_file}.so"
|
||||||
end
|
end
|
||||||
sh "rm -rf #{LOCATION}"
|
sh "rm -rf #{LOCATION}"
|
||||||
rescue
|
rescue
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
task :build => SO_LIBS do
|
task :build => [:shared, *SO_LIBS] do
|
||||||
end
|
end
|
||||||
|
@ -21,13 +21,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "main.hpp"
|
#include "main.hpp"
|
||||||
|
#include "global.hpp"
|
||||||
VALUE globalSFMLNamespace;
|
#include "Vector2.hpp"
|
||||||
|
#include "Vector3.hpp"
|
||||||
/* External classes */
|
#include "NonCopyable.hpp"
|
||||||
VALUE globalVector2Class;
|
|
||||||
VALUE globalVector3Class;
|
|
||||||
VALUE globalNonCopyableModule;
|
|
||||||
|
|
||||||
static bool CheckDependencies( void )
|
static bool CheckDependencies( void )
|
||||||
{
|
{
|
||||||
@ -47,8 +44,8 @@ void Init_audio( void )
|
|||||||
{
|
{
|
||||||
rb_raise( rb_eRuntimeError, "This module depends on sfml-window" );
|
rb_raise( rb_eRuntimeError, "This module depends on sfml-window" );
|
||||||
}
|
}
|
||||||
globalVector2Class = RetrieveSFMLClass( "Vector2" );
|
/*globalVector2Class = RetrieveSFMLClass( "Vector2" );
|
||||||
globalVector3Class = RetrieveSFMLClass( "Vector3" );
|
globalVector3Class = RetrieveSFMLClass( "Vector3" );
|
||||||
globalNonCopyableModule = RetrieveSFMLClass( "NonCopyable" );
|
globalNonCopyableModule = RetrieveSFMLClass( "NonCopyable" );*/
|
||||||
rb_define_const(globalSFMLNamespace, "AudioLoaded", Qtrue);
|
rb_define_const(globalSFMLNamespace, "AudioLoaded", Qtrue);
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
#define SFML_RUBYEXT_AUDIO_MAIN_HEADER_
|
#define SFML_RUBYEXT_AUDIO_MAIN_HEADER_
|
||||||
|
|
||||||
#include "ruby.h"
|
#include "ruby.h"
|
||||||
#include "../../sfml-system/system/main.hpp"
|
#include "global.hpp"
|
||||||
|
|
||||||
// Ruby initiation function
|
// Ruby initiation function
|
||||||
extern "C" void Init_audio( void );
|
extern "C" void Init_audio( void );
|
||||||
|
@ -470,7 +470,7 @@ static VALUE Drawable_TransformToLocal( VALUE self, VALUE aPoint )
|
|||||||
*/
|
*/
|
||||||
static VALUE Drawable_TransformToGlobal( VALUE self, VALUE aPoint )
|
static VALUE Drawable_TransformToGlobal( VALUE self, VALUE aPoint )
|
||||||
{
|
{
|
||||||
VALUE point = Vector2_ForceType( point );
|
VALUE point = Vector2_ForceType(point);
|
||||||
rbDrawable *object = NULL;
|
rbDrawable *object = NULL;
|
||||||
Data_Get_Struct( self, rbDrawable, object );
|
Data_Get_Struct( self, rbDrawable, object );
|
||||||
sf::Vector2f newPoint = object->TransformToGlobal( sf::Vector2f( NUM2DBL( Vector2_GetX( point ) ),
|
sf::Vector2f newPoint = object->TransformToGlobal( sf::Vector2f( NUM2DBL( Vector2_GetX( point ) ),
|
||||||
|
@ -21,6 +21,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "main.hpp"
|
#include "main.hpp"
|
||||||
|
#include "Vector2.hpp"
|
||||||
|
#include "Vector3.hpp"
|
||||||
|
#include "NonCopyable.hpp"
|
||||||
#include "Color.hpp"
|
#include "Color.hpp"
|
||||||
#include "Rect.hpp"
|
#include "Rect.hpp"
|
||||||
#include "Drawable.hpp"
|
#include "Drawable.hpp"
|
||||||
@ -39,14 +42,10 @@
|
|||||||
|
|
||||||
#include <SFML/Graphics.hpp>
|
#include <SFML/Graphics.hpp>
|
||||||
|
|
||||||
VALUE globalSFMLNamespace;
|
|
||||||
VALUE globalBlendNamespace;
|
VALUE globalBlendNamespace;
|
||||||
|
|
||||||
/* External classes */
|
/* External classes */
|
||||||
VALUE globalVector2Class;
|
|
||||||
VALUE globalVector3Class;
|
|
||||||
VALUE globalWindowClass;
|
VALUE globalWindowClass;
|
||||||
VALUE globalNonCopyableModule;
|
|
||||||
|
|
||||||
static bool CheckDependencies( void )
|
static bool CheckDependencies( void )
|
||||||
{
|
{
|
||||||
@ -71,15 +70,15 @@ static void CreateBlendEnum( void )
|
|||||||
void Init_graphics( void )
|
void Init_graphics( void )
|
||||||
{
|
{
|
||||||
/* SFML namespace which contains the classes of this module. */
|
/* SFML namespace which contains the classes of this module. */
|
||||||
globalSFMLNamespace = rb_define_module( "SFML" );
|
/*globalSFMLNamespace = rb_define_module( "SFML" );*/
|
||||||
if( CheckDependencies() == false )
|
if( CheckDependencies() == false )
|
||||||
{
|
{
|
||||||
rb_raise( rb_eRuntimeError, "This module depends on sfml-window" );
|
rb_raise( rb_eRuntimeError, "This module depends on sfml-window" );
|
||||||
}
|
}
|
||||||
globalVector2Class = RetrieveSFMLClass( "Vector2" );
|
/*globalVector2Class = RetrieveSFMLClass( "Vector2" );
|
||||||
globalVector3Class = RetrieveSFMLClass( "Vector3" );
|
globalVector3Class = RetrieveSFMLClass( "Vector3" );*/
|
||||||
globalWindowClass = RetrieveSFMLClass( "Window" );
|
globalWindowClass = RetrieveSFMLClass( "Window" );
|
||||||
globalNonCopyableModule = RetrieveSFMLClass( "NonCopyable" );
|
/*globalNonCopyableModule = RetrieveSFMLClass( "NonCopyable" );*/
|
||||||
rb_define_const(globalSFMLNamespace, "GraphicsLoaded", Qtrue);
|
rb_define_const(globalSFMLNamespace, "GraphicsLoaded", Qtrue);
|
||||||
|
|
||||||
CreateBlendEnum();
|
CreateBlendEnum();
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
#define SFML_RUBYEXT_GRAPHICS_MAIN_HEADER_
|
#define SFML_RUBYEXT_GRAPHICS_MAIN_HEADER_
|
||||||
|
|
||||||
#include "ruby.h"
|
#include "ruby.h"
|
||||||
#include "../../sfml-system/system/main.hpp"
|
#include "global.hpp"
|
||||||
|
|
||||||
// Ruby initiation function
|
// Ruby initiation function
|
||||||
extern "C" void Init_graphics( void );
|
extern "C" void Init_graphics( void );
|
||||||
|
@ -21,24 +21,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "main.hpp"
|
#include "main.hpp"
|
||||||
|
#include "global.hpp"
|
||||||
#include "Clock.hpp"
|
#include "Clock.hpp"
|
||||||
#include "Vector2.hpp"
|
#include "Vector2.hpp"
|
||||||
#include "Vector3.hpp"
|
#include "Vector3.hpp"
|
||||||
#include "NonCopyable.hpp"
|
#include "NonCopyable.hpp"
|
||||||
|
|
||||||
VALUE globalSFMLNamespace;
|
|
||||||
|
|
||||||
VALUE RetrieveSFMLClass( const char * aName )
|
|
||||||
{
|
|
||||||
ID name = rb_intern( aName );
|
|
||||||
if( rb_cvar_defined( globalSFMLNamespace, name ) == Qfalse )
|
|
||||||
{
|
|
||||||
rb_raise( rb_eRuntimeError, "This module depends on SFML::%s", aName );
|
|
||||||
}
|
|
||||||
|
|
||||||
return rb_cvar_get( globalSFMLNamespace, name );
|
|
||||||
}
|
|
||||||
|
|
||||||
void Init_system( void )
|
void Init_system( void )
|
||||||
{
|
{
|
||||||
/* SFML namespace which contains the classes of this module. */
|
/* SFML namespace which contains the classes of this module. */
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "main.hpp"
|
#include "main.hpp"
|
||||||
|
#include "Vector2.hpp"
|
||||||
|
#include "NonCopyable.hpp"
|
||||||
#include "Context.hpp"
|
#include "Context.hpp"
|
||||||
#include "ContextSettings.hpp"
|
#include "ContextSettings.hpp"
|
||||||
#include "Event.hpp"
|
#include "Event.hpp"
|
||||||
@ -33,15 +35,12 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
/* SFML Namespace which contains all classes in this module. */
|
/* SFML Namespace which contains all classes in this module. */
|
||||||
VALUE globalSFMLNamespace;
|
|
||||||
VALUE globalKeyNamespace;
|
VALUE globalKeyNamespace;
|
||||||
VALUE globalMouseNamespace;
|
VALUE globalMouseNamespace;
|
||||||
VALUE globalJoyNamespace;
|
VALUE globalJoyNamespace;
|
||||||
VALUE globalStyleNamespace;
|
VALUE globalStyleNamespace;
|
||||||
|
extern VALUE globalVector2Class;
|
||||||
/* External classes */
|
extern VALUE globalNonCopyableModule;
|
||||||
VALUE globalVector2Class;
|
|
||||||
VALUE globalNonCopyableModule;
|
|
||||||
|
|
||||||
static const char * keyNamesMisc[] =
|
static const char * keyNamesMisc[] =
|
||||||
{
|
{
|
||||||
@ -163,8 +162,9 @@ void Init_window( void )
|
|||||||
rb_raise( rb_eRuntimeError, "This module depends on sfml-system" );
|
rb_raise( rb_eRuntimeError, "This module depends on sfml-system" );
|
||||||
}
|
}
|
||||||
|
|
||||||
globalVector2Class = RetrieveSFMLClass( "Vector2" );
|
|
||||||
globalNonCopyableModule = RetrieveSFMLClass( "NonCopyable" );
|
globalVector2Class = rb_define_class_under(globalSFMLNamespace, "Vector2", rb_cObject );
|
||||||
|
globalNonCopyableModule = rb_define_module_under(globalSFMLNamespace, "NonCopyable");
|
||||||
|
|
||||||
rb_define_const( globalSFMLNamespace, "WindowLoaded", Qtrue );
|
rb_define_const( globalSFMLNamespace, "WindowLoaded", Qtrue );
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
#define SFML_RUBYEXT_WINDOW_MAIN_HEADER_
|
#define SFML_RUBYEXT_WINDOW_MAIN_HEADER_
|
||||||
|
|
||||||
#include "ruby.h"
|
#include "ruby.h"
|
||||||
#include "../../sfml-system/system/main.hpp"
|
#include "global.hpp"
|
||||||
|
|
||||||
// Ruby initiation function
|
// Ruby initiation function
|
||||||
extern "C" void Init_window( void );
|
extern "C" void Init_window( void );
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "NonCopyable.hpp"
|
#include "NonCopyable.hpp"
|
||||||
#include "main.hpp"
|
#include "global.hpp"
|
||||||
|
|
||||||
VALUE globalNonCopyableModule;
|
VALUE globalNonCopyableModule;
|
||||||
|
|
@ -21,7 +21,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Vector2.hpp"
|
#include "Vector2.hpp"
|
||||||
#include "main.hpp"
|
#include "global.hpp"
|
||||||
|
|
||||||
VALUE globalVector2Class;
|
VALUE globalVector2Class;
|
||||||
|
|
@ -21,7 +21,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Vector3.hpp"
|
#include "Vector3.hpp"
|
||||||
#include "main.hpp"
|
#include "global.hpp"
|
||||||
|
|
||||||
VALUE globalVector3Class;
|
VALUE globalVector3Class;
|
||||||
|
|
36
bindings/ruby/shared/global.cpp
Normal file
36
bindings/ruby/shared/global.cpp
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
/* rbSFML - Copyright (c) 2010 Henrik Valter Vogelius Hansson - groogy@groogy.se
|
||||||
|
* This software is provided 'as-is', without any express or
|
||||||
|
* implied warranty. In no event will the authors be held
|
||||||
|
* liable for any damages arising from the use of this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
|
* including commercial applications, and to alter it and redistribute
|
||||||
|
* it freely, subject to the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be misrepresented;
|
||||||
|
* you must not claim that you wrote the original software.
|
||||||
|
* If you use this software in a product, an acknowledgment
|
||||||
|
* in the product documentation would be appreciated but
|
||||||
|
* is not required.
|
||||||
|
*
|
||||||
|
* 2. Altered source versions must be plainly marked as such,
|
||||||
|
* and must not be misrepresented as being the original software.
|
||||||
|
*
|
||||||
|
* 3. This notice may not be removed or altered from any
|
||||||
|
* source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "global.hpp"
|
||||||
|
|
||||||
|
VALUE globalSFMLNamespace;
|
||||||
|
|
||||||
|
VALUE RetrieveSFMLClass( const char * aName )
|
||||||
|
{
|
||||||
|
ID name = rb_intern( aName );
|
||||||
|
if( rb_cvar_defined( globalSFMLNamespace, name ) == Qfalse )
|
||||||
|
{
|
||||||
|
rb_raise( rb_eRuntimeError, "This module depends on SFML::%s", aName );
|
||||||
|
}
|
||||||
|
|
||||||
|
return rb_cvar_get( globalSFMLNamespace, name );
|
||||||
|
}
|
49
bindings/ruby/shared/global.hpp
Normal file
49
bindings/ruby/shared/global.hpp
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
/* rbSFML - Copyright (c) 2010 Henrik Valter Vogelius Hansson - groogy@groogy.se
|
||||||
|
* This software is provided 'as-is', without any express or
|
||||||
|
* implied warranty. In no event will the authors be held
|
||||||
|
* liable for any damages arising from the use of this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
|
* including commercial applications, and to alter it and redistribute
|
||||||
|
* it freely, subject to the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be misrepresented;
|
||||||
|
* you must not claim that you wrote the original software.
|
||||||
|
* If you use this software in a product, an acknowledgment
|
||||||
|
* in the product documentation would be appreciated but
|
||||||
|
* is not required.
|
||||||
|
*
|
||||||
|
* 2. Altered source versions must be plainly marked as such,
|
||||||
|
* and must not be misrepresented as being the original software.
|
||||||
|
*
|
||||||
|
* 3. This notice may not be removed or altered from any
|
||||||
|
* source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SFML_RUBYEXT_GLOBAL_HEADER_
|
||||||
|
#define SFML_RUBYEXT_GLOBAL_HEADER_
|
||||||
|
|
||||||
|
#include "ruby.h"
|
||||||
|
|
||||||
|
#define SFML_STATIC
|
||||||
|
|
||||||
|
extern VALUE globalSFMLNamespace;
|
||||||
|
|
||||||
|
VALUE RetrieveSFMLClass( const char * aName );
|
||||||
|
|
||||||
|
typedef VALUE ( *RubyFunctionPtr )( ... );
|
||||||
|
|
||||||
|
#define MAX( x, y ) ( ( x ) < ( y ) ? ( y ) : ( x ) )
|
||||||
|
#define MIN( x, y ) ( ( x ) > ( y ) ? ( x ) : ( y ) )
|
||||||
|
|
||||||
|
#define VALIDATE_CLASS( variable, type, name ) \
|
||||||
|
if( rb_obj_is_kind_of( variable, type ) != Qtrue ) \
|
||||||
|
{ \
|
||||||
|
rb_raise( rb_eTypeError, "%s argument must be instance of %s", name, rb_string_value_cstr ( &type ) ); \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define rb_define_module_function( klass, name, func, argc, ... ) rb_define_module_function( klass, name, reinterpret_cast< RubyFunctionPtr >( func ), argc, ##__VA_ARGS__ )
|
||||||
|
#define rb_define_singleton_method( klass, name, func, argc, ... ) rb_define_singleton_method( klass, name, reinterpret_cast< RubyFunctionPtr >( func ), argc, ##__VA_ARGS__ )
|
||||||
|
#define rb_define_method( klass, name, func, argc, ... ) rb_define_method( klass, name, reinterpret_cast< RubyFunctionPtr >( func ), argc, ##__VA_ARGS__ )
|
||||||
|
|
||||||
|
#endif // SFML_RUBYEXT_SYSTEM_MAIN_HEADER_
|
Loading…
Reference in New Issue
Block a user