<commit_before>#ifndef object_wrap_h
#define object_wrap_h

#include <v8.h>
#include <assert.h>

namespace libxmljs {

class ObjectWrap {
public:
  virtual
  ~ObjectWrap()
  {
    if (!handle_.IsEmpty()) {
      assert(handle_.IsNearDeath());
      handle_->SetInternalField(0, v8::Undefined());
      handle_.Dispose();
      handle_.Clear();
    }
  }

  template <class T>
  static inline T*
  Unwrap(
    v8::Handle<v8::Object> handle)
  {
    assert(!handle.IsEmpty());
    assert(handle->InternalFieldCount() > 0);
    return static_cast<T*>(v8::Handle<v8::External>::Cast(
        handle->GetInternalField(0))->Value());
  }

  inline void
  Wrap(
    v8::Handle<v8::Object> handle)
  {
    assert(handle_.IsEmpty());
    assert(handle->InternalFieldCount() > 0);
    handle_ = v8::Persistent<v8::Object>::New(handle);
    handle_->SetInternalField(0, v8::External::New(this));
    MakeWeak();
  }

  inline void
  MakeWeak (
    void)
  {
    handle_.MakeWeak(this, WeakCallback);
  }

  v8::Persistent<v8::Object> handle_; // ro

private:
  static void
  WeakCallback(
    v8::Persistent<v8::Value> value,
    void *data)
  {
    ObjectWrap *obj = static_cast<ObjectWrap*>(data);
    assert(value == obj->handle_);
    obj->MakeWeak();
  }
};

} // namespace node
#endif // object_wrap_h<commit_msg>strip out more node.js specifics<commit_after>#ifndef object_wrap_h
#define object_wrap_h

#include <v8.h>
#include <assert.h>

namespace libxmljs {

class ObjectWrap {
public:
  virtual
  ~ObjectWrap()
  {
    if (!handle_.IsEmpty()) {
      assert(handle_.IsNearDeath());
      handle_->SetInternalField(0, v8::Undefined());
      handle_.Dispose();
      handle_.Clear();
    }
  }

  template <class T>
  static inline T*
  Unwrap(
    v8::Handle<v8::Object> handle)
  {
    assert(!handle.IsEmpty());
    assert(handle->InternalFieldCount() > 0);
    return static_cast<T*>(v8::Handle<v8::External>::Cast(
        handle->GetInternalField(0))->Value());
  }

  inline void
  Wrap(
    v8::Handle<v8::Object> handle)
  {
    assert(handle_.IsEmpty());
    assert(handle->InternalFieldCount() > 0);
    handle_ = v8::Persistent<v8::Object>::New(handle);
    handle_->SetInternalField(0, v8::External::New(this));
  }

  v8::Persistent<v8::Object> handle_; // ro
};

} // namespace node
#endif // object_wrap_h
{'fraction_non_alphanumeric': 0.16637931034482759, 'fraction_numerical': 0.016379310344827588, 'mean_word_length': 3.688888888888889, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '3991010', 'n_tokens_mistral': 822, 'n_tokens_neox': 797, 'n_words': 136}