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

#define VTK_WRAPPING_CXX
#define VTK_STREAMS_FWD_ONLY
#include <nan.h>

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

using namespace v8;

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

VtkPNGReaderWrap::VtkPNGReaderWrap()
{ }

VtkPNGReaderWrap::VtkPNGReaderWrap(vtkSmartPointer<vtkPNGReader> _native)
{ native = _native; }

VtkPNGReaderWrap::~VtkPNGReaderWrap()
{ }

void VtkPNGReaderWrap::Init(v8::Local<v8::Object> exports)
{
	Nan::SetAccessor(exports, Nan::New("vtkPNGReader").ToLocalChecked(), ConstructorGetter);
	Nan::SetAccessor(exports, Nan::New("PNGReader").ToLocalChecked(), ConstructorGetter);
}

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

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

	Nan::SetPrototypeMethod(tpl, "CanReadFile", CanReadFile);
	Nan::SetPrototypeMethod(tpl, "canReadFile", CanReadFile);

	Nan::SetPrototypeMethod(tpl, "GetDescriptiveName", GetDescriptiveName);
	Nan::SetPrototypeMethod(tpl, "getDescriptiveName", GetDescriptiveName);

	Nan::SetPrototypeMethod(tpl, "GetFileExtensions", GetFileExtensions);
	Nan::SetPrototypeMethod(tpl, "getFileExtensions", GetFileExtensions);

	Nan::SetPrototypeMethod(tpl, "GetReadSpacingFromFile", GetReadSpacingFromFile);
	Nan::SetPrototypeMethod(tpl, "getReadSpacingFromFile", GetReadSpacingFromFile);

	Nan::SetPrototypeMethod(tpl, "GetTextChunks", GetTextChunks);
	Nan::SetPrototypeMethod(tpl, "getTextChunks", GetTextChunks);

	Nan::SetPrototypeMethod(tpl, "GetTextKey", GetTextKey);
	Nan::SetPrototypeMethod(tpl, "getTextKey", GetTextKey);

	Nan::SetPrototypeMethod(tpl, "GetTextValue", GetTextValue);
	Nan::SetPrototypeMethod(tpl, "getTextValue", GetTextValue);

	Nan::SetPrototypeMethod(tpl, "NewInstance", NewInstance);
	Nan::SetPrototypeMethod(tpl, "newInstance", NewInstance);

	Nan::SetPrototypeMethod(tpl, "ReadSpacingFromFileOff", ReadSpacingFromFileOff);
	Nan::SetPrototypeMethod(tpl, "readSpacingFromFileOff", ReadSpacingFromFileOff);

	Nan::SetPrototypeMethod(tpl, "ReadSpacingFromFileOn", ReadSpacingFromFileOn);
	Nan::SetPrototypeMethod(tpl, "readSpacingFromFileOn", ReadSpacingFromFileOn);

	Nan::SetPrototypeMethod(tpl, "SafeDownCast", SafeDownCast);
	Nan::SetPrototypeMethod(tpl, "safeDownCast", SafeDownCast);

	Nan::SetPrototypeMethod(tpl, "SetReadSpacingFromFile", SetReadSpacingFromFile);
	Nan::SetPrototypeMethod(tpl, "setReadSpacingFromFile", SetReadSpacingFromFile);

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

void VtkPNGReaderWrap::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<vtkPNGReader> native = vtkSmartPointer<vtkPNGReader>::New();
		VtkPNGReaderWrap* obj = new VtkPNGReaderWrap(native);
		obj->Wrap(info.This());
	}
	else
	{
		if(info[0]->ToObject() != vtkNodeJsNoWrap )
		{
			Nan::ThrowError("Parameter Error");
			return;
		}
	}

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

void VtkPNGReaderWrap::CanReadFile(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkPNGReaderWrap *wrapper = ObjectWrap::Unwrap<VtkPNGReaderWrap>(info.Holder());
	vtkPNGReader *native = (vtkPNGReader *)wrapper->native.GetPointer();
	if(info.Length() > 0 && info[0]->IsString())
	{
		Nan::Utf8String a0(info[0]);
		int r;
		if(info.Length() != 1)
		{
			Nan::ThrowError("Too many parameters.");
			return;
		}
		r = native->CanReadFile(
			*a0
		);
		info.GetReturnValue().Set(Nan::New(r));
		return;
	}
	Nan::ThrowError("Parameter mismatch");
}

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

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

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

void VtkPNGReaderWrap::GetTextChunks(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkPNGReaderWrap *wrapper = ObjectWrap::Unwrap<VtkPNGReaderWrap>(info.Holder());
	vtkPNGReader *native = (vtkPNGReader *)wrapper->native.GetPointer();
	size_t i;
	if(info.Length() > 0 && info[0]->IsString())
	{
		Nan::Utf8String a0(info[0]);
		if(info.Length() > 1 && info[1]->IsInt32Array())
		{
			v8::Local<v8::Int32Array>a1(v8::Local<v8::Int32Array>::Cast(info[1]->ToObject()));
			if( a1->Length() < 2 )
			{
				Nan::ThrowError("Array too short.");
				return;
			}

						if(info.Length() != 2)
			{
				Nan::ThrowError("Too many parameters.");
				return;
			}
			native->GetTextChunks(
				*a0,
				(int *)(a1->Buffer()->GetContents().Data())
			);
			return;
		}
		else if(info.Length() > 1 && info[1]->IsArray())
		{
			v8::Local<v8::Array>a1(v8::Local<v8::Array>::Cast(info[1]->ToObject()));
			int b1[2];
			if( a1->Length() < 2 )
			{
				Nan::ThrowError("Array too short.");
				return;
			}

			for( i = 0; i < 2; i++ )
			{
				if( !a1->Get(i)->IsInt32() )
				{
					Nan::ThrowError("Array contents invalid.");
					return;
				}
				b1[i] = a1->Get(i)->Int32Value();
			}
						if(info.Length() != 2)
			{
				Nan::ThrowError("Too many parameters.");
				return;
			}
			native->GetTextChunks(
				*a0,
				b1
			);
			return;
		}
	}
	Nan::ThrowError("Parameter mismatch");
}

