octave-maintainers
[Top][All Lists]
Advanced

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

Re: OOP and load/save


From: Robert T. Short
Subject: Re: OOP and load/save
Date: Wed, 22 Apr 2009 18:42:58 -0700
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.21) Gecko/20090402 SeaMonkey/1.1.16

John W. Eaton wrote:
On 22-Apr-2009, Robert T. Short wrote:

| I have no idea how to cause the constructor to
| be parsed and executed, but I am sure I can figure this out.

Something like this should work:

DEFUN (doit, args, , "")
{
  octave_value retval;

  if (args.length () == 1)
    {
      std::string cname = args(0).string_value ();

      octave_value ctor = symbol_table::find_method (cname, cname);

      if (ctor.is_defined ())
        {
          octave_value_list result = feval (ctor, 1);

          if (result.length () == 1)
            {
              octave_value object  = result(0);

              // do something with the newly constructed object...
              retval = object;
            }
          else
            error ("call to constructor for class %s failed", cname.c_str ());
        }
      else
        error ("no constructor for class %s", cname.c_str ());
    }
  else
    print_usage ();

  return retval;
}

Play with it as is, or extract what you need...

jwe


Not sure I understand at a glance, but thanks and I will work at it.

Bob



reply via email to

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