<commit_before>/**
 ** \file object/UVar.cc
 ** \brief Creation of the URBI object UVar.
 */

# include <kernel/userver.hh>
# include <kernel/uvalue-cast.hh>

# include <object/global.hh>
# include <object/list.hh>
# include <object/symbols.hh>
# include <object/urbi-exception.hh>
# include <object/uvar.hh>

# include <runner/runner.hh>


namespace object
{
  static inline void callNotify(runner::Runner& r, rObject self,
                                libport::Symbol notifyList) throw()
  {
    rList l = self->slot_get(notifyList).value().unsafe_cast<List>();
    objects_type args;
    args.push_back(self);
    List::value_type& callbacks = l->value_get();
    for (List::value_type::iterator i = callbacks.begin();
         i != callbacks.end(); )
    {
      try
      {
         r.apply(*i, SYMBOL(NOTIFY), args);
         ++i;
      }
      catch(UrbiException& e)
      {
        std::cerr << "Urbi Exception caught while processing notify: "
          << *e.value_get() << std::endl;
        std::cerr <<"backtrace: " << std::endl;
        rforeach (call_type c, e.backtrace_get())
        {
          std::ostringstream o;
          std::cerr << "    called from: ";
          if (c.second)
            std::cerr  << *c.second << ": ";
          std::cerr << c.first << std::endl;
        }
        i = callbacks.erase(i);
      }
      catch(...)
      {
        std::cerr << "Unknown exception caught while processing notify."
          << std::endl;
        i = callbacks.erase(i);
      }
    }
  }

  static rObject
  update_bounce(objects_type args)
  {
    //called with self slotname slotval
    check_arg_count(args.size() - 1, 2);
    libport::intrusive_ptr<UVar> rvar =
      args.front()
      ->slot_get(libport::Symbol(args[1]->as<String>()->value_get())).value()
      .unsafe_cast<UVar>();
    rvar->update_(args[2]);
    return void_class;
  }

  UVar::UVar()
    : Primitive( boost::bind(&UVar::accessor, this))
    , looping_(false)<commit_msg>Fix shutdown; when a notifychange/access loop is running.<commit_after>/**
 ** \file object/UVar.cc
 ** \brief Creation of the URBI object UVar.
 */

# include <kernel/userver.hh>
# include <kernel/uvalue-cast.hh>

# include <object/global.hh>
# include <object/list.hh>
# include <object/symbols.hh>
# include <object/urbi-exception.hh>
# include <object/uvar.hh>

# include <runner/runner.hh>


namespace object
{
  static inline void callNotify(runner::Runner& r, rObject self,
                                libport::Symbol notifyList)
  {
    rList l = self->slot_get(notifyList).value().unsafe_cast<List>();
    objects_type args;
    args.push_back(self);
    List::value_type& callbacks = l->value_get();
    for (List::value_type::iterator i = callbacks.begin();
         i != callbacks.end(); )
    {
      try
      {
         r.apply(*i, SYMBOL(NOTIFY), args);
         ++i;
      }
      catch(UrbiException& e)
      {
        std::cerr << "Urbi Exception caught while processing notify: "
          << *e.value_get() << std::endl;
        std::cerr <<"backtrace: " << std::endl;
        rforeach (call_type c, e.backtrace_get())
        {
          std::ostringstream o;
          std::cerr << "    called from: ";
          if (c.second)
            std::cerr  << *c.second << ": ";
          std::cerr << c.first << std::endl;
        }
        i = callbacks.erase(i);
      }
      catch(sched::exception& e)
      {
        throw;
      }
      catch(...)
      {
        std::cerr << "Unknown exception caught while processing notify."
          << std::endl;
        i = callbacks.erase(i);
      }
    }
  }

  static rObject
  update_bounce(objects_type args)
  {
    //called with self slotname slotval
    check_arg_count(args.size() - 1, 2);
    libport::intrusive_ptr<UVar> rvar =
      args.front()
      ->slot_get(libport::Symbol(args[1]->as<String>()->value_get())).value()
      .unsafe_cast<UVar>();
    rvar->update_(args[2]);
    return void_class;
  }

  UVar::UVar()
    : Primitive( boost::bind(&UVar::accessor, this))
    , looping_(false)
{'fraction_non_alphanumeric': 0.1594381468703795, 'fraction_numerical': 0.001971414489896501, 'mean_word_length': 2.343492586490939, 'pattern_counts': {'":': 2, '<': 75, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2597036', 'n_tokens_mistral': 1363, 'n_tokens_neox': 1342, 'n_words': 260}