mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-24 18:02:20 +00:00
This will allow us to use the GC to manage the lifetime of objects that are not C++ objects, such as Swift objects. In the future we could expand this cursed FFI to other languages as well.
57 lines
1.3 KiB
C++
57 lines
1.3 KiB
C++
/*
|
|
* Copyright (c) 2024, Matthew Olsson <mattco@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
// RUN: %clang++ -cc1 -verify %plugin_opts% %s 2>&1
|
|
// expected-no-diagnostics
|
|
|
|
#include <LibGC/ForeignCell.h>
|
|
#include <LibJS/Runtime/PrototypeObject.h>
|
|
#include <LibWeb/Bindings/PlatformObject.h>
|
|
|
|
class TestCellClass : JS::Cell {
|
|
GC_CELL(TestCellClass, JS::Cell);
|
|
};
|
|
|
|
class TestForeignCellClass : GC::ForeignCell {
|
|
FOREIGN_CELL(TestForeignCellClass, GC::ForeignCell);
|
|
};
|
|
|
|
class TestObjectClass : JS::Object {
|
|
JS_OBJECT(TestObjectClass, JS::Object);
|
|
};
|
|
|
|
class TestEnvironmentClass : JS::Environment {
|
|
JS_ENVIRONMENT(TestEnvironmentClass, JS::Environment);
|
|
};
|
|
|
|
class TestPlatformClass : Web::Bindings::PlatformObject {
|
|
WEB_PLATFORM_OBJECT(TestPlatformClass, Web::Bindings::PlatformObject);
|
|
};
|
|
|
|
namespace JS {
|
|
|
|
class TestPrototypeClass : JS::PrototypeObject<TestCellClass, TestCellClass> {
|
|
JS_PROTOTYPE_OBJECT(TestPrototypeClass, TestCellClass, TestCellClass);
|
|
};
|
|
|
|
}
|
|
|
|
// Nested classes
|
|
class Parent1 { };
|
|
class Parent2 : JS::Cell {
|
|
GC_CELL(Parent2, JS::Cell);
|
|
};
|
|
class Parent3 { };
|
|
class Parent4 : public Parent2 {
|
|
GC_CELL(Parent4, Parent2);
|
|
};
|
|
|
|
class NestedCellClass
|
|
: Parent1
|
|
, Parent3
|
|
, Parent4 {
|
|
GC_CELL(NestedCellClass, Parent4); // Not Parent2
|
|
};
|