1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "CompilationInfo.h"
7 #include "CompilationMessage.h"
8 #include "ShaderModule.h"
9 #include "mozilla/dom/WebGPUBinding.h"
11 namespace mozilla::webgpu
{
13 GPU_IMPL_CYCLE_COLLECTION(CompilationInfo
, mParent
, mMessages
)
14 GPU_IMPL_JS_WRAP(CompilationInfo
)
16 CompilationInfo::CompilationInfo(Device
* const aParent
) : ChildOf(aParent
) {}
18 void CompilationInfo::SetMessages(
19 nsTArray
<mozilla::webgpu::WebGPUCompilationMessage
>& aMessages
) {
20 for (auto& msg
: aMessages
) {
21 mMessages
.AppendElement(MakeAndAddRef
<mozilla::webgpu::CompilationMessage
>(
22 mParent
, msg
.lineNum
, msg
.linePos
, msg
.offset
, std::move(msg
.message
)));
26 void CompilationInfo::GetMessages(
27 nsTArray
<RefPtr
<mozilla::webgpu::CompilationMessage
>>& aMessages
) {
28 for (auto& msg
: mMessages
) {
29 aMessages
.AppendElement(msg
);
33 } // namespace mozilla::webgpu