octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Minor oop fix.


From: Robert T. Short
Subject: Minor oop fix.
Date: Mon, 27 Apr 2009 13:18:41 -0700
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.21) Gecko/20090402 SeaMonkey/1.1.16

Attached is a minor fix that cleans up a couple of "FIXMEs".

Also attached are changlog entries.

Bob

# HG changeset patch
# User Robert T. Short <address@hidden>
# Date 1240863382 25200
# Node ID 2b123c389862bea82ac91e6aa742c4197caca7df
# Parent  ad20b967e1c951c3a736043c5d645694a3aa130c
liboctave/file-ops.h: Added a method to extract the trailing element
of a path.

src/ov-base.h: Returning a zero is ok, so removed the FIXME.

src/ov-class.cc: Cleaned up the way the method class name is
discovered.

diff -r ad20b967e1c9 -r 2b123c389862 liboctave/ChangeLog
--- a/liboctave/ChangeLog       Sun Apr 26 22:19:57 2009 -0700
+++ b/liboctave/ChangeLog       Mon Apr 27 13:16:22 2009 -0700
@@ -1,3 +1,8 @@
+2009-04-27  Robert T. Short <address@hidden>
+
+        * Added a tail () function to extract the last element of a path.
+
+
 2009-04-16  Jaroslav Hajek  <address@hidden>
 
        * idx-vector.cc (idx_vector::idx_range_rep::idx_range_rep (const
diff -r ad20b967e1c9 -r 2b123c389862 liboctave/file-ops.h
--- a/liboctave/file-ops.h      Sun Apr 26 22:19:57 2009 -0700
+++ b/liboctave/file-ops.h      Mon Apr 27 13:16:22 2009 -0700
@@ -109,6 +109,18 @@
     return static_members::dir_sep_chars ();
   }
 
+  // Return the tail member of a path.
+  static std::string tail (std::string path)
+  {
+    size_t ipos = path.find_last_of (dir_sep_char ());
+
+    if (ipos != std::string::npos)
+      ipos++;
+    else
+      ipos = 0;
+    return path.substr (ipos);
+  }
+
 private:
 
   // Use a singleton class for these data members instead of just
diff -r ad20b967e1c9 -r 2b123c389862 src/ChangeLog
--- a/src/ChangeLog     Sun Apr 26 22:19:57 2009 -0700
+++ b/src/ChangeLog     Mon Apr 27 13:16:22 2009 -0700
@@ -1,3 +1,11 @@
+2009-04-27  Robert T. Short <address@hidden>
+        A couple of FIXMEs
+        * ov-class.cc: Fixed get_current_method_class to extract the class
+          name properly.
+        * ov-base.h: Removed the fixme comment.  Since a zero is returned 
+          when a parent class is not found, it shouldn't be a problem for
+          the base class to return a zero.
+
 2009-04-23  John W. Eaton  <address@hidden>
 
        * ov-class.cc (Fclass): Check newly constructed classes against
diff -r ad20b967e1c9 -r 2b123c389862 src/ov-base.h
--- a/src/ov-base.h     Sun Apr 26 22:19:57 2009 -0700
+++ b/src/ov-base.h     Mon Apr 27 13:16:22 2009 -0700
@@ -458,7 +458,6 @@
 
   virtual string_vector parent_class_names (void) const;
 
-  // FIXME -- should this warn if called for a non-class type?
   virtual octave_base_value *find_parent_class (const std::string&)
     { return 0; }
 
diff -r ad20b967e1c9 -r 2b123c389862 src/ov-class.cc
--- a/src/ov-class.cc   Sun Apr 26 22:19:57 2009 -0700
+++ b/src/ov-class.cc   Mon Apr 27 13:16:22 2009 -0700
@@ -33,6 +33,7 @@
 #include "Cell.h"
 #include "defun.h"
 #include "error.h"
+#include "file-ops.h"
 #include "gripes.h"
 #include "load-path.h"
 #include "ls-hdf5.h"
@@ -96,16 +97,13 @@
 static std::string
 get_current_method_class (void)
 {
-  // FIXME -- is there a better way to do this?
   octave_function *fcn = octave_call_stack::current ();
 
   std::string my_dir = fcn->dir_name ();
 
-  size_t ipos = my_dir.find_last_of ("@");
+  std::string method_class = file_ops::tail(my_dir);
 
-  assert (ipos != std::string::npos);
-
-  return my_dir.substr (ipos+1);
+  return method_class.substr (1);
 }
 
 static void

reply via email to

[Prev in Thread] Current Thread [Next in Thread]