changeset 10191:a552859b009a

rename member functions in prog_args class to avoid conflicts with gnulib definitions
author John W. Eaton <jwe@octave.org>
date Fri, 22 Jan 2010 16:44:01 -0500
parents 30aeda033364
children fc95c80058d8
files liboctave/ChangeLog liboctave/prog-args.cc liboctave/prog-args.h src/ChangeLog src/DLD-FUNCTIONS/__magick_read__.cc src/octave.cc
diffstat 6 files changed, 100 insertions(+), 51 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/ChangeLog	Fri Jan 22 16:34:07 2010 -0500
+++ b/liboctave/ChangeLog	Fri Jan 22 16:44:01 2010 -0500
@@ -1,3 +1,9 @@
+2010-01-22  John W. Eaton  <jwe@octave.org>
+
+	* prog-args.h (prog_args::get_option): Rename from getopt. Now const.
+	(prog_args::option_argument): Rename from optarg.  Now const.
+	(prog_args::option_index): Rename from optind.  Now const.
+
 2010-01-22  John W. Eaton  <jwe@octave.org>
 
 	* file-ops.cc: Don't include statdefs.h.
--- a/liboctave/prog-args.cc	Fri Jan 22 16:34:07 2010 -0500
+++ b/liboctave/prog-args.cc	Fri Jan 22 16:44:01 2010 -0500
@@ -29,7 +29,7 @@
 #include "prog-args.h"
 
 int
-prog_args::getopt (void)
+prog_args::get_option (void) const
 {
   if (long_opts)
     return ::octave_getopt_long
@@ -40,13 +40,13 @@
 }
 
 const char *
-prog_args::optarg (void)
+prog_args::option_argument (void) const
 {
   return ::optarg;
 }
 
 int
-prog_args::optind (void)
+prog_args::option_index (void) const
 {
   return ::optind;
 }
--- a/liboctave/prog-args.h	Fri Jan 22 16:34:07 2010 -0500
+++ b/liboctave/prog-args.h	Fri Jan 22 16:44:01 2010 -0500
@@ -55,11 +55,11 @@
 
   ~prog_args (void) { }
 
-  int getopt (void);
+  int get_option (void) const;
 
-  const char *optarg (void);
+  const char *option_argument (void) const;
 
-  int optind (void);
+  int option_index (void) const;
 
 private:
 
--- a/src/ChangeLog	Fri Jan 22 16:34:07 2010 -0500
+++ b/src/ChangeLog	Fri Jan 22 16:44:01 2010 -0500
@@ -1,3 +1,8 @@
+2010-01-22  John W. Eaton  <jwe@octave.org>
+
+	* octave.cc (octave_main): Use new names for prog_args member
+	functions.
+
 2010-01-22  John W. Eaton  <jwe@octave.org>
 
 	* octave.cc: Don't include sys/types.h, unistd.h, or fstream.
--- a/src/DLD-FUNCTIONS/__magick_read__.cc	Fri Jan 22 16:34:07 2010 -0500
+++ b/src/DLD-FUNCTIONS/__magick_read__.cc	Fri Jan 22 16:44:01 2010 -0500
@@ -35,7 +35,29 @@
 
 #include <Magick++.h>
 
