mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-21 07:58:04 +03:00
Use message_translation from parent folder
This commit is contained in:
parent
54acfd507f
commit
4d07f406ca
@ -22,11 +22,11 @@
|
||||
'../v8_extensions/atom_linux.cpp',
|
||||
'../v8_extensions/native_linux.cpp',
|
||||
'../v8_extensions/onig_reg_exp_linux.cpp',
|
||||
'../message_translation.cpp',
|
||||
'atom.cpp',
|
||||
'atom_cef_render_process_handler.cpp',
|
||||
'client_handler.cpp',
|
||||
'io_utils.cpp',
|
||||
'message_translation.cpp',
|
||||
'native_handler.cpp',
|
||||
'onig_regexp_extension.cpp',
|
||||
],
|
||||
|
@ -1,82 +0,0 @@
|
||||
#include <assert.h>
|
||||
#include "message_translation.h"
|
||||
|
||||
// Transfer a V8 value to a List index.
|
||||
void TranslateListValue(CefRefPtr<CefListValue> list, int index, CefRefPtr<CefV8Value> value) {
|
||||
if (value->IsArray()) {
|
||||
CefRefPtr<CefListValue> new_list = CefListValue::Create();
|
||||
TranslateList(value, new_list);
|
||||
list->SetList(index, new_list);
|
||||
} else if (value->IsString()) {
|
||||
list->SetString(index, value->GetStringValue());
|
||||
} else if (value->IsBool()) {
|
||||
list->SetBool(index, value->GetBoolValue());
|
||||
} else if (value->IsInt()) {
|
||||
list->SetInt(index, value->GetIntValue());
|
||||
} else if (value->IsDouble()) {
|
||||
list->SetDouble(index, value->GetDoubleValue());
|
||||
}
|
||||
}
|
||||
|
||||
// Transfer a V8 array to a List.
|
||||
void TranslateList(CefRefPtr<CefV8Value> source, CefRefPtr<CefListValue> target) {
|
||||
assert(source->IsArray());
|
||||
|
||||
int arg_length = source->GetArrayLength();
|
||||
if (arg_length == 0)
|
||||
return;
|
||||
|
||||
// Start with null types in all spaces.
|
||||
target->SetSize(arg_length);
|
||||
|
||||
for (int i = 0; i < arg_length; ++i) {
|
||||
TranslateListValue(target, i, source->GetValue(i));
|
||||
}
|
||||
}
|
||||
|
||||
// Transfer a List value to a V8 array index.
|
||||
void TranslateListValue(CefRefPtr<CefV8Value> list, int index, CefRefPtr<CefListValue> value) {
|
||||
CefRefPtr<CefV8Value> new_value;
|
||||
|
||||
CefValueType type = value->GetType(index);
|
||||
switch (type) {
|
||||
case VTYPE_LIST: {
|
||||
CefRefPtr<CefListValue> list = value->GetList(index);
|
||||
new_value = CefV8Value::CreateArray(list->GetSize());
|
||||
TranslateList(list, new_value);
|
||||
} break;
|
||||
case VTYPE_BOOL:
|
||||
new_value = CefV8Value::CreateBool(value->GetBool(index));
|
||||
break;
|
||||
case VTYPE_DOUBLE:
|
||||
new_value = CefV8Value::CreateDouble(value->GetDouble(index));
|
||||
break;
|
||||
case VTYPE_INT:
|
||||
new_value = CefV8Value::CreateInt(value->GetInt(index));
|
||||
break;
|
||||
case VTYPE_STRING:
|
||||
new_value = CefV8Value::CreateString(value->GetString(index));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (new_value.get()) {
|
||||
list->SetValue(index, new_value);
|
||||
} else {
|
||||
list->SetValue(index, CefV8Value::CreateNull());
|
||||
}
|
||||
}
|
||||
|
||||
// Transfer a List to a V8 array.
|
||||
void TranslateList(CefRefPtr<CefListValue> source, CefRefPtr<CefV8Value> target) {
|
||||
assert(target->IsArray());
|
||||
|
||||
int arg_length = source->GetSize();
|
||||
if (arg_length == 0)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < arg_length; ++i) {
|
||||
TranslateListValue(target, i, source);
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
#ifndef ATOM_CEF_CLIENT_H_
|
||||
#define ATOM_CEF_CLIENT_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/cef_v8.h"
|
||||
|
||||
// IPC data translation functions: translate a V8 array to a List, and vice versa
|
||||
void TranslateList(CefRefPtr<CefV8Value> source, CefRefPtr<CefListValue> target);
|
||||
void TranslateList(CefRefPtr<CefListValue> source, CefRefPtr<CefV8Value> target);
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user