octave-maintainers
[Top][All Lists]
Advanced

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

Re: Mex Extensions


From: David Bateman
Subject: Re: Mex Extensions
Date: Thu, 11 Jan 2007 14:18:19 +0100
User-agent: Thunderbird 1.5.0.7 (X11/20060921)

John W. Eaton wrote:
> On 10-Jan-2007, David Bateman wrote:
>
> | If no help is found in an oct-file it shouldn't go looking for it in an
> | m-file...
>
> Octave already does this.  
Does it? If the doc string is empty then (help.cc)help_from_symbol_table
returns false and then if an m-file is found (help.cc)help_from_file
takes the help from there.

> One case where this behavior makes sense is
> if you have both .oct and .mex versions of a function (you need .mex
> for Matlab and you want to use .oct for Octave so that you avoid the
> data copying issues with using .mex in Octave) and you only want to
> store the doc string in one place.  In that case, you should omit it
> from the .oct file and store it in a corresponding .m file and then it
> will work for both Octave and Matlab without having to have two copies
> of the doc string.
>   
So the current behavior is desired, and you see a reason to look in a
m-file for the doc string if the oct-file doesn't have help?

However, that isn't the only situation my previous suggestion addressed.
It also fixed the header to state where the function was defined not
where the help came from. To get the behavior you want help_from_file
should look something like


static bool
help_from_file (std::ostream& os, const std::string& nm, bool& symbol_found)
{
  bool retval = false;

  std::string file;

  std::string header;

  if (symbol_found)
    {
      symbol_record *sym_rec = lookup_by_name (nm, 0);

      if (sym_rec && sym_rec->is_defined ())
        {
      header = sym_rec->which();
        }
      else
    symbol_found = false;
    }

  if (! symbol_found)
    header = nm + " is the file " + file + "\n\n";

  std::string h = get_help_from_file (nm, symbol_found, file);

  if (h.length () > 0)
    {
      os << header;
      display_help_text (os, h);
      os << "\n";
      retval = true;
    }

  return retval;
}

Cheers
David


-- 
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]