Commit 526bbe3f authored by Oleg.Korshul's avatar Oleg.Korshul Committed by Alexander Trofimov

(1.0.0.10) new V8 engine !!!!!!!!!!!!!!!!!!!

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@59115 954022d7-b5bf-4e40-9824-e11837661b57
parent 3a5745cc
...@@ -10,13 +10,26 @@ ...@@ -10,13 +10,26 @@
//#pragma comment(lib, "../../../../../../../v8/build/Debug/lib/v8_nosnapshot.ia32.lib") //#pragma comment(lib, "../../../../../../../v8/build/Debug/lib/v8_nosnapshot.ia32.lib")
//#pragma comment(lib, "../../../../../../../v8/build/Debug/lib/v8_snapshot.lib") //#pragma comment(lib, "../../../../../../../v8/build/Debug/lib/v8_snapshot.lib")
#pragma comment(lib, "../../../../../../v8/build/Release/lib/icui18n.lib") #ifdef _DEBUG
#pragma comment(lib, "../../../../../../v8/build/Release/lib/icuuc.lib") #pragma comment(lib, "../../../../../../v8_trunk/build/Debug/lib/icui18n.lib")
#pragma comment(lib, "../../../../../../v8/build/Release/lib/v8_base.ia32.lib") #pragma comment(lib, "../../../../../../v8_trunk/build/Debug/lib/icuuc.lib")
#pragma comment(lib, "../../../../../../v8/build/Release/lib/v8_nosnapshot.ia32.lib") #pragma comment(lib, "../../../../../../v8_trunk/build/Debug/lib/v8_libbase.lib")
#pragma comment(lib, "../../../../../../v8/build/Release/lib/v8_snapshot.lib") #pragma comment(lib, "../../../../../../v8_trunk/build/Debug/lib/v8_base.lib")
#pragma comment(lib, "../../../../../../v8_trunk/build/Debug/lib/v8_nosnapshot.lib")
#include "../../../../../../v8/include/v8.h" #pragma comment(lib, "../../../../../../v8_trunk/build/Debug/lib/v8_snapshot.lib")
#pragma comment(lib, "../../../../../../v8_trunk/build/Debug/lib/v8_libplatform.lib")
#else
#pragma comment(lib, "../../../../../../v8_trunk/build/Release/lib/icui18n.lib")
#pragma comment(lib, "../../../../../../v8_trunk/build/Release/lib/icuuc.lib")
#pragma comment(lib, "../../../../../../v8_trunk/build/Release/lib/v8_libbase.lib")
#pragma comment(lib, "../../../../../../v8_trunk/build/Release/lib/v8_base.lib")
#pragma comment(lib, "../../../../../../v8_trunk/build/Release/lib/v8_nosnapshot.lib")
#pragma comment(lib, "../../../../../../v8_trunk/build/Release/lib/v8_snapshot.lib")
#pragma comment(lib, "../../../../../../v8_trunk/build/Release/lib/v8_libplatform.lib")
#endif
#include "../../../../../../v8_trunk/include/v8.h"
#include "../../../../../../v8_trunk/include/libplatform/libplatform.h"
class CMemoryStream class CMemoryStream
{ {
...@@ -174,7 +187,7 @@ void _ms_write_byte(const v8::FunctionCallbackInfo<v8::Value>& args) ...@@ -174,7 +187,7 @@ void _ms_write_byte(const v8::FunctionCallbackInfo<v8::Value>& args)
BYTE arg = (BYTE)args[0]->Int32Value(); BYTE arg = (BYTE)args[0]->Int32Value();
pNative->WriteBYTE(arg); pNative->WriteBYTE(arg);
args.GetReturnValue().Set(v8::Undefined()); args.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent()));
} }
void _ms_write_bool(const v8::FunctionCallbackInfo<v8::Value>& args) void _ms_write_bool(const v8::FunctionCallbackInfo<v8::Value>& args)
{ {
...@@ -183,7 +196,7 @@ void _ms_write_bool(const v8::FunctionCallbackInfo<v8::Value>& args) ...@@ -183,7 +196,7 @@ void _ms_write_bool(const v8::FunctionCallbackInfo<v8::Value>& args)
BYTE arg = (BYTE)args[0]->BooleanValue(); BYTE arg = (BYTE)args[0]->BooleanValue();
pNative->WriteBYTE(arg ? 1 : 0); pNative->WriteBYTE(arg ? 1 : 0);
args.GetReturnValue().Set(v8::Undefined()); args.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent()));
} }
void _ms_write_long(const v8::FunctionCallbackInfo<v8::Value>& args) void _ms_write_long(const v8::FunctionCallbackInfo<v8::Value>& args)
{ {
...@@ -192,7 +205,7 @@ void _ms_write_long(const v8::FunctionCallbackInfo<v8::Value>& args) ...@@ -192,7 +205,7 @@ void _ms_write_long(const v8::FunctionCallbackInfo<v8::Value>& args)
LONG arg = (LONG)args[0]->Int32Value(); LONG arg = (LONG)args[0]->Int32Value();
pNative->WriteLONG(arg); pNative->WriteLONG(arg);
args.GetReturnValue().Set(v8::Undefined()); args.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent()));
} }
void _ms_write_double(const v8::FunctionCallbackInfo<v8::Value>& args) void _ms_write_double(const v8::FunctionCallbackInfo<v8::Value>& args)
{ {
...@@ -201,7 +214,7 @@ void _ms_write_double(const v8::FunctionCallbackInfo<v8::Value>& args) ...@@ -201,7 +214,7 @@ void _ms_write_double(const v8::FunctionCallbackInfo<v8::Value>& args)
double arg = (double)args[0]->NumberValue(); double arg = (double)args[0]->NumberValue();
pNative->WriteLONG((LONG)(arg * 100000)); pNative->WriteLONG((LONG)(arg * 100000));
args.GetReturnValue().Set(v8::Undefined()); args.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent()));
} }
void _ms_writestring1(const v8::FunctionCallbackInfo<v8::Value>& args) void _ms_writestring1(const v8::FunctionCallbackInfo<v8::Value>& args)
...@@ -209,14 +222,14 @@ void _ms_writestring1(const v8::FunctionCallbackInfo<v8::Value>& args) ...@@ -209,14 +222,14 @@ void _ms_writestring1(const v8::FunctionCallbackInfo<v8::Value>& args)
CMemoryStream* pNative = unwrap_memorystream(args.This()); CMemoryStream* pNative = unwrap_memorystream(args.This());
v8::String::Value data(args[0]); v8::String::Value data(args[0]);
pNative->WriteString((wchar_t*)*data, data.length()); pNative->WriteString((wchar_t*)*data, data.length());
args.GetReturnValue().Set(v8::Undefined()); args.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent()));
} }
void _ms_writestring2(const v8::FunctionCallbackInfo<v8::Value>& args) void _ms_writestring2(const v8::FunctionCallbackInfo<v8::Value>& args)
{ {
CMemoryStream* pNative = unwrap_memorystream(args.This()); CMemoryStream* pNative = unwrap_memorystream(args.This());
v8::String::Value data(args[0]); v8::String::Value data(args[0]);
pNative->WriteString2((wchar_t*)*data, data.length()); pNative->WriteString2((wchar_t*)*data, data.length());
args.GetReturnValue().Set(v8::Undefined()); args.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent()));
} }
void _ms_copy(const v8::FunctionCallbackInfo<v8::Value>& args) void _ms_copy(const v8::FunctionCallbackInfo<v8::Value>& args)
...@@ -229,44 +242,48 @@ void _ms_copy(const v8::FunctionCallbackInfo<v8::Value>& args) ...@@ -229,44 +242,48 @@ void _ms_copy(const v8::FunctionCallbackInfo<v8::Value>& args)
pNative->Copy(pNative2, pos, len); pNative->Copy(pNative2, pos, len);
args.GetReturnValue().Set(v8::Undefined()); args.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent()));
} }
void _ms_clearnoattack(const v8::FunctionCallbackInfo<v8::Value>& args) void _ms_clearnoattack(const v8::FunctionCallbackInfo<v8::Value>& args)
{ {
CMemoryStream* pNative = unwrap_memorystream(args.This()); CMemoryStream* pNative = unwrap_memorystream(args.This());
pNative->ClearNoAttack(); pNative->ClearNoAttack();
args.GetReturnValue().Set(v8::Undefined()); args.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent()));
} }
void _ms_pos(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info) void _ms_pos(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
{ {
CMemoryStream* pNative = unwrap_memorystream(info.Holder()); CMemoryStream* pNative = unwrap_memorystream(info.Holder());
info.GetReturnValue().Set(v8::Integer::New(pNative->GetSize())); info.GetReturnValue().Set(v8::Integer::New(v8::Isolate::GetCurrent(), pNative->GetSize()));
} }
v8::Handle<v8::ObjectTemplate> CreateMemoryStreamTemplate(v8::Isolate* isolate) v8::Handle<v8::ObjectTemplate> CreateMemoryStreamTemplate(v8::Isolate* isolate)
{ {
v8::HandleScope handle_scope(isolate); //v8::HandleScope handle_scope(isolate);
v8::Local<v8::ObjectTemplate> result = v8::ObjectTemplate::New(); v8::Local<v8::ObjectTemplate> result = v8::ObjectTemplate::New();
result->SetInternalFieldCount(1); // CNativeControl result->SetInternalFieldCount(1); // CNativeControl
v8::Isolate* current = v8::Isolate::GetCurrent();
// property // property
result->SetAccessor(v8::String::NewSymbol("pos"), _ms_pos); // result->SetAccessor(v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), "pos"), _ms_pos); //
// - // -
result->Set(v8::String::NewSymbol("Copy"), v8::FunctionTemplate::New(_ms_copy)); result->Set(v8::String::NewFromUtf8(current, "Copy"), v8::FunctionTemplate::New(current, _ms_copy));
result->Set(v8::String::NewSymbol("ClearNoAttack"), v8::FunctionTemplate::New(_ms_clearnoattack)); result->Set(v8::String::NewFromUtf8(current, "ClearNoAttack"), v8::FunctionTemplate::New(current, _ms_clearnoattack));
result->Set(v8::String::NewSymbol("WriteByte"), v8::FunctionTemplate::New(_ms_write_byte)); result->Set(v8::String::NewFromUtf8(current, "WriteByte"), v8::FunctionTemplate::New(current, _ms_write_byte));
result->Set(v8::String::NewSymbol("WriteBool"), v8::FunctionTemplate::New(_ms_write_bool)); result->Set(v8::String::NewFromUtf8(current, "WriteBool"), v8::FunctionTemplate::New(current, _ms_write_bool));
result->Set(v8::String::NewSymbol("WriteLong"), v8::FunctionTemplate::New(_ms_write_long)); result->Set(v8::String::NewFromUtf8(current, "WriteLong"), v8::FunctionTemplate::New(current, _ms_write_long));
result->Set(v8::String::NewSymbol("WriteDouble"), v8::FunctionTemplate::New(_ms_write_double)); result->Set(v8::String::NewFromUtf8(current, "WriteDouble"), v8::FunctionTemplate::New(current, _ms_write_double));
result->Set(v8::String::NewSymbol("WriteString"), v8::FunctionTemplate::New(_ms_writestring1)); result->Set(v8::String::NewFromUtf8(current, "WriteString"), v8::FunctionTemplate::New(current, _ms_writestring1));
result->Set(v8::String::NewSymbol("WriteString2"), v8::FunctionTemplate::New(_ms_writestring2)); result->Set(v8::String::NewFromUtf8(current, "WriteString2"), v8::FunctionTemplate::New(current, _ms_writestring2));
// , HandleScope // , HandleScope
// "" HandleScope - handle_scope // "" HandleScope - handle_scope
return handle_scope.Close(result);
//return handle_scope.Close(result);
return result;
} }
...@@ -22,7 +22,7 @@ void CreateNativeObject(const v8::FunctionCallbackInfo<v8::Value>& args) ...@@ -22,7 +22,7 @@ void CreateNativeObject(const v8::FunctionCallbackInfo<v8::Value>& args)
CNativeControl* pNativeObject = new CNativeControl(); CNativeControl* pNativeObject = new CNativeControl();
v8::Local<v8::Object> obj = NativeObjectTemplate->NewInstance(); v8::Local<v8::Object> obj = NativeObjectTemplate->NewInstance();
obj->SetInternalField(0, v8::External::New(pNativeObject)); obj->SetInternalField(0, v8::External::New(v8::Isolate::GetCurrent(), pNativeObject));
args.GetReturnValue().Set(obj); args.GetReturnValue().Set(obj);
} }
...@@ -35,7 +35,7 @@ void CreateNativeMemoryStream(const v8::FunctionCallbackInfo<v8::Value>& args) ...@@ -35,7 +35,7 @@ void CreateNativeMemoryStream(const v8::FunctionCallbackInfo<v8::Value>& args)
CMemoryStream* pMemoryObject = new CMemoryStream(); CMemoryStream* pMemoryObject = new CMemoryStream();
v8::Local<v8::Object> obj = MemoryObjectTemplate->NewInstance(); v8::Local<v8::Object> obj = MemoryObjectTemplate->NewInstance();
obj->SetInternalField(0, v8::External::New(pMemoryObject)); obj->SetInternalField(0, v8::External::New(v8::Isolate::GetCurrent(), pMemoryObject));
args.GetReturnValue().Set(obj); args.GetReturnValue().Set(obj);
} }
...@@ -495,6 +495,12 @@ private: ...@@ -495,6 +495,12 @@ private:
{ {
CString strException = _T(""); CString strException = _T("");
v8::V8::InitializeICU();
v8::Platform* platform = v8::platform::CreateDefaultPlatform();
v8::V8::InitializePlatform(platform);
v8::V8::Initialize();
if (!m_bIsInitTypedArrays) if (!m_bIsInitTypedArrays)
{ {
enableTypedArrays(); enableTypedArrays();
...@@ -503,17 +509,24 @@ private: ...@@ -503,17 +509,24 @@ private:
WCHAR* javascript = (WCHAR*)strScript.GetBuffer(); WCHAR* javascript = (WCHAR*)strScript.GetBuffer();
v8::Isolate* isolate = v8::Isolate::GetCurrent(); v8::Isolate* isolate = v8::Isolate::New();
isolate->Enter();
v8::Isolate::Scope isolate_cope(isolate);
v8::Locker isolate_locker(isolate);
v8::HandleScope handle_scope(isolate); v8::HandleScope handle_scope(isolate);
v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New(); v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New();
global->Set(v8::String::NewSymbol("CreateNativeEngine"), v8::FunctionTemplate::New(CreateNativeObject)); global->Set(v8::String::NewFromUtf8(isolate, "CreateNativeEngine"), v8::FunctionTemplate::New(isolate, CreateNativeObject));
global->Set(v8::String::NewSymbol("CreateNativeMemoryStream"), v8::FunctionTemplate::New(CreateNativeMemoryStream)); global->Set(v8::String::NewFromUtf8(isolate, "CreateNativeMemoryStream"), v8::FunctionTemplate::New(isolate, CreateNativeMemoryStream));
v8::Local<v8::Context> context = v8::Context::New(isolate, NULL, global); v8::Local<v8::Context> context = v8::Context::New(isolate, NULL, global);
context->Enter();
v8::Context::Scope context_scope(context); v8::Context::Scope context_scope(context);
v8::TryCatch try_catch; v8::TryCatch try_catch;
v8::Local<v8::String> source = v8::String::New((uint16_t*)javascript); v8::Local<v8::String> source = v8::String::NewFromTwoByte(isolate, (uint16_t*)javascript);
v8::Local<v8::Script> script = v8::Script::Compile(source); v8::Local<v8::Script> script = v8::Script::Compile(source);
if (try_catch.HasCaught()) if (try_catch.HasCaught())
...@@ -521,10 +534,11 @@ private: ...@@ -521,10 +534,11 @@ private:
CString strCode = to_cstring(try_catch.Message()->GetSourceLine()); CString strCode = to_cstring(try_catch.Message()->GetSourceLine());
strException = to_cstring(try_catch.Message()->Get()); strException = to_cstring(try_catch.Message()->Get());
CStringA ss = (CStringA)strException;
strError = _T("code=\"compile\""); strError = _T("code=\"compile\"");
return FALSE; return FALSE;
} }
v8::Local<v8::Value> result = script->Run(); v8::Local<v8::Value> result = script->Run();
if (try_catch.HasCaught()) if (try_catch.HasCaught())
...@@ -539,22 +553,22 @@ private: ...@@ -539,22 +553,22 @@ private:
//--------------------------------------------------------------- //---------------------------------------------------------------
v8::Local<v8::Object> global_js = context->Global(); v8::Local<v8::Object> global_js = context->Global();
v8::Handle<v8::Value> args[1]; v8::Handle<v8::Value> args[1];
args[0] = v8::Int32::New(0); args[0] = v8::Int32::New(isolate, 0);
// all // all
v8::Handle<v8::Value> js_func_open = global_js->Get(v8::String::New("NativeOpenFile")); v8::Handle<v8::Value> js_func_open = global_js->Get(v8::String::NewFromUtf8(isolate, "NativeOpenFile"));
v8::Handle<v8::Value> js_func_id = global_js->Get(v8::String::New("GetNativeId")); v8::Handle<v8::Value> js_func_id = global_js->Get(v8::String::NewFromUtf8(isolate, "GetNativeId"));
// changes // changes
v8::Handle<v8::Value> js_func_apply_changes = global_js->Get(v8::String::New("NativeApplyChanges")); v8::Handle<v8::Value> js_func_apply_changes = global_js->Get(v8::String::NewFromUtf8(isolate, "NativeApplyChanges"));
// save T format // save T format
v8::Handle<v8::Value> js_func_get_file_s = global_js->Get(v8::String::New("NativeGetFileString")); v8::Handle<v8::Value> js_func_get_file_s = global_js->Get(v8::String::NewFromUtf8(isolate, "NativeGetFileString"));
// pdf // pdf
v8::Handle<v8::Value> js_func_calculate = global_js->Get(v8::String::New("NativeCalculateFile")); v8::Handle<v8::Value> js_func_calculate = global_js->Get(v8::String::NewFromUtf8(isolate, "NativeCalculateFile"));
v8::Handle<v8::Value> js_func_pages_count = global_js->Get(v8::String::New("GetNativeCountPages")); v8::Handle<v8::Value> js_func_pages_count = global_js->Get(v8::String::NewFromUtf8(isolate, "GetNativeCountPages"));
v8::Handle<v8::Value> js_func_page = global_js->Get(v8::String::New("GetNativePageBase64")); v8::Handle<v8::Value> js_func_page = global_js->Get(v8::String::NewFromUtf8(isolate, "GetNativePageBase64"));
CString strDocumentId = _T(""); CString strDocumentId = _T("");
LONG lPagesCount = 0; LONG lPagesCount = 0;
...@@ -578,7 +592,7 @@ private: ...@@ -578,7 +592,7 @@ private:
CNativeControl* pNative = NULL; CNativeControl* pNative = NULL;
v8::Handle<v8::Value> js_func_get_native = global_js->Get(v8::String::New("GetNativeEngine")); v8::Handle<v8::Value> js_func_get_native = global_js->Get(v8::String::NewFromUtf8(isolate, "GetNativeEngine"));
v8::Local<v8::Object> objNative; v8::Local<v8::Object> objNative;
if (js_func_get_native->IsFunction()) if (js_func_get_native->IsFunction())
{ {
...@@ -736,7 +750,7 @@ private: ...@@ -736,7 +750,7 @@ private:
for (LONG i = 0; i < lPagesCount; i++) for (LONG i = 0; i < lPagesCount; i++)
{ {
args[0] = v8::Int32::New(i); args[0] = v8::Int32::New(isolate, i);
v8::Local<v8::Value> js_result3 = func_page->Call(global_js, 1, args); v8::Local<v8::Value> js_result3 = func_page->Call(global_js, 1, args);
if (try_catch.HasCaught()) if (try_catch.HasCaught())
...@@ -782,7 +796,6 @@ private: ...@@ -782,7 +796,6 @@ private:
break; break;
} }
return FALSE; return FALSE;
} }
......
...@@ -14,7 +14,7 @@ static CString to_cstring(v8::Local<v8::Value> v) ...@@ -14,7 +14,7 @@ static CString to_cstring(v8::Local<v8::Value> v)
static CStringA to_cstringA(v8::Local<v8::Value> v) static CStringA to_cstringA(v8::Local<v8::Value> v)
{ {
v8::String::AsciiValue data(v); v8::String::Utf8Value data(v);
const char* p = (char*)*data; const char* p = (char*)*data;
if (NULL == p) if (NULL == p)
return ""; return "";
...@@ -101,11 +101,11 @@ CNativeControl* unwrap_nativeobject(v8::Handle<v8::Object> obj) ...@@ -101,11 +101,11 @@ CNativeControl* unwrap_nativeobject(v8::Handle<v8::Object> obj)
void _GetFilePath(const v8::FunctionCallbackInfo<v8::Value>& args) void _GetFilePath(const v8::FunctionCallbackInfo<v8::Value>& args)
{ {
CNativeControl* pNative = unwrap_nativeobject(args.This()); CNativeControl* pNative = unwrap_nativeobject(args.This());
args.GetReturnValue().Set(v8::String::New((uint16_t*)pNative->GetFilePath().GetBuffer())); args.GetReturnValue().Set(v8::String::NewFromTwoByte(v8::Isolate::GetCurrent(), (uint16_t*)pNative->GetFilePath().GetBuffer()));
} }
void _SetFilePath(const v8::FunctionCallbackInfo<v8::Value>& args) void _SetFilePath(const v8::FunctionCallbackInfo<v8::Value>& args)
{ {
args.GetReturnValue().Set(v8::Undefined()); args.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent()));
if (args.Length() < 1) if (args.Length() < 1)
return; return;
...@@ -117,13 +117,13 @@ void _SetFilePath(const v8::FunctionCallbackInfo<v8::Value>& args) ...@@ -117,13 +117,13 @@ void _SetFilePath(const v8::FunctionCallbackInfo<v8::Value>& args)
void _GetFontsDirectory(const v8::FunctionCallbackInfo<v8::Value>& args) void _GetFontsDirectory(const v8::FunctionCallbackInfo<v8::Value>& args)
{ {
CNativeControl* pNative = unwrap_nativeobject(args.This()); CNativeControl* pNative = unwrap_nativeobject(args.This());
args.GetReturnValue().Set(v8::String::New((uint16_t*)pNative->m_strFontsDirectory.GetBuffer())); args.GetReturnValue().Set(v8::String::NewFromTwoByte(v8::Isolate::GetCurrent(), (uint16_t*)pNative->m_strFontsDirectory.GetBuffer()));
} }
void _GetEditorType(const v8::FunctionCallbackInfo<v8::Value>& args) void _GetEditorType(const v8::FunctionCallbackInfo<v8::Value>& args)
{ {
CNativeControl* pNative = unwrap_nativeobject(args.This()); CNativeControl* pNative = unwrap_nativeobject(args.This());
args.GetReturnValue().Set(v8::String::New((uint16_t*)pNative->m_strEditorType.GetBuffer())); args.GetReturnValue().Set(v8::String::NewFromTwoByte(v8::Isolate::GetCurrent(), (uint16_t*)pNative->m_strEditorType.GetBuffer()));
} }
void _GetChangesCount(const v8::FunctionCallbackInfo<v8::Value>& args) void _GetChangesCount(const v8::FunctionCallbackInfo<v8::Value>& args)
...@@ -133,14 +133,14 @@ void _GetChangesCount(const v8::FunctionCallbackInfo<v8::Value>& args) ...@@ -133,14 +133,14 @@ void _GetChangesCount(const v8::FunctionCallbackInfo<v8::Value>& args)
int nCount = 0; int nCount = 0;
if (pNative->m_pChanges != NULL) if (pNative->m_pChanges != NULL)
nCount = (int)pNative->m_pChanges->GetCount(); nCount = (int)pNative->m_pChanges->GetCount();
args.GetReturnValue().Set(v8::Integer::New(nCount)); args.GetReturnValue().Set(v8::Integer::New(v8::Isolate::GetCurrent(), nCount));
} }
void _GetChangesFile(const v8::FunctionCallbackInfo<v8::Value>& args) void _GetChangesFile(const v8::FunctionCallbackInfo<v8::Value>& args)
{ {
CNativeControl* pNative = unwrap_nativeobject(args.This()); CNativeControl* pNative = unwrap_nativeobject(args.This());
if (args.Length() < 1) if (args.Length() < 1)
args.GetReturnValue().Set(v8::Undefined()); args.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent()));
v8::Local<v8::Int32> intValue = args[0]->ToInt32(); v8::Local<v8::Int32> intValue = args[0]->ToInt32();
int nIndex = (int)intValue->Value(); int nIndex = (int)intValue->Value();
...@@ -149,17 +149,17 @@ void _GetChangesFile(const v8::FunctionCallbackInfo<v8::Value>& args) ...@@ -149,17 +149,17 @@ void _GetChangesFile(const v8::FunctionCallbackInfo<v8::Value>& args)
if (pNative->m_pChanges != NULL) if (pNative->m_pChanges != NULL)
strFile = pNative->m_pChanges->GetAt((size_t)nIndex); strFile = pNative->m_pChanges->GetAt((size_t)nIndex);
args.GetReturnValue().Set(v8::String::New((uint16_t*)strFile.GetBuffer())); args.GetReturnValue().Set(v8::String::NewFromTwoByte(v8::Isolate::GetCurrent(), (uint16_t*)strFile.GetBuffer()));
} }
void _GetFileId(const v8::FunctionCallbackInfo<v8::Value>& args) void _GetFileId(const v8::FunctionCallbackInfo<v8::Value>& args)
{ {
CNativeControl* pNative = unwrap_nativeobject(args.This()); CNativeControl* pNative = unwrap_nativeobject(args.This());
args.GetReturnValue().Set(v8::String::New((uint16_t*)pNative->GetFileId().GetBuffer())); args.GetReturnValue().Set(v8::String::NewFromTwoByte(v8::Isolate::GetCurrent(), (uint16_t*)pNative->GetFileId().GetBuffer()));
} }
void _SetFileId(const v8::FunctionCallbackInfo<v8::Value>& args) void _SetFileId(const v8::FunctionCallbackInfo<v8::Value>& args)
{ {
args.GetReturnValue().Set(v8::Undefined()); args.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent()));
if (args.Length() < 1) if (args.Length() < 1)
return; return;
...@@ -177,18 +177,18 @@ void _CheckNextChange(const v8::FunctionCallbackInfo<v8::Value>& args) ...@@ -177,18 +177,18 @@ void _CheckNextChange(const v8::FunctionCallbackInfo<v8::Value>& args)
{ {
if (pNative->m_nCurrentChangesNumber >= pNative->m_nMaxChangesNumber) if (pNative->m_nCurrentChangesNumber >= pNative->m_nMaxChangesNumber)
{ {
args.GetReturnValue().Set(v8::Boolean::New(false)); args.GetReturnValue().Set(v8::Boolean::New(v8::Isolate::GetCurrent(), false));
return; return;
} }
} }
args.GetReturnValue().Set(v8::Boolean::New(true)); args.GetReturnValue().Set(v8::Boolean::New(v8::Isolate::GetCurrent(), true));
} }
void _GetFileArrayBuffer(const v8::FunctionCallbackInfo<v8::Value>& args) void _GetFileArrayBuffer(const v8::FunctionCallbackInfo<v8::Value>& args)
{ {
if (args.Length() < 1) if (args.Length() < 1)
{ {
args.GetReturnValue().Set(v8::Undefined()); args.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent()));
return; return;
} }
...@@ -198,7 +198,7 @@ void _GetFileArrayBuffer(const v8::FunctionCallbackInfo<v8::Value>& args) ...@@ -198,7 +198,7 @@ void _GetFileArrayBuffer(const v8::FunctionCallbackInfo<v8::Value>& args)
DWORD len = 0; DWORD len = 0;
pNative->getFileData(to_cstring(args[0]), pData, len); pNative->getFileData(to_cstring(args[0]), pData, len);
v8::Local<v8::ArrayBuffer> _buffer = v8::ArrayBuffer::New((void*)pData, (size_t)len); v8::Local<v8::ArrayBuffer> _buffer = v8::ArrayBuffer::New(v8::Isolate::GetCurrent(), (void*)pData, (size_t)len);
v8::Local<v8::Uint8Array> _array = v8::Uint8Array::New(_buffer, 0, (size_t)len); v8::Local<v8::Uint8Array> _array = v8::Uint8Array::New(_buffer, 0, (size_t)len);
args.GetReturnValue().Set(_array); args.GetReturnValue().Set(_array);
...@@ -208,7 +208,7 @@ void _GetFontArrayBuffer(const v8::FunctionCallbackInfo<v8::Value>& args) ...@@ -208,7 +208,7 @@ void _GetFontArrayBuffer(const v8::FunctionCallbackInfo<v8::Value>& args)
{ {
if (args.Length() < 1) if (args.Length() < 1)
{ {
args.GetReturnValue().Set(v8::Undefined()); args.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent()));
return; return;
} }
...@@ -224,7 +224,7 @@ void _GetFontArrayBuffer(const v8::FunctionCallbackInfo<v8::Value>& args) ...@@ -224,7 +224,7 @@ void _GetFontArrayBuffer(const v8::FunctionCallbackInfo<v8::Value>& args)
strDir += to_cstring(args[0]); strDir += to_cstring(args[0]);
pNative->getFileData(strDir, pData, len); pNative->getFileData(strDir, pData, len);
v8::Local<v8::ArrayBuffer> _buffer = v8::ArrayBuffer::New((void*)pData, (size_t)len); v8::Local<v8::ArrayBuffer> _buffer = v8::ArrayBuffer::New(v8::Isolate::GetCurrent(), (void*)pData, (size_t)len);
v8::Local<v8::Uint8Array> _array = v8::Uint8Array::New(_buffer, 0, (size_t)len); v8::Local<v8::Uint8Array> _array = v8::Uint8Array::New(_buffer, 0, (size_t)len);
args.GetReturnValue().Set(_array); args.GetReturnValue().Set(_array);
...@@ -234,7 +234,7 @@ void _GetFileString(const v8::FunctionCallbackInfo<v8::Value>& args) ...@@ -234,7 +234,7 @@ void _GetFileString(const v8::FunctionCallbackInfo<v8::Value>& args)
{ {
if (args.Length() < 1) if (args.Length() < 1)
{ {
args.GetReturnValue().Set(v8::Undefined()); args.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent()));
return; return;
} }
...@@ -244,12 +244,12 @@ void _GetFileString(const v8::FunctionCallbackInfo<v8::Value>& args) ...@@ -244,12 +244,12 @@ void _GetFileString(const v8::FunctionCallbackInfo<v8::Value>& args)
DWORD len = 0; DWORD len = 0;
pNative->getFileData(to_cstring(args[0]), pData, len); pNative->getFileData(to_cstring(args[0]), pData, len);
args.GetReturnValue().Set(v8::String::NewSymbol((char*)pData, len)); args.GetReturnValue().Set(v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), (char*)pData, v8::String::kNormalString, len));
} }
void _ConsoleLog(const v8::FunctionCallbackInfo<v8::Value>& args) void _ConsoleLog(const v8::FunctionCallbackInfo<v8::Value>& args)
{ {
args.GetReturnValue().Set(v8::Undefined()); args.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent()));
if (args.Length() < 1) if (args.Length() < 1)
return; return;
...@@ -259,32 +259,36 @@ void _ConsoleLog(const v8::FunctionCallbackInfo<v8::Value>& args) ...@@ -259,32 +259,36 @@ void _ConsoleLog(const v8::FunctionCallbackInfo<v8::Value>& args)
v8::Handle<v8::ObjectTemplate> CreateNativeControlTemplate(v8::Isolate* isolate) v8::Handle<v8::ObjectTemplate> CreateNativeControlTemplate(v8::Isolate* isolate)
{ {
v8::HandleScope handle_scope(isolate); //v8::HandleScope handle_scope(isolate);
v8::Local<v8::ObjectTemplate> result = v8::ObjectTemplate::New(); v8::Local<v8::ObjectTemplate> result = v8::ObjectTemplate::New();
result->SetInternalFieldCount(1); // CNativeControl result->SetInternalFieldCount(1); // CNativeControl
v8::Isolate* current = v8::Isolate::GetCurrent();
// - // -
result->Set(v8::String::NewSymbol("SetFilePath"), v8::FunctionTemplate::New(_SetFilePath)); result->Set(v8::String::NewFromUtf8(current, "SetFilePath"), v8::FunctionTemplate::New(current, _SetFilePath));
result->Set(v8::String::NewSymbol("GetFilePath"), v8::FunctionTemplate::New(_GetFilePath)); result->Set(v8::String::NewFromUtf8(current, "GetFilePath"), v8::FunctionTemplate::New(current, _GetFilePath));
result->Set(v8::String::NewSymbol("SetFileId"), v8::FunctionTemplate::New(_SetFileId)); result->Set(v8::String::NewFromUtf8(current, "SetFileId"), v8::FunctionTemplate::New(current, _SetFileId));
result->Set(v8::String::NewSymbol("GetFileId"), v8::FunctionTemplate::New(_GetFileId)); result->Set(v8::String::NewFromUtf8(current, "GetFileId"), v8::FunctionTemplate::New(current, _GetFileId));
result->Set(v8::String::NewSymbol("GetFileBinary"), v8::FunctionTemplate::New(_GetFileArrayBuffer)); result->Set(v8::String::NewFromUtf8(current, "GetFileBinary"), v8::FunctionTemplate::New(current, _GetFileArrayBuffer));
result->Set(v8::String::NewSymbol("GetFontBinary"), v8::FunctionTemplate::New(_GetFontArrayBuffer)); result->Set(v8::String::NewFromUtf8(current, "GetFontBinary"), v8::FunctionTemplate::New(current, _GetFontArrayBuffer));
result->Set(v8::String::NewSymbol("GetFontsDirectory"), v8::FunctionTemplate::New(_GetFontsDirectory)); result->Set(v8::String::NewFromUtf8(current, "GetFontsDirectory"), v8::FunctionTemplate::New(current, _GetFontsDirectory));
result->Set(v8::String::NewSymbol("GetFileString"), v8::FunctionTemplate::New(_GetFileString)); result->Set(v8::String::NewFromUtf8(current, "GetFileString"), v8::FunctionTemplate::New(current, _GetFileString));
result->Set(v8::String::NewSymbol("GetEditorType"), v8::FunctionTemplate::New(_GetEditorType)); result->Set(v8::String::NewFromUtf8(current, "GetEditorType"), v8::FunctionTemplate::New(current, _GetEditorType));
result->Set(v8::String::NewSymbol("CheckNextChange"), v8::FunctionTemplate::New(_CheckNextChange)); result->Set(v8::String::NewFromUtf8(current, "CheckNextChange"), v8::FunctionTemplate::New(current, _CheckNextChange));
result->Set(v8::String::NewSymbol("GetCountChanges"), v8::FunctionTemplate::New(_GetChangesCount)); result->Set(v8::String::NewFromUtf8(current, "GetCountChanges"), v8::FunctionTemplate::New(current, _GetChangesCount));
result->Set(v8::String::NewSymbol("GetChangesFile"), v8::FunctionTemplate::New(_GetChangesFile)); result->Set(v8::String::NewFromUtf8(current, "GetChangesFile"), v8::FunctionTemplate::New(current, _GetChangesFile));
result->Set(v8::String::NewSymbol("ConsoleLog"), v8::FunctionTemplate::New(_ConsoleLog)); result->Set(v8::String::NewFromUtf8(current, "ConsoleLog"), v8::FunctionTemplate::New(current, _ConsoleLog));
// , HandleScope // , HandleScope
// "" HandleScope - handle_scope // "" HandleScope - handle_scope
return handle_scope.Close(result);
//return handle_scope.Close(result);
return result;
} }
// -------------------------- // --------------------------
......
...@@ -8,24 +8,6 @@ ...@@ -8,24 +8,6 @@
#define STRICT #define STRICT
#endif #endif
// Modify the following defines if you have to target a platform prior to the ones specified below.
// Refer to MSDN for the latest info on corresponding values for different platforms.
#ifndef WINVER // Allow use of features specific to Windows 95 and Windows NT 4 or later.
#define WINVER 0x0400 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
#endif
#ifndef _WIN32_WINNT // Allow use of features specific to Windows NT 4 or later.
#define _WIN32_WINNT 0x0400 // Change this to the appropriate value to target Windows 2000 or later.
#endif
#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later.
#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
#endif
#ifndef _WIN32_IE // Allow use of features specific to IE 4.0 or later.
#define _WIN32_IE 0x0400 // Change this to the appropriate value to target IE 5.0 or later.
#endif
#define _ATL_APARTMENT_THREADED #define _ATL_APARTMENT_THREADED
#define _ATL_NO_AUTOMATIC_NAMESPACE #define _ATL_NO_AUTOMATIC_NAMESPACE
...@@ -44,6 +26,8 @@ ...@@ -44,6 +26,8 @@
#include <atlhost.h> #include <atlhost.h>
#include <atlcoll.h> #include <atlcoll.h>
#define _USE_LIBXML2_READER_
using namespace ATL; using namespace ATL;
#include "../ASCImageStudio3/ASCGraphics/Interfaces/ASCRenderer.h" #include "../ASCImageStudio3/ASCGraphics/Interfaces/ASCRenderer.h"
......
...@@ -2,6 +2,6 @@ ...@@ -2,6 +2,6 @@
//1 //1
//0 //0
//0 //0
//9 //10
#define INTVER 1,0,0,9 #define INTVER 1,0,0,10
#define STRVER "1,0,0,9\0" #define STRVER "1,0,0,10\0"
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment