<commit_before>/*
 * Copyright (C) 2009, <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 <libport/compiler.hh>
#include <libport/debug.hh>
#include <iostream>
#include <sstream>

#include <libport/unistd.h>

#include <urbi/uobject.hh>

GD_CATEGORY(all);

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

  all(const std::string& name)
    : urbi::UObject(name)
  {
    UBindFunction(all, init);
    UBindFunction(all, setOwned);
    UBindFunction(all, setNotifyChange);

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

    UBindFunction(all, setNotifyAccess);
    UBindFunction(all, setNotifyChangeByName);
    UBindFunction(all, setNotifyChangeByUVar);
    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);
    UBindVar(all,b);
    UBindVar(all,c);
    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);
    UBindFunction(all, writeL);
    UBindFunction(all, writeB);
    UBindFunction(all, writeBNone);
    UBindFunction(all, writeI);
    UBindFunction(all, writeSnd);
    UBindFunction(all, writeRI);
    UBindFunction(all, writeRSnd);

    UBindFunction(all, transmitD);
    UBindFunction(all, transmitS);
    UBindFunction(all, transmitL);
    UBindFunction(all, transmitB);
    UBindFunction(all, transmitI);
    UBindFunction(all, transmitSnd);

    UBindFunction(all, loop_yield);
    UBindFunction(all, yield_for);
    UBindFunction(urbi::UContext, side_effect_free_get);
    UBindFunction(urbi::UContext, side_effect_free_set);
    UBindFunction(urbi::UContext, yield);
    UBindFunction(urbi::UContext, yield_until_things_changed);

    UBindFunction(all, getDestructionCount);

    vars[0] = &a;
    vars[1] = &b;
    vars[2] = &c;
  }

  ~all()
  {
    ++destructionCount;
  }

  int setBypassNotifyChangeBinary(const std::string& name)
  {
    UNotifyChange(name, &all::onBinaryBypass);
    return 0;
  }
  int setBypassNotifyChangeImage(const std::string& name)
  {
    UNotifyChange(name, &all::onImageBypass);
    return 0;
  }
  int markBypass(int id, bool state)
  {
    return vars[id]->setBypass(state);
  }
  int onBinaryBypass(urbi::UVar& var)
  {
    const urbi::UBinary& cb = var;
    std::cerr << "onbin cptr " << cb.common.data << std::endl;
    urbi::UBinary& b = const_cast<urbi::UBinary&>(cb);
    for (unsigned int i=0; i<b.common.size; ++i)
      ((char*)b.common.data)[i]++;
    return 0;
  }
  int onImageBypass(urbi::UVar& var)
  {
    const urbi::UImage& cb = var;
    std::cerr << "onimg cptr " << (void*)cb.data << std::endl;
    urbi::UImage& b = const_cast<urbi::UImage&>(cb);
    for (unsigned int i=0; i<b.size; ++i)
      b.data[i]++;
    return 0;
  }
  std::string selfWriteB(int idx, const std::string& content)
  {
    urbi::UBinary b;
    b.type = urbi::BINARY_IMAGE;
    // Dup since we want to test no-copy op: the other end will write.
    b.common.data = strdup(content.c_str());
    b.common.size = content.length();
    std::cerr <<"writeB cptr " << b.common.data << std::endl;
    *vars[idx] = b;
    std::string res((char*)b.common.data, b.common.size);
    free(b.common.data);
    b.common.data = 0;
    return res;
  }
  std::string selfWriteI(int idx, const std::string& content)
  {
    urbi::UImage i;
    i.data = (unsigned char*)strdup(content.c_str());
    std::cerr <<"writeI cptr " << (void*)i.data << std::endl;
    i.size = content.length();
    *vars[idx] = i;
    std::string res((char*)i.data, i.size);
    free(i.data);
    return res;

  }
  int writeOwnByName(const std::string& name, int val)
  {
    urbi::UVar v(__name + "." + name);
    v = val;
    return 0;
  }<commit_msg>Formatting changes.<commit_after>/*
 * Copyright (C) 2009, <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 <libport/compiler.hh>
#include <libport/debug.hh>
#include <iostream>
#include <sstream>

#include <libport/unistd.h>

#include <urbi/uobject.hh>

GD_CATEGORY(all);

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

  all(const std::string& name)
    : urbi::UObject(name)
  {
    UBindFunction(all, init);
    UBindFunction(all, setOwned);
    UBindFunction(all, setNotifyChange);

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

    UBindFunction(all, setNotifyAccess);
    UBindFunction(all, setNotifyChangeByName);
    UBindFunction(all, setNotifyChangeByUVar);
    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);
    UBindVar(all,b);
    UBindVar(all,c);
    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);
    UBindFunction(all, writeL);
    UBindFunction(all, writeB);
    UBindFunction(all, writeBNone);
    UBindFunction(all, writeI);
    UBindFunction(all, writeSnd);
    UBindFunction(all, writeRI);
    UBindFunction(all, writeRSnd);

    UBindFunction(all, transmitD);
    UBindFunction(all, transmitS);
    UBindFunction(all, transmitL);
    UBindFunction(all, transmitB);
    UBindFunction(all, transmitI);
    UBindFunction(all, transmitSnd);

    UBindFunction(all, loop_yield);
    UBindFunction(all, yield_for);
    UBindFunction(urbi::UContext, side_effect_free_get);
    UBindFunction(urbi::UContext, side_effect_free_set);
    UBindFunction(urbi::UContext, yield);
    UBindFunction(urbi::UContext, yield_until_things_changed);

    UBindFunction(all, getDestructionCount);

    vars[0] = &a;
    vars[1] = &b;
    vars[2] = &c;
  }

  ~all()
  {
    ++destructionCount;
  }

  int setBypassNotifyChangeBinary(const std::string& name)
  {
    UNotifyChange(name, &all::onBinaryBypass);
    return 0;
  }
  int setBypassNotifyChangeImage(const std::string& name)
  {
    UNotifyChange(name, &all::onImageBypass);
    return 0;
  }
  int markBypass(int id, bool state)
  {
    return vars[id]->setBypass(state);
  }
  int onBinaryBypass(urbi::UVar& var)
  {
    const urbi::UBinary& cb = var;
    std::cerr << "onbin cptr " << cb.common.data << std::endl;
    urbi::UBinary& b = const_cast<urbi::UBinary&>(cb);
    for (unsigned int i=0; i<b.common.size; ++i)
      ((char*)b.common.data)[i]++;
    return 0;
  }
  int onImageBypass(urbi::UVar& var)
  {
    const urbi::UImage& cb = var;
    std::cerr << "onimg cptr " << (void*)cb.data << std::endl;
    urbi::UImage& b = const_cast<urbi::UImage&>(cb);
    for (unsigned int i=0; i<b.size; ++i)
      b.data[i]++;
    return 0;
  }
  std::string selfWriteB(int idx, const std::string& content)
  {
    urbi::UBinary b;
    b.type = urbi::BINARY_IMAGE;
    // Dup since we want to test no-copy op: the other end will write.
    b.common.data = strdup(content.c_str());
    b.common.size = content.length();
    std::cerr << "writeB cptr " << b.common.data << std::endl;
    *vars[idx] = b;
    std::string res((char*)b.common.data, b.common.size);
    free(b.common.data);
    b.common.data = 0;
    return res;
  }
  std::string selfWriteI(int idx, const std::string& content)
  {
    urbi::UImage i;
    i.data = (unsigned char*)strdup(content.c_str());
    std::cerr << "writeI cptr " << (void*)i.data << std::endl;
    i.size = content.length();
    *vars[idx] = i;
    std::string res((char*)i.data, i.size);
    free(i.data);
    return res;

  }
  int writeOwnByName(const std::string& name, int val)
  {
    urbi::UVar v(__name + "." + name);
    v = val;
    return 0;
  }
{'fraction_non_alphanumeric': 0.14293171852161202, 'fraction_numerical': 0.003549801628732512, 'mean_word_length': 3.8403233956543708, 'pattern_counts': {'":': 0, '<': 73, '<?xml version=': 0, '>': 23, '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': '5435697', 'n_tokens_mistral': 3461, 'n_tokens_neox': 3423, 'n_words': 691}