rays 0.1.2 → 0.1.3

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.
@@ -0,0 +1,52 @@
1
+ #include <rucy.h>
2
+ #include <rays/rays.h>
3
+ #include "defs.h"
4
+
5
+
6
+ using namespace Rucy;
7
+
8
+
9
+ namespace Rays
10
+ {
11
+
12
+
13
+ static Module mRays;
14
+
15
+ Module
16
+ rays_module ()
17
+ {
18
+ return mRays;
19
+ }
20
+
21
+
22
+ }// Rays
23
+
24
+
25
+ static
26
+ VALUE init(VALUE self)
27
+ {
28
+ if (!Rays::init())
29
+ error("Rays::init() failed.");
30
+
31
+ return self;
32
+ }
33
+
34
+ static
35
+ VALUE fin(VALUE self)
36
+ {
37
+ if (!Rays::fin())
38
+ error("Rays::fin() failed.");
39
+
40
+ return self;
41
+ }
42
+
43
+
44
+ void
45
+ Init_rays ()
46
+ {
47
+ Module m = rb_define_module("Rays");
48
+ Rays::mRays = m;
49
+
50
+ m.define_singleton_method("init!", init);
51
+ m.define_singleton_method("fin!", fin);
52
+ }
@@ -0,0 +1,128 @@
1
+ #include "rays/ruby/texture.h"
2
+
3
+
4
+ #include <rucy.h>
5
+ #include <rays/ruby/bitmap.h>
6
+ #include "defs.h"
7
+
8
+
9
+ using namespace Rucy;
10
+
11
+ using Rays::coord;
12
+
13
+
14
+ namespace Rays
15
+ {
16
+
17
+
18
+ static Class cTexture;
19
+
20
+ Class
21
+ texture_class ()
22
+ {
23
+ return cTexture;
24
+ }
25
+
26
+
27
+ }// Rays
28
+
29
+
30
+ namespace Rucy
31
+ {
32
+
33
+
34
+ Value
35
+ value (const Rays::Texture& texture)
36
+ {
37
+ return new_type<Rays::Texture>(
38
+ Rays::texture_class(), new Rays::Texture(texture));
39
+ }
40
+
41
+
42
+ }// Rucy
43
+
44
+
45
+ #define this to<Rays::Texture*>(self)
46
+
47
+ #define CHECK CHECK_OBJECT(self, Rays::Texture, Rays::texture_class())
48
+
49
+
50
+ static
51
+ VALUE alloc(VALUE klass)
52
+ {
53
+ return new_type<Rays::Texture>(klass, new Rays::Texture);
54
+ }
55
+
56
+ static
57
+ VALUE initialize(VALUE self)
58
+ {
59
+ CHECK_OBJ(self, Rays::Texture, Rays::texture_class());
60
+ if (argc != 1 && argc != 2) arg_count_error("Texture#initialize", argc, 1, 2);
61
+
62
+ Rays::Bitmap* bitmap = to<Rays::Bitmap*>(argv[0]);
63
+ bool alphaonly = (argc == 2) ? to<bool>(argv[1]) : false;
64
+
65
+ if (!bitmap)
66
+ argument_error("%s is not a Bitmap object.", argv[0].inspect().c_str());
67
+
68
+ *this = Rays::Texture(*bitmap, alphaonly);
69
+ return self;
70
+ }
71
+
72
+ static
73
+ VALUE width(VALUE self)
74
+ {
75
+ CHECK;
76
+
77
+ return value(this->width());
78
+ }
79
+
80
+ static
81
+ VALUE height(VALUE self)
82
+ {
83
+ CHECK;
84
+
85
+ return value(this->height());
86
+ }
87
+
88
+ static
89
+ VALUE s_max(VALUE self)
90
+ {
91
+ CHECK;
92
+
93
+ return value(this->s_max());
94
+ }
95
+
96
+ static
97
+ VALUE t_max(VALUE self)
98
+ {
99
+ CHECK;
100
+
101
+ return value(this->t_max());
102
+ }
103
+
104
+ static
105
+ VALUE bitmap(VALUE self)
106
+ {
107
+ CHECK;
108
+
109
+ return value(this->bitmap());
110
+ }
111
+
112
+
113
+ void
114
+ Init_texture ()
115
+ {
116
+ Module m = rb_define_module("Rays");
117
+
118
+ Class c = rb_define_class_under(m, "Texture", rb_cObject);
119
+ Rays::cTexture = c;
120
+
121
+ rb_define_alloc_func(c, alloc);
122
+ rb_define_method(c, "initialize", RUBY_METHOD_FUNC(initialize), -1);
123
+ rb_define_method(c, "width", RUBY_METHOD_FUNC(width), 0);
124
+ rb_define_method(c, "height", RUBY_METHOD_FUNC(height), 0);
125
+ rb_define_method(c, "s_max", RUBY_METHOD_FUNC(s_max), 0);
126
+ rb_define_method(c, "t_max", RUBY_METHOD_FUNC(t_max), 0);
127
+ rb_define_method(c, "bitmap", RUBY_METHOD_FUNC(bitmap), 0);
128
+ }
data/Rakefile CHANGED
@@ -1,47 +1,21 @@
1
1
  # -*- mode: ruby; coding: utf-8 -*-
