/* this file has been autogenerated by vtkNodeJsWrap */
/* editing this might proof futile */

#define VTK_WRAPPING_CXX
#include <nan.h>

#include "vtkObjectBaseWrap.h"
#include "../../plus/plus.h"

using namespace v8;

extern Nan::Persistent<v8::Object> vtkNodeJsNoWrap;
Nan::Persistent<v8::FunctionTemplate> VtkObjectBaseWrap::ptpl;

VtkObjectBaseWrap::VtkObjectBaseWrap()
{ }

VtkObjectBaseWrap::VtkObjectBaseWrap(vtkSmartPointer<vtkObjectBase> _native)
{ native = _native; }

VtkObjectBaseWrap::~VtkObjectBaseWrap()
{ }

void VtkObjectBaseWrap::Init(v8::Local<v8::Object> exports)
{
	Nan::SetAccessor(exports, Nan::New("vtkObjectBase").ToLocalChecked(), ConstructorGetter);
	Nan::SetAccessor(exports, Nan::New("ObjectBase").ToLocalChecked(), ConstructorGetter);
}

void VtkObjectBaseWrap::ConstructorGetter(
	v8::Local<v8::String> property,
	const Nan::PropertyCallbackInfo<v8::Value>& info)
{
	InitPtpl();
	info.GetReturnValue().Set(Nan::New(ptpl)->GetFunction());
}

void VtkObjectBaseWrap::InitPtpl()
{
	if (!ptpl.IsEmpty()) return;
	v8::Local<v8::FunctionTemplate> tpl = Nan::New<v8::FunctionTemplate>(New);
	tpl->SetClassName(Nan::New("VtkObjectBaseWrap").ToLocalChecked());
	tpl->InstanceTemplate()->SetInternalFieldCount(1);

	Nan::SetPrototypeMethod(tpl, "GetClassName", GetClassName);
	Nan::SetPrototypeMethod(tpl, "getClassName", GetClassName);

	Nan::SetPrototypeMethod(tpl, "InitializeObjectBase", InitializeObjectBase);
	Nan::SetPrototypeMethod(tpl, "initializeObjectBase", InitializeObjectBase);

#ifdef VTK_NODE_PLUS_VTKOBJECTBASEWRAP_INITPTPL
	VTK_NODE_PLUS_VTKOBJECTBASEWRAP_INITPTPL
#endif
	ptpl.Reset( tpl );
}

void VtkObjectBaseWrap::New(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	if(!info.IsConstructCall())
	{
		Nan::ThrowError("Constructor not called in a construct call.");
		return;
	}

	if(info.Length() == 0)
	{
		vtkSmartPointer<vtkObjectBase> native = vtkSmartPointer<vtkObjectBase>::New();
		VtkObjectBaseWrap* obj = new VtkObjectBaseWrap(native);
		obj->Wrap(info.This());
	}
	else
	{
		if(info[0]->ToObject() != vtkNodeJsNoWrap )
		{
			Nan::ThrowError("Parameter Error");
			return;
		}
	}

	info.GetReturnValue().Set(info.This());
}

void VtkObjectBaseWrap::GetClassName(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkObjectBaseWrap *wrapper = ObjectWrap::Unwrap<VtkObjectBaseWrap>(info.Holder());
	vtkObjectBase *native = (vtkObjectBase *)wrapper->native.GetPointer();
	char const * r;
	if(info.Length() != 0)
	{
		Nan::ThrowError("Too many parameters.");
		return;
	}
	r = native->GetClassName();
	info.GetReturnValue().Set(Nan::New(r).ToLocalChecked());
}

void VtkObjectBaseWrap::InitializeObjectBase(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkObjectBaseWrap *wrapper = ObjectWrap::Unwrap<VtkObjectBaseWrap>(info.Holder());
	vtkObjectBase *native = (vtkObjectBase *)wrapper->native.GetPointer();
		if(info.Length() != 0)
	{
		Nan::ThrowError("Too many parameters.");
		return;
	}
	native->InitializeObjectBase();
}

