<commit_before>#include <cstdio>

#include "hook.h"

int multiply(int x, int y)
{
  int r = x*y;
  return r;
}

int add(int x, int y)
{
  int r = x+y;
  return r;
}

int main()
{
  Hook<functor2<int,int,int> >* hook = new Hook<functor2<int,int,int> >;

  hook->addCallback((functor2<int,int,int>::ftype)&multiply);
  hook->addCallback((functor2<int,int,int>::ftype)&add);

  printf("We have %d callback(s)\n\n", hook->numCallbacks());

  functor2<int,int,int>::atype* args = new functor2<int,int,int>::atype(4, 5);

  printf("Calling all callbacks\n");
  hook->doAll(args);
  printf("Done!\n\n");

  if (hook->doOne(args))
  {
    printf("Yay, one of our callbacks returned true or a value that was successfully cast to boolean and evaluated thusly!\n\n");
  }
  else
  {
    printf("Apparently none of our callbacks was up to the task :(\n\n");
  }

  printf("First callback returns: %d\n", hook->doThis(0, args));
}<commit_msg>made a plugin style example<commit_after>#include <cstdio>

#include "hook.h"

int multiply(int x, int y)
{
  int r = x*y;
  return r;
}

int add(int x, int y)
{
  int r = x+y;
  return r;
}

struct Plugin
{
public:
  static Plugin* get()
  {
    static Plugin m_self;
    return &m_self;
  }

  typedef functor2<int,int,int> typeTest;
  Hook<typeTest>* hookTest;
  typedef typeTest::ftype funcTest;
  typedef typeTest::atype argsTest;

private:
  Plugin()
  {
    hookTest = new Hook<typeTest>;
  }
};

int main()
{
  Plugin::get()->hookTest->addCallback(&multiply);
  Plugin::get()->hookTest->addCallback(&add);

  printf("We have %d callback(s)\n\n", Plugin::get()->hookTest->numCallbacks());

  Plugin::argsTest* args = new Plugin::argsTest(4, 5);

  printf("Calling all callbacks\n");
  Plugin::get()->hookTest->doAll(args);
  printf("Done!\n\n");

  if (Plugin::get()->hookTest->doOne(args))
  {
    printf("Yay, one of our callbacks returned true or a value that was successfully cast to boolean and evaluated thusly!\n\n");
  }
  else
  {
    printf("Apparently none of our callbacks was up to the task :(\n\n");
  }

  printf("First callback returns: %d\n", Plugin::get()->hookTest->doThis(0, args));
}
{'fraction_non_alphanumeric': 0.1733644859813084, 'fraction_numerical': 0.006074766355140187, 'mean_word_length': 4.12200956937799, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 34, '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': '1096928', 'n_tokens_mistral': 816, 'n_tokens_neox': 781, 'n_words': 199}