mirror of
https://github.com/cefsharp/CefSharp.git
synced 2026-12-04 19:25:01 +00:00
normal bound objects transfered with cef ipc as well
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
// Copyright © 2010-2015 The CefSharp Authors. All rights reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "JsObjectsSerialization.h"
|
||||
#include "../CefSharp.Core/Internals/Serialization/Primitives.h"
|
||||
#include "../CefSharp.Core/Internals/Serialization/ObjectsSerialization.h"
|
||||
|
||||
namespace CefSharp
|
||||
{
|
||||
namespace Internals
|
||||
{
|
||||
namespace Serialization
|
||||
{
|
||||
JavascriptObject^ DeserializeJsObject(const CefRefPtr<CefListValue>& rootList, int index)
|
||||
{
|
||||
if (rootList->GetType(index) == VTYPE_INVALID ||
|
||||
rootList->GetType(index) == VTYPE_NULL)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto list = rootList->GetList(index);
|
||||
auto jsObject = gcnew JavascriptObject();
|
||||
jsObject->Id = GetInt64(list, 0);
|
||||
jsObject->Name = StringUtils::ToClr(list->GetString(1));
|
||||
jsObject->JavascriptName = StringUtils::ToClr(list->GetString(2));
|
||||
|
||||
auto methodList = list->GetList(3);
|
||||
auto methodCount = methodList->GetInt(0);
|
||||
auto k = 1;
|
||||
for (auto j = 0; j < methodCount; j++)
|
||||
{
|
||||
auto jsMethod = gcnew JavascriptMethod();
|
||||
|
||||
jsMethod->Id = GetInt64(methodList, k++);
|
||||
jsMethod->ManagedName = StringUtils::ToClr(methodList->GetString(k++));
|
||||
jsMethod->JavascriptName = StringUtils::ToClr(methodList->GetString(k++));
|
||||
jsMethod->ParameterCount = methodList->GetInt(k++);
|
||||
|
||||
jsObject->Methods->Add(jsMethod);
|
||||
}
|
||||
|
||||
auto propertyList = list->GetList(4);
|
||||
auto propertyCount = propertyList->GetInt(0);
|
||||
k = 1;
|
||||
for (auto j = 0; j < propertyCount; j++)
|
||||
{
|
||||
auto jsProperty = gcnew JavascriptProperty();
|
||||
|
||||
jsProperty->Id = GetInt64(propertyList, k++);
|
||||
jsProperty->ManagedName = StringUtils::ToClr(propertyList->GetString(k++));
|
||||
jsProperty->JavascriptName = StringUtils::ToClr(propertyList->GetString(k++));
|
||||
jsProperty->IsComplexType = propertyList->GetBool(k++);
|
||||
jsProperty->IsReadOnly = propertyList->GetBool(k++);
|
||||
|
||||
jsProperty->JsObject = DeserializeJsObject(propertyList, k++);
|
||||
jsProperty->PropertyValue = DeserializeObject(propertyList, k++, nullptr);
|
||||
|
||||
jsObject->Properties->Add(jsProperty);
|
||||
}
|
||||
return jsObject;
|
||||
}
|
||||
|
||||
JavascriptRootObject^ DeserializeJsRootObject(const CefRefPtr<CefListValue>& list, int index)
|
||||
{
|
||||
auto result = gcnew JavascriptRootObject();
|
||||
auto subList = list->GetList(index);
|
||||
for (auto i = 0; i < subList->GetSize(); i++)
|
||||
{
|
||||
result->MemberObjects->Add(DeserializeJsObject(subList, i));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user