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/SkinOption_v8_wrapper.cpp | 179 ++++++++++++++++++++++++ 1 file changed, 179 insertions(+) create mode 100644 plugins/Skins/SkinLib/SkinOption_v8_wrapper.cpp (limited to 'plugins/Skins/SkinLib/SkinOption_v8_wrapper.cpp') diff --git a/plugins/Skins/SkinLib/SkinOption_v8_wrapper.cpp b/plugins/Skins/SkinLib/SkinOption_v8_wrapper.cpp new file mode 100644 index 0000000000..11a401ad2e --- /dev/null +++ b/plugins/Skins/SkinLib/SkinOption_v8_wrapper.cpp @@ -0,0 +1,179 @@ +#include "globals.h" +#include "SkinOption_v8_wrapper.h" +#include +#include "SkinOption.h" +#include + +using namespace v8; + + +#ifdef UNICODE +# define V8_TCHAR uint16_t +#else +# define V8_TCHAR char +#endif + + +static Handle Get_SkinOption_description(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() ); + + SkinOption *tmp = (SkinOption *) wrap->Value(); + if (tmp == NULL) + return scope.Close( Undefined() ); + + return scope.Close( String::New((const V8_TCHAR *) tmp->getDescription()) ); +} + +static void Set_SkinOption_description(Local property, Local value, const AccessorInfo& info) +{ + HandleScope scope; + + Local self = info.Holder(); + Local wrap = Local::Cast(self->GetInternalField(0)); + if (wrap.IsEmpty()) + return; + + SkinOption *tmp = (SkinOption *) wrap->Value(); + if (tmp == NULL) + return; + + if (!value.IsEmpty() && value->IsString()) + { + String::Utf8Value utf8_value(value); + tmp->setDescription(Utf8ToTchar(*utf8_value)); + } +} + + +static Handle Get_SkinOption_min(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() ); + + SkinOption *tmp = (SkinOption *) wrap->Value(); + if (tmp == NULL) + return scope.Close( Undefined() ); + + return scope.Close( Int32::New(tmp->getMin()) ); +} + +static void Set_SkinOption_min(Local property, Local value, const AccessorInfo& info) +{ + HandleScope scope; + + Local self = info.Holder(); + Local wrap = Local::Cast(self->GetInternalField(0)); + if (wrap.IsEmpty()) + return; + + SkinOption *tmp = (SkinOption *) wrap->Value(); + if (tmp == NULL) + return; + + if (!value.IsEmpty() && value->IsNumber()) + tmp->setMin(value->Int32Value()); +} + + +static Handle Get_SkinOption_max(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() ); + + SkinOption *tmp = (SkinOption *) wrap->Value(); + if (tmp == NULL) + return scope.Close( Undefined() ); + + return scope.Close( Int32::New(tmp->getMax()) ); +} + +static void Set_SkinOption_max(Local property, Local value, const AccessorInfo& info) +{ + HandleScope scope; + + Local self = info.Holder(); + Local wrap = Local::Cast(self->GetInternalField(0)); + if (wrap.IsEmpty()) + return; + + SkinOption *tmp = (SkinOption *) wrap->Value(); + if (tmp == NULL) + return; + + if (!value.IsEmpty() && value->IsNumber()) + tmp->setMax(value->Int32Value()); +} + + +static Handle Get_SkinOption_type(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() ); + + SkinOption *tmp = (SkinOption *) wrap->Value(); + if (tmp == NULL) + return scope.Close( Undefined() ); + + switch(tmp->getType()) + { + case CHECKBOX: return scope.Close( String::New((const V8_TCHAR *) _T("CHECKBOX")) ); + case NUMBER: return scope.Close( String::New((const V8_TCHAR *) _T("NUMBER")) ); + case TEXT: return scope.Close( String::New((const V8_TCHAR *) _T("TEXT")) ); + } + return scope.Close( Undefined() ); +} + +static void Set_SkinOption_type(Local property, Local value, const AccessorInfo& info) +{ + HandleScope scope; + + Local self = info.Holder(); + Local wrap = Local::Cast(self->GetInternalField(0)); + if (wrap.IsEmpty()) + return; + + SkinOption *tmp = (SkinOption *) wrap->Value(); + if (tmp == NULL) + return; + + if (!value.IsEmpty() && value->IsString()) + { + String::Utf8Value utf8_value(value); + Utf8ToTchar tval(*utf8_value); + if ( lstrcmpi(_T("CHECKBOX"), tval) == 0 ) + tmp->setType(CHECKBOX); + else if ( lstrcmpi(_T("NUMBER"), tval) == 0 ) + tmp->setType(NUMBER); + else if ( lstrcmpi(_T("TEXT"), tval) == 0 ) + tmp->setType(TEXT); + } +} + + +void AddSkinOptionAcessors(Handle &templ) +{ + HandleScope scope; + + templ->SetAccessor(String::New("description"), Get_SkinOption_description, Set_SkinOption_description); + templ->SetAccessor(String::New("min"), Get_SkinOption_min, Set_SkinOption_min); + templ->SetAccessor(String::New("max"), Get_SkinOption_max, Set_SkinOption_max); + templ->SetAccessor(String::New("type"), Get_SkinOption_type, Set_SkinOption_type); +} -- cgit v1.2.3