From 9242a80a84fa5c96dbadec9594177875aeeec1ac Mon Sep 17 00:00:00 2001 From: Kirill Volinsky Date: Tue, 10 Jul 2012 18:37:21 +0000 Subject: only added MyDetails and Skins. not adopted yet git-svn-id: http://svn.miranda-ng.org/main/trunk@892 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Skins/SkinLib/DialogState_v8_wrapper.cpp | 233 +++++++++++++++++++++++ 1 file changed, 233 insertions(+) create mode 100644 plugins/Skins/SkinLib/DialogState_v8_wrapper.cpp (limited to 'plugins/Skins/SkinLib/DialogState_v8_wrapper.cpp') diff --git a/plugins/Skins/SkinLib/DialogState_v8_wrapper.cpp b/plugins/Skins/SkinLib/DialogState_v8_wrapper.cpp new file mode 100644 index 0000000000..5739414d69 --- /dev/null +++ b/plugins/Skins/SkinLib/DialogState_v8_wrapper.cpp @@ -0,0 +1,233 @@ +#include "globals.h" +#include "DialogState_v8_wrapper.h" +#include +#include "DialogState.h" + +using namespace v8; + + +#ifdef UNICODE +# define V8_TCHAR uint16_t +#else +# define V8_TCHAR char +#endif + + +static Handle Get_DialogState_width(Local property, const AccessorInfo &info) +{ + HandleScope scope; + + Local self = info.Holder(); + Local wrap = Local::Cast(self->GetInternalField(0)); + if (wrap.IsEmpty()) + return scope.Close( Undefined() ); + + DialogState *tmp = (DialogState *) wrap->Value(); + if (tmp == NULL) + return scope.Close( Undefined() ); + + return scope.Close( Int32::New(tmp->getWidth()) ); +} + +static void Set_DialogState_width(Local property, Local value, const AccessorInfo& info) +{ + HandleScope scope; + + Local self = info.Holder(); + Local wrap = Local::Cast(self->GetInternalField(0)); + if (wrap.IsEmpty()) + return; + + DialogState *tmp = (DialogState *) wrap->Value(); + if (tmp == NULL) + return; + + if (!value.IsEmpty() && value->IsNumber()) + tmp->setWidth(value->Int32Value()); +} + + +static Handle Get_DialogState_height(Local property, const AccessorInfo &info) +{ + HandleScope scope; + + Local self = info.Holder(); + Local wrap = Local::Cast(self->GetInternalField(0)); + if (wrap.IsEmpty()) + return scope.Close( Undefined() ); + + DialogState *tmp = (DialogState *) wrap->Value(); + if (tmp == NULL) + return scope.Close( Undefined() ); + + return scope.Close( Int32::New(tmp->getHeight()) ); +} + +static void Set_DialogState_height(Local property, Local value, const AccessorInfo& info) +{ + HandleScope scope; + + Local self = info.Holder(); + Local wrap = Local::Cast(self->GetInternalField(0)); + if (wrap.IsEmpty()) + return; + + DialogState *tmp = (DialogState *) wrap->Value(); + if (tmp == NULL) + return; + + if (!value.IsEmpty() && value->IsNumber()) + tmp->setHeight(value->Int32Value()); +} + + +static Handle Get_DialogState_x(Local property, const AccessorInfo &info) +{ + HandleScope scope; + + Local self = info.Holder(); + Local wrap = Local::Cast(self->GetInternalField(0)); + if (wrap.IsEmpty()) + return scope.Close( Undefined() ); + + DialogState *tmp = (DialogState *) wrap->Value(); + if (tmp == NULL) + return scope.Close( Undefined() ); + + return scope.Close( Int32::New(tmp->getX()) ); +} + + +static Handle Get_DialogState_y(Local property, const AccessorInfo &info) +{ + HandleScope scope; + + Local self = info.Holder(); + Local wrap = Local::Cast(self->GetInternalField(0)); + if (wrap.IsEmpty()) + return scope.Close( Undefined() ); + + DialogState *tmp = (DialogState *) wrap->Value(); + if (tmp == NULL) + return scope.Close( Undefined() ); + + return scope.Close( Int32::New(tmp->getY()) ); +} + + +static Handle Get_DialogState_left(Local property, const AccessorInfo &info) +{ + HandleScope scope; + + Local self = info.Holder(); + Local wrap = Local::Cast(self->GetInternalField(0)); + if (wrap.IsEmpty()) + return scope.Close( Undefined() ); + + DialogState *tmp = (DialogState *) wrap->Value(); + if (tmp == NULL) + return scope.Close( Undefined() ); + + return scope.Close( Int32::New(tmp->getLeft()) ); +} + + +static Handle Get_DialogState_top(Local property, const AccessorInfo &info) +{ + HandleScope scope; + + Local self = info.Holder(); + Local wrap = Local::Cast(self->GetInternalField(0)); + if (wrap.IsEmpty()) + return scope.Close( Undefined() ); + + DialogState *tmp = (DialogState *) wrap->Value(); + if (tmp == NULL) + return scope.Close( Undefined() ); + + return scope.Close( Int32::New(tmp->getTop()) ); +} + + +static Handle Get_DialogState_right(Local property, const AccessorInfo &info) +{ + HandleScope scope; + + Local self = info.Holder(); + Local wrap = Local::Cast(self->GetInternalField(0)); + if (wrap.IsEmpty()) + return scope.Close( Undefined() ); + + DialogState *tmp = (DialogState *) wrap->Value(); + if (tmp == NULL) + return scope.Close( Undefined() ); + + return scope.Close( Int32::New(tmp->getRight()) ); +} + + +static Handle Get_DialogState_bottom(Local property, const AccessorInfo &info) +{ + HandleScope scope; + + Local self = info.Holder(); + Local wrap = Local::Cast(self->GetInternalField(0)); + if (wrap.IsEmpty()) + return scope.Close( Undefined() ); + + DialogState *tmp = (DialogState *) wrap->Value(); + if (tmp == NULL) + return scope.Close( Undefined() ); + + return scope.Close( Int32::New(tmp->getBottom()) ); +} + + +static Handle Get_DialogState_borders(Local property, const AccessorInfo &info) +{ + HandleScope scope; + + Local self = info.Holder(); + Local wrap = Local::Cast(self->GetInternalField(0)); + if (wrap.IsEmpty()) + return scope.Close( Undefined() ); + + DialogState *tmp = (DialogState *) wrap->Value(); + if (tmp == NULL) + return scope.Close( Undefined() ); + + return scope.Close( self->Get(String::New("bordersRaw")) ); +} + +static void Set_DialogState_borders(Local property, Local value, const AccessorInfo& info) +{ + HandleScope scope; + + Local self = info.Holder(); + Local wrap = Local::Cast(self->GetInternalField(0)); + if (wrap.IsEmpty()) + return; + + DialogState *tmp = (DialogState *) wrap->Value(); + if (tmp == NULL) + return; + + if (!value.IsEmpty() && value->IsInt32()) + tmp->getBorders()->setAll(value->Int32Value()); +} + + +void AddDialogStateAcessors(Handle &templ) +{ + HandleScope scope; + + templ->SetAccessor(String::New("width"), Get_DialogState_width, Set_DialogState_width); + templ->SetAccessor(String::New("height"), Get_DialogState_height, Set_DialogState_height); + templ->SetAccessor(String::New("x"), Get_DialogState_x, NULL, Handle(), DEFAULT, ReadOnly); + templ->SetAccessor(String::New("y"), Get_DialogState_y, NULL, Handle(), DEFAULT, ReadOnly); + templ->SetAccessor(String::New("left"), Get_DialogState_left, NULL, Handle(), DEFAULT, ReadOnly); + templ->SetAccessor(String::New("top"), Get_DialogState_top, NULL, Handle(), DEFAULT, ReadOnly); + templ->SetAccessor(String::New("right"), Get_DialogState_right, NULL, Handle(), DEFAULT, ReadOnly); + templ->SetAccessor(String::New("bottom"), Get_DialogState_bottom, NULL, Handle(), DEFAULT, ReadOnly); + templ->SetAccessor(String::New("borders"), Get_DialogState_borders, Set_DialogState_borders); +} -- cgit v1.2.3