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/FieldState_v8_wrapper.cpp | 145 ++++++++++++++++++------ 1 file changed, 112 insertions(+), 33 deletions(-) (limited to 'Plugins/skins/SkinLib/FieldState_v8_wrapper.cpp') diff --git a/Plugins/skins/SkinLib/FieldState_v8_wrapper.cpp b/Plugins/skins/SkinLib/FieldState_v8_wrapper.cpp index a4213b1..31e0e7d 100644 --- a/Plugins/skins/SkinLib/FieldState_v8_wrapper.cpp +++ b/Plugins/skins/SkinLib/FieldState_v8_wrapper.cpp @@ -16,20 +16,24 @@ using namespace v8; static Handle Get_FieldState_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() ); FieldState *tmp = (FieldState *) wrap->Value(); if (tmp == NULL) - return Undefined(); + return scope.Close( Undefined() ); - return Int32::New(tmp->getX()); + return scope.Close( Int32::New(tmp->getX()) ); } static void Set_FieldState_x(Local property, Local value, const AccessorInfo& info) { + HandleScope scope; + Local self = info.Holder(); Local wrap = Local::Cast(self->GetInternalField(0)); if (wrap.IsEmpty()) @@ -46,20 +50,24 @@ static void Set_FieldState_x(Local property, Local value, const A static Handle Get_FieldState_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() ); FieldState *tmp = (FieldState *) wrap->Value(); if (tmp == NULL) - return Undefined(); + return scope.Close( Undefined() ); - return Int32::New(tmp->getY()); + return scope.Close( Int32::New(tmp->getY()) ); } static void Set_FieldState_y(Local property, Local value, const AccessorInfo& info) { + HandleScope scope; + Local self = info.Holder(); Local wrap = Local::Cast(self->GetInternalField(0)); if (wrap.IsEmpty()) @@ -76,20 +84,24 @@ static void Set_FieldState_y(Local property, Local value, const A static Handle Get_FieldState_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() ); FieldState *tmp = (FieldState *) 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_FieldState_width(Local property, Local value, const AccessorInfo& info) { + HandleScope scope; + Local self = info.Holder(); Local wrap = Local::Cast(self->GetInternalField(0)); if (wrap.IsEmpty()) @@ -106,20 +118,24 @@ static void Set_FieldState_width(Local property, Local value, con static Handle Get_FieldState_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() ); FieldState *tmp = (FieldState *) 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_FieldState_height(Local property, Local value, const AccessorInfo& info) { + HandleScope scope; + Local self = info.Holder(); Local wrap = Local::Cast(self->GetInternalField(0)); if (wrap.IsEmpty()) @@ -136,20 +152,24 @@ static void Set_FieldState_height(Local property, Local value, co static Handle Get_FieldState_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() ); FieldState *tmp = (FieldState *) wrap->Value(); if (tmp == NULL) - return Undefined(); + return scope.Close( Undefined() ); - return Int32::New(tmp->getLeft()); + return scope.Close( Int32::New(tmp->getLeft()) ); } static void Set_FieldState_left(Local property, Local value, const AccessorInfo& info) { + HandleScope scope; + Local self = info.Holder(); Local wrap = Local::Cast(self->GetInternalField(0)); if (wrap.IsEmpty()) @@ -166,20 +186,24 @@ static void Set_FieldState_left(Local property, Local value, cons static Handle Get_FieldState_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() ); FieldState *tmp = (FieldState *) wrap->Value(); if (tmp == NULL) - return Undefined(); + return scope.Close( Undefined() ); - return Int32::New(tmp->getTop()); + return scope.Close( Int32::New(tmp->getTop()) ); } static void Set_FieldState_top(Local property, Local value, const AccessorInfo& info) { + HandleScope scope; + Local self = info.Holder(); Local wrap = Local::Cast(self->GetInternalField(0)); if (wrap.IsEmpty()) @@ -196,20 +220,24 @@ static void Set_FieldState_top(Local property, Local value, const static Handle Get_FieldState_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() ); FieldState *tmp = (FieldState *) wrap->Value(); if (tmp == NULL) - return Undefined(); + return scope.Close( Undefined() ); - return Int32::New(tmp->getRight()); + return scope.Close( Int32::New(tmp->getRight()) ); } static void Set_FieldState_right(Local property, Local value, const AccessorInfo& info) { + HandleScope scope; + Local self = info.Holder(); Local wrap = Local::Cast(self->GetInternalField(0)); if (wrap.IsEmpty()) @@ -226,20 +254,24 @@ static void Set_FieldState_right(Local property, Local value, con static Handle Get_FieldState_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() ); FieldState *tmp = (FieldState *) wrap->Value(); if (tmp == NULL) - return Undefined(); + return scope.Close( Undefined() ); - return Int32::New(tmp->getBottom()); + return scope.Close( Int32::New(tmp->getBottom()) ); } static void Set_FieldState_bottom(Local property, Local value, const AccessorInfo& info) { + HandleScope scope; + Local self = info.Holder(); Local wrap = Local::Cast(self->GetInternalField(0)); if (wrap.IsEmpty()) @@ -256,20 +288,24 @@ static void Set_FieldState_bottom(Local property, Local value, co static Handle Get_FieldState_visible(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() ); FieldState *tmp = (FieldState *) wrap->Value(); if (tmp == NULL) - return Undefined(); + return scope.Close( Undefined() ); - return Boolean::New(tmp->isVisible()); + return scope.Close( Boolean::New(tmp->isVisible()) ); } static void Set_FieldState_visible(Local property, Local value, const AccessorInfo& info) { + HandleScope scope; + Local self = info.Holder(); Local wrap = Local::Cast(self->GetInternalField(0)); if (wrap.IsEmpty()) @@ -286,35 +322,41 @@ static void Set_FieldState_visible(Local property, Local value, c static Handle Get_FieldState_enabled(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() ); FieldState *tmp = (FieldState *) wrap->Value(); if (tmp == NULL) - return Undefined(); + return scope.Close( Undefined() ); - return Boolean::New(tmp->isEnabled()); + return scope.Close( Boolean::New(tmp->isEnabled()) ); } static Handle Get_FieldState_toolTip(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() ); FieldState *tmp = (FieldState *) wrap->Value(); if (tmp == NULL) - return Undefined(); + return scope.Close( Undefined() ); - return String::New((const V8_TCHAR *) tmp->getToolTip()); + return scope.Close( String::New((const V8_TCHAR *) tmp->getToolTip()) ); } static void Set_FieldState_toolTip(Local property, Local value, const AccessorInfo& info) { + HandleScope scope; + Local self = info.Holder(); Local wrap = Local::Cast(self->GetInternalField(0)); if (wrap.IsEmpty()) @@ -332,8 +374,44 @@ static void Set_FieldState_toolTip(Local property, Local value, c } +static Handle Get_FieldState_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() ); + + FieldState *tmp = (FieldState *) wrap->Value(); + if (tmp == NULL) + return scope.Close( Undefined() ); + + return scope.Close( self->Get(String::New("bordersRaw")) ); +} + +static void Set_FieldState_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; + + FieldState *tmp = (FieldState *) wrap->Value(); + if (tmp == NULL) + return; + + if (!value.IsEmpty() && value->IsInt32()) + tmp->getBorders()->setAll(value->Int32Value()); +} + + void AddFieldStateAcessors(Handle &templ) { + HandleScope scope; + templ->SetAccessor(String::New("x"), Get_FieldState_x, Set_FieldState_x); templ->SetAccessor(String::New("y"), Get_FieldState_y, Set_FieldState_y); templ->SetAccessor(String::New("width"), Get_FieldState_width, Set_FieldState_width); @@ -345,4 +423,5 @@ void AddFieldStateAcessors(Handle &templ) templ->SetAccessor(String::New("visible"), Get_FieldState_visible, Set_FieldState_visible); templ->SetAccessor(String::New("enabled"), Get_FieldState_enabled, NULL, Handle(), DEFAULT, ReadOnly); templ->SetAccessor(String::New("toolTip"), Get_FieldState_toolTip, Set_FieldState_toolTip); + templ->SetAccessor(String::New("borders"), Get_FieldState_borders, Set_FieldState_borders); } -- cgit v1.2.3