2
2
 
3
3
 
4
- %w[. ./lib ../rucy/lib].each do |path|
4
+ %w[. ../xot ../rucy].map {|s| "#{s}/lib"}.each do |path|
5
5
  $: << File.expand_path(File.join File.dirname(__FILE__), *path.split('/'))
6
6
  end
7
7
 
8
8
  require 'rubygems'
9
- require 'rbconfig'
10
- require 'support'
9
+ require 'xot/rake/helpers'
10
+ require 'xot/module'
11
+ require 'rucy/module'
11
12
  require 'rays/module'
12
13
 
14
+ include Xot::Rake
13
15
 
14
- MODULE = Rays
15
- NAME = MODULE.name.downcase
16
16
 
17
- SRCDIR = 'src'
18
- INCDIR = 'include'
19
- LIBDIR = 'lib'
20
- EXTDIR = 'ext'
21
- TASKDIR = 'task'
22
-
23
- EXTEXT = RbConfig::CONFIG['DLEXT'] || 'so'
24
-
25
- DEFS = %w[]
26
- DEFS << 'WIN32' if win32?
27
- DEFS << 'COCOA' if cocoa?
28
-
29
- incroot = RbConfig::CONFIG['rubyhdrdir']
30
- INCDIRS = Rays.include_dirs + [
31
- incroot,
32
- "#{incroot}/#{RUBY_PLATFORM}",
33
- '/opt/local/include',
34
- '/opt/include'
35
- ]
36
-
37
- RUBY = ENV['RUBY'] || 'ruby'
38
- GEM = ENV['GEM'] || 'gem'
39
- GIT = ENV['GIT'] || 'git'
40
- MAKE = ENV['MAKE'] || 'make'
41
- CC = RbConfig::CONFIG['CC'] || ENV['CC'] || 'g++'
42
- CFLAGS = '-Wall -O' + DEFS.map{|s| " -D#{s}"}.join
43
- AR = ENV['AR'] || 'ar'
44
- ARFLAGS = 'crs'
17
+ MODULE = Rays
18
+ INCDIRS = [Rays, Rucy].map {|m| m.include_dirs}.flatten
45
19
 
46
20
 
47
21
  task :default => :build
@@ -54,6 +28,8 @@ task :lib => 'lib:build'
54
28
 
55
29
  task :ext => 'ext:build'
56
30
 
31
+ task :doc => 'ext:doc'
32
+
57
33
  task :gem => 'gem:build'
58
34
 
59
35
  task :install => 'gem:install'
@@ -69,4 +45,4 @@ task :test => :ext do
69
45
  end
