<commit_before>{% each fields|fieldsInfo as field %}
  {% if not field.ignore %}
    NAN_GETTER({{ cppClassName }}::Get{{ field.cppFunctionName }}) {
      NanScope();

      {{ cppClassName }} *wrapper = ObjectWrap::Unwrap<{{ cppClassName }}>(args.This());

      {% if field.isEnum %}
        NanReturnValue(NanNew((int)wrapper->GetValue()->{{ field.name }}));

      {% elsif field.isLibgitType | or field.payloadFor %}
        NanReturnValue(wrapper->{{ field.name }});

      {% elsif field.isCallbackFunction %}
        NanReturnValue(wrapper->{{ field.name }}->GetFunction());

      {% elsif field.cppClassName == 'String' %}
        if (wrapper->GetValue()->{{ field.name }}) {
          NanReturnValue(NanNew<String>(wrapper->GetValue()->{{ field.name }}));
        }
        else {
          NanReturnUndefined();
        }

      {% elsif field.cppClassName|isV8Value %}
        NanReturnValue(NanNew<{{ field.cppClassName }}>(wrapper->GetValue()->{{ field.name }}));
      {% endif %}
    }

    NAN_SETTER({{ cppClassName }}::Set{{ field.cppFunctionName }}) {
      NanScope();

      {{ cppClassName }} *wrapper = ObjectWrap::Unwrap<{{ cppClassName }}>(args.This());

      {% if field.isEnum %}
        if (value->IsNumber()) {
          wrapper->GetValue()->{{ field.name }} = ({{ field.cType }}) value->Int32Value();
        }

      {% elsif field.isLibgitType %}
        NanDisposePersistent(wrapper->{{ field.name }});
        wrapper->raw->{{ field.name }} = {% if not field.cType | isPointer %}*{% endif %}ObjectWrap::Unwrap<{{ field.cppClassName }}>(value->ToObject())->GetValue();

      {% elsif field.isCallbackFunction %}
        if (wrapper->{{ field.name }} != NULL) {
          delete wrapper->{{ field.name }};
        }

        if (value->IsFunction()) {
          if (!wrapper->raw->{{ field.name }}) {
            wrapper->raw->{{ field.name }} = ({{ field.cType }}){{ field.name }}_cppCallback;
          }

          wrapper->{{ field.name }} = new NanCallback(value.As<Function>());
        }

      {% elsif field.payloadFor %}
        NanAssignPersistent(wrapper->{{ field.name }}, value);

      {% elsif field.cppClassName == 'String' %}
        if (wrapper->GetValue()->{{ field.name }}) {
        }

        String::Utf8Value str(value);
        wrapper->GetValue()->{{ field.name }} = strdup(*str);

      {% elsif field.isCppClassIntType %}
        if (value->IsNumber()) {
          wrapper->GetValue()->{{ field.name }} = value->{{field.cppClassName}}Value();
        }
<commit_msg>Make callbacks on structs persist<commit_after>{% each fields|fieldsInfo as field %}
  {% if not field.ignore %}
    NAN_GETTER({{ cppClassName }}::Get{{ field.cppFunctionName }}) {
      NanScope();

      {{ cppClassName }} *wrapper = ObjectWrap::Unwrap<{{ cppClassName }}>(args.This());

      {% if field.isEnum %}
        NanReturnValue(NanNew((int)wrapper->GetValue()->{{ field.name }}));

      {% elsif field.isLibgitType | or field.payloadFor %}
        NanReturnValue(wrapper->{{ field.name }});

      {% elsif field.isCallbackFunction %}
        NanReturnValue(wrapper->{{ field.name }}->GetFunction());

      {% elsif field.cppClassName == 'String' %}
        if (wrapper->GetValue()->{{ field.name }}) {
          NanReturnValue(NanNew<String>(wrapper->GetValue()->{{ field.name }}));
        }
        else {
          NanReturnUndefined();
        }

      {% elsif field.cppClassName|isV8Value %}
        NanReturnValue(NanNew<{{ field.cppClassName }}>(wrapper->GetValue()->{{ field.name }}));
      {% endif %}
    }

    NAN_SETTER({{ cppClassName }}::Set{{ field.cppFunctionName }}) {
      NanScope();

      {{ cppClassName }} *wrapper = ObjectWrap::Unwrap<{{ cppClassName }}>(args.This());

      {% if field.isEnum %}
        if (value->IsNumber()) {
          wrapper->GetValue()->{{ field.name }} = ({{ field.cType }}) value->Int32Value();
        }

      {% elsif field.isLibgitType %}
        Handle<Object> {{ field.name }}(value->ToObject());
        NanDisposePersistent(wrapper->{{ field.name }});

        NanAssignPersistent(wrapper->{{ field.name }}, {{ field.name }});

        wrapper->raw->{{ field.name }} = {% if not field.cType | isPointer %}*{% endif %}ObjectWrap::Unwrap<{{ field.cppClassName }}>({{ field.name }}->ToObject())->GetValue();

      {% elsif field.isCallbackFunction %}
        if (wrapper->{{ field.name }} != NULL) {
          delete wrapper->{{ field.name }};
        }

        if (value->IsFunction()) {
          if (!wrapper->raw->{{ field.name }}) {
            wrapper->raw->{{ field.name }} = ({{ field.cType }}){{ field.name }}_cppCallback;
          }

          wrapper->{{ field.name }} = new NanCallback(value.As<Function>());
        }

      {% elsif field.payloadFor %}
        NanAssignPersistent(wrapper->{{ field.name }}, value);

      {% elsif field.cppClassName == 'String' %}
        if (wrapper->GetValue()->{{ field.name }}) {
        }

        String::Utf8Value str(value);
        wrapper->GetValue()->{{ field.name }} = strdup(*str);

      {% elsif field.isCppClassIntType %}
        if (value->IsNumber()) {
          wrapper->GetValue()->{{ field.name }} = value->{{field.cppClassName}}Value();
        }

{'fraction_non_alphanumeric': 0.19908204245553643, 'fraction_numerical': 0.0015299292407726143, 'mean_word_length': 2.6344683808200138, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 92, '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': '6532197', 'n_tokens_mistral': 1648, 'n_tokens_neox': 1534, 'n_words': 267}