Loading ...
Sorry, an error occurred while loading the content.
 

Fwd: How to obtain an error string from eval_expr

Expand Messages
  • Matt Tolton
    Hi, I sent the message below to vim_dev. I figured I should forward it to this list as well in case anyone has any ideas. Thanks, Matt ... From: Matt Tolton
    Message 1 of 1 , Jun 20, 2008
      Hi,

      I sent the message below to vim_dev. I figured I should forward it to
      this list as well in case anyone has any ideas.

      Thanks,

      Matt


      ---------- Forwarded message ----------
      From: Matt Tolton <matt@...>
      Date: Fri, Jun 20, 2008 at 10:50 PM
      Subject: How to obtain an error string from eval_expr
      To: vim_dev@...


      Hi,

      I'm doing some work on MacVim and I've written a function (see below)
      to programmatically evaluate an expression in vim and convert the
      result to cocoa values. I'd like to be able to return information
      about why the evaluation failed if it does. Can anyone give me tips
      on how to get an error string or something?

      Thanks,

      Matt

      ----------------------------------------

      // This function is modeled after eval_client_expr_to_string found in main.c
      // Returns nil if there was an error evaluating the expression
      static id evalExprCocoa(NSString * expr)
      {

      char_u *s = (char_u*)[expr UTF8String];

      #ifdef FEAT_MBYTE
      s = CONVERT_FROM_UTF8(s);
      #endif

      int save_dbl = debug_break_level;
      int save_ro = redir_off;

      debug_break_level = -1;
      redir_off = 0;
      ++emsg_skip;

      typval_T * tvres = eval_expr(s, NULL);

      debug_break_level = save_dbl;
      redir_off = save_ro;
      --emsg_skip;

      setcursor();
      out_flush();

      #ifdef FEAT_MBYTE
      CONVERT_FROM_UTF8_FREE(s);
      #endif

      #ifdef FEAT_GUI
      if (gui.in_use)
      gui_update_cursor(FALSE, FALSE);
      #endif

      if (tvres == NULL)
      return nil;

      id res = vimToCocoa(tvres, 1);

      free_tv(tvres);

      return res;

      }

      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_mac" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    Your message has been successfully submitted and would be delivered to recipients shortly.