help-octave
[Top][All Lists]
Advanced

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

Re: Custom type subscript assignment


From: r-j-k
Subject: Re: Custom type subscript assignment
Date: Wed, 22 Jul 2009 17:28:38 -0700 (PDT)

The problem turned out to be (subtly) that my clone() method wasn't const and so presumably wasn't being called. The reason it wasn't const is because I based my class on the make_int.cc example which has the same problem. I'm not sure if make_int.cc is still being maintained but I found it a useful resource. It currently does not compile under 3.2.0 due to a change to mlock(). Also, there is a bug in it which causes the type to be re-installed with every call to make_int(). Attached is a patch for make_int.cc for 3.2.0 which fixes these problems. I'm not sure if this works with the latest version but I know make_int.cc hasn't changed since 3.2.0.
*** octave-3.2.0/examples/make_int.cc	2009-07-23 10:13:17.000000000 +1000
--- octave-3.2.0-changed/examples/make_int.cc	2009-07-23 10:17:11.000000000 +1000
*************** class octave_value_list;
*** 31,36 ****
--- 31,37 ----
  class tree_walker;
  
  // Integer values.
+ // Compile with: mkoctfile make_int.cc
  
  class
  octave_integer : public octave_base_value
*************** public:
*** 48,54 ****
  
    ~octave_integer (void) { }
  
!   octave_base_value *clone (void) { return new octave_integer (*this); }
  
  #if 0
    void *operator new (size_t size);
--- 49,55 ----
  
    ~octave_integer (void) { }
  
!   octave_base_value *clone (void) const { return new octave_integer (*this); }
  
  #if 0
    void *operator new (size_t size);
*************** DEFBINOP (el_ldiv, integer, integer)
*** 231,247 ****
  DEFBINOP_OP (el_and, integer, integer, &&)
  DEFBINOP_OP (el_or, integer, integer, ||)
  
  DEFUN_DLD (make_int, args, ,
    "int_val = make_int (val)\n\
  \n\
  Creates an integer variable from VAL.")
  {
-   static bool type_loaded = false;
- 
    if (! type_loaded)
      {
        octave_integer::register_type ();
!       mlock ("make_int");
  
        octave_stdout << "installing integer type at type-id = "
  	   << octave_integer::static_type_id () << "\n";
--- 232,249 ----
  DEFBINOP_OP (el_and, integer, integer, &&)
  DEFBINOP_OP (el_or, integer, integer, ||)
  
+ static bool type_loaded = false;
+ 
  DEFUN_DLD (make_int, args, ,
    "int_val = make_int (val)\n\
  \n\
  Creates an integer variable from VAL.")
  {
    if (! type_loaded)
      {
+       type_loaded = true;
        octave_integer::register_type ();
!       mlock ();
  
        octave_stdout << "installing integer type at type-id = "
  	   << octave_integer::static_type_id () << "\n";
Thanks
John W. Eaton-3 wrote:
If you want help with some detail like this, I think your best bet is to post the code so other people can try it out and (maybe) give you somem help. jwe


View this message in context: Re: Custom type subscript assignment
Sent from the Octave - General mailing list archive at Nabble.com.

reply via email to

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