70
46
 
71
47
 
72
- Dir["#{TASKDIR}/**/*.rake"].each {|path| load path}
48
+ [Xot, Rucy, Rays].each {|m| m.load_tasks}
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.1.3
data/ext/rays/bitmap.cpp CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
 
4
4
  #include <rucy.h>
5
- #include "rays.h"
5
+ #include "defs.h"
6
6
 
7
7
 
8
8
  using namespace Rucy;
@@ -17,11 +17,12 @@ namespace Rays
17
17
  {
18
18
 
19
19
 
20
+ static Class cBitmap;
21
+
20
22
  Class
21
23
  bitmap_class ()
22
24
  {
23
- static Class c = rays_module().define_class("Bitmap");
24
- return c;
25
+ return cBitmap;
25
26
  }
26
27
 
27
28
 
@@ -306,17 +307,20 @@ RUBY_END
306
307
  void
307
308
  Init_bitmap ()
308
309
  {
309
- Rays::rays_module()
310
- .define_const("RGB", Rays::RGB)
311
- .define_const("RGBA", Rays::RGBA);
312
-
313
- Rays::bitmap_class()
314
- .define_alloc_func(alloc)
315
- .define_method("initialize", initialize)
316
- .define_method("width", width)
317
- .define_method("height", height)
318
- .define_method("color_space", color_space)
319
- .define_method("[]", at)
320
- .define_method("[]=", assign_at)
321
- .define_function("load", load);
310
+ Module m = define_module("Rays");
311
+
312
+ m.define_const("RGB", Rays::RGB);
313
+ m.define_const("RGBA", Rays::RGBA);
314
+
315
+ Class c = m.define_class("Bitmap");
316
+ Rays::cBitmap = c;
317
+
318
+ c.define_alloc_func(alloc);
319
+ c.define_method("initialize", initialize);
320
+ c.define_method("width", width);
321
+ c.define_method("height", height);
322
+ c.define_method("color_space", color_space);
323
+ c.define_method("[]", at);
324
+ c.define_method("[]=", assign_at);
325
+ c.define_function("load", load);
322
326
  }
@@ -1,22 +1,13 @@
1
1
  // -*- c++ -*-
2
2
  #pragma once
3
- #ifndef __RAYS_EXT_RAYS_H__
4
- #define __RAYS_EXT_RAYS_H__
3
+ #ifndef __RAYS_EXT_DEFS_H__
4
+ #define __RAYS_EXT_DEFS_H__
5
5
 
6
6
 
7
- #include <rucy/class.h>
8
- #include "rays/ruby/rays.h"
7
+ #include <rays/exception.h>
9
8
 
10
9
 
11
- namespace Rays
12
- {
13
-
14
-
15
- Rucy::Class rays_error_class ();
16
- // class Rays::RaysError < Rucy::NativeError
17
-
18
-
19
- }// Rays
10
+ using Rays::error;
20
11
 
21
12
 
22
13
  #define CHECK_OBJ(obj, type, klass) \
data/ext/rays/extconf.rb CHANGED
@@ -1,42 +1,51 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
 
4
- %w[../../../rucy/lib ../../lib].each do |path|
4
+ %w[. xot rucy].map {|s| "../../#{s}/lib"}.each do |path|
5
5
  $: << File.expand_path(File.join File.dirname(__FILE__), *path.split('/'))
6
6
  end
7
7
 
8
8
  require 'rubygems'
9
9
  require 'mkmf'
10
+ require 'xot/rake/helpers'
11
+ require 'xot/module'
10
12
  require 'rucy/module'
11
13
  require 'rays/module'
12
14
 
15
+ include Xot::Rake
13
16
 
14
- DEBUG = ENV['DEBUG'] || false
17
+
18
+ DEBUG = env :DEBUG, false
15
19
 
16
20
  DEFS = []
17
- INCDIRS = %w[/opt/local/include /opt/include] +
18
- Rucy.include_dirs + Rays.include_dirs
19
- LIBDIRS = %w[] +
20
- Rucy.library_dirs + Rays.library_dirs
21
+ INCDIRS = %w[
22
+ /opt/local/include
23
+ /opt/include
24
+ ]
25
+ LIBDIRS = []
21
26
 
22
- HEADERS = %w[
23
- boost/scoped_array.hpp
27
+ HEADERS = %w[
24
28
  boost/shared_ptr.hpp
25
29
  ruby.h
30
+ xot.h
26
31
  rucy.h
27
32
  rays.h
28
33
  ]
29
- LIBS = %w[stdc++ rucy rays]
30
- FRAMEWORKS = %w[]
34
+ LIBS = %w[
35
+ stdc++
36
+ xot
37
+ rucy
38
+ rays
39
+ ]
40
+ FRAMEWORKS = []
31
41
 
32
42
 
33
43
  DEFS << '_DEBUG' if DEBUG
34
-
35
- case RUBY_PLATFORM
36
- when /mswin|ming|cygwin/
37
- DEFS << 'WINDOWS' << 'WIN32' << $~[0].upcase
44
+ DEFS << $~[0].upcase if RUBY_PLATFORM =~ /mswin|ming|cygwin|darwin/i
45
+ if win32?
46
+ DEFS << 'WINDOWS' << 'WIN32'
38
47
  LIBS.unshift 'gdi32', 'opengl32'
39
- when /darwin/
48
+ elsif cocoa?
40
49
  DEFS << 'COCOA'
41
50
  FRAMEWORKS << 'AppKit' << 'OpenGL'
42
51
  end
@@ -47,13 +56,14 @@ $LDFLAGS << LIBDIRS.map {|s| " -L#{s}"}.join
47
56
  $LDFLAGS << FRAMEWORKS.map {|s| " -framework #{s}"}.join
48
57
  $LOCAL_LIBS << ' -lrucy'
49
58
 
59
+ Config::CONFIG.each {|key, val| val.gsub!(/gcc/, 'g++')}
60
+
61
+
50
62
  dir_config 'boost'
63
+ dir_config 'xot', Xot.root_dir
51
64
  dir_config 'rucy', Rucy.root_dir
52
65
  dir_config 'rays', Rays.root_dir
53
66
 
54
-
55
- Config::CONFIG.each {|key, val| val.gsub!(/gcc/, 'g++')}
56
-
57
67
  exit 1 unless HEADERS.all? {|s| have_header(s)}
58
68
  exit 1 unless LIBS.all? {|s| have_library(s)}
59
69
 
data/ext/rays/font.cpp CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
 
4
4
  #include <rucy.h>
5
- #include "rays.h"
5
+ #include "defs.h"
6
6
 
7
7
 
8
8
  using namespace Rucy;
@@ -14,11 +14,12 @@ namespace Rays
14
14
  {
15
15
 
16
16
 
17
+ static Class cFont;
18
+
17
19
  Class
18
20
  font_class ()
19
21
  {
20
- static Class c = rays_module().define_class("Font");
21
- return c;
22
+ return cFont;
22
23
  }
23
24
 
24
25
 
@@ -115,11 +116,15 @@ RUBY_END
115
116
  void
116
117
  Init_font ()
117
118
  {
118
- Rays::font_class()
119
- .define_alloc_func(alloc)
120
- .define_method("initialize", initialize)
121
- .define_method("name", name)
122
- .define_method("size", size)
123
- .define_method("width", width)
124
- .define_method("height", height);
119
+ Module m = define_module("Rays");
120
+
121
+ Class c = m.define_class("Font");
122
+ Rays::cFont = c;
123
+
124
+ c.define_alloc_func(alloc);
125
+ c.define_method("initialize", initialize);
126
+ c.define_method("name", name);
127
+ c.define_method("size", size);
128
+ c.define_method("width", width);
129
+ c.define_method("height", height);
125
130
  }