octave-maintainers
[Top][All Lists]
Advanced

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

Change of current context ? (whos -file ...)


From: David Bateman
Subject: Change of current context ? (whos -file ...)
Date: Mon, 22 Sep 2008 16:01:23 +0200
User-agent: Thunderbird 2.0.0.16 (X11/20080725)

I just thought of a way to easily implement "whos -file", but I'm having issues with the use of the new symbol table code. What I thought to do was something like


     if (argv[i] == "-file")
   {
     if (i == argc - 1)
       error ("whos: -file argument must be followed by a file name");
     else
       {
         std::string nm = argv [i + 1];

         symbol_table::scope_id tmp_scope = symbol_table::alloc_scope ();

         unwind_protect::begin_frame ("do_who_file");

         symbol_table::push_scope (tmp_scope);

         unwind_protect::add (symbol_table::pop_scope);

         feval ("load", octave_value (nm), 0);

         std::string newmsg = std::string ("Variables in the file ") +
       nm + ":\n\n";

         if (!error_state)
       retval =  do_who (i - 1, argv, return_list, verbose, newmsg);

         unwind_protect::run_frame ("do_who_file");

         symbol_table::erase_scope (tmp_scope);
       }

     return retval;
   }

That if the -file flag is given treats the following argument as a file name, and all following arguments are dropped, a new context is created the file is loaded to this context and who is rerun within this temporary context.

However, the above doesn't seem to be the correct manner to push/pop the current context. Anyone see what I'm missing?

D.


--
David Bateman                                address@hidden
Motorola Labs - Paris +33 1 69 35 48 04 (Ph) Parc Les Algorithmes, Commune de St Aubin +33 6 72 01 06 33 (Mob) 91193 Gif-Sur-Yvette FRANCE +33 1 69 35 77 01 (Fax) The information contained in this communication has been classified as: [x] General Business Information [ ] Motorola Internal Use Only [ ] Motorola Confidential Proprietary



reply via email to

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