Skip to content

Commit 892c7c8

Browse files
committed
chore: reformat
1 parent 5a63ef5 commit 892c7c8

File tree

1 file changed

+23
-22
lines changed

1 file changed

+23
-22
lines changed

bridge/bindings/qjs/js_context.h

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
#ifndef KRAKENBRIDGE_JS_CONTEXT_H
77
#define KRAKENBRIDGE_JS_CONTEXT_H
88

9+
#include "js_context_macros.h"
910
#include "kraken_foundation.h"
11+
#include "qjs_patch.h"
1012
#include <memory>
11-
#include <unordered_map>
12-
#include <quickjs/quickjs.h>
1313
#include <quickjs/list.h>
14-
#include "js_context_macros.h"
15-
#include "qjs_patch.h"
14+
#include <quickjs/quickjs.h>
15+
#include <unordered_map>
1616

1717
using QjsContext = JSContext;
1818
using JSExceptionHandler = std::function<void(int32_t contextId, const char *message)>;
@@ -67,10 +67,10 @@ class JSContext {
6767
bool handleException(JSValue *exc);
6868
void drainPendingPromiseJobs();
6969
void defineGlobalProperty(const char *prop, JSValueConst value);
70-
uint8_t *dumpByteCode(const char* code, uint32_t codeLength, const char *sourceURL, size_t* bytecodeLength);
70+
uint8_t *dumpByteCode(const char *code, uint32_t codeLength, const char *sourceURL, size_t *bytecodeLength);
7171

7272
std::chrono::time_point<std::chrono::system_clock> timeOrigin;
73-
std::unordered_map<std::string, void*> constructorMap;
73+
std::unordered_map<std::string, void *> constructorMap;
7474

7575
int32_t uniqueId;
7676
struct list_head node_job_list;
@@ -87,7 +87,6 @@ class JSContext {
8787
static JSClassID kHostExoticObjectClassId;
8888

8989
private:
90-
9190
static void promiseRejectTracker(QjsContext *ctx, JSValueConst promise, JSValueConst reason, JS_BOOL is_handled,
9291
void *opaque);
9392
void dispatchGlobalErrorEvent(JSValueConst error);
@@ -105,9 +104,10 @@ class JSContext {
105104
WindowInstance *m_window{nullptr};
106105
};
107106

108-
// The read object's method or properties via Proxy, we should redirect this_val from Proxy into target property of proxy object.
107+
// The read object's method or properties via Proxy, we should redirect this_val from Proxy into target property of
108+
// proxy object.
109109
static JSValue handleCallThisOnProxy(QjsContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv, int data_len,
110-
JSValueConst *data) {
110+
JSValueConst *data) {
111111
JSValue f = data[0];
112112
JSValue result;
113113
if (JS_IsProxy(this_val)) {
@@ -123,8 +123,8 @@ class ObjectProperty {
123123

124124
public:
125125
ObjectProperty() = delete;
126-
explicit ObjectProperty(JSContext *context, JSValueConst thisObject, const char *property,
127-
JSCFunction getterFunction, JSCFunction setterFunction) {
126+
explicit ObjectProperty(JSContext *context, JSValueConst thisObject, const char *property, JSCFunction getterFunction,
127+
JSCFunction setterFunction) {
128128
JSValue ge = JS_NewCFunction(context->ctx(), getterFunction, "get", 0);
129129
JSValue se = JS_NewCFunction(context->ctx(), setterFunction, "set", 1);
130130

@@ -135,16 +135,15 @@ class ObjectProperty {
135135
JS_FreeValue(context->ctx(), se);
136136

137137
JSAtom key = JS_NewAtom(context->ctx(), property);
138-
JS_DefinePropertyGetSet(context->ctx(), thisObject, key, pge, pse,
139-
JS_PROP_C_W_E);
138+
JS_DefinePropertyGetSet(context->ctx(), thisObject, key, pge, pse, JS_PROP_C_W_E);
140139
JS_FreeAtom(context->ctx(), key);
141140
};
142141
explicit ObjectProperty(JSContext *context, JSValueConst thisObject, const char *property,
143142
JSCFunction getterFunction) {
144143
JSValue get = JS_NewCFunction(context->ctx(), getterFunction, "get", 0);
145144
JSAtom key = JS_NewAtom(context->ctx(), property);
146145
JS_DefineProperty(context->ctx(), thisObject, key, JS_UNDEFINED, get, JS_UNDEFINED,
147-
JS_PROP_HAS_CONFIGURABLE | JS_PROP_ENUMERABLE | JS_PROP_HAS_GET);
146+
JS_PROP_HAS_CONFIGURABLE | JS_PROP_ENUMERABLE | JS_PROP_HAS_GET);
148147
JS_FreeAtom(context->ctx(), key);
149148
}
150149
};
@@ -154,8 +153,8 @@ class ObjectFunction {
154153

155154
public:
156155
ObjectFunction() = delete;
157-
explicit ObjectFunction(JSContext *context, JSValueConst thisObject, const char *functionName,
158-
JSCFunction function, int argc) {
156+
explicit ObjectFunction(JSContext *context, JSValueConst thisObject, const char *functionName, JSCFunction function,
157+
int argc) {
159158
JSValue f = JS_NewCFunction(context->ctx(), function, functionName, argc);
160159
JSValue pf = JS_NewCFunctionData(context->ctx(), handleCallThisOnProxy, argc, 0, 1, &f);
161160
JSAtom key = JS_NewAtom(context->ctx(), functionName);
@@ -164,19 +163,19 @@ class ObjectFunction {
164163

165164
// We should avoid overwrite exist property functions.
166165
#ifdef DEBUG
167-
assert_m(JS_HasProperty(context->ctx(), thisObject, key) == 0, (std::string("Found exist function property: ") + std::string(functionName)).c_str());
166+
assert_m(JS_HasProperty(context->ctx(), thisObject, key) == 0,
167+
(std::string("Found exist function property: ") + std::string(functionName)).c_str());
168168
#endif
169169

170-
JS_DefinePropertyValue(context->ctx(), thisObject, key, pf,
171-
JS_PROP_ENUMERABLE);
170+
JS_DefinePropertyValue(context->ctx(), thisObject, key, pf, JS_PROP_ENUMERABLE);
172171
JS_FreeAtom(context->ctx(), key);
173172
};
174173
};
175174

176175
class JSValueHolder {
177176
public:
178177
JSValueHolder() = delete;
179-
explicit JSValueHolder(QjsContext *ctx, JSValue value): m_value(value), m_ctx(ctx) {};
178+
explicit JSValueHolder(QjsContext *ctx, JSValue value) : m_value(value), m_ctx(ctx){};
180179
~JSValueHolder() {
181180
JS_FreeValue(m_ctx, m_value);
182181
}
@@ -186,7 +185,10 @@ class JSValueHolder {
186185
}
187186
m_value = JS_DupValue(m_ctx, value);
188187
};
189-
inline JSValue value() const { return JS_DupValue(m_ctx, m_value); }
188+
inline JSValue value() const {
189+
return JS_DupValue(m_ctx, m_value);
190+
}
191+
190192
private:
191193
QjsContext *m_ctx{nullptr};
192194
JSValue m_value{JS_NULL};
@@ -208,7 +210,6 @@ void arraySpliceValue(QjsContext *ctx, JSValue array, uint32_t start, uint32_t d
208210
void arraySpliceValue(QjsContext *ctx, JSValue array, uint32_t start, uint32_t deleteCount, JSValue replacedValue);
209211
JSValue objectGetKeys(QjsContext *ctx, JSValue obj);
210212

211-
212213
} // namespace kraken::binding::qjs
213214

214215
#endif // KRAKENBRIDGE_JS_CONTEXT_H

0 commit comments

Comments
 (0)