/* 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 "vtkAbstractContextItemWrap.h"
#include "vtkContextClipWrap.h"
#include "vtkObjectBaseWrap.h"
#include "vtkContext2DWrap.h"
#include "../../plus/plus.h"

using namespace v8;

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

VtkContextClipWrap::VtkContextClipWrap()
{ }

VtkContextClipWrap::VtkContextClipWrap(vtkSmartPointer<vtkContextClip> _native)
{ native = _native; }

VtkContextClipWrap::~VtkContextClipWrap()
{ }

void VtkContextClipWrap::Init(v8::Local<v8::Object> exports)
{
	Nan::SetAccessor(exports, Nan::New("vtkContextClip").ToLocalChecked(), ConstructorGetter);
	Nan::SetAccessor(exports, Nan::New("ContextClip").ToLocalChecked(), ConstructorGetter);
}

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

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

	Nan::SetPrototypeMethod(tpl, "GetHeight", GetHeight);
	Nan::SetPrototypeMethod(tpl, "getHeight", GetHeight);

	Nan::SetPrototypeMethod(tpl, "GetRect", GetRect);
	Nan::SetPrototypeMethod(tpl, "getRect", GetRect);

	Nan::SetPrototypeMethod(tpl, "GetWidth", GetWidth);
	Nan::SetPrototypeMethod(tpl, "getWidth", GetWidth);

	Nan::SetPrototypeMethod(tpl, "GetX", GetX);
	Nan::SetPrototypeMethod(tpl, "getX", GetX);

	Nan::SetPrototypeMethod(tpl, "GetY", GetY);
	Nan::SetPrototypeMethod(tpl, "getY", GetY);

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

	Nan::SetPrototypeMethod(tpl, "Paint", Paint);
	Nan::SetPrototypeMethod(tpl, "paint", Paint);

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

	Nan::SetPrototypeMethod(tpl, "SetClip", SetClip);
	Nan::SetPrototypeMethod(tpl, "setClip", SetClip);

	Nan::SetPrototypeMethod(tpl, "Update", Update);
	Nan::SetPrototypeMethod(tpl, "update", Update);

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

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

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

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

void VtkContextClipWrap::GetRect(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkContextClipWrap *wrapper = ObjectWrap::Unwrap<VtkContextClipWrap>(info.Holder());
	vtkContextClip *native = (vtkContextClip *)wrapper->native.GetPointer();
	size_t i;
	if(info.Length() > 0 && info[0]->IsFloat32Array())
	{
		v8::Local<v8::Float32Array>a0(v8::Local<v8::Float32Array>::Cast(info[0]->ToObject()));
		if( a0->Length() < 4 )
		{
			Nan::ThrowError("Array too short.");
			return;
		}

				if(info.Length() != 1)
		{
			Nan::ThrowError("Too many parameters.");
			return;
		}
		native->GetRect(
			(float *)(a0->Buffer()->GetContents().Data())
		);
		return;
	}
	else if(info.Length() > 0 && info[0]->IsArray())
	{
		v8::Local<v8::Array>a0(v8::Local<v8::Array>::Cast(info[0]->ToObject()));
		float b0[4];
		if( a0->Length() < 4 )
		{
			Nan::ThrowError("Array too short.");
			return;
		}

		for( i = 0; i < 4; i++ )
		{
			if( !a0->Get(i)->IsNumber() )
			{
				Nan::ThrowError("Array contents invalid.");
				return;
			}
			b0[i] = a0->Get(i)->NumberValue();
		}
				if(info.Length() != 1)
		{
			Nan::ThrowError("Too many parameters.");
			return;
		}
		native->GetRect(
			b0
		);
		return;
	}
	Nan::ThrowError("Parameter mismatch");
}

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

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

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

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

void VtkContextClipWrap::Paint(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkContextClipWrap *wrapper = ObjectWrap::Unwrap<VtkContextClipWrap>(info.Holder());
	vtkContextClip *native = (vtkContextClip *)wrapper->native.GetPointer();
	if(info.Length() > 0 && info[0]->IsObject() && (Nan::New(VtkContext2DWrap::ptpl))->HasInstance(info[0]))
	{
		VtkContext2DWrap *a0 = ObjectWrap::Unwrap<VtkContext2DWrap>(info[0]->ToObject());
		bool r;
		if(info.Length() != 1)
		{
			Nan::ThrowError("Too many parameters.");
			return;
		}
		r = native->Paint(
			(vtkContext2D *) a0->native.GetPointer()
		);
		info.GetReturnValue().Set(Nan::New(r));
		return;
	}
	Nan::ThrowError("Parameter mismatch");
}

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

void VtkContextClipWrap::SetClip(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkContextClipWrap *wrapper = ObjectWrap::Unwrap<VtkContextClipWrap>(info.Holder());
	vtkContextClip *native = (vtkContextClip *)wrapper->native.GetPointer();
	if(info.Length() > 0 && info[0]->IsNumber())
	{
		if(info.Length() > 1 && info[1]->IsNumber())
		{
			if(info.Length() > 2 && info[2]->IsNumber())
			{
				if(info.Length() > 3 && info[3]->IsNumber())
				{
										if(info.Length() != 4)
					{
						Nan::ThrowError("Too many parameters.");
						return;
					}
					native->SetClip(
						info[0]->NumberValue(),
						info[1]->NumberValue(),
						info[2]->NumberValue(),
						info[3]->NumberValue()
					);
					return;
				}
			}
		}
	}
	Nan::ThrowError("Parameter mismatch");
}

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

