From 334bfbad3fda3860f51b74cd6370786ef253ad49 Mon Sep 17 00:00:00 2001 From: pescuma Date: Tue, 20 Jan 2009 23:24:30 +0000 Subject: skins: templates are kept in memory git-svn-id: http://pescuma.googlecode.com/svn/trunk/Miranda@128 c086bb3d-8645-0410-b8da-73a8550f86e7 --- Plugins/skins/SkinLib/DialogState_v8_wrapper.cpp | 105 +++++++++++++++++------ 1 file changed, 81 insertions(+), 24 deletions(-) (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 index c1c49e3..4ab4951 100644 --- a/Plugins/skins/SkinLib/DialogState_v8_wrapper.cpp +++ b/Plugins/skins/SkinLib/DialogState_v8_wrapper.cpp @@ -15,20 +15,24 @@ using namespace v8; 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 Undefined(); + return scope.Close( Undefined() ); DialogState *tmp = (DialogState *) wrap->Value(); if (tmp == NULL) - return Undefined(); + return scope.Close( Undefined() ); - return Int32::New(tmp->getWidth()); + 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()) @@ -45,20 +49,24 @@ static void Set_DialogState_width(Local property, Local value, co 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 Undefined(); + return scope.Close( Undefined() ); DialogState *tmp = (DialogState *) wrap->Value(); if (tmp == NULL) - return Undefined(); + return scope.Close( Undefined() ); - return Int32::New(tmp->getHeight()); + 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()) @@ -75,96 +83,144 @@ static void Set_DialogState_height(Local property, Local value, c 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 Undefined(); + return scope.Close( Undefined() ); DialogState *tmp = (DialogState *) wrap->Value(); if (tmp == NULL) - return Undefined(); + return scope.Close( Undefined() ); - return Int32::New(tmp->getX()); + 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 Undefined(); + return scope.Close( Undefined() ); DialogState *tmp = (DialogState *) wrap->Value(); if (tmp == NULL) - return Undefined(); + return scope.Close( Undefined() ); - return Int32::New(tmp->getY()); + 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 Undefined(); + return scope.Close( Undefined() ); DialogState *tmp = (DialogState *) wrap->Value(); if (tmp == NULL) - return Undefined(); + return scope.Close( Undefined() ); - return Int32::New(tmp->getLeft()); + 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 Undefined(); + return scope.Close( Undefined() ); DialogState *tmp = (DialogState *) wrap->Value(); if (tmp == NULL) - return Undefined(); + return scope.Close( Undefined() ); - return Int32::New(tmp->getTop()); + 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 Undefined(); + return scope.Close( Undefined() ); DialogState *tmp = (DialogState *) wrap->Value(); if (tmp == NULL) - return Undefined(); + return scope.Close( Undefined() ); - return Int32::New(tmp->getRight()); + 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 Undefined(); + return scope.Close( Undefined() ); DialogState *tmp = (DialogState *) wrap->Value(); if (tmp == NULL) - return Undefined(); + return scope.Close( Undefined() ); - return Int32::New(tmp->getBottom()); + 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); @@ -173,4 +229,5 @@ void AddDialogStateAcessors(Handle &templ) 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