summaryrefslogtreecommitdiff
path: root/Plugins/skins/SkinLib/SkinOption_v8_wrapper.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Plugins/skins/SkinLib/SkinOption_v8_wrapper.cpp')
-rw-r--r--Plugins/skins/SkinLib/SkinOption_v8_wrapper.cpp105
1 files changed, 105 insertions, 0 deletions
diff --git a/Plugins/skins/SkinLib/SkinOption_v8_wrapper.cpp b/Plugins/skins/SkinLib/SkinOption_v8_wrapper.cpp
new file mode 100644
index 0000000..61e1c14
--- /dev/null
+++ b/Plugins/skins/SkinLib/SkinOption_v8_wrapper.cpp
@@ -0,0 +1,105 @@
+#include "globals.h"
+#include "SkinOption_v8_wrapper.h"
+#include <v8.h>
+#include "SkinOption.h"
+#include "utf8_helpers.h"
+
+using namespace v8;
+
+
+#ifdef UNICODE
+# define V8_TCHAR uint16_t
+#else
+# define V8_TCHAR char
+#endif
+
+
+static Handle<Value> Get_SkinOption_description(Local<String> property, const AccessorInfo &info)
+{
+ Local<Object> self = info.Holder();
+ Local<External> wrap = Local<External>::Cast(self->GetInternalField(0));
+ SkinOption *tmp = (SkinOption *) wrap->Value();
+ return String::New((const V8_TCHAR *) tmp->getDescription());
+}
+
+static void Set_SkinOption_description(Local<String> property, Local<Value> value, const AccessorInfo& info)
+{
+ Local<Object> self = info.Holder();
+ Local<External> wrap = Local<External>::Cast(self->GetInternalField(0));
+ SkinOption *tmp = (SkinOption *) wrap->Value();
+ String::Utf8Value utf8_value(value);
+ tmp->setDescription(Utf8ToTchar(*utf8_value));
+}
+
+
+static Handle<Value> Get_SkinOption_min(Local<String> property, const AccessorInfo &info)
+{
+ Local<Object> self = info.Holder();
+ Local<External> wrap = Local<External>::Cast(self->GetInternalField(0));
+ SkinOption *tmp = (SkinOption *) wrap->Value();
+ return Int32::New(tmp->getMin());
+}
+
+static void Set_SkinOption_min(Local<String> property, Local<Value> value, const AccessorInfo& info)
+{
+ Local<Object> self = info.Holder();
+ Local<External> wrap = Local<External>::Cast(self->GetInternalField(0));
+ SkinOption *tmp = (SkinOption *) wrap->Value();
+ tmp->setMin(value->Int32Value());
+}
+
+
+static Handle<Value> Get_SkinOption_max(Local<String> property, const AccessorInfo &info)
+{
+ Local<Object> self = info.Holder();
+ Local<External> wrap = Local<External>::Cast(self->GetInternalField(0));
+ SkinOption *tmp = (SkinOption *) wrap->Value();
+ return Int32::New(tmp->getMax());
+}
+
+static void Set_SkinOption_max(Local<String> property, Local<Value> value, const AccessorInfo& info)
+{
+ Local<Object> self = info.Holder();
+ Local<External> wrap = Local<External>::Cast(self->GetInternalField(0));
+ SkinOption *tmp = (SkinOption *) wrap->Value();
+ tmp->setMax(value->Int32Value());
+}
+
+
+static Handle<Value> Get_SkinOption_type(Local<String> property, const AccessorInfo &info)
+{
+ Local<Object> self = info.Holder();
+ Local<External> wrap = Local<External>::Cast(self->GetInternalField(0));
+ SkinOption *tmp = (SkinOption *) wrap->Value();
+ switch(tmp->getType())
+ {
+ case CHECKBOX: return String::New((const V8_TCHAR *) _T("CHECKBOX"));
+ case NUMBER: return String::New((const V8_TCHAR *) _T("NUMBER"));
+ case TEXT: return String::New((const V8_TCHAR *) _T("TEXT"));
+ }
+ return Undefined();
+}
+
+static void Set_SkinOption_type(Local<String> property, Local<Value> value, const AccessorInfo& info)
+{
+ Local<Object> self = info.Holder();
+ Local<External> wrap = Local<External>::Cast(self->GetInternalField(0));
+ SkinOption *tmp = (SkinOption *) wrap->Value();
+ 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<ObjectTemplate> &templ)
+{
+ 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);
+}