Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: optimize create element and create text node. #952

Merged
merged 26 commits into from
Dec 14, 2021
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
168841f
feat: optimize create element and create textnode.
andycall Dec 8, 2021
98224cf
feat: optimize all nodes.
andycall Dec 8, 2021
ad56a79
Committing clang-format changes
Dec 8, 2021
ee9388c
feat: create setter to standalone function.
andycall Dec 8, 2021
0d8300c
feat: generate setter by needs.
andycall Dec 8, 2021
e3f1ec8
feat: use JSPropertyDescriptor instead of magic
andycall Dec 8, 2021
15f9517
Merge branch 'feat/optimize-create-element' of github.com:openkraken/…
andycall Dec 8, 2021
6d26cae
Committing clang-format changes
Dec 8, 2021
e2aa09d
fix: fix customEvent.detail and Event.cancelBubble.
andycall Dec 9, 2021
d4caa50
Merge branch 'feat/optimize-create-element' of github.com:openkraken/…
andycall Dec 9, 2021
65c323f
chore: rename macros.
andycall Dec 9, 2021
6fa8be7
refactor: refactor TemplateElement.
andycall Dec 9, 2021
af2389e
chore: remove test code.
andycall Dec 9, 2021
22dd3e9
Committing clang-format changes
Dec 9, 2021
17ef126
Merge remote-tracking branch 'origin/main' into feat/optimize-create-…
andycall Dec 9, 2021
34df7da
refactor: rename PROP_GETTER and PROP_SETTER
andycall Dec 9, 2021
93fb600
Merge branch 'feat/optimize-create-element' of github.com:openkraken/…
andycall Dec 9, 2021
fb92107
fix: fix text node
andycall Dec 9, 2021
0da17b4
fix: rename prop macro and fix instance prototype.
andycall Dec 9, 2021
8d27fe8
fix: fix prop getter no ENUMERABLE.
andycall Dec 9, 2021
51a47e7
refactor: refactor macros.
andycall Dec 9, 2021
6b43f30
fix: fix code linter
andycall Dec 9, 2021
da84c1b
refactor: refactor ObjectFunction to macro.
andycall Dec 10, 2021
71b5549
fix: fix performance
andycall Dec 10, 2021
67088ec
fix: fix style methods.
andycall Dec 10, 2021
519c7d4
refactor: rename prop getter and setter.
andycall Dec 10, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/code_linter.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: Run Code Linter

on: [push]
on:
andycall marked this conversation as resolved.
Show resolved Hide resolved
push:
andycall marked this conversation as resolved.
Show resolved Hide resolved
branches:
- main

jobs:
reformat-bridge:
Expand Down
12 changes: 2 additions & 10 deletions bridge/bindings/qjs/bom/blob.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,15 @@ JSValue Blob::instanceConstructor(QjsContext* ctx, JSValue func_obj, JSValue thi
return blob->instanceObject;
}

PROP_GETTER(BlobInstance, type)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
PROP_GETTER_IMPL(Blob, type)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
auto* blobInstance = static_cast<BlobInstance*>(JS_GetOpaque(this_val, Blob::kBlobClassID));
return JS_NewString(blobInstance->m_ctx, blobInstance->mimeType.empty() ? "" : blobInstance->mimeType.c_str());
}
PROP_SETTER(BlobInstance, type)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
return JS_NULL;
}

PROP_GETTER(BlobInstance, size)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
PROP_GETTER_IMPL(Blob, size)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
auto* blobInstance = static_cast<BlobInstance*>(JS_GetOpaque(this_val, Blob::kBlobClassID));
return JS_NewFloat64(blobInstance->m_ctx, blobInstance->_size);
}
PROP_SETTER(BlobInstance, size)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
return JS_NULL;
}

JSValue Blob::arrayBuffer(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
JSValue resolving_funcs[2];
Expand Down Expand Up @@ -154,15 +148,13 @@ JSValue Blob::slice(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv)

if (start == 0 && end == blob->_data.size()) {
auto newBlob = new BlobInstance(reinterpret_cast<Blob*>(blob->m_hostClass), std::move(blob->_data), mimeType);
JS_SetPrototype(blob->m_ctx, newBlob->instanceObject, blob->m_hostClass->prototype());
return newBlob->instanceObject;
}
std::vector<uint8_t> newData;
newData.reserve(blob->_data.size() - (end - start));
newData.insert(newData.begin(), blob->_data.begin() + start, blob->_data.end() - (blob->_data.size() - end));

auto newBlob = new BlobInstance(reinterpret_cast<Blob*>(blob->m_hostClass), std::move(newData), mimeType);
JS_SetPrototype(blob->m_ctx, newBlob->instanceObject, blob->m_hostClass->prototype());
return newBlob->instanceObject;
}

Expand Down
2 changes: 1 addition & 1 deletion bridge/bindings/qjs/bom/blob.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class Blob : public HostClass {

private:
friend BlobInstance;
DEFINE_PROTOTYPE_READONLY_PROPERTY(2, type, size);

ObjectFunction m_arrayBuffer{m_context, m_prototypeObject, "arrayBuffer", arrayBuffer, 0};
ObjectFunction m_slice{m_context, m_prototypeObject, "slice", slice, 3};
Expand All @@ -51,7 +52,6 @@ class BlobInstance : public Instance {
int32_t size();

private:
DEFINE_HOST_CLASS_PROPERTY(2, type, size);
size_t _size;
std::string mimeType{""};
std::vector<uint8_t> _data;
Expand Down
20 changes: 10 additions & 10 deletions bridge/bindings/qjs/bom/performance.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,44 +18,44 @@ void bindPerformance(std::unique_ptr<JSContext>& context) {

using namespace std::chrono;

PROP_GETTER(PerformanceEntry, name)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
PROP_GETTER_IMPL(PerformanceEntry, name)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
auto* entry = static_cast<PerformanceEntry*>(JS_GetOpaque(this_val, JSContext::kHostObjectClassId));
return JS_NewString(ctx, entry->m_nativePerformanceEntry->name);
}
PROP_SETTER(PerformanceEntry, name)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
PROP_SETTER_IMPL(PerformanceEntry, name)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
return JS_NULL;
}

PROP_GETTER(PerformanceEntry, entryType)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
PROP_GETTER_IMPL(PerformanceEntry, entryType)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
auto* entry = static_cast<PerformanceEntry*>(JS_GetOpaque(this_val, JSContext::kHostObjectClassId));
return JS_NewString(ctx, entry->m_nativePerformanceEntry->entryType);
}
PROP_SETTER(PerformanceEntry, entryType)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
PROP_SETTER_IMPL(PerformanceEntry, entryType)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
return JS_NULL;
}

PROP_GETTER(PerformanceEntry, startTime)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
PROP_GETTER_IMPL(PerformanceEntry, startTime)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
andycall marked this conversation as resolved.
Show resolved Hide resolved
auto* entry = static_cast<PerformanceEntry*>(JS_GetOpaque(this_val, JSContext::kHostObjectClassId));
return JS_NewUint32(ctx, entry->m_nativePerformanceEntry->startTime);
}
PROP_SETTER(PerformanceEntry, startTime)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
PROP_SETTER_IMPL(PerformanceEntry, startTime)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
return JS_NULL;
}

PROP_GETTER(PerformanceEntry, duration)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
PROP_GETTER_IMPL(PerformanceEntry, duration)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
auto* entry = static_cast<PerformanceEntry*>(JS_GetOpaque(this_val, JSContext::kHostObjectClassId));
return JS_NewUint32(ctx, entry->m_nativePerformanceEntry->duration);
}
PROP_SETTER(PerformanceEntry, duration)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
PROP_SETTER_IMPL(PerformanceEntry, duration)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
return JS_NULL;
}

PROP_GETTER(Performance, timeOrigin)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
PROP_GETTER_IMPL(Performance, timeOrigin)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
auto* performance = static_cast<Performance*>(JS_GetOpaque(this_val, JSContext::kHostObjectClassId));
int64_t time = std::chrono::duration_cast<std::chrono::milliseconds>(performance->m_context->timeOrigin.time_since_epoch()).count();
return JS_NewUint32(ctx, time);
}
PROP_SETTER(Performance, timeOrigin)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
PROP_SETTER_IMPL(Performance, timeOrigin)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
return JS_NULL;
}

Expand Down
8 changes: 4 additions & 4 deletions bridge/bindings/qjs/bom/screen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ void bindScreen(std::unique_ptr<JSContext>& context) {
context->defineGlobalProperty("screen", screen->jsObject);
}

PROP_GETTER(Screen, width)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
PROP_GETTER_IMPL(Screen, width)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
if (getDartMethod()->getScreen == nullptr) {
return JS_ThrowTypeError(ctx, "Failed to read screen: dart method (getScreen) is not registered.");
}
Expand All @@ -21,11 +21,11 @@ PROP_GETTER(Screen, width)(QjsContext* ctx, JSValue this_val, int argc, JSValue*
NativeScreen* screen = getDartMethod()->getScreen(context->getContextId());
return JS_NewFloat64(ctx, screen->width);
}
PROP_SETTER(Screen, width)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
PROP_SETTER_IMPL(Screen, width)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
return JS_UNDEFINED;
}

PROP_GETTER(Screen, height)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
PROP_GETTER_IMPL(Screen, height)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
if (getDartMethod()->getScreen == nullptr) {
return JS_ThrowTypeError(ctx, "Failed to read screen: dart method (getScreen) is not registered.");
}
Expand All @@ -34,7 +34,7 @@ PROP_GETTER(Screen, height)(QjsContext* ctx, JSValue this_val, int argc, JSValue
NativeScreen* screen = getDartMethod()->getScreen(context->getContextId());
return JS_NewFloat64(ctx, screen->height);
}
PROP_SETTER(Screen, height)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
PROP_SETTER_IMPL(Screen, height)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
return JS_UNDEFINED;
}

Expand Down
50 changes: 12 additions & 38 deletions bridge/bindings/qjs/bom/window.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ JSValue Window::postMessage(QjsContext* ctx, JSValue this_val, int argc, JSValue
return JS_NULL;
}

PROP_GETTER(Window, devicePixelRatio)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
PROP_GETTER_IMPL(Window, devicePixelRatio)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
if (getDartMethod()->devicePixelRatio == nullptr) {
return JS_ThrowTypeError(ctx, "Failed to read devicePixelRatio: dart method (devicePixelRatio) is not register.");
}
Expand All @@ -79,11 +79,8 @@ PROP_GETTER(Window, devicePixelRatio)(QjsContext* ctx, JSValue this_val, int arg
double devicePixelRatio = getDartMethod()->devicePixelRatio(context->getContextId());
return JS_NewFloat64(ctx, devicePixelRatio);
}
PROP_SETTER(Window, devicePixelRatio)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
return JS_NULL;
}

PROP_GETTER(Window, colorScheme)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
PROP_GETTER_IMPL(Window, colorScheme)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
if (getDartMethod()->platformBrightness == nullptr) {
return JS_ThrowTypeError(ctx, "Failed to read colorScheme: dart method (platformBrightness) not register.");
}
Expand All @@ -92,62 +89,42 @@ PROP_GETTER(Window, colorScheme)(QjsContext* ctx, JSValue this_val, int argc, JS
const NativeString* code = getDartMethod()->platformBrightness(context->getContextId());
return JS_NewUnicodeString(context->runtime(), ctx, code->string, code->length);
}
PROP_SETTER(Window, colorScheme)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
return JS_NULL;
}

PROP_GETTER(Window, __location__)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
PROP_GETTER_IMPL(Window, __location__)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
auto* window = static_cast<WindowInstance*>(JS_GetOpaque(this_val, 1));
if (window == nullptr)
return JS_UNDEFINED;
return JS_DupValue(ctx, window->m_location.value());
}
PROP_SETTER(Window, __location__)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
return JS_NULL;
}

PROP_GETTER(Window, location)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
PROP_GETTER_IMPL(Window, location)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
auto* window = static_cast<WindowInstance*>(JS_GetOpaque(this_val, 1));
return JS_GetPropertyStr(ctx, window->m_context->global(), "location");
}
PROP_SETTER(Window, location)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
return JS_NULL;
}

PROP_GETTER(Window, window)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
PROP_GETTER_IMPL(Window, window)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
return JS_GetGlobalObject(ctx);
}
PROP_SETTER(Window, window)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
return JS_NULL;
}
PROP_GETTER(Window, parent)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {

PROP_GETTER_IMPL(Window, parent)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
return JS_GetGlobalObject(ctx);
}
PROP_SETTER(Window, parent)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
return JS_NULL;
}

PROP_GETTER(Window, scrollX)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
PROP_GETTER_IMPL(Window, scrollX)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
auto* window = static_cast<WindowInstance*>(JS_GetOpaque(this_val, 1));
return window->callNativeMethods("scrollX", 0, nullptr);
}
PROP_SETTER(Window, scrollX)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
return JS_NULL;
}

PROP_GETTER(Window, scrollY)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
PROP_GETTER_IMPL(Window, scrollY)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
auto* window = static_cast<WindowInstance*>(JS_GetOpaque(this_val, 1));
return window->callNativeMethods("scrollY", 0, nullptr);
}
PROP_SETTER(Window, scrollY)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
return JS_NULL;
}

PROP_GETTER(Window, onerror)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
PROP_GETTER_IMPL(Window, onerror)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
auto* window = static_cast<WindowInstance*>(JS_GetOpaque(this_val, 1));
return JS_DupValue(ctx, window->onerror);
}
PROP_SETTER(Window, onerror)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
PROP_SETTER_IMPL(Window, onerror)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
auto* window = static_cast<WindowInstance*>(JS_GetOpaque(this_val, 1));
JSValue eventString = JS_NewString(ctx, "onerror");
JSString* p = JS_VALUE_GET_STRING(eventString);
Expand All @@ -162,10 +139,7 @@ PROP_SETTER(Window, onerror)(QjsContext* ctx, JSValue this_val, int argc, JSValu
return JS_NULL;
}

PROP_SETTER(Window, self)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
return JS_NULL;
}
PROP_GETTER(Window, self)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
PROP_GETTER_IMPL(Window, self)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
return JS_GetGlobalObject(ctx);
}

Expand Down
3 changes: 2 additions & 1 deletion bridge/bindings/qjs/bom/window.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ class Window : public EventTarget {
ObjectFunction m_scrollBy{m_context, m_prototypeObject, "scrollBy", scrollBy, 2};
ObjectFunction m_postMessage{m_context, m_prototypeObject, "postMessage", postMessage, 3};

DEFINE_HOST_CLASS_PROTOTYPE_PROPERTY(10, devicePixelRatio, colorScheme, __location__, location, window, parent, scrollX, scrollY, onerror, self);
DEFINE_PROTOTYPE_READONLY_PROPERTY(9, devicePixelRatio, colorScheme, __location__, location, window, parent, scrollX, scrollY, self)
DEFINE_PROTOTYPE_PROPERTY(1, onerror);
friend WindowInstance;
};

Expand Down
4 changes: 2 additions & 2 deletions bridge/bindings/qjs/dom/all_collection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ void AllCollection::internalAdd(NodeInstance* node, NodeInstance* before) {
}
}

PROP_GETTER(AllCollection, length)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
PROP_GETTER_IMPL(AllCollection, length)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
auto* collection = static_cast<AllCollection*>(JS_GetOpaque(this_val, JSContext::kHostObjectClassId));
return JS_NewUint32(ctx, collection->m_nodes.size());
}
PROP_SETTER(AllCollection, length)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
PROP_SETTER_IMPL(AllCollection, length)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
return JS_NULL;
}

Expand Down
15 changes: 3 additions & 12 deletions bridge/bindings/qjs/dom/comment_node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,17 @@ JSValue Comment::instanceConstructor(QjsContext* ctx, JSValue func_obj, JSValue
return (new CommentInstance(this))->instanceObject;
}

PROP_GETTER(CommentInstance, data)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
PROP_GETTER_IMPL(Comment, data)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
return JS_NewString(ctx, "");
}
PROP_SETTER(CommentInstance, data)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
return JS_NULL;
}

PROP_GETTER(CommentInstance, nodeName)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
PROP_GETTER_IMPL(Comment, nodeName)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
return JS_NewString(ctx, "#comment");
}
PROP_SETTER(CommentInstance, nodeName)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
return JS_NULL;
}

PROP_GETTER(CommentInstance, length)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
PROP_GETTER_IMPL(Comment, length)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
return JS_NewUint32(ctx, 0);
}
PROP_SETTER(CommentInstance, length)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
return JS_NULL;
}

CommentInstance::CommentInstance(Comment* comment) : NodeInstance(comment, NodeType::COMMENT_NODE, DocumentInstance::instance(Document::instance(comment->m_context)), Comment::classId(), "Comment") {
::foundation::UICommandBuffer::instance(m_context->getContextId())->addCommand(m_eventTargetId, UICommand::createComment, nativeEventTarget);
Expand Down
3 changes: 1 addition & 2 deletions bridge/bindings/qjs/dom/comment_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class Comment : public Node {
JSValue instanceConstructor(QjsContext* ctx, JSValue func_obj, JSValue this_val, int argc, JSValue* argv) override;

private:
DEFINE_PROTOTYPE_READONLY_PROPERTY(3, data, nodeName, length)
friend CommentInstance;
};

Expand All @@ -35,8 +36,6 @@ class CommentInstance : public NodeInstance {
explicit CommentInstance(Comment* comment);

private:
DEFINE_HOST_CLASS_PROPERTY(3, data, nodeName, length)

friend Comment;
};

Expand Down
9 changes: 1 addition & 8 deletions bridge/bindings/qjs/dom/custom_event.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,10 @@ JSValue CustomEvent::instanceConstructor(QjsContext* ctx, JSValue func_obj, JSVa
return customEvent->instanceObject;
}

PROP_GETTER(CustomEventInstance, detail)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
PROP_GETTER_IMPL(CustomEvent, detail)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
auto* customEventInstance = static_cast<CustomEventInstance*>(JS_GetOpaque(this_val, Event::kEventClassID));
return customEventInstance->m_detail.value();
}
PROP_SETTER(CustomEventInstance, detail)(QjsContext* ctx, JSValue this_val, int argc, JSValue* argv) {
if (argc == 0)
return JS_NULL;
auto* customEventInstance = static_cast<CustomEventInstance*>(JS_GetOpaque(this_val, Event::kEventClassID));
customEventInstance->m_detail.value(argv[0]);
return JS_NULL;
}

CustomEventInstance::CustomEventInstance(CustomEvent* jsCustomEvent, JSAtom customEventType, JSValue eventInit) : EventInstance(jsCustomEvent, customEventType, eventInit) {
if (!JS_IsNull(eventInit)) {
Expand Down
3 changes: 1 addition & 2 deletions bridge/bindings/qjs/dom/custom_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class CustomEvent : public Event {
OBJECT_INSTANCE(CustomEvent);

private:
DEFINE_PROTOTYPE_READONLY_PROPERTY(1, detail);
ObjectFunction m_initCustomEvent{m_context, m_prototypeObject, "initCustomEvent", initCustomEvent, 4};
friend CustomEventInstance;
};
Expand All @@ -39,8 +40,6 @@ class CustomEventInstance : public EventInstance {
explicit CustomEventInstance(CustomEvent* jsCustomEvent, NativeCustomEvent* nativeCustomEvent);

private:
DEFINE_HOST_CLASS_PROPERTY(1, detail);

JSValueHolder m_detail{m_ctx, JS_NULL};
NativeCustomEvent* nativeCustomEvent{nullptr};
friend CustomEvent;
Expand Down
Loading