Skip to content

Commit

Permalink
Committing clang-format changes
Browse files Browse the repository at this point in the history
  • Loading branch information
openkraken-bot committed Jan 6, 2022
1 parent d6f00d7 commit aebe7b6
Show file tree
Hide file tree
Showing 12 changed files with 47 additions and 60 deletions.
8 changes: 2 additions & 6 deletions bridge/bindings/qjs/bom/location.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Location : public GarbageCollected<Location> {
static Location* create(JSContext* ctx);
static JSValue reload(JSContext* ctx, JSValueConst this_val, int argc, JSValueConst* argv);

void trace(JSRuntime *rt, JSValue val, JS_MarkFunc *mark_func) const override;
void trace(JSRuntime* rt, JSValue val, JS_MarkFunc* mark_func) const override;
void dispose() const override;
};

Expand All @@ -35,11 +35,7 @@ auto locationCreator = [](JSContext* ctx, JSValueConst func_obj, JSValueConst th
return location->toQuickJS();
};

const WrapperTypeInfo locationTypeInfo = {
"Location",
nullptr,
locationCreator
};
const WrapperTypeInfo locationTypeInfo = {"Location", nullptr, locationCreator};

} // namespace kraken::binding::qjs

Expand Down
4 changes: 1 addition & 3 deletions bridge/bindings/qjs/bom/window.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ void bindWindow(std::unique_ptr<ExecutionContext>& context);

class Window : public EventTarget {
public:

Window();

static JSClassID classId;
Expand All @@ -42,7 +41,7 @@ class Window : public EventTarget {

DEFINE_PROTOTYPE_PROPERTY(onerror);

void trace(JSRuntime *rt, JSValue val, JS_MarkFunc *mark_func) const override;
void trace(JSRuntime* rt, JSValue val, JS_MarkFunc* mark_func) const override;

private:
DocumentInstance* document();
Expand All @@ -53,7 +52,6 @@ class Window : public EventTarget {
};

auto windowCreator = [](JSContext* ctx, JSValueConst func_obj, JSValueConst this_val, int argc, JSValueConst* argv, int flags) -> JSValue {

auto* type = static_cast<const WrapperTypeInfo*>(JS_GetOpaque(func_obj, JSValueGetClassId(func_obj)));
auto* window = Window::create(ctx);
auto* context = static_cast<ExecutionContext*>(JS_GetContextOpaque(ctx));
Expand Down
4 changes: 2 additions & 2 deletions bridge/bindings/qjs/dom/event_target.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ class EventTarget : public GarbageCollected<EventTarget> {
static void copyNodeProperties(EventTarget* newNode, EventTarget* referenceNode);

NativeEventTarget* nativeEventTarget{new NativeEventTarget(this)};
private:

private:
static int hasProperty(JSContext* ctx, JSValueConst obj, JSAtom atom);
static JSValue getProperty(JSContext* ctx, JSValueConst obj, JSAtom atom, JSValueConst receiver);
static int setProperty(JSContext* ctx, JSValueConst obj, JSAtom atom, JSValueConst value, JSValueConst receiver, int flags);
Expand All @@ -100,7 +101,6 @@ class EventTarget : public GarbageCollected<EventTarget> {
// property are not defined by Object.defineProperty or setProperty.
// We store there values in here.
EventTargetProperties m_properties{this->m_ctx};

};

auto eventTargetCreator = [](JSContext* ctx, JSValueConst func_obj, JSValueConst this_val, int argc, JSValueConst* argv, int flags) -> JSValue {
Expand Down
41 changes: 19 additions & 22 deletions bridge/bindings/qjs/dom/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,13 @@ class Node : public EventTarget {
virtual void internalSetTextContent(JSValue content);
JSValue internalReplaceChild(NodeInstance* newChild, NodeInstance* oldChild);


void setParentNode(NodeInstance* parent);
void removeParentNode();
NodeType nodeType;
JSValue parentNode{JS_NULL};
JSValue childNodes{JS_NewArray(m_ctx)};


protected:
protected:
NodeJob nodeLink{this};

void refer();
Expand All @@ -81,25 +79,24 @@ class Node : public EventTarget {

void trace(JSRuntime* rt, JSValue val, JS_MarkFunc* mark_func) const override;


private:
// DEFINE_PROTOTYPE_PROPERTY(textContent);
//
// DEFINE_PROTOTYPE_READONLY_PROPERTY(isConnected);
// DEFINE_PROTOTYPE_READONLY_PROPERTY(ownerDocument);
// DEFINE_PROTOTYPE_READONLY_PROPERTY(firstChild);
// DEFINE_PROTOTYPE_READONLY_PROPERTY(lastChild);
// DEFINE_PROTOTYPE_READONLY_PROPERTY(parentNode);
// DEFINE_PROTOTYPE_READONLY_PROPERTY(previousSibling);
// DEFINE_PROTOTYPE_READONLY_PROPERTY(nextSibling);
// DEFINE_PROTOTYPE_READONLY_PROPERTY(nodeType);
//
// DEFINE_PROTOTYPE_FUNCTION(cloneNode, 1);
// DEFINE_PROTOTYPE_FUNCTION(appendChild, 1);
// DEFINE_PROTOTYPE_FUNCTION(remove, 0);
// DEFINE_PROTOTYPE_FUNCTION(removeChild, 1);
// DEFINE_PROTOTYPE_FUNCTION(insertBefore, 2);
// DEFINE_PROTOTYPE_FUNCTION(replaceChild, 2);
private:
// DEFINE_PROTOTYPE_PROPERTY(textContent);
//
// DEFINE_PROTOTYPE_READONLY_PROPERTY(isConnected);
// DEFINE_PROTOTYPE_READONLY_PROPERTY(ownerDocument);
// DEFINE_PROTOTYPE_READONLY_PROPERTY(firstChild);
// DEFINE_PROTOTYPE_READONLY_PROPERTY(lastChild);
// DEFINE_PROTOTYPE_READONLY_PROPERTY(parentNode);
// DEFINE_PROTOTYPE_READONLY_PROPERTY(previousSibling);
// DEFINE_PROTOTYPE_READONLY_PROPERTY(nextSibling);
// DEFINE_PROTOTYPE_READONLY_PROPERTY(nodeType);
//
// DEFINE_PROTOTYPE_FUNCTION(cloneNode, 1);
// DEFINE_PROTOTYPE_FUNCTION(appendChild, 1);
// DEFINE_PROTOTYPE_FUNCTION(remove, 0);
// DEFINE_PROTOTYPE_FUNCTION(removeChild, 1);
// DEFINE_PROTOTYPE_FUNCTION(insertBefore, 2);
// DEFINE_PROTOTYPE_FUNCTION(replaceChild, 2);

DocumentInstance* m_document{nullptr};
ObjectProperty m_childNodes{context(), jsObject, "childNodes", childNodes};
Expand Down
1 change: 0 additions & 1 deletion bridge/bindings/qjs/executing_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,6 @@ void installPropertyGetter(ExecutionContext* context, JSValue thisObject, const
JS_FreeValue(context->ctx(), getter);
}


DOMTimerCoordinator* ExecutionContext::timers() {
return &m_timers;
}
Expand Down
2 changes: 1 addition & 1 deletion bridge/bindings/qjs/executing_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
#include <mutex>
#include <unordered_map>
#include "bindings/qjs/bom/dom_timer_coordinator.h"
#include "executing_context_data.h"
#include "foundation/ui_command_buffer.h"
#include "garbage_collected.h"
#include "js_context_macros.h"
#include "kraken_foundation.h"
#include "executing_context_data.h"
#include "qjs_patch.h"
#include "wrapper_type_info.h"

Expand Down
3 changes: 1 addition & 2 deletions bridge/bindings/qjs/executing_context_data.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* Author: Kraken Team.
*/


#include "executing_context_data.h"

namespace kraken::binding::qjs {
Expand Down Expand Up @@ -71,4 +70,4 @@ JSValue ExecutionContextData::constructorForIdSlowCase(const WrapperTypeInfo* ty
return classObject;
}

}
} // namespace kraken::binding::qjs
5 changes: 2 additions & 3 deletions bridge/bindings/qjs/executing_context_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace kraken::binding::qjs {
// has a 1:1 relationship with ExecutionContext.
class ExecutionContextData final {
public:
explicit ExecutionContextData(ExecutionContext& context): m_context(context) {};
explicit ExecutionContextData(ExecutionContext& context) : m_context(context){};
ExecutionContextData(const ExecutionContextData&) = delete;
ExecutionContextData& operator=(const ExecutionContextData&) = delete;

Expand All @@ -33,7 +33,6 @@ class ExecutionContextData final {
ExecutionContext& m_context;
};


}
} // namespace kraken::binding::qjs

#endif // KRAKENBRIDGE_CONTEXT_DATA_H
12 changes: 8 additions & 4 deletions bridge/bindings/qjs/garbage_collected.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ class GarbageCollected {
public:
using ParentMostGarbageCollectedType = T;

template<typename P> P* initialize(JSContext* ctx, JSClassID* classId);
template<typename P> P* initialize(JSContext* ctx, JSClassID* classId, JSClassExoticMethods* exoticMethods);
template <typename P>
P* initialize(JSContext* ctx, JSClassID* classId);
template <typename P>
P* initialize(JSContext* ctx, JSClassID* classId, JSClassExoticMethods* exoticMethods);

// Must use MakeGarbageCollected.
void* operator new(size_t) = delete;
Expand Down Expand Up @@ -91,7 +93,8 @@ class MakeGarbageCollectedTrait {
};

template <typename T>
template <typename P> P* GarbageCollected<T>::initialize(JSContext* ctx, JSClassID* classId, JSClassExoticMethods* exoticMethods) {
template <typename P>
P* GarbageCollected<T>::initialize(JSContext* ctx, JSClassID* classId, JSClassExoticMethods* exoticMethods) {
JSRuntime* runtime = JS_GetRuntime(ctx);

/// When classId is 0, it means this class are not initialized. We should create a JSClassDef to describe the behavior of this class and associate with classID.
Expand Down Expand Up @@ -141,7 +144,8 @@ template <typename P> P* GarbageCollected<T>::initialize(JSContext* ctx, JSClass
}

template <typename T>
template <typename P> P* GarbageCollected<T>::initialize(JSContext* ctx, JSClassID* classId) {
template <typename P>
P* GarbageCollected<T>::initialize(JSContext* ctx, JSClassID* classId) {
return initialize<P>(ctx, classId, nullptr);
}

Expand Down
18 changes: 7 additions & 11 deletions bridge/bindings/qjs/js_context_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,45 +23,41 @@
#define IMPL_PROPERTY_GETTER(Constructor, Property) JSValue Constructor::Property##PropertyDescriptor::getter
#define IMPL_PROPERTY_SETTER(Constructor, Property) JSValue Constructor::Property##PropertyDescriptor::setter

#define INSTALL_READONLY_PROPERTY(Host, thisObject, property) \
installPropertyGetter(context.get(), thisObject, #property, Host::property##PropertyDescriptor::getter)
#define INSTALL_READONLY_PROPERTY(Host, thisObject, property) installPropertyGetter(context.get(), thisObject, #property, Host::property##PropertyDescriptor::getter)

#define INSTALL_PROPERTY(Host, thisObject, property) \
installPropertyGetterSetter(context.get(), thisObject, #property, Host::property##PropertyDescriptor::getter, Host::property##PropertyDescriptor::setter)

#define INSTALL_FUNCTION(Host, thisObject, property, argc) \
installFunctionProperty(context.get(), thisObject, #property, Host::m_##property##_, 1);
#define INSTALL_FUNCTION(Host, thisObject, property, argc) installFunctionProperty(context.get(), thisObject, #property, Host::m_##property##_, 1);

#define DEFINE_FUNCTION(NAME) \
static JSValue m_##NAME##_(JSContext* ctx, JSValueConst this_val, int argc, JSValueConst* argv);
#define DEFINE_FUNCTION(NAME) static JSValue m_##NAME##_(JSContext* ctx, JSValueConst this_val, int argc, JSValueConst* argv);

#define IMPL_FUNCTION(Host, NAME) JSValue Host::m_##NAME##_


#define DEFINE_PROTOTYPE_READONLY_PROPERTY(PROPERTY) \
class PROPERTY##PropertyDescriptor { \
public: \
static JSValue getter(JSContext* ctx, JSValueConst this_val, int argc, JSValueConst* argv); \
}; \
};

#define DEFINE_PROTOTYPE_PROPERTY(PROPERTY) \
class PROPERTY##PropertyDescriptor { \
public: \
static JSValue getter(JSContext* ctx, JSValueConst this_val, int argc, JSValueConst* argv); \
static JSValue setter(JSContext* ctx, JSValueConst this_val, int argc, JSValueConst* argv); \
}; \
};

#define DEFINE_READONLY_PROPERTY(PROPERTY) \
class PROPERTY##PropertyDescriptor { \
public: \
static JSValue getter(JSContext* ctx, JSValueConst this_val, int argc, JSValueConst* argv); \
}; \
};

#define DEFINE_PROPERTY(PROPERTY) \
class PROPERTY##PropertyDescriptor { \
public: \
static JSValue getter(JSContext* ctx, JSValueConst this_val, int argc, JSValueConst* argv); \
static JSValue setter(JSContext* ctx, JSValueConst this_val, int argc, JSValueConst* argv); \
}; \
};

#endif // KRAKENBRIDGE_JS_CONTEXT_MACROS_H
7 changes: 3 additions & 4 deletions bridge/bindings/qjs/wrapper_type_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#ifndef KRAKENBRIDGE_WRAPPER_TYPE_INFO_H
#define KRAKENBRIDGE_WRAPPER_TYPE_INFO_H

#include <quickjs/quickjs.h>
#include <assert.h>
#include <quickjs/quickjs.h>
#include "bindings/qjs/qjs_patch.h"
#include "include/kraken_foundation.h"

Expand All @@ -22,8 +22,7 @@ class WrapperTypeInfo final {
bool equals(const WrapperTypeInfo* that) const { return this == that; }

bool isSubclass(const WrapperTypeInfo* that) const {
for (const WrapperTypeInfo* current = this; current;
current = current->parent_class) {
for (const WrapperTypeInfo* current = this; current; current = current->parent_class) {
if (current == that)
return true;
}
Expand All @@ -37,6 +36,6 @@ class WrapperTypeInfo final {
JSClassID classId{0};
};

}
} // namespace kraken::binding::qjs

#endif // KRAKENBRIDGE_WRAPPER_TYPE_INFO_H
2 changes: 1 addition & 1 deletion bridge/page.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@

#include "bindings/qjs/bom/blob.h"
#include "bindings/qjs/bom/console.h"
#include "bindings/qjs/bom/location.h"
#include "bindings/qjs/bom/performance.h"
#include "bindings/qjs/bom/screen.h"
#include "bindings/qjs/bom/timer.h"
#include "bindings/qjs/bom/location.h"
#include "bindings/qjs/bom/window.h"
#include "bindings/qjs/dom/comment_node.h"
#include "bindings/qjs/dom/custom_event.h"
Expand Down

0 comments on commit aebe7b6

Please sign in to comment.