<commit_before>#ifndef _WLCJS_H
#define _WLCJS_H

extern "C" {
#include <wlc/wlc.h>
}

#include <node.h>
#include <stdarg.h>
#include "uv.h"

namespace wlcjs {

using v8::Isolate;
using v8::HandleScope;
using v8::Object;
using v8::Local;
using v8::Value;
using v8::String;
using v8::Function;
using v8::Persistent;
using v8::Number;
using v8::Integer;
using v8::FunctionCallbackInfo;
using v8::Exception;
using v8::Array;
using v8::FunctionTemplate;
using v8::ObjectTemplate;
using v8::AccessorSignature;
using v8::PropertyCallbackInfo;
using v8::AccessControl;
using v8::PropertyAttribute;
using v8::Undefined;
using v8::Boolean;
using v8::Signature;
using v8::MaybeLocal;
using v8::Maybe;
using v8::Nothing;
using v8::Just;
using v8::NewStringType;
using v8::Context;
using v8::TryCatch;

#define ISOLATE(V) Isolate* isolate = (V).GetIsolate();

#define MK_VARIADIC(ORIGIN, LAST_ARG) {\
  va_list args; \
  va_start(args, LAST_ARG); \
  auto result = ORIGIN(LAST_ARG, args); \
  va_end(args); \
  return result;\
}

#define MK_VARIADIC_N(ORIGIN, LAST_ARG, ...) {\
  va_list args; \
  va_start(args, LAST_ARG); \
  auto result = ORIGIN(__VA_ARGS__, LAST_ARG, args); \
  va_end(args); \
  return result;\
}


inline Local<String> NewString(const char* s) {
  return String::NewFromUtf8(Isolate::GetCurrent(), s, NewStringType::kInternalized).ToLocalChecked();
}

inline Local<String> NewStringFormated(const char* format, va_list args) {
  char buffer[256];
  vsnprintf(buffer, 256, format, args);
  return NewString(buffer);
}

inline Local<String> NewStringFormated(const char* format, ...)
  MK_VARIADIC(NewStringFormated, format)

inline void ThrowException(Local<Value> (*ex)(Local<String>), const char* format, ...) {
  va_list args;
  va_start(args, format);
  Isolate::GetCurrent()->ThrowException(ex(NewStringFormated(format, args)));
  va_end(args);
}

#define THROW(T, ...) do {\
  ThrowException(Exception::T, ##__VA_ARGS__);\
  return;\
} while(0)

#define RETURN(A, V) \
  (A).GetReturnValue().Set(V);\
  return;

#define METHOD(N) void N(const FunctionCallbackInfo<Value>& info)

#define DEFINE_METHOD(TPL, NAME, FN) do {\
  Local<Function> fn;\
  MaybeLocal<Function> maybe_fn =\
    FunctionTemplate::New(\<commit_msg>Simplify ThrowException<commit_after>#ifndef _WLCJS_H
#define _WLCJS_H

extern "C" {
#include <wlc/wlc.h>
}

#include <node.h>
#include <stdarg.h>
#include "uv.h"

namespace wlcjs {

using v8::Isolate;
using v8::HandleScope;
using v8::Object;
using v8::Local;
using v8::Value;
using v8::String;
using v8::Function;
using v8::Persistent;
using v8::Number;
using v8::Integer;
using v8::FunctionCallbackInfo;
using v8::Exception;
using v8::Array;
using v8::FunctionTemplate;
using v8::ObjectTemplate;
using v8::AccessorSignature;
using v8::PropertyCallbackInfo;
using v8::AccessControl;
using v8::PropertyAttribute;
using v8::Undefined;
using v8::Boolean;
using v8::Signature;
using v8::MaybeLocal;
using v8::Maybe;
using v8::Nothing;
using v8::Just;
using v8::NewStringType;
using v8::Context;
using v8::TryCatch;

#define ISOLATE(V) Isolate* isolate = (V).GetIsolate();

inline Local<String> NewString(const char* s) {
  return String::NewFromUtf8(Isolate::GetCurrent(), s, NewStringType::kInternalized).ToLocalChecked();
}

inline void ThrowException(Local<Value> (*ex)(Local<String>), const char* format, ...) {
  va_list args;
  va_start(args, format);

  char buffer[256];
  vsnprintf(buffer, 256, format, args);
  Isolate::GetCurrent()->ThrowException(ex(NewString(buffer)));
  va_end(args);
}

#define THROW(T, ...) do {\
  ThrowException(Exception::T, ##__VA_ARGS__);\
  return;\
} while(0)

#define RETURN(A, V) \
  (A).GetReturnValue().Set(V);\
  return;

#define METHOD(N) void N(const FunctionCallbackInfo<Value>& info)

#define DEFINE_METHOD(TPL, NAME, FN) do {\
  Local<Function> fn;\
  MaybeLocal<Function> maybe_fn =\
    FunctionTemplate::New(\
{'fraction_non_alphanumeric': 0.15588084232152027, 'fraction_numerical': 0.019003595274781716, 'mean_word_length': 6.1599264705882355, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 25, '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': '7075051', 'n_tokens_mistral': 1459, 'n_tokens_neox': 1421, 'n_words': 316}