From 68777ae639f79bb564365bd2dcf64e41ead4add0 Mon Sep 17 00:00:00 2001 From: openkraken-bot Date: Sat, 29 Jan 2022 09:15:25 +0000 Subject: [PATCH] Committing clang-format changes --- bridge/bindings/qjs/dart_methods.cc | 15 ++++------- bridge/bindings/qjs/executing_context.cc | 1 - bridge/bindings/qjs/executing_context.h | 4 +-- bridge/bindings/qjs/native_string.cc | 6 +---- bridge/bindings/qjs/native_string.h | 8 +++--- bridge/core/html/html_all_collection.cc | 12 ++++----- bridge/core/html/html_all_collection.h | 4 +-- bridge/core/html/html_image_element.cc | 32 ++++++++++++------------ bridge/core/html/html_image_element.h | 10 ++++---- bridge/foundation/logging.h | 6 ++--- bridge/foundation/macros.h | 1 - bridge/foundation/native_value.cc | 4 +-- bridge/foundation/native_value.h | 2 +- bridge/foundation/ref_ptr.h | 2 +- bridge/foundation/ui_command_buffer.h | 20 +++++++-------- bridge/kraken_bridge.cc | 14 +++++------ bridge/page.cc | 19 ++++++++------ bridge/page.h | 2 +- 18 files changed, 77 insertions(+), 85 deletions(-) diff --git a/bridge/bindings/qjs/dart_methods.cc b/bridge/bindings/qjs/dart_methods.cc index 2f955890ae..564fb50273 100644 --- a/bridge/bindings/qjs/dart_methods.cc +++ b/bridge/bindings/qjs/dart_methods.cc @@ -4,13 +4,12 @@ */ #include "dart_methods.h" -#include "foundation/macros.h" #include +#include "foundation/macros.h" namespace kraken { -//std::shared_ptr methodPointer = std::make_shared() - +// std::shared_ptr methodPointer = std::make_shared() std::shared_ptr getDartMethod() { std::thread::id currentThread = std::this_thread::get_id(); @@ -24,16 +23,12 @@ std::shared_ptr getDartMethod() { return std::make_shared(); } #endif -// return methodPointer; + // return methodPointer; } -void registerDartMethods(std::shared_ptr methodPointer, uint64_t* methodBytes, int32_t length) { +void registerDartMethods(std::shared_ptr methodPointer, uint64_t* methodBytes, int32_t length) {} -} - -void registerTestEnvDartMethods(std::shared_ptr methodPointer, uint64_t* methodBytes, int32_t length) { - -} +void registerTestEnvDartMethods(std::shared_ptr methodPointer, uint64_t* methodBytes, int32_t length) {} #if ENABLE_PROFILE void registerGetPerformanceEntries(GetPerformanceEntries getPerformanceEntries) { diff --git a/bridge/bindings/qjs/executing_context.cc b/bridge/bindings/qjs/executing_context.cc index 8459229641..bce62fe431 100644 --- a/bridge/bindings/qjs/executing_context.cc +++ b/bridge/bindings/qjs/executing_context.cc @@ -381,7 +381,6 @@ void buildUICommandArgs(JSContext* ctx, JSValue key, NativeString& args_01) { args_01.length = length; } - // An lock free context validator. bool isContextValid(int32_t contextId) { if (contextId > running_context_list) diff --git a/bridge/bindings/qjs/executing_context.h b/bridge/bindings/qjs/executing_context.h index 86bb222198..0132b271d8 100644 --- a/bridge/bindings/qjs/executing_context.h +++ b/bridge/bindings/qjs/executing_context.h @@ -16,14 +16,14 @@ #include #include #include -#include "foundation/macros.h" #include "bindings/qjs/bom/dom_timer_coordinator.h" +#include "dart_methods.h" #include "executing_context_data.h" +#include "foundation/macros.h" #include "foundation/ui_command_buffer.h" #include "garbage_collected.h" #include "kraken_foundation.h" #include "qjs_patch.h" -#include "dart_methods.h" #include "wrapper_type_info.h" using JSExceptionHandler = std::function; diff --git a/bridge/bindings/qjs/native_string.cc b/bridge/bindings/qjs/native_string.cc index 278f97b805..61d4b12e47 100644 --- a/bridge/bindings/qjs/native_string.cc +++ b/bridge/bindings/qjs/native_string.cc @@ -8,7 +8,6 @@ namespace kraken { - NativeString* NativeString::clone() { auto* newNativeString = new NativeString(); auto* newString = new uint16_t[length]; @@ -45,7 +44,6 @@ std::unique_ptr jsValueToNativeString(JSContext* ctx, JSValue valu return ptr; } - std::unique_ptr stringToNativeString(const std::string& string) { std::u16string utf16; fromUTF8(string, utf16); @@ -76,6 +74,4 @@ std::string jsAtomToStdString(JSContext* ctx, JSAtom atom) { return str; } - - -} +} // namespace kraken diff --git a/bridge/bindings/qjs/native_string.h b/bridge/bindings/qjs/native_string.h index 92783e2aae..f966063bd1 100644 --- a/bridge/bindings/qjs/native_string.h +++ b/bridge/bindings/qjs/native_string.h @@ -8,10 +8,10 @@ #include #include -#include -#include -#include #include +#include +#include +#include namespace kraken { @@ -54,7 +54,7 @@ void fromUTF8(const std::string& source, std::basic_stringm_nodes[index]; // return node->jsObject; //} -//JSValue AllCollection::add(JSContext* ctx, JSValue this_val, int argc, JSValue* argv) { +// JSValue AllCollection::add(JSContext* ctx, JSValue this_val, int argc, JSValue* argv) { // if (argc < 1) { // return JS_ThrowTypeError(ctx, "Failed to execute add() on HTMLAllCollection: 1 arguments required."); // } @@ -50,7 +50,7 @@ // // return JS_NULL; //} -//JSValue AllCollection::remove(JSContext* ctx, JSValue this_val, int argc, JSValue* argv) { +// JSValue AllCollection::remove(JSContext* ctx, JSValue this_val, int argc, JSValue* argv) { // if (argc < 1) { // return JS_ThrowTypeError(ctx, "Failed to execute remove() on HTMLAllCollection: 1 arguments required."); // } @@ -61,7 +61,7 @@ // collection->m_nodes.erase(collection->m_nodes.begin() + index); // return JS_NULL; //} -//void AllCollection::internalAdd(NodeInstance* node, NodeInstance* before) { +// void AllCollection::internalAdd(NodeInstance* node, NodeInstance* before) { // if (before != nullptr) { // auto it = std::find(m_nodes.begin(), m_nodes.end(), before); // m_nodes.erase(it); @@ -71,7 +71,7 @@ // } //} // -//IMPL_PROPERTY_GETTER(AllCollection, length)(JSContext* ctx, JSValue this_val, int argc, JSValue* argv) { +// IMPL_PROPERTY_GETTER(AllCollection, length)(JSContext* ctx, JSValue this_val, int argc, JSValue* argv) { // auto* collection = static_cast(JS_GetOpaque(this_val, ExecutionContext::kHostObjectClassId)); // return JS_NewUint32(ctx, collection->m_nodes.size()); //} diff --git a/bridge/core/html/html_all_collection.h b/bridge/core/html/html_all_collection.h index 9946cd154a..9483d30fd0 100644 --- a/bridge/core/html/html_all_collection.h +++ b/bridge/core/html/html_all_collection.h @@ -8,9 +8,9 @@ // //#include "bindings/qjs/garbage_collected.h" // -//namespace kraken { +// namespace kraken { // -//class HTMLAllCollection : public HostObject { +// class HTMLAllCollection : public HostObject { // public: // AllCollection(ExecutionContext* context) : HostObject(context, "AllCollection"){}; // diff --git a/bridge/core/html/html_image_element.cc b/bridge/core/html/html_image_element.cc index 874d50634a..a7017caf2b 100644 --- a/bridge/core/html/html_image_element.cc +++ b/bridge/core/html/html_image_element.cc @@ -7,28 +7,28 @@ //#include "bindings/qjs/qjs_patch.h" //#include "page.h" // -//namespace kraken { +// namespace kraken { // -//ImageElement::ImageElement(ExecutionContext* context) : Element(context) { +// ImageElement::ImageElement(ExecutionContext* context) : Element(context) { // JS_SetPrototype(m_ctx, m_prototypeObject, Element::instance(m_context)->prototype()); //} // -//void bindImageElement(ExecutionContext* context) { +// void bindImageElement(ExecutionContext* context) { // auto* constructor = ImageElement::instance(context); // context->defineGlobalProperty("HTMLImageElement", constructor->jsObject); // context->defineGlobalProperty("Image", JS_DupValue(context->ctx(), constructor->jsObject)); //} // -//JSValue ImageElement::instanceConstructor(JSContext* ctx, JSValue func_obj, JSValue this_val, int argc, JSValue* argv) { +// JSValue ImageElement::instanceConstructor(JSContext* ctx, JSValue func_obj, JSValue this_val, int argc, JSValue* argv) { // auto instance = new ImageElementInstance(this); // return instance->jsObject; //} -//IMPL_PROPERTY_GETTER(ImageElement, width)(JSContext* ctx, JSValue this_val, int argc, JSValue* argv) { +// IMPL_PROPERTY_GETTER(ImageElement, width)(JSContext* ctx, JSValue this_val, int argc, JSValue* argv) { // getDartMethod()->flushUICommand(); // auto* element = static_cast(JS_GetOpaque(this_val, Element::classId())); // return element->getNativeProperty("width"); //} -//IMPL_PROPERTY_SETTER(ImageElement, width)(JSContext* ctx, JSValue this_val, int argc, JSValue* argv) { +// IMPL_PROPERTY_SETTER(ImageElement, width)(JSContext* ctx, JSValue this_val, int argc, JSValue* argv) { // auto* element = static_cast(JS_GetOpaque(this_val, Element::classId())); // std::string key = "width"; // std::unique_ptr args_01 = stringToNativeString(key); @@ -36,12 +36,12 @@ // element->m_context->uiCommandBuffer()->addCommand(element->m_eventTargetId, UICommand::setProperty, *args_01, *args_02, nullptr); // return JS_NULL; //} -//IMPL_PROPERTY_GETTER(ImageElement, height)(JSContext* ctx, JSValue this_val, int argc, JSValue* argv) { +// IMPL_PROPERTY_GETTER(ImageElement, height)(JSContext* ctx, JSValue this_val, int argc, JSValue* argv) { // getDartMethod()->flushUICommand(); // auto* element = static_cast(JS_GetOpaque(this_val, Element::classId())); // return element->getNativeProperty("height"); //} -//IMPL_PROPERTY_SETTER(ImageElement, height)(JSContext* ctx, JSValue this_val, int argc, JSValue* argv) { +// IMPL_PROPERTY_SETTER(ImageElement, height)(JSContext* ctx, JSValue this_val, int argc, JSValue* argv) { // auto* element = static_cast(JS_GetOpaque(this_val, Element::classId())); // std::string key = "height"; // std::unique_ptr args_01 = stringToNativeString(key); @@ -49,22 +49,22 @@ // element->m_context->uiCommandBuffer()->addCommand(element->m_eventTargetId, UICommand::setProperty, *args_01, *args_02, nullptr); // return JS_NULL; //} -//IMPL_PROPERTY_GETTER(ImageElement, naturalWidth)(JSContext* ctx, JSValue this_val, int argc, JSValue* argv) { +// IMPL_PROPERTY_GETTER(ImageElement, naturalWidth)(JSContext* ctx, JSValue this_val, int argc, JSValue* argv) { // getDartMethod()->flushUICommand(); // auto* element = static_cast(JS_GetOpaque(this_val, Element::classId())); // return element->getNativeProperty("naturalWidth"); //} -//IMPL_PROPERTY_GETTER(ImageElement, naturalHeight)(JSContext* ctx, JSValue this_val, int argc, JSValue* argv) { +// IMPL_PROPERTY_GETTER(ImageElement, naturalHeight)(JSContext* ctx, JSValue this_val, int argc, JSValue* argv) { // getDartMethod()->flushUICommand(); // auto* element = static_cast(JS_GetOpaque(this_val, Element::classId())); // return element->getNativeProperty("naturalHeight"); //} -//IMPL_PROPERTY_GETTER(ImageElement, src)(JSContext* ctx, JSValue this_val, int argc, JSValue* argv) { +// IMPL_PROPERTY_GETTER(ImageElement, src)(JSContext* ctx, JSValue this_val, int argc, JSValue* argv) { // getDartMethod()->flushUICommand(); // auto* element = static_cast(JS_GetOpaque(this_val, Element::classId())); // return element->getNativeProperty("src"); //} -//IMPL_PROPERTY_SETTER(ImageElement, src)(JSContext* ctx, JSValue this_val, int argc, JSValue* argv) { +// IMPL_PROPERTY_SETTER(ImageElement, src)(JSContext* ctx, JSValue this_val, int argc, JSValue* argv) { // auto* element = static_cast(JS_GetOpaque(this_val, Element::classId())); // std::string key = "src"; // std::unique_ptr args_01 = stringToNativeString(key); @@ -72,12 +72,12 @@ // element->m_context->uiCommandBuffer()->addCommand(element->m_eventTargetId, UICommand::setProperty, *args_01, *args_02, nullptr); // return JS_NULL; //} -//IMPL_PROPERTY_GETTER(ImageElement, loading)(JSContext* ctx, JSValue this_val, int argc, JSValue* argv) { +// IMPL_PROPERTY_GETTER(ImageElement, loading)(JSContext* ctx, JSValue this_val, int argc, JSValue* argv) { // getDartMethod()->flushUICommand(); // auto* element = static_cast(JS_GetOpaque(this_val, Element::classId())); // return element->getNativeProperty("loading"); //} -//IMPL_PROPERTY_SETTER(ImageElement, loading)(JSContext* ctx, JSValue this_val, int argc, JSValue* argv) { +// IMPL_PROPERTY_SETTER(ImageElement, loading)(JSContext* ctx, JSValue this_val, int argc, JSValue* argv) { // auto* element = static_cast(JS_GetOpaque(this_val, Element::classId())); // std::string key = "loading"; // std::unique_ptr args_01 = stringToNativeString(key); @@ -86,12 +86,12 @@ // return JS_NULL; //} // -//ImageElementInstance::ImageElementInstance(ImageElement* element) : ElementInstance(element, "img", true) { +// ImageElementInstance::ImageElementInstance(ImageElement* element) : ElementInstance(element, "img", true) { // // Protect image instance util load or error event triggered. // refer(); //} // -//bool ImageElementInstance::dispatchEvent(EventInstance* event) { +// bool ImageElementInstance::dispatchEvent(EventInstance* event) { // std::u16string u16EventType = std::u16string(reinterpret_cast(event->nativeEvent->type->string), event->nativeEvent->type->length); // std::string eventType = toUTF8(u16EventType); // bool result = EventTargetInstance::dispatchEvent(event); diff --git a/bridge/core/html/html_image_element.h b/bridge/core/html/html_image_element.h index e1e2d051d4..4df787ea41 100644 --- a/bridge/core/html/html_image_element.h +++ b/bridge/core/html/html_image_element.h @@ -8,12 +8,12 @@ // //#include "bindings/qjs/dom/element.h" // -//namespace kraken { +// namespace kraken { // -//void bindImageElement(ExecutionContext* context); +// void bindImageElement(ExecutionContext* context); // -//class ImageElementInstance; -//class ImageElement : public Element { +// class ImageElementInstance; +// class ImageElement : public Element { // public: // ImageElement() = delete; // explicit ImageElement(ExecutionContext* context); @@ -32,7 +32,7 @@ // friend ImageElementInstance; //}; // -//class ImageElementInstance : public ElementInstance { +// class ImageElementInstance : public ElementInstance { // public: // ImageElementInstance() = delete; // explicit ImageElementInstance(ImageElement* element); diff --git a/bridge/foundation/logging.h b/bridge/foundation/logging.h index 5e2f47805a..2efe33d7af 100644 --- a/bridge/foundation/logging.h +++ b/bridge/foundation/logging.h @@ -33,18 +33,18 @@ constexpr LogSeverity LOG_NUM_SEVERITIES = 5; constexpr LogSeverity LOG_FATAL = 6; class LogMessageVoidify { -public: + public: void operator&(std::ostream&) {} }; class LogMessage { - public: + public: LogMessage(LogSeverity severity, const char* file, int line, const char* condition); ~LogMessage(); std::ostream& stream() { return stream_; } - private: + private: std::ostringstream stream_; const LogSeverity severity_; const char* file_; diff --git a/bridge/foundation/macros.h b/bridge/foundation/macros.h index a65cf1ec79..85ae551827 100644 --- a/bridge/foundation/macros.h +++ b/bridge/foundation/macros.h @@ -40,5 +40,4 @@ TypeName() = delete; \ KRAKEN_DISALLOW_COPY_ASSIGN_AND_MOVE(TypeName) - #endif // KRAKENBRIDGE_MACROS_H diff --git a/bridge/foundation/native_value.cc b/bridge/foundation/native_value.cc index 8bc6bdaf3d..6a98c6fa17 100644 --- a/bridge/foundation/native_value.cc +++ b/bridge/foundation/native_value.cc @@ -4,9 +4,9 @@ */ #include "native_value.h" +#include "bindings/qjs/dom/event_target.h" #include "bindings/qjs/executing_context.h" #include "bindings/qjs/qjs_patch.h" -#include "bindings/qjs/dom/event_target.h" namespace kraken { @@ -272,4 +272,4 @@ JSValue nativeValueToJSValue(ExecutionContext* context, NativeValue& value) { return JS_NULL; } -} // namespace kraken::binding::qjs +} // namespace kraken diff --git a/bridge/foundation/native_value.h b/bridge/foundation/native_value.h index d031856943..8be7ef12ed 100644 --- a/bridge/foundation/native_value.h +++ b/bridge/foundation/native_value.h @@ -66,6 +66,6 @@ NativeValue Native_NewJSON(ExecutionContext* context, JSValue& value); NativeValue jsValueToNativeValue(JSContext* ctx, JSValue& value); JSValue nativeValueToJSValue(ExecutionContext* context, NativeValue& value); -} // namespace kraken::binding::qjs +} // namespace kraken #endif // KRAKENBRIDGE_NATIVE_VALUE_H diff --git a/bridge/foundation/ref_ptr.h b/bridge/foundation/ref_ptr.h index ddadd0e382..3b47ebd881 100644 --- a/bridge/foundation/ref_ptr.h +++ b/bridge/foundation/ref_ptr.h @@ -13,8 +13,8 @@ #include #include "logging.h" -#include "ref_ptr_internal.h" #include "macros.h" +#include "ref_ptr_internal.h" namespace fml { diff --git a/bridge/foundation/ui_command_buffer.h b/bridge/foundation/ui_command_buffer.h index 0a249dde16..bf02f8a70f 100644 --- a/bridge/foundation/ui_command_buffer.h +++ b/bridge/foundation/ui_command_buffer.h @@ -6,10 +6,10 @@ #ifndef KRAKENBRIDGE_FOUNDATION_UI_COMMAND_BUFFER_H_ #define KRAKENBRIDGE_FOUNDATION_UI_COMMAND_BUFFER_H_ -#include #include -#include "native_value.h" +#include #include "bindings/qjs/native_string.h" +#include "native_value.h" namespace kraken { @@ -31,15 +31,15 @@ enum UICommand { struct UICommandItem { UICommandItem(int32_t id, int32_t type, NativeString args_01, NativeString args_02, void* nativePtr) - : type(type), - string_01(reinterpret_cast(args_01.string)), - args_01_length(args_01.length), - string_02(reinterpret_cast(args_02.string)), - args_02_length(args_02.length), - id(id), - nativePtr(reinterpret_cast(nativePtr)){}; + : type(type), + string_01(reinterpret_cast(args_01.string)), + args_01_length(args_01.length), + string_02(reinterpret_cast(args_02.string)), + args_02_length(args_02.length), + id(id), + nativePtr(reinterpret_cast(nativePtr)){}; UICommandItem(int32_t id, int32_t type, NativeString args_01, void* nativePtr) - : type(type), string_01(reinterpret_cast(args_01.string)), args_01_length(args_01.length), id(id), nativePtr(reinterpret_cast(nativePtr)){}; + : type(type), string_01(reinterpret_cast(args_01.string)), args_01_length(args_01.length), id(id), nativePtr(reinterpret_cast(nativePtr)){}; UICommandItem(int32_t id, int32_t type, void* nativePtr) : type(type), id(id), nativePtr(reinterpret_cast(nativePtr)){}; int32_t type; int32_t id; diff --git a/bridge/kraken_bridge.cc b/bridge/kraken_bridge.cc index 26237b63b1..c7a8873477 100644 --- a/bridge/kraken_bridge.cc +++ b/bridge/kraken_bridge.cc @@ -4,15 +4,15 @@ */ #include -#include #include +#include -#include "include/kraken_bridge.h" +#include "bindings/qjs/native_string.h" #include "foundation/inspector_task_queue.h" #include "foundation/logging.h" -#include "foundation/ui_task_queue.h" #include "foundation/ui_command_buffer.h" -#include "bindings/qjs/native_string.h" +#include "foundation/ui_task_queue.h" +#include "include/kraken_bridge.h" #include "page.h" #if defined(_WIN32) @@ -162,9 +162,9 @@ void registerDartMethods(int32_t contextId, uint64_t* methodBytes, int32_t lengt } NativeScreen* createScreen(double width, double height) { -// screen.width = width; -// screen.height = height; -// return &screen; + // screen.width = width; + // screen.height = height; + // return &screen; } static KrakenInfo* krakenInfo{nullptr}; diff --git a/bridge/page.cc b/bridge/page.cc index 0274e4bf37..2e0c0831d4 100644 --- a/bridge/page.cc +++ b/bridge/page.cc @@ -5,10 +5,10 @@ #include -#include "foundation/logging.h" -#include "polyfill.h" #include "bindings/qjs/qjs_patch.h" +#include "foundation/logging.h" #include "page.h" +#include "polyfill.h" #include "bindings/qjs/bom/blob.h" #include "bindings/qjs/bom/console.h" @@ -57,12 +57,15 @@ KrakenPage::KrakenPage(int32_t contextId, const JSExceptionHandler& handler) : c #if ENABLE_PROFILE auto jsContextStartTime = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); #endif - m_context = new ExecutionContext(contextId, [this](int32_t contextId, const char* message) { - if (m_context->dartMethodPtr()->onJsError != nullptr) { - m_context->dartMethodPtr()->onJsError(contextId, message); - } - KRAKEN_LOG(ERROR) << message << std::endl; - }, this); + m_context = new ExecutionContext( + contextId, + [this](int32_t contextId, const char* message) { + if (m_context->dartMethodPtr()->onJsError != nullptr) { + m_context->dartMethodPtr()->onJsError(contextId, message); + } + KRAKEN_LOG(ERROR) << message << std::endl; + }, + this); #if ENABLE_PROFILE auto nativePerformance = Performance::instance(m_context)->m_nativePerformance; diff --git a/bridge/page.h b/bridge/page.h index d979b5b322..68a75231a5 100644 --- a/bridge/page.h +++ b/bridge/page.h @@ -9,8 +9,8 @@ #include #include #include -#include #include +#include #include "bindings/qjs/executing_context.h" #include "bindings/qjs/html_parser.h"