<commit_before>/*
 * Copyright (C) 2008-2011, <NAME>.
 *
 * This software is provided "as is" without warranty of any kind,
 * either expressed or implied, including but not limited to the
 * implied warranties of fitness for a particular purpose.
 *
 * See the LICENSE file for more information.
 */

#include <iostream>
#include <libport/cmath>
#include <libport/compiler.hh>
#include <libport/containers.hh>
#include <libport/debug.hh>
#include <libport/ufloat.hh>
#include <libport/unistd.h>
#include <sstream>
#include <stdexcept>

#include <urbi/uclient.hh>
#undef URBI
#include <urbi/uobject.hh>
#include <urbi/input-port.hh>

GD_CATEGORY(all);

/// Same as strdup, but without the \0 limitation.
static void*
memdup(const void *data, size_t size)
{
  return memcpy(malloc(size), data, size);
}


struct Point
{
  Point()
    : x(0)
    , y(0)
  {}
  double x,y;
};
struct Rect
{
  Point a;
  Point b;
};

struct PointOfInterest
{
  std::string sectorName;
  std::vector<Rect> subSectors;
  boost::unordered_map<std::string, Rect> byName;
};

URBI_REGISTER_STRUCT(Point, x, y);
URBI_REGISTER_STRUCT(Rect, a, b);
URBI_REGISTER_STRUCT(PointOfInterest, sectorName, subSectors, byName);

class all: public urbi::UObject
{
public:
  typedef urbi::UObject super_type;
  pthread_t mainthread;

  inline void threadCheck() const
  {
    aver(mainthread == pthread_self());
  }

  all()
  {
    GD_INFO_TRACE("all default ctor");
    count = 0;
    mainthread = pthread_self();
    setup();
    init(1);
  }

  all(const std::string& name)
    : urbi::UObject(name)
  {
    GD_INFO_TRACE("all string ctor");
    count = 0;
    mainthread = pthread_self();
    if (getenv("CTOR_EXCEPTION") &&
        !strcmp(getenv("CTOR_EXCEPTION"), "true"))
    throw std::runtime_error("constructor failure");
    setup();
  }

