#include "ObjectWrap.h"

NAN_MODULE_INIT(ObjectWrap::Init) {
  v8::Local<v8::FunctionTemplate> constructorTemplate = Nan::New<v8::FunctionTemplate>(New);
  constructorTemplate->SetClassName(Nan::New("FontFace").ToLocalChecked());

  v8::Local<v8::ObjectTemplate> instanceTemplate = constructorTemplate->InstanceTemplate();
  Nan::SetAccessor(instanceTemplate, Nan::New("num_faces").ToLocalChecked(), acc_num_faces);
  instanceTemplate->SetInternalFieldCount(1);

  // constructor.Reset(isolate, constructorTemplate->GetFunction());
}

v8::Local<v8::Function> ObjectWrap::GetConstructor() {
  Nan::EscapableHandleScope scope;

  if (constructor.IsEmpty()) {
    v8::Local<v8::FunctionTemplate> tpl = Nan::New<v8::FunctionTemplate>(New);

    tpl->SetClassName(Nan::New("SassBoolean").ToLocalChecked());
    tpl->InstanceTemplate()->SetInternalFieldCount(1);
  }

  return scope.Escape(constructor);
}

// v8::Persistent<v8::Function> FontFace::constructor;

// void FontFace::New(const Nan::FunctionCallbackInfo<v8::Value>& info) {
NAN_METHOD(ObjectWrap::New) {
  FontFace* fontFace = new FontFace();
  fontFace->Wrap(info.This());
  info.GetReturnValue().Set(info.This());
}