void VtkPNGReaderWrap::GetTextKey(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkPNGReaderWrap *wrapper = ObjectWrap::Unwrap<VtkPNGReaderWrap>(info.Holder());
	vtkPNGReader *native = (vtkPNGReader *)wrapper->native.GetPointer();
	if(info.Length() > 0 && info[0]->IsInt32())
	{
		char const * r;
		if(info.Length() != 1)
		{
			Nan::ThrowError("Too many parameters.");
			return;
		}
		r = native->GetTextKey(
			info[0]->Int32Value()
		);
		info.GetReturnValue().Set(Nan::New(r).ToLocalChecked());
		return;
	}
	Nan::ThrowError("Parameter mismatch");
}

void VtkPNGReaderWrap::GetTextValue(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkPNGReaderWrap *wrapper = ObjectWrap::Unwrap<VtkPNGReaderWrap>(info.Holder());
	vtkPNGReader *native = (vtkPNGReader *)wrapper->native.GetPointer();
	if(info.Length() > 0 && info[0]->IsInt32())
	{
		char const * r;
		if(info.Length() != 1)
		{
			Nan::ThrowError("Too many parameters.");
			return;
		}
		r = native->GetTextValue(
			info[0]->Int32Value()
		);
		info.GetReturnValue().Set(Nan::New(r).ToLocalChecked());
		return;
	}
	Nan::ThrowError("Parameter mismatch");
}

void VtkPNGReaderWrap::NewInstance(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkPNGReaderWrap *wrapper = ObjectWrap::Unwrap<VtkPNGReaderWrap>(info.Holder());
	vtkPNGReader *native = (vtkPNGReader *)wrapper->native.GetPointer();
	vtkPNGReader * r;
	if(info.Length() != 0)
	{
		Nan::ThrowError("Too many parameters.");
		return;
	}
	r = native->NewInstance();
	VtkPNGReaderWrap::InitPtpl();
	v8::Local<v8::Value> argv[1] =
		{ Nan::New(vtkNodeJsNoWrap) };
	v8::Local<v8::Function> cons =
		Nan::New<v8::FunctionTemplate>(VtkPNGReaderWrap::ptpl)->GetFunction();
	v8::Local<v8::Object> wo = cons->NewInstance(1, argv);
	VtkPNGReaderWrap *w = new VtkPNGReaderWrap();
	w->native = r;
	w->Wrap(wo);
	info.GetReturnValue().Set(wo);
}

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

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

void VtkPNGReaderWrap::SafeDownCast(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkPNGReaderWrap *wrapper = ObjectWrap::Unwrap<VtkPNGReaderWrap>(info.Holder());
	vtkPNGReader *native = (vtkPNGReader *)wrapper->native.GetPointer();
	if(info.Length() > 0 && info[0]->IsObject() && (Nan::New(VtkObjectBaseWrap::ptpl))->HasInstance(info[0]))
	{
		VtkObjectBaseWrap *a0 = ObjectWrap::Unwrap<VtkObjectBaseWrap>(info[0]->ToObject());
		vtkPNGReader * r;
		if(info.Length() != 1)
		{
			Nan::ThrowError("Too many parameters.");
			return;
		}
		r = native->SafeDownCast(
			(vtkObjectBase *) a0->native.GetPointer()
		);
		VtkPNGReaderWrap::InitPtpl();
		v8::Local<v8::Value> argv[1] =
			{ Nan::New(vtkNodeJsNoWrap) };
		v8::Local<v8::Function> cons =
			Nan::New<v8::FunctionTemplate>(VtkPNGReaderWrap::ptpl)->GetFunction();
		v8::Local<v8::Object> wo = cons->NewInstance(1, argv);
		VtkPNGReaderWrap *w = new VtkPNGReaderWrap();
		w->native = r;
		w->Wrap(wo);
		info.GetReturnValue().Set(wo);
		return;
	}
	Nan::ThrowError("Parameter mismatch");
}

void VtkPNGReaderWrap::SetReadSpacingFromFile(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkPNGReaderWrap *wrapper = ObjectWrap::Unwrap<VtkPNGReaderWrap>(info.Holder());
	vtkPNGReader *native = (vtkPNGReader *)wrapper->native.GetPointer();
	if(info.Length() > 0 && info[0]->IsBoolean())
	{
				if(info.Length() != 1)
		{
			Nan::ThrowError("Too many parameters.");
			return;
		}
		native->SetReadSpacingFromFile(
			info[0]->BooleanValue()
		);
		return;
	}
	Nan::ThrowError("Parameter mismatch");
}

