Files
cefsharp/CefSharp.BrowserSubprocess.Core/Serialization/ObjectsSerialization.cpp
T
2015-08-03 10:43:35 +10:00

49 lines
1.9 KiB
C++

// 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 "ObjectsSerialization.h"
#include "../CefSharp.Core/Internals/Serialization/Primitives.h"
namespace CefSharp
{
namespace Internals
{
namespace Serialization
{
JavascriptRootObject^ DeserializeJsObject(const CefRefPtr<CefListValue>& list, int index)
{
auto result = gcnew JavascriptRootObject();
auto subList = list->GetList(index);
for (auto i = 0; i < subList->GetSize(); i++)
{
auto objList = subList->GetList(i);
auto jsObject = gcnew JavascriptObject();
jsObject->Id = GetInt64(objList, 0);
jsObject->Name = StringUtils::ToClr(objList->GetString(1));
jsObject->JavascriptName = StringUtils::ToClr(objList->GetString(2));
auto methodList = objList->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);
}
result->MemberObjects->Add(jsObject);
}
return result;
}
}
}
}