  void setup()
  {
    UBindFunction(all, init);
    UBindFunction(all, setOwned);
    UBindFunction(all, setNotifyChange);

    /** BYPASS check **/
    UBindFunction(all, setBypassNotifyChangeBinary);
    UBindFunction(all, setBypassNotifyChangeImage);
    UBindFunctions(all, markBypass, markRTP);
    UBindFunctions(all, selfWriteB, selfWriteI, selfWriteVD);

    UBindFunctions(all, setNotifyAccess, setNotifyChangeByName, setNotifyChangeByUVar, sendEvent8Args, unnotify,
                   setThreadedNotifyChange, setThreadedNotifyChangeByUVar);
    UBindFunction(all, read);
    UBindFunction(all, write);
    UBindFunction(all, readByName);
    UBindFunction(all, writeByName);
    UBindFunction(all, writeByUVar);
    UBindFunction(all, writeOwnByName);
    UBindFunction(all, urbiWriteOwnByName);
    UBindFunction(all, sendString);
    UBindFunction(all, sendBuf);
    UBindFunction(all, sendPar);
    UBindFunction(all, typeOf);
    UBindFunction(all, uobjectName);
    UBindFunction(all, allUObjectName);
    UBindVar(all,a);
    UBindVars(all, b, c, d);
    UBindVar(all, initCalled);
    initCalled = 0;
    UBindVar(all, lastChange);
    UBindVar(all, lastAccess);
    UBindVar(all, lastChangeVal);
    lastChangeVal = -1;
    UBindVar(all, lastAccessVal);
    UBindVar(all, removeNotify);
    removeNotify = "";
    // Properties.
    UBindFunction(all, readProps);
    UBindFunction(all, writeProps);

    UBindFunction(all, writeD);
    UBindFunction(all, writeS);<commit_msg>Formatting changes.<commit_after>/*
 * Copyright (C) 2008-2011, <NAME>.
 *
 * This software is provided "as is" without warranty of any kind,
 * either expressed or implied, including but not limited to the
 * implied warranties of fitness for a particular purpose.
 *
 * See the LICENSE file for more information.
 */

#include <iostream>
#include <libport/cmath>
#include <libport/compiler.hh>
#include <libport/containers.hh>
#include <libport/debug.hh>
#include <libport/ufloat.hh>
#include <libport/unistd.h>
#include <sstream>
#include <stdexcept>

#include <urbi/uclient.hh>
#undef URBI
#include <urbi/uobject.hh>
#include <urbi/input-port.hh>

GD_CATEGORY(all);

/// Same as strdup, but without the \0 limitation.
static void*
memdup(const void *data, size_t size)
{
  return memcpy(malloc(size), data, size);
}


struct Point
{
  Point()
    : x(0)
    , y(0)
  {}
  double x,y;
};
struct Rect
{
  Point a;
  Point b;
};

struct PointOfInterest
{
  std::string sectorName;
  std::vector<Rect> subSectors;
  boost::unordered_map<std::string, Rect> byName;
};

URBI_REGISTER_STRUCT(Point, x, y);
URBI_REGISTER_STRUCT(Rect, a, b);
URBI_REGISTER_STRUCT(PointOfInterest, sectorName, subSectors, byName);

class all: public urbi::UObject
{
public:
  typedef urbi::UObject super_type;
  pthread_t mainthread;

  inline void threadCheck() const
  {
    aver(mainthread == pthread_self());
  }

  all()
  {
    GD_INFO_TRACE("all default ctor");
    count = 0;
    mainthread = pthread_self();
    setup();
    init(1);
  }

  all(const std::string& name)
    : urbi::UObject(name)
  {
    GD_INFO_TRACE("all string ctor");
    count = 0;
    mainthread = pthread_self();
    if (getenv("CTOR_EXCEPTION") &&
        !strcmp(getenv("CTOR_EXCEPTION"), "true"))
    throw std::runtime_error("constructor failure");
    setup();
  }

  void setup()
  {
    UBindFunction(all, init);
    UBindFunction(all, setOwned);
    UBindFunction(all, setNotifyChange);

    /** BYPASS check **/
    UBindFunction(all, setBypassNotifyChangeBinary);
    UBindFunction(all, setBypassNotifyChangeImage);
    UBindFunctions(all, markBypass, markRTP);
    UBindFunctions(all, selfWriteB, selfWriteI, selfWriteVD);

    UBindFunctions
      (all,
       setNotifyAccess, setNotifyChangeByName, setNotifyChangeByUVar,
       sendEvent8Args,
       unnotify,
       setThreadedNotifyChange, setThreadedNotifyChangeByUVar);
    UBindFunction(all, read);
    UBindFunction(all, write);
    UBindFunction(all, readByName);
    UBindFunction(all, writeByName);
    UBindFunction(all, writeByUVar);
    UBindFunction(all, writeOwnByName);
    UBindFunction(all, urbiWriteOwnByName);
    UBindFunction(all, sendString);
    UBindFunction(all, sendBuf);
    UBindFunction(all, sendPar);
    UBindFunction(all, typeOf);
    UBindFunction(all, uobjectName);
    UBindFunction(all, allUObjectName);
    UBindVar(all,a);
    UBindVars(all, b, c, d);
    UBindVar(all, initCalled);
    initCalled = 0;
    UBindVar(all, lastChange);
    UBindVar(all, lastAccess);
    UBindVar(all, lastChangeVal);
    lastChangeVal = -1;
    UBindVar(all, lastAccessVal);
    UBindVar(all, removeNotify);
    removeNotify = "";
    // Properties.
    UBindFunction(all, readProps);
    UBindFunction(all, writeProps);

    UBindFunction(all, writeD);
    UBindFunction(all, writeS);
{'fraction_non_alphanumeric': 0.12548960530280204, 'fraction_numerical': 0.005122024706236818, 'mean_word_length': 4.166536964980545, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 33, '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': '5385258', 'n_tokens_mistral': 2312, 'n_tokens_neox': 2290, 'n_words': 501}