octave-ruby 1.0.9 → 2.0.0

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.
@@ -1,3 +1,9 @@
1
+ == 2.0.0 / 2012-11-08
2
+
3
+ * 2 major enhancements
4
+ * Octave 3.6 compatability. Support for 3.0 has been deprecated
5
+ * Added Ruby 1.9 compatability
6
+
1
7
  == 1.0.9 / 2008-12-30
2
8
 
3
9
  * 1 major bug fix
data/README.txt CHANGED
@@ -55,4 +55,4 @@ If you have Octave installed in a non-standard location, you can specify the loc
55
55
 
56
56
  octave-ruby is licensed under the GPL License.
57
57
 
58
- Copyright (c) 2007 Jonathan Younger <jonathan.younger@lipomics.com>
58
+ Copyright (c) 2007-2012 Jonathan Younger <jonathan@daikini.com>
@@ -1,63 +1,98 @@
1
1
 
2
2
  SHELL = /bin/sh
3
3
 
4
+ # V=0 quiet, V=1 verbose. other values don't work.
5
+ V = 0
6
+ Q1 = $(V:1=)
7
+ Q = $(Q1:0=@)
8
+ n=$(NULLCMD)
9
+ ECHO1 = $(V:1=@$n)
10
+ ECHO = $(ECHO1:0=@echo)
11
+
4
12
  #### Start of system configuration section. ####
5
13
 
6
- srcdir = .
7
- topdir = /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin9.0
8
- hdrdir = $(topdir)
9
- VPATH = $(srcdir):$(topdir):$(hdrdir)
10
- prefix = $(DESTDIR)/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr
14
+ srcdir = /Volumes/MacintoshHD/Projects/Daikini/octave-ruby/ext/octave_api
15
+ topdir = /Users/jonathan/.rbenv/versions/1.9.3-p286/include/ruby-1.9.1
16
+ hdrdir = /Users/jonathan/.rbenv/versions/1.9.3-p286/include/ruby-1.9.1
17
+ arch_hdrdir = /Users/jonathan/.rbenv/versions/1.9.3-p286/include/ruby-1.9.1/$(arch)
18
+ VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
19
+ prefix = $(DESTDIR)/Users/jonathan/.rbenv/versions/1.9.3-p286
20
+ rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
11
21
  exec_prefix = $(prefix)
12
- sitedir = $(DESTDIR)/Library/Ruby/Site
13
- rubylibdir = $(libdir)/ruby/$(ruby_version)
14
- docdir = $(datarootdir)/doc/$(PACKAGE)
15
- dvidir = $(docdir)
16
- datarootdir = $(prefix)/share
17
- archdir = $(rubylibdir)/$(arch)
18
- sbindir = $(exec_prefix)/sbin
19
- psdir = $(docdir)
22
+ vendorhdrdir = $(rubyhdrdir)/vendor_ruby
23
+ sitehdrdir = $(rubyhdrdir)/site_ruby
24
+ rubyhdrdir = $(includedir)/$(RUBY_BASE_NAME)-$(ruby_version)
25
+ vendordir = $(rubylibprefix)/vendor_ruby
26
+ sitedir = $(rubylibprefix)/site_ruby
27
+ ridir = $(datarootdir)/$(RI_BASE_NAME)
28
+ mandir = $(datarootdir)/man
20
29
  localedir = $(datarootdir)/locale
30
+ libdir = $(exec_prefix)/lib
31
+ psdir = $(docdir)
32
+ pdfdir = $(docdir)
33
+ dvidir = $(docdir)
21
34
  htmldir = $(docdir)
22
- datadir = $(datarootdir)
35
+ infodir = $(datarootdir)/info
36
+ docdir = $(datarootdir)/doc/$(PACKAGE)
37
+ oldincludedir = $(DESTDIR)/usr/include
23
38
  includedir = $(prefix)/include
24
- infodir = $(DESTDIR)/usr/share/info
25
- sysconfdir = $(prefix)/etc
26
- mandir = $(DESTDIR)/usr/share/man
27
- libdir = $(exec_prefix)/lib
39
+ localstatedir = $(prefix)/var
28
40
  sharedstatedir = $(prefix)/com
29
- oldincludedir = $(DESTDIR)/usr/include
30
- pdfdir = $(docdir)
31
- sitearchdir = $(sitelibdir)/$(sitearch)
41
+ sysconfdir = $(prefix)/etc
42
+ datadir = $(datarootdir)
43
+ datarootdir = $(prefix)/share
44
+ libexecdir = $(exec_prefix)/libexec
45
+ sbindir = $(exec_prefix)/sbin
32
46
  bindir = $(exec_prefix)/bin
33
- localstatedir = $(prefix)/var
47
+ rubylibdir = $(rubylibprefix)/$(ruby_version)
48
+ archdir = $(rubylibdir)/$(arch)
34
49
  sitelibdir = $(sitedir)/$(ruby_version)
35
- libexecdir = $(exec_prefix)/libexec
50
+ sitearchdir = $(sitelibdir)/$(sitearch)
51
+ vendorlibdir = $(vendordir)/$(ruby_version)
52
+ vendorarchdir = $(vendorlibdir)/$(sitearch)
53
+
54
+ NULLCMD = :
36
55
 
37
56
  CC = gcc
38
- LIBRUBY = $(LIBRUBY_SO)
57
+ CXX = g++
58
+ LIBRUBY = $(LIBRUBY_A)
39
59
  LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
40
- LIBRUBYARG_SHARED = -l$(RUBY_SO_NAME)
41
- LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)
60
+ LIBRUBYARG_SHARED =
61
+ LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static
62
+ empty =
63
+ OUTFLAG = -o $(empty)
64
+ COUTFLAG = -o $(empty)
42
65
 
43
66
  RUBY_EXTCONF_H =
44
- CFLAGS = -fno-common -arch i386 -Os -pipe -fno-common
45
- INCFLAGS = -I. -I. -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin9.0 -I.
46
- CPPFLAGS = -DHAVE_OCTAVE_H -I/Applications/Octave.app/Contents/Resources/include -I/Applications/Octave.app/Contents/Resources/lib -I/Applications/Octave.app/Contents/Resources/include/octave-3.0.2/octave -I/Applications/Octave.app/Contents/Resources/lib/octave-3.0.2 -I/Applications/Octave.app/Contents/Resources/include/octave-3.0.2
47
- CXXFLAGS = $(CFLAGS)
48
- DLDFLAGS = -L. -arch i386
67
+ cflags = $(optflags) $(debugflags) $(warnflags)
68
+ optflags = -O3
69
+ debugflags = -ggdb
70
+ warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration
71
+ CFLAGS = -fno-common $(cflags) -pipe $(ARCH_FLAG)
72
+ INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir)/ruby/backward -I$(hdrdir) -I$(srcdir)
73
+ DEFS =
74
+ CPPFLAGS = -DHAVE_OCTAVE_H -I/usr/local/include -I/usr/local/lib/octave -I/usr/local/include/octave-3.6.2/octave -I/usr/local/lib/octave/3.6.2 -I/usr/local/include/octave-3.6.2
75
+ CXXFLAGS = $(CFLAGS) $(cxxflags)
76
+ ldflags = -L. -L'/Users/jonathan/.rbenv/versions/1.9.3-p286/lib'
77
+ dldflags = -Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress -Wl,-flat_namespace
78
+ ARCH_FLAG =
79
+ DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
49
80
  LDSHARED = g++ -pipe -bundle
81
+ LDSHAREDXX = $(CXX) -dynamic -bundle
50
82
  AR = ar
51
83
  EXEEXT =
52
84
 
85
+ RUBY_BASE_NAME = ruby
53
86
  RUBY_INSTALL_NAME = ruby
54
87
  RUBY_SO_NAME = ruby
55
- arch = universal-darwin9.0
56
- sitearch = universal-darwin9.0
57
- ruby_version = 1.8
58
- ruby = /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
88
+ arch = x86_64-darwin12.2.0
89
+ sitearch = $(arch)
90
+ ruby_version = 1.9.1
91
+ ruby = /Users/jonathan/.rbenv/versions/1.9.3-p286/bin/ruby
59
92
  RUBY = $(ruby)
60
93
  RM = rm -f
94
+ RM_RF = $(RUBY) -run -e rm -- -rf
95
+ RMDIRS = rmdir -p
61
96
  MAKEDIRS = mkdir -p
62
97
  INSTALL = /usr/bin/install -c
63
98
  INSTALL_PROG = $(INSTALL) -m 0755
@@ -68,18 +103,19 @@ COPY = cp
68
103
 
69
104
  preload =
70
105
 
71
- libpath = . $(libdir) /Applications/Octave.app/Contents/Resources/lib /Applications/Octave.app/Contents/Resources/lib/octave-3.0.2
72
- LIBPATH = -L"." -L"$(libdir)" -L"/Applications/Octave.app/Contents/Resources/lib" -L"/Applications/Octave.app/Contents/Resources/lib/octave-3.0.2"
106
+ libpath = . $(libdir) /usr/local/lib/octave /usr/local/lib/octave/3.6.2
107
+ LIBPATH = -L. -L$(libdir) -L/usr/local/lib/octave -L/usr/local/lib/octave/3.6.2
73
108
  DEFFILE =
74
109
 
75
110
  CLEANFILES = mkmf.log
76
111
  DISTCLEANFILES =
112
+ DISTCLEANDIRS =
77
113
 
78
114
  extout =
79
115
  extout_prefix =
80
116
  target_prefix =
81
117
  LOCAL_LIBS =
82
- LIBS = $(LIBRUBYARG_SHARED) -loctinterp -lcruft -loctave -lpthread -ldl -lm
118
+ LIBS = -loctinterp -lcruft -loctave -lpthread -ldl -lobjc
83
119
  SRCS = octave_api.c octave-ruby.cpp or-array.cpp or-boolean_matrix.cpp or-cell_matrix.cpp or-hash.cpp or-matrix.cpp or-string.cpp or-struct_matrix.cpp or-variable.cpp
84
120
  OBJS = octave_api.o octave-ruby.o or-array.o or-boolean_matrix.o or-cell_matrix.o or-hash.o or-matrix.o or-string.o or-struct_matrix.o or-variable.o
85
121
  TARGET = octave_api
@@ -87,63 +123,92 @@ DLLIB = $(TARGET).bundle
87
123
  EXTSTATIC =
88
124
  STATIC_LIB =
89
125
 
126
+ BINDIR = $(bindir)
90
127
  RUBYCOMMONDIR = $(sitedir)$(target_prefix)
91
128
  RUBYLIBDIR = $(sitelibdir)$(target_prefix)
92
129
  RUBYARCHDIR = $(sitearchdir)$(target_prefix)
130
+ HDRDIR = $(rubyhdrdir)/ruby$(target_prefix)
131
+ ARCHHDRDIR = $(rubyhdrdir)/$(arch)/ruby$(target_prefix)
93
132
 
94
133
  TARGET_SO = $(DLLIB)
95
- CLEANLIBS = $(TARGET).bundle $(TARGET).il? $(TARGET).tds $(TARGET).map
96
- CLEANOBJS = *.o *.a *.s[ol] *.pdb *.exp *.bak
97
-
98
- all: $(DLLIB)
99
- static: $(STATIC_LIB)
100
-
101
- clean:
134
+ CLEANLIBS = $(TARGET).bundle
135
+ CLEANOBJS = *.o *.bak
136
+
137
+ all: $(DLLIB)
138
+ static: $(STATIC_LIB)
139
+ .PHONY: all install static install-so install-rb
140
+ .PHONY: clean clean-so clean-rb
141
+
142
+ clean-rb-default::
143
+ clean-rb::
144
+ clean-so::
145
+ clean: clean-so clean-rb-default clean-rb
102
146
  @-$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES)
103
147
 
104
- distclean: clean
148
+ distclean-rb-default::
149
+ distclean-rb::
150
+ distclean-so::
151
+ distclean: clean distclean-so distclean-rb-default distclean-rb
105
152
  @-$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
106
153
  @-$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
154
+ @-$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
107
155
 
108
- realclean: distclean
156
+ realclean: distclean
109
157
  install: install-so install-rb
110
158
 
111
159
  install-so: $(RUBYARCHDIR)
112
160
  install-so: $(RUBYARCHDIR)/$(DLLIB)
113
161
  $(RUBYARCHDIR)/$(DLLIB): $(DLLIB)
114
- $(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
162
+ @-$(MAKEDIRS) $(@D)
163
+ $(INSTALL_PROG) $(DLLIB) $(@D)
115
164
  install-rb: pre-install-rb install-rb-default
116
165
  install-rb-default: pre-install-rb-default
117
166
  pre-install-rb: Makefile
118
167
  pre-install-rb-default: Makefile
168
+ pre-install-rb-default:
169
+ $(ECHO) installing default octave_api libraries
119
170
  $(RUBYARCHDIR):
120
- $(MAKEDIRS) $@
171
+ $(Q) $(MAKEDIRS) $@
121
172
 
122
173
  site-install: site-install-so site-install-rb
123
174
  site-install-so: install-so
124
175
  site-install-rb: install-rb
125
176
 
126
- .SUFFIXES: .c .m .cc .cxx .cpp .C .o
177
+ .SUFFIXES: .c .m .cc .mm .cxx .cpp .C .o
127
178
 
128
179
  .cc.o:
129
- $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
180
+ $(ECHO) compiling $(<)
181
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
182
+
183
+ .mm.o:
184
+ $(ECHO) compiling $(<)
185
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
130
186
 
131
187
  .cxx.o:
132
- $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
188
+ $(ECHO) compiling $(<)
189
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
133
190
 
134
191
  .cpp.o:
135
- $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
192
+ $(ECHO) compiling $(<)
193
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
136
194
 
137
195
  .C.o:
138
- $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
196
+ $(ECHO) compiling $(<)
197
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
139
198
 
140
199
  .c.o:
141
- $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) -c $<
200
+ $(ECHO) compiling $(<)
201
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
202
+
203
+ .m.o:
204
+ $(ECHO) compiling $(<)
205
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
142
206
 
143
- $(DLLIB): $(OBJS)
144
- @-$(RM) $@
145
- $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
207
+ $(DLLIB): $(OBJS) Makefile
208
+ $(ECHO) linking shared-object $(DLLIB)
209
+ @-$(RM) $(@)
210
+ $(Q) $(LDSHAREDXX) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
146
211
 
147
212
 
148
213
 
149
- $(OBJS): ruby.h defines.h
214
+ $(OBJS): $(hdrdir)/ruby.h $(hdrdir)/ruby/defines.h $(arch_hdrdir)/ruby/config.h
@@ -7,7 +7,7 @@ dep_dirs = dir_config( "dep", octave_dirs.first.split(File::SEPARATOR)[0..-3].jo
7
7
  if have_header("octave.h" ) &&
8
8
  have_library("octave") &&
9
9
  have_library("cruft") &&
10
- have_library("octinterp", "octave_main" )
10
+ have_library("octinterp")
11
11
 
12
12
  if Config::CONFIG["arch"] =~ /-darwin\d/
13
13
  CONFIG['LDSHARED'] = "g++ -pipe -bundle"
@@ -26,5 +26,9 @@ if have_header("octave.h" ) &&
26
26
  end
27
27
  end
28
28
 
29
+ if RUBY_VERSION =~ /1.8/ then
30
+ $CPPFLAGS += " -DRUBY_18"
31
+ end
32
+
29
33
  create_makefile( "octave_api" )
30
34
  end
@@ -1,3 +1,6 @@
1
+ #ifndef OCTAVE_INCLUDES_H_INCLUDED_
2
+ #define OCTAVE_INCLUDES_H_INCLUDED_
3
+
1
4
  #include "octave/config.h"
2
5
  #include "octave.h"
3
6
  #include "symtab.h"
@@ -9,3 +12,5 @@
9
12
  #include "sighandlers.h"
10
13
  #include "sysdep.h"
11
14
  #include "ov-struct.h"
15
+
16
+ #endif /*OCTAVE_INCLUDES_H_INCLUDED_ */
@@ -13,11 +13,11 @@ void initialize_octave()
13
13
 
14
14
  extern void recover_from_exception(void)
15
15
  {
16
- unwind_protect::run_all();
16
+ // unwind_protect::run_all();
17
17
  can_interrupt = true;
18
18
  octave_interrupt_immediately = 0;
19
19
  octave_interrupt_state = 0;
20
- octave_allocation_error = 0;
20
+ octave_exception_state = octave_no_exception;
21
21
  }
22
22
 
23
23
  VALUE or_feval(VALUE function_name, VALUE arguments)
@@ -26,14 +26,14 @@ VALUE or_feval(VALUE function_name, VALUE arguments)
26
26
  int i, n;
27
27
  octave_value_list argList;
28
28
 
29
- n = RARRAY(arguments)->len;
29
+ n = RARRAY_LEN(arguments);
30
30
 
31
31
  for (i = 0; i < n; i++) {
32
- argList(i) = OR_Variable(RARRAY(arguments)->ptr[i]).to_octave();
32
+ argList(i) = OR_Variable(RARRAY_PTR(arguments)[i]).to_octave();
33
33
  }
34
34
 
35
35
  if (octave_set_current_context) {
36
- unwind_protect::run_all();
36
+ // unwind_protect::run_all();
37
37
  raw_mode(0);
38
38
  }
39
39
 
@@ -41,10 +41,10 @@ VALUE or_feval(VALUE function_name, VALUE arguments)
41
41
  octave_initialized = true;
42
42
 
43
43
  try {
44
- curr_sym_tab = top_level_sym_tab;
44
+ symbol_table::set_scope(symbol_table::top_scope());
45
45
  reset_error_handler();
46
46
 
47
- octave_value_list val = feval(std::string(RSTRING(function_name)->ptr), argList, 1);
47
+ octave_value_list val = feval(std::string(RSTRING_PTR(function_name)), argList, 1);
48
48
  if(val.length() > 0 && val(0).is_defined()) {
49
49
  ruby_val = OR_Variable(val(0)).to_ruby();
50
50
  }
@@ -60,3 +60,14 @@ VALUE or_feval(VALUE function_name, VALUE arguments)
60
60
 
61
61
  return(ruby_val);
62
62
  }
63
+
64
+ extern VALUE or_get_variable(VALUE variable_name)
65
+ {
66
+ return OR_Variable(get_top_level_value(std::string(RSTRING_PTR(variable_name)))).to_ruby();
67
+ }
68
+
69
+ extern VALUE or_put_variable(VALUE variable_name, VALUE value)
70
+ {
71
+ set_top_level_value(std::string(RSTRING_PTR(variable_name)), OR_Variable(value).to_octave());
72
+ return value;
73
+ }
@@ -7,8 +7,18 @@
7
7
  extern "C"
8
8
  {
9
9
  #endif
10
+
11
+ /* Macros for backwards compatibility with 1.8 */
12
+ #ifdef RUBY_18
13
+ #define RARRAY_LEN(a) (RARRAY(a)->len)
14
+ #define RARRAY_PTR(a) (RARRAY(a)->ptr)
15
+ #define RFLOAT_VALUE(v) (RFLOAT(v)->value)
16
+ #define RSTRING_PTR(s) (RSTRING(s)->ptr)
17
+ #endif
10
18
 
11
19
  extern VALUE or_feval(VALUE function_name, VALUE arguments);
20
+ extern VALUE or_get_variable(VALUE variable_name);
21
+ extern VALUE or_put_variable(VALUE variable_name, VALUE value);
12
22
  extern void initialize_octave();
13
23
 
14
24
  #ifdef __cplusplus /* extern "C" */
@@ -12,7 +12,8 @@ void Init_octave_api() {
12
12
  OCTAVE_API = rb_define_module_under(OCTAVE_API, "Native");
13
13
  OCTAVE_API = rb_define_module_under(OCTAVE_API, "API");
14
14
  rb_define_module_function(OCTAVE_API, "feval", feval, 2);
15
-
15
+ rb_define_module_function(OCTAVE_API, "get_variable", get_variable, 1);
16
+ rb_define_module_function(OCTAVE_API, "put_variable", put_variable, 2);
16
17
  initialize_octave();
17
18
  }
18
19
 
@@ -20,3 +21,13 @@ VALUE feval(VALUE self, VALUE function_name, VALUE arguments)
20
21
  {
21
22
  return or_feval(function_name, arguments);
22
23
  }
24
+
25
+ static VALUE get_variable(VALUE self, VALUE variable_name)
26
+ {
27
+ return or_get_variable(variable_name);
28
+ }
29
+
30
+ static VALUE put_variable(VALUE self, VALUE variable_name, VALUE value)
31
+ {
32
+ return or_put_variable(variable_name, value);
33
+ }
@@ -7,7 +7,8 @@ extern "C" {
7
7
  // Prototype for the initialization method - Ruby calls this, not you
8
8
  void Init_octave_api();
9
9
  static VALUE feval(VALUE self, VALUE function_name, VALUE arguments);
10
-
10
+ static VALUE get_variable(VALUE self, VALUE variable_name);
11
+ static VALUE put_variable(VALUE self, VALUE variable_name, VALUE value);
11
12
  #ifdef __cplusplus
12
13
  }
13
14
  #endif
@@ -6,14 +6,14 @@ OR_Array::~OR_Array() {}
6
6
  octave_value OR_Array::to_octave()
7
7
  {
8
8
  int row_index;
9
- int number_of_rows = RARRAY(ruby_val)->len;
9
+ int number_of_rows = RARRAY_LEN(ruby_val);
10
10
  VALUE cell;
11
11
 
12
12
  if (should_convert_to_cell_matrix()) {
13
13
  Cell matrix = Cell(number_of_rows, 1);
14
14
 
15
15
  for (row_index = 0; row_index < number_of_rows; row_index++) {
16
- cell = RARRAY(ruby_val)->ptr[row_index];
16
+ cell = RARRAY_PTR(ruby_val)[row_index];
17
17
  matrix(row_index, 0) = OR_Variable(cell).to_octave();
18
18
  }
19
19
 
@@ -22,10 +22,10 @@ octave_value OR_Array::to_octave()
22
22
  Matrix matrix = Matrix(number_of_rows, 1);
23
23
 
24
24
  for (row_index = 0; row_index < number_of_rows; row_index++) {
25
- cell = RARRAY(ruby_val)->ptr[row_index];
25
+ cell = RARRAY_PTR(ruby_val)[row_index];
26
26
 
27
27
  if (rb_type(cell) == T_FLOAT) {
28
- matrix(row_index, 0) = RFLOAT(cell)->value;
28
+ matrix(row_index, 0) = RFLOAT_VALUE(cell);
29
29
  } else if (rb_type(cell) == T_FIXNUM) {
30
30
  matrix(row_index, 0) = FIX2LONG(cell);
31
31
  } else {
@@ -42,10 +42,10 @@ bool OR_Array::should_convert_to_cell_matrix()
42
42
  int row_index;
43
43
  VALUE value;
44
44
  VALUE type;
45
- int number_of_rows = RARRAY(ruby_val)->len;
45
+ int number_of_rows = RARRAY_LEN(ruby_val);
46
46
 
47
47
  for (row_index = 0; row_index < number_of_rows; row_index++) {
48
- value = RARRAY(ruby_val)->ptr[row_index];
48
+ value = RARRAY_PTR(ruby_val)[row_index];
49
49
  type = rb_type(value);
50
50
  if (type != T_FLOAT && type != T_FIXNUM && value != Qnil) {
51
51
  return true;
@@ -54,10 +54,10 @@ octave_value OR_CellMatrix::to_octave()
54
54
  Cell matrix = Cell(number_of_rows, number_of_columns);
55
55
 
56
56
  for (row_index = 0; row_index < number_of_rows; row_index++) {
57
- row = RARRAY(cells)->ptr[row_index];
57
+ row = RARRAY_PTR(cells)[row_index];
58
58
 
59
59
  for (column_index = 0; column_index < number_of_columns; column_index++) {
60
- cell = RARRAY(row)->ptr[column_index];
60
+ cell = RARRAY_PTR(row)[column_index];
61
61
  matrix(row_index, column_index) = OR_Variable(cell).to_octave();
62
62
  }
63
63
  }
@@ -7,16 +7,16 @@ octave_value OR_Hash::to_octave()
7
7
  {
8
8
  int i;
9
9
  VALUE names = rb_funcall(ruby_val, rb_intern("keys"), 0);
10
- int number_of_keys = RARRAY(names)->len;
10
+ int number_of_keys = RARRAY_LEN(names);
11
11
 
12
12
  string_vector keys = string_vector();
13
13
  for (i = 0; i < number_of_keys; i++) {
14
- keys.append(std::string(RSTRING(RARRAY(names)->ptr[i])->ptr));
14
+ keys.append(std::string(RSTRING_PTR(RARRAY_PTR(names)[i])));
15
15
  }
16
16
 
17
17
  Octave_map struct_matrix = Octave_map(dim_vector(1, 1), Cell(keys));
18
18
  for (i = 0; i < number_of_keys; i++) {
19
- struct_matrix.contents(std::string(RSTRING(RARRAY(names)->ptr[i])->ptr)) = OR_Variable(rb_hash_aref(ruby_val, rb_str_new2(RSTRING(RARRAY(names)->ptr[i])->ptr))).to_octave();
19
+ struct_matrix.contents(std::string(RSTRING_PTR(RARRAY_PTR(names)[i]))) = OR_Variable(rb_hash_aref(ruby_val, rb_str_new2(RSTRING_PTR(RARRAY_PTR(names)[i])))).to_octave();
20
20
  }
21
21
 
22
22
  return struct_matrix;
@@ -70,13 +70,13 @@ octave_value OR_Matrix::to_octave()
70
70
  Matrix matrix = Matrix(number_of_rows, number_of_columns);
71
71
 
72
72
  for (row_index = 0; row_index < number_of_rows; row_index++) {
73
- row = RARRAY(cells)->ptr[row_index];
73
+ row = RARRAY_PTR(cells)[row_index];
74
74
 
75
75
  for (column_index = 0; column_index < number_of_columns; column_index++) {
76
- cell = RARRAY(row)->ptr[column_index];
76
+ cell = RARRAY_PTR(row)[column_index];
77
77
 
78
78
  if (rb_type(cell) == T_FLOAT) {
79
- matrix(row_index, column_index) = RFLOAT(cell)->value;
79
+ matrix(row_index, column_index) = RFLOAT_VALUE(cell);
80
80
  } else if (rb_type(cell) == T_FIXNUM) {
81
81
  matrix(row_index, column_index) = FIX2LONG(cell);
82
82
  } else {
@@ -9,5 +9,5 @@ VALUE OR_String::to_ruby()
9
9
 
10
10
  octave_value OR_String::to_octave()
11
11
  {
12
- return std::string(RSTRING(ruby_val)->ptr);
12
+ return std::string(RSTRING_PTR(ruby_val));
13
13
  }
@@ -62,24 +62,24 @@ octave_value OR_StructMatrix::to_octave()
62
62
  VALUE row, cell;
63
63
  VALUE cells = rb_iv_get(ruby_val, "@cells");
64
64
  VALUE names = rb_iv_get(ruby_val, "@names");
65
- int number_of_keys = RARRAY(names)->len;
65
+ int number_of_keys = RARRAY_LEN(names);
66
66
  int number_of_rows = FIX2INT(rb_iv_get(ruby_val, "@m"));
67
67
  int number_of_columns = FIX2INT(rb_iv_get(ruby_val, "@n"));
68
68
 
69
69
  string_vector keys = string_vector();
70
70
  for (i = 0; i < number_of_keys; i++) {
71
- keys.append(std::string(RSTRING(RARRAY(names)->ptr[i])->ptr));
71
+ keys.append(std::string(RSTRING_PTR(RARRAY_PTR(names)[i])));
72
72
  }
73
73
 
74
74
  Octave_map struct_matrix = Octave_map(dim_vector(number_of_rows, number_of_columns), Cell(keys));
75
75
  for (row_index = 0; row_index < number_of_rows; row_index++) {
76
- row = RARRAY(cells)->ptr[row_index];
76
+ row = RARRAY_PTR(cells)[row_index];
77
77
 
78
78
  for (column_index = 0; column_index < number_of_columns; column_index++) {
79
- cell = RARRAY(row)->ptr[column_index];
79
+ cell = RARRAY_PTR(row)[column_index];
80
80
 
81
81
  for (i = 0; i < number_of_keys; i++) {
82
- struct_matrix.contents(std::string(RSTRING(RARRAY(names)->ptr[i])->ptr))(row_index, column_index) = OR_Variable(rb_hash_aref(cell, rb_str_new2(RSTRING(RARRAY(names)->ptr[i])->ptr))).to_octave();
82
+ struct_matrix.contents(std::string(RSTRING_PTR(RARRAY_PTR(names)[i])))(row_index, column_index) = OR_Variable(rb_hash_aref(cell, rb_str_new2(RSTRING_PTR(RARRAY_PTR(names)[i])))).to_octave();
83
83
  }
84
84
  }
85
85
  }
@@ -39,7 +39,7 @@ octave_value OR_Variable::to_octave()
39
39
  } else if (ruby_val == Qnil) {
40
40
  return octave_NaN;
41
41
  } else if (rb_type(ruby_val) == T_FLOAT) {
42
- return RFLOAT(ruby_val)->value;
42
+ return RFLOAT_VALUE(ruby_val);
43
43
  } else if (rb_type(ruby_val) == T_FIXNUM) {
44
44
  return FIX2LONG(ruby_val);
45
45
  } else if (rb_obj_is_kind_of(ruby_val, rb_path2class("Array")) == Qtrue) {
@@ -11,16 +11,11 @@ module Octave ; module Driver ; module Native
11
11
  end
12
12
 
13
13
  def put_variable(name, value)
14
- global_name = "octave_ruby_#{name}"
15
- feval("eval", "function octave_ruby_put_variable(value) global #{global_name}; #{global_name} = value; endfunction")
16
- feval("octave_ruby_put_variable", value)
17
- result = feval("eval", "global #{global_name}; #{name} = #{global_name}")
18
- feval("clear", global_name)
19
- result
14
+ API.put_variable(name, value)
20
15
  end
21
16
 
22
17
  def get_variable(name)
23
- feval("eval", name)
18
+ API.get_variable(name)
24
19
  end
25
20
  end
26
21
  end ; end ; end
@@ -1,10 +1,10 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = %q{octave-ruby}
3
- s.version = "1.0.9"
3
+ s.version = "2.0.0"
4
4
 
5
5
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
6
6
  s.authors = ["Jonathan Younger"]
7
- s.date = %q{2008-12-30}
7
+ s.date = %q{2012-11-08}
8
8
  s.description = %q{== USAGE: require 'octave' engine = Octave::Engine.new engine.eval "123.456 * 789.101112" engine.rand(10) matrix = Octave::Matrix.new(20, 400) 20.times { |m| 400.times { |n| matrix[m, n] = rand } } engine.put_variable("m", matrix) engine.save "/tmp/20_x_400_matrix" == REQUIREMENTS: * Octave * GCC or some other compiler to build the included extension * Mocha (For testing only)}
9
9
  s.email = ["jonathan@daikini.com"]
10
10
  s.extensions = ["ext/octave_api/extconf.rb"]
@@ -9,11 +9,11 @@ require 'yaml'
9
9
  class ConversionsTest < Test::Unit::TestCase
10
10
  def setup
11
11
  @driver = Octave::Driver::Native::Driver.new
12
- @driver.feval "eval", "function r = to_octave(val); r = val; endfunction"
13
12
  end
14
13
 
15
14
  def to_octave_to_ruby(value)
16
- @driver.feval "to_octave", value
15
+ @driver.put_variable("to_octave_to_ruby_variable", value)
16
+ @driver.get_variable("to_octave_to_ruby_variable")
17
17
  end
18
18
 
19
19
  def assert_octave_and_ruby_equal(value)
@@ -197,7 +197,8 @@ class ConversionsTest < Test::Unit::TestCase
197
197
 
198
198
  def test_should_convert_boolean_matrix
199
199
  assert_octave_and_ruby_equal [true, false, true]
200
- boolean_matrix = @driver.feval "eval", "x = [1,2]; (x > 2 | x < 2)"
200
+ @driver.put_variable("x", [1,2])
201
+ boolean_matrix = @driver.feval "eval", "(x > 2 | x < 2)"
201
202
  assert_equal [true, false], boolean_matrix
202
203
  end
203
204
  end
@@ -24,9 +24,12 @@ class DriverTest < Test::Unit::TestCase
24
24
 
25
25
  def test_putting_variable_with_same_name_multiple_times
26
26
  assert_equal "foo", @driver.put_variable("some_variable_name", "foo")
27
+ assert_equal "foo", @driver.get_variable("some_variable_name")
28
+
27
29
  assert_equal "bar", @driver.put_variable("some_variable_name", "bar")
28
- assert_equal "baz", @driver.put_variable("some_variable_name", "baz")
30
+ assert_equal "bar", @driver.get_variable("some_variable_name")
29
31
 
32
+ assert_equal "baz", @driver.put_variable("some_variable_name", "baz")
30
33
  assert_equal "baz", @driver.get_variable("some_variable_name")
31
34
  end
32
35
  end
@@ -19,12 +19,15 @@ class EngineTest_Init < Test::Unit::TestCase
19
19
  exception = assert_raise(LoadError) do
20
20
  engine = Octave::Engine.new(:driver => "foo")
21
21
  end
22
- assert_equal "no such file to load -- octave/driver/foo/driver", exception.message
22
+
23
+ expected_message = "-- octave/driver/foo/driver"
24
+ assert_equal expected_message, exception.message[-expected_message.length, expected_message.length]
23
25
 
24
26
  exception = assert_raise(LoadError) do
25
27
  engine = Octave::Engine.new(:driver => :bar)
26
28
  end
27
- assert_equal "no such file to load -- octave/driver/bar/driver", exception.message
29
+ expected_message = "-- octave/driver/bar/driver"
30
+ assert_equal expected_message, exception.message[-expected_message.length, expected_message.length]
28
31
  end
29
32
 
30
33
  def test_new_with_native_driver
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: octave-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.9
4
+ prerelease: false
5
+ segments:
6
+ - 2
7
+ - 0
8
+ - 0
9
+ version: 2.0.0
5
10
  platform: ruby
6
11
  authors:
7
12
  - Jonathan Younger
@@ -9,19 +14,10 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2008-12-30 00:00:00 -07:00
17
+ date: 2012-11-08 00:00:00 -07:00
13
18
  default_executable:
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: hoe
17
- type: :development
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: 1.8.2
24
- version:
19
+ dependencies: []
20
+
25
21
  description: "== USAGE: require 'octave' engine = Octave::Engine.new engine.eval \"123.456 * 789.101112\" engine.rand(10) matrix = Octave::Matrix.new(20, 400) 20.times { |m| 400.times { |n| matrix[m, n] = rand } } engine.put_variable(\"m\", matrix) engine.save \"/tmp/20_x_400_matrix\" == REQUIREMENTS: * Octave * GCC or some other compiler to build the included extension * Mocha (For testing only)"
26
22
  email:
27
23
  - jonathan@daikini.com
@@ -76,6 +72,8 @@ files:
76
72
  - test/test_engine.rb
77
73
  has_rdoc: true
78
74
  homepage: http://octave-ruby.rubyforge.org/
75
+ licenses: []
76
+
79
77
  post_install_message:
80
78
  rdoc_options:
81
79
  - --main
@@ -87,20 +85,22 @@ required_ruby_version: !ruby/object:Gem::Requirement
87
85
  requirements:
88
86
  - - ">="
89
87
  - !ruby/object:Gem::Version
88
+ segments:
89
+ - 0
90
90
  version: "0"
91
- version:
92
91
  required_rubygems_version: !ruby/object:Gem::Requirement
93
92
  requirements:
94
93
  - - ">="
95
94
  - !ruby/object:Gem::Version
95
+ segments:
96
+ - 0
96
97
  version: "0"
97
- version:
98
98
  requirements: []
99
99
 
100
100
  rubyforge_project: octave-ruby
101
- rubygems_version: 1.3.1
101
+ rubygems_version: 1.3.6
102
102
  signing_key:
103
- specification_version: 2
103
+ specification_version: 3
104
104
  summary: A Ruby interface to the Octave interpreted language.
105
105
  test_files:
106
106
  - test/driver/native/test_conversions.rb