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