-unsigned int
+template <class P, unsigned int depth, unsigned int quantumdepth>
+inline P
+scale_quantum_to_depth (const Magick::Quantum& quantum)
+{
+  return (static_cast<P> (static_cast<double> (quantum)
+                                     / MaxRGB * ((1 << depth) - 1)));
+}
+
+template <>
+inline octave_uint8
+scale_quantum_to_depth<octave_uint8, 8, 8> (const Magick::Quantum& quantum)
+{
+  return static_cast<octave_uint8> (quantum);
+}
+
+template <>
+inline octave_uint16
+scale_quantum_to_depth<octave_uint16, 16, 16> (const Magick::Quantum& quantum)
+{
+  return static_cast<octave_uint16> (quantum);
+}
+
+inline unsigned int
 scale_quantum_to_depth (const Magick::Quantum& quantum, unsigned int depth)
 {
   return (static_cast<unsigned int> (static_cast<double> (quantum)
@@ -190,7 +212,7 @@
   return output;
 }
 
-template <class T>
+template <class T, class P, unsigned int D>
 octave_value_list
 read_images (const std::vector<Magick::Image>& imvec,
              const Array<int>& frameidx, unsigned int depth)
@@ -269,31 +291,41 @@
 
     case Magick::PaletteType:
     case Magick::TrueColorType:
-      idim(2) = 3;
-      im = T (idim);
-      for (int frame = 0; frame < nframes; frame++)
-        {
-          const Magick::PixelPacket *pix
-            = imvec[frameidx(frame)].getConstPixels (0, 0, columns, rows);
+      {
+        idim(2) = 3;
+        im = T (idim);
+        P *vec = reinterpret_cast<P *> (im.fortran_vec ());
 
-          int i = 0;
-          idx(3) = frame;
+        for (int frame = 0; frame < nframes; frame++)
+          {
+            const Magick::PixelPacket *pix
+              = imvec[frameidx(frame)].getConstPixels (0, 0, columns, rows);
 
-          for (int y = 0; y < rows; y++)
-            {
-              idx(0) = y;
-              for (int x = 0; x < columns; x++)
-                {
-                  idx(1) = x;
-                  idx(2) = 0;
-                  im(idx) = scale_quantum_to_depth (pix[i].red, depth);
-                  idx(2) = 1;
-                  im(idx) = scale_quantum_to_depth (pix[i].green, depth);
-                  idx(2) = 2;
-                  im(idx) = scale_quantum_to_depth (pix[i].blue, depth);
-                  i++;
-                }
-            }
+            int i = 0;
+            P *rbuf, *gbuf, *bbuf;
+            rbuf = vec;
+            gbuf = vec + rows * columns;
+            bbuf = vec + rows * columns * 2;
+            for (int y = 0; y < rows; y++)
+              {
+                for (int x = 0; x < columns; x++)
+                  {
+                    *rbuf = scale_quantum_to_depth<P, D, QuantumDepth> (pix[i].red);
+                    *gbuf = scale_quantum_to_depth<P, D, QuantumDepth> (pix[i].green);
+                    *bbuf = scale_quantum_to_depth<P, D, QuantumDepth> (pix[i].blue);
+                    i++;
+                    rbuf += rows;
+                    gbuf += rows;
+                    bbuf += rows;
+                  }
+                rbuf -= rows * columns - 1;
+                gbuf -= rows * columns - 1;
+                bbuf -= rows * columns - 1;
+              }
+
+            // Next frame.
+            vec += rows * columns * 3;
+          }
         }
       break;
 
@@ -426,17 +458,23 @@
       switch (depth)
         {
         case 1:
-          output = read_images<boolNDArray> (imvec, frameidx, depth);
+          output = read_images<boolNDArray, bool, 1> (imvec, frameidx, depth);
           break;
 
         case 2:
+          output = read_images<uint8NDArray, octave_uint8, 2> (imvec, frameidx, depth) ;
+          break;
+
         case 4:
+          output = read_images<uint8NDArray, octave_uint8, 4> (imvec, frameidx, depth) ;
+          break;
+
         case 8:
-          output = read_images<uint8NDArray> (imvec, frameidx, depth) ;
+          output = read_images<uint8NDArray, octave_uint8, 8> (imvec, frameidx, depth) ;
           break;
 
         case 16:
-          output = read_images<uint16NDArray> (imvec, frameidx, depth);
+          output = read_images<uint16NDArray, octave_uint16, 16> (imvec, frameidx, depth);
           break;
 
         case 32:
--- a/src/octave.cc	Fri Jan 22 16:34:07 2010 -0500
+++ b/src/octave.cc	Fri Jan 22 16:44:01 2010 -0500
@@ -634,7 +634,7 @@
   bool read_history_file = true;
 
   int optc;
-  while ((optc = args.getopt ()) != EOF)
+  while ((optc = args.get_option ()) != EOF)
     {
       switch (optc)
 	{
@@ -667,8 +667,8 @@
 	  break;
 
 	case 'p':
-	  if (args.optarg ())
-	    load_path::set_command_line_path (args.optarg ());
+	  if (args.option_argument ())
+	    load_path::set_command_line_path (args.option_argument ());
 	  break;
 
 	case 'q':
@@ -687,38 +687,38 @@
 	  break;
 
 	case DOC_CACHE_FILE_OPTION:
-	  if (args.optarg ())
-	    bind_internal_variable ("doc_cache_file", args.optarg ());
+	  if (args.option_argument ())
+	    bind_internal_variable ("doc_cache_file", args.option_argument ());
 	  break;
 
 	case EVAL_OPTION:
-	  if (args.optarg ())
+	  if (args.option_argument ())
 	    {
 	      if (code_to_eval.empty ())
-		code_to_eval = args.optarg ();
+		code_to_eval = args.option_argument ();
 	      else
-		code_to_eval += std::string (" ") + args.optarg ();
+		code_to_eval += std::string (" ") + args.option_argument ();
 	    }
 	  break;
 
 	case EXEC_PATH_OPTION:
-	  if (args.optarg ())
-	    set_exec_path (args.optarg ());
+	  if (args.option_argument ())
+	    set_exec_path (args.option_argument ());
 	  break;
 
 	case IMAGE_PATH_OPTION:
-	  if (args.optarg ())
-	    set_image_path (args.optarg ());
+	  if (args.option_argument ())
+	    set_image_path (args.option_argument ());
 	  break;
 
 	case INFO_FILE_OPTION:
-	  if (args.optarg ())
-	    bind_internal_variable ("info_file", args.optarg ());
+	  if (args.option_argument ())
+	    bind_internal_variable ("info_file", args.option_argument ());
 	  break;
 
 	case INFO_PROG_OPTION:
-	  if (args.optarg ())
-	    bind_internal_variable ("info_program", args.optarg ());
+	  if (args.option_argument ())
+	    bind_internal_variable ("info_program", args.option_argument ());
 	  break;
 
 	case LINE_EDITING_OPTION:
@@ -817,7 +817,7 @@
   // Additional arguments are taken as command line options for the
   // script.
 
-  int last_arg_idx = args.optind ();
+  int last_arg_idx = args.option_index ();
 
   int remaining_args = argc - last_arg_idx;