mathgl 0.0.1 → 0.0.2

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: 731510d909819e3d4c79ccb77ec242531feae656
4
- data.tar.gz: 7bd7350c2351b457b960dac546ab8cf456f2f330
3
+ metadata.gz: 7da21f8407a4fec9815c7b4a243dbcd235b0d790
4
+ data.tar.gz: 58ebeb769a243d649e8c31b09010a6af82342a12
5
5
  SHA512:
6
- metadata.gz: 72a5b2d53d6a7c43a8d97bb236092890d17fd62cd4d802988967d803cf99320d1de1bc95e338490b8af11b5572bdf8f7e35c5ad28b8fff5267ef9bac4937d2f1
7
- data.tar.gz: 4d0735fc064802b7ee9be08a937ca5b10bb0787eefdef0a91568ded98da79ba3519f864bef58d08e44e3bc326f66dc0cb059d74668afca3c2ea6a8314e1b666d
6
+ metadata.gz: b3d1ee2ac5d134d7aff6a2a1fc35814f0d84e7f243bcd81b3e711eb93347904f3ebd5d8779a400006d3e0852516ec8e1b4bdcb977e3287a13b39bae7519ffc2c
7
+ data.tar.gz: cc0f8ce9f74c90f9bb690990e3e597f54c4f67064f317cce114d239924c23c399f15468556c758a4bdf34b9407e533b2a0683c3724a4d77d3ca6ab2ef420a8f3
data/.gitignore CHANGED
@@ -25,15 +25,17 @@ tmp
25
25
  .#*
26
26
  */.#*
27
27
  */*/.#*
28
+ #*
29
+ */#*
30
+ */*/#*
28
31
  rhosts
29
32
  spec/*/*.dat
30
33
  spec/*/*.csv
31
34
 
32
- **/Makefile
33
- **/*.o
34
- **/*.so
35
35
  mkmf.log
36
-
37
- ext/mathgl/*/*.cxx
38
- ext/mathgl/*/Makefile
36
+ ext/mathgl/*.o
37
+ ext/mathgl/qt.cxx
38
+ ext/mathgl/fltk.cxx
39
+ ext/mathgl/glut.cxx
40
+ ext/mathgl/mathgl.so
39
41
  ext/mathgl/Makefile
data/README.md CHANGED
@@ -1,21 +1,21 @@
1
- # Mathgl
1
+ # Ruby/MathGL
2
2
 
3
- Ruby/MathGL : MathGL wrapper for Ruby made using SWIG
4
-
5
- MathGL - library for scientific data visualization
3
+ Ruby wrapper of MathGL - library for scientific data visualization
6
4
  http://mathgl.sourceforge.net/
7
5
 
8
6
  (This package is under construction.)
9
7
 
10
8
  ## Installation
11
9
 
12
- Install from source:
10
+ 1. Install MathGL2 library: http://mathgl.sourceforge.net/
11
+
12
+ 2. Install Ruby/MathGL from source:
13
13
 
14
14
  ruby setup.rb config --prefix=$HOME/local -- --with-mathgl-dir=/usr/local
15
15
  ruby setup.rb setup
16
16
  ruby setup.rb install
17
17
 
18
- Or install it yourself as:
18
+ Or install with gem:
19
19
 
20
20
  $ gem install mathgl -- --with-mathgl-dir=/usr/local
21
21
 
@@ -1,2 +1,12 @@
1
1
  mathgl.cxx: mathgl.i rubymgl.i
2
2
  swig -ruby -autorename -c++ $(INCFLAGS) -o $@ $<
3
+ fltk.cxx: tmpl/mkwin.rb tmpl/win.erb.cxx
4
+ ruby tmpl/mkwin.rb fltk > $@
5
+ glut.cxx: tmpl/mkwin.rb tmpl/win.erb.cxx
6
+ ruby tmpl/mkwin.rb glut > $@
7
+ qt.cxx: tmpl/mkwin.rb tmpl/win.erb.cxx
8
+ ruby tmpl/mkwin.rb qt > $@
9
+
10
+ .PHONY : cleancxx
11
+ cleancxx: clean
12
+ rm -f qt.cxx fltk.cxx glut.cxx
@@ -9,9 +9,22 @@ dir_config("mathgl")
9
9
  exit unless have_header("mgl2/type.h")
10
10
  exit unless have_header("mgl2/data.h")
11
11
  exit unless have_header("mgl2/mgl.h")
12
- #exit unless have_header("mgl2/qt.h")
13
12
  exit unless have_library("mgl")
14
- #exit unless have_library("mgl-qt")
15
13
  $objs = ["mathgl.o"]
14
+ if have_header("mgl2/qt.h") && have_library("mgl-qt")
15
+ $objs << "qt.o"
16
+ $defs << "-DHAVE_QT"
17
+ end
18
+ if have_header("mgl2/fltk.h") && have_library("mgl-fltk")
19
+ $objs << "fltk.o"
20
+ $defs << "-DHAVE_FLTK"
21
+ end
22
+ if have_header("mgl2/glut.h") && have_library("mgl-glut")
23
+ $objs << "glut.o"
24
+ $defs << "-DHAVE_GLUT"
25
+ end
26
+ if File.exist?("mathgl.cxx")
27
+ FileUtils.touch("mathgl.cxx")
28
+ end
16
29
  $CPPFLAGS.split.each{|x| $INCFLAGS+=" "+x if /^-I\S+$/=~x}
17
30
  create_makefile("mathgl")
@@ -1911,6 +1911,26 @@ struct timeval rb_time_timeval(VALUE);
1911
1911
  #endif
1912
1912
 
1913
1913
 
1914
+ extern "C" {
1915
+ void Init_MathGL();
1916
+ void Init_mathgl_qt();
1917
+ void Init_mathgl_fltk();
1918
+ void Init_mathgl_glut();
1919
+ void Init_mathgl() {
1920
+ Init_MathGL();
1921
+ #ifdef HAVE_QT
1922
+ Init_mathgl_qt();
1923
+ #endif
1924
+ #ifdef HAVE_FLTK
1925
+ Init_mathgl_fltk();
1926
+ #endif
1927
+ #ifdef HAVE_GLUT
1928
+ Init_mathgl_glut();
1929
+ #endif
1930
+ }
1931
+ }
1932
+
1933
+
1914
1934
  static mglPoint GetMglPoint(VALUE arg)
1915
1935
  {
1916
1936
  if (TYPE(arg)==T_ARRAY) {
@@ -2264,12 +2284,6 @@ SWIGINTERN void mglGraph_SetFunc__SWIG_1(mglGraph *self,char const *EqX,int EqY=
2264
2284
  SWIGINTERN void mglGraph_SetFunc__SWIG_5(mglGraph *self,char const *EqX,char const *EqY,int EqZ=0,int EqA=0){ self->SetFunc(EqX, EqY, 0, 0); }
2265
2285
  SWIGINTERN void mglGraph_SetFunc__SWIG_8(mglGraph *self,char const *EqX,char const *EqY,char const *EqZ=NULL,int EqA=0){ self->SetFunc(EqX, EqY, EqZ, 0); }
2266
2286
 
2267
- extern "C" {
2268
- void Init_MathGL();
2269
- void Init_mathgl(){ Init_MathGL(); }
2270
- }
2271
-
2272
-
2273
2287
  /*
2274
2288
  Document-method: MathGL.Pi
2275
2289
 
@@ -112,12 +112,3 @@ import_array();
112
112
  void __setitem__( int i, float y) { self->SetVal(y,i); };
113
113
  void __paren_asgn( int i, float y) { self->SetVal(y,i); };
114
114
  };
115
-
116
- #ifdef SWIGRUBY
117
- %{
118
- extern "C" {
119
- void Init_MathGL();
120
- void Init_mathgl(){ Init_MathGL(); }
121
- }
122
- %}
123
- #endif
@@ -1,6 +1,28 @@
1
1
  %include "typemaps.i"
2
2
  %include "wchar.i"
3
3
 
4
+ %{
5
+ extern "C" {
6
+ void Init_MathGL();
7
+ void Init_mathgl_qt();
8
+ void Init_mathgl_fltk();
9
+ void Init_mathgl_glut();
10
+
11
+ void Init_mathgl() {
12
+ Init_MathGL();
13
+ #ifdef HAVE_QT
14
+ Init_mathgl_qt();
15
+ #endif
16
+ #ifdef HAVE_FLTK
17
+ Init_mathgl_fltk();
18
+ #endif
19
+ #ifdef HAVE_GLUT
20
+ Init_mathgl_glut();
21
+ #endif
22
+ }
23
+ }
24
+ %}
25
+
4
26
  //-- mglPoint --
5
27
  %{
6
28
  static mglPoint GetMglPoint(VALUE arg)
@@ -0,0 +1,135 @@
1
+ #include "ruby.h"
2
+
3
+ #include "mgl2/type.h"
4
+ #include "mgl2/data.h"
5
+ #include "mgl2/mgl.h"
6
+ #include "mgl2/<%=low%>.h"
7
+
8
+ #define VALUEFUNC(f) ((VALUE (*)(ANYARGS)) f)
9
+
10
+ static ID id_call;
11
+ static ID id_draw;
12
+ static ID id_handler;
13
+ static ID id_instance_eval;
14
+ static VALUE mMglGraph;
15
+
16
+ class mglRubyDraw : public mglDraw
17
+ {
18
+ VALUE ruby_block;
19
+ int arity;
20
+ public:
21
+ mglRubyDraw(VALUE block) : mglDraw()
22
+ {
23
+ ruby_block = block;
24
+ if (RTEST(block)) {
25
+ arity = rb_proc_arity(block);
26
+ if (arity<0 || arity>1) {
27
+ rb_raise(rb_eArgError,"wrong # of block argument (%d for 0..1)",
28
+ arity);
29
+ }
30
+ } else {
31
+ arity = 0;
32
+ }
33
+ }
34
+ int Draw(mglGraph *gr)
35
+ {
36
+ VALUE graph;
37
+ if (RTEST(ruby_block)) {
38
+ graph = Data_Wrap_Struct(mMglGraph, 0, 0, gr);
39
+ if (arity==1) {
40
+ rb_funcall(ruby_block, id_call, 1, graph);
41
+ } else {
42
+ rb_funcall_with_block(graph, id_instance_eval, 0, 0, ruby_block);
43
+ }
44
+ }
45
+ return 0;
46
+ }
47
+ void Reload() {} ///< Function for reloading data
48
+ void Click() {} ///< Callback function on mouse click
49
+ ~mglRubyDraw() {}
50
+ };
51
+
52
+ static void
53
+ mgl<%=low%>_free(mgl<%=up%> *arg1)
54
+ {
55
+ delete arg1;
56
+ }
57
+
58
+ static VALUE
59
+ mgl<%=low%>_s_allocate(VALUE klass)
60
+ {
61
+ return Data_Wrap_Struct(klass, 0, mgl<%=low%>_free, 0);
62
+ }
63
+
64
+ static VALUE mgl<%=low%>_initialize(int nargs, VALUE *args, VALUE self)
65
+ {
66
+ mgl<%=up%> *result = 0;
67
+ mglRubyDraw *mgl_draw = 0;
68
+ const char *title = 0;
69
+ VALUE block=Qnil;
70
+ VALUE v;
71
+
72
+ switch (nargs) {
73
+ case 0:
74
+ break;
75
+ case 1:
76
+ if (rb_obj_is_kind_of(args[0],rb_cString)) {
77
+ title = StringValueCStr(args[0]);
78
+ } else {
79
+ rb_raise(rb_eArgError, "argument is not a String");
80
+ }
81
+ default:
82
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 0..1)",nargs);
83
+ }
84
+
85
+ if (rb_block_given_p()) {
86
+ block = rb_block_proc();
87
+ }
88
+ mgl_draw = (mglRubyDraw *)new mglRubyDraw(block);
89
+ v = Data_Wrap_Struct(rb_cData, 0, -1, mgl_draw);
90
+ rb_ivar_set(v, id_handler, block);
91
+ rb_ivar_set(self, id_draw, v);
92
+
93
+ if (title==0) {
94
+ result = (mgl<%=up%> *)new mgl<%=up%>(mgl_draw);
95
+ } else {
96
+ result = (mgl<%=up%> *)new mgl<%=up%>(mgl_draw, title);
97
+ }
98
+ DATA_PTR(self) = result;
99
+ return self;
100
+ }
101
+
102
+ <% if has_run %>
103
+ static VALUE mgl<%=low%>_run(VALUE self)
104
+ {
105
+ mgl<%=up%> *arg;
106
+ int result;
107
+ arg = reinterpret_cast< mgl<%=up%> * >(DATA_PTR(self));
108
+ result = (int)(arg)->Run();
109
+ return INT2NUM(result);
110
+ }
111
+ <% end %>
112
+
113
+ extern "C" {
114
+ void
115
+ Init_mathgl_<%=low%>()
116
+ {
117
+ VALUE mMathGL;
118
+ VALUE cMgl<%=up%>;
119
+
120
+ mMathGL = rb_const_get(rb_cObject, rb_intern("MathGL"));
121
+ mMglGraph = rb_const_get(mMathGL, rb_intern("MglGraph"));
122
+
123
+ cMgl<%=up%> = rb_define_class_under(mMathGL, "Mgl<%=up%>", rb_cObject);
124
+ rb_define_alloc_func(cMgl<%=up%>, mgl<%=low%>_s_allocate);
125
+ rb_define_method(cMgl<%=up%>, "initialize", VALUEFUNC(mgl<%=low%>_initialize), -1);
126
+ <% if has_run %>
127
+ rb_define_method(cMgl<%=up%>, "run", VALUEFUNC(mgl<%=low%>_run), 0);
128
+ <% end %>
129
+
130
+ id_call = rb_intern("call");
131
+ id_draw = rb_intern("draw");
132
+ id_handler = rb_intern("handler");
133
+ id_instance_eval = rb_intern("instance_eval");
134
+ }
135
+ }
@@ -1,3 +1,3 @@
1
1
  module Mathgl
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
12
12
  spec.summary = %q{Ruby wrapper for MathGL - library for scientific data visualization}
13
13
  spec.homepage = "https://github.com/masa16/ruby-mathgl"
14
14
  spec.license = "LGPL"
15
- spec.extensions = `git ls-files ext`.split($/).grep(/extconf/)
15
+ spec.extensions = ["ext/mathgl/extconf.rb"]
16
16
 
17
17
  spec.files = `git ls-files`.split($/)
18
18
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
@@ -21,4 +21,15 @@ Gem::Specification.new do |spec|
21
21
 
22
22
  spec.add_development_dependency "bundler", "~> 1.3"
23
23
  spec.add_development_dependency "rake"
24
+
25
+ spec.rdoc_options = %w[
26
+ --exclude lib/mathgl.so
27
+ --exclude doc/
28
+ --exclude ext/
29
+ --exclude sample/
30
+ --exclude setup.rb
31
+ --exclude mathgl.gemspec
32
+ --exclude Gemfile
33
+ --exclude Rakefile
34
+ ]
24
35
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mathgl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masahiro TANAKA
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-21 00:00:00.000000000 Z
11
+ date: 2013-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -44,9 +44,6 @@ email:
44
44
  executables: []
45
45
  extensions:
46
46
  - ext/mathgl/extconf.rb
47
- - ext/mathgl/fltk/extconf.rb
48
- - ext/mathgl/glut/extconf.rb
49
- - ext/mathgl/qt/extconf.rb
50
47
  extra_rdoc_files: []
51
48
  files:
52
49
  - .gitignore
@@ -56,14 +53,8 @@ files:
56
53
  - Rakefile
57
54
  - ext/mathgl/depend
58
55
  - ext/mathgl/extconf.rb
59
- - ext/mathgl/fltk/depend
60
- - ext/mathgl/fltk/extconf.rb
61
- - ext/mathgl/glut/depend
62
- - ext/mathgl/glut/extconf.rb
63
56
  - ext/mathgl/mathgl.cxx
64
57
  - ext/mathgl/mathgl.i
65
- - ext/mathgl/qt/depend
66
- - ext/mathgl/qt/extconf.rb
67
58
  - ext/mathgl/rubymgl.i
68
59
  - ext/mathgl/tmpl/mkwin.rb
69
60
  - ext/mathgl/tmpl/win.erb.cxx
@@ -78,7 +69,23 @@ licenses:
78
69
  - LGPL
79
70
  metadata: {}
80
71
  post_install_message:
81
- rdoc_options: []
72
+ rdoc_options:
73
+ - --exclude
74
+ - lib/mathgl.so
75
+ - --exclude
76
+ - doc/
77
+ - --exclude
78
+ - ext/
79
+ - --exclude
80
+ - sample/
81
+ - --exclude
82
+ - setup.rb
83
+ - --exclude
84
+ - mathgl.gemspec
85
+ - --exclude
86
+ - Gemfile
87
+ - --exclude
88
+ - Rakefile
82
89
  require_paths:
83
90
  - lib
84
91
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -1,2 +0,0 @@
1
- fltk.cxx: ../tmpl/mkwin.rb ../tmpl/win.erb.cxx
2
- ruby ../tmpl/mkwin.rb fltk > $@
@@ -1,20 +0,0 @@
1
- require "mkmf"
2
-
3
- # configure options:
4
- # --with-mathgl-dir=path
5
- # --with-mathgl-include=path
6
- # --with-mathgl-lib=path
7
-
8
- dir_config("mathgl")
9
-
10
- #with_cppflags "-g -O0 -Wall"
11
-
12
- exit unless have_header("mgl2/type.h")
13
- exit unless have_header("mgl2/data.h")
14
- exit unless have_header("mgl2/mgl.h")
15
- exit unless have_header("mgl2/fltk.h")
16
- exit unless have_library("mgl")
17
- exit unless have_library("mgl-fltk")
18
- $objs = ["fltk.o"]
19
- $CPPFLAGS.split.each{|x| $INCFLAGS+=" "+x if /^-I\S+$/=~x}
20
- create_makefile("fltk")
@@ -1,2 +0,0 @@
1
- glut.cxx: ../tmpl/mkwin.rb ../tmpl/win.erb.cxx
2
- ruby ../tmpl/mkwin.rb glut > $@
@@ -1,20 +0,0 @@
1
- require "mkmf"
2
-
3
- # configure options:
4
- # --with-mathgl-dir=path
5
- # --with-mathgl-include=path
6
- # --with-mathgl-lib=path
7
-
8
- dir_config("mathgl")
9
-
10
- #with_cppflags "-g -O0 -Wall"
11
-
12
- exit unless have_header("mgl2/type.h")
13
- exit unless have_header("mgl2/data.h")
14
- exit unless have_header("mgl2/mgl.h")
15
- exit unless have_header("mgl2/glut.h")
16
- exit unless have_library("mgl")
17
- exit unless have_library("mgl-glut")
18
- $objs = ["glut.o"]
19
- $CPPFLAGS.split.each{|x| $INCFLAGS+=" "+x if /^-I\S+$/=~x}
20
- create_makefile("glut")
@@ -1,2 +0,0 @@
1
- qt.cxx: ../tmpl/mkwin.rb ../tmpl/win.erb.cxx
2
- ruby ../tmpl/mkwin.rb qt > $@
@@ -1,20 +0,0 @@
1
- require "mkmf"
2
-
3
- # configure options:
4
- # --with-mathgl-dir=path
5
- # --with-mathgl-include=path
6
- # --with-mathgl-lib=path
7
-
8
- dir_config("mathgl")
9
-
10
- #with_cppflags "-g -O0 -Wall"
11
-
12
- exit unless have_header("mgl2/type.h")
13
- exit unless have_header("mgl2/data.h")
14
- exit unless have_header("mgl2/mgl.h")
15
- exit unless have_header("mgl2/qt.h")
16
- exit unless have_library("mgl")
17
- exit unless have_library("mgl-qt")
18
- $objs = ["qt.o"]
19
- $CPPFLAGS.split.each{|x| $INCFLAGS+=" "+x if /^-I\S+$/=~x}
20
- create_makefile("qt")