mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-02 04:27:12 +02:00
LibWasm+LibWeb: Partially resolve memory exports
This allows the JS side to access the wasm memory, assuming it's exported by the module. This can be used to draw stuff on the wasm side and display them from the js side, for example :^)
This commit is contained in:
committed by
Ali Mohammad Pur
parent
4a459d2430
commit
cf8b75c2e5
Notes:
sideshowbarker
2024-07-18 17:23:16 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/cf8b75c2e57 Pull-request: https://github.com/SerenityOS/serenity/pull/7395 Reviewed-by: https://github.com/linusg
@@ -9,6 +9,7 @@
|
||||
#include <LibJS/Runtime/Object.h>
|
||||
#include <LibWasm/AbstractMachine/AbstractMachine.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
#include <LibWeb/WebAssembly/WebAssemblyObjectPrototype.h>
|
||||
|
||||
namespace Web::Bindings {
|
||||
|
||||
@@ -58,21 +59,6 @@ private:
|
||||
size_t m_index { 0 };
|
||||
};
|
||||
|
||||
class WebAssemblyInstancePrototype final : public JS::Object {
|
||||
JS_OBJECT(WebAssemblyInstancePrototype, JS::Object);
|
||||
|
||||
public:
|
||||
explicit WebAssemblyInstancePrototype(JS::GlobalObject& global_object)
|
||||
: JS::Object(global_object)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void initialize(JS::GlobalObject&) override;
|
||||
|
||||
private:
|
||||
JS_DECLARE_NATIVE_GETTER(exports_getter);
|
||||
};
|
||||
|
||||
class WebAssemblyInstanceObject final : public JS::Object {
|
||||
JS_OBJECT(WebAssemblyInstanceObject, JS::Object);
|
||||
|
||||
@@ -93,4 +79,21 @@ private:
|
||||
JS::Object* m_exports_object { nullptr };
|
||||
};
|
||||
|
||||
class WebAssemblyMemoryObject final : public JS::Object {
|
||||
JS_OBJECT(WebAssemblyModuleObject, JS::Object);
|
||||
|
||||
public:
|
||||
explicit WebAssemblyMemoryObject(JS::GlobalObject&, Wasm::MemoryAddress);
|
||||
virtual void initialize(JS::GlobalObject&) override;
|
||||
virtual ~WebAssemblyMemoryObject() override = default;
|
||||
|
||||
auto address() const { return m_address; }
|
||||
|
||||
private:
|
||||
JS_DECLARE_NATIVE_FUNCTION(grow);
|
||||
JS_DECLARE_NATIVE_GETTER(buffer);
|
||||
|
||||
Wasm::MemoryAddress m_address;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user