| 1 | /* |
| 2 | This file is part of the WebKit open source project. |
| 3 | This file has been generated by generate-bindings.pl. DO NOT MODIFY! |
| 4 | |
| 5 | This library is free software; you can redistribute it and/or |
| 6 | modify it under the terms of the GNU Library General Public |
| 7 | License as published by the Free Software Foundation; either |
| 8 | version 2 of the License, or (at your option) any later version. |
| 9 | |
| 10 | This library is distributed in the hope that it will be useful, |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | Library General Public License for more details. |
| 14 | |
| 15 | You should have received a copy of the GNU Library General Public License |
| 16 | along with this library; see the file COPYING.LIB. If not, write to |
| 17 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 18 | Boston, MA 02110-1301, USA. |
| 19 | */ |
| 20 | |
| 21 | #include "config.h" |
| 22 | |
| 23 | #if ENABLE(WEBGPU) |
| 24 | |
| 25 | #include "JSWebGPURenderPassDescriptor.h" |
| 26 | |
| 27 | #include "JSDOMConvertEnumeration.h" |
| 28 | #include "JSDOMConvertInterface.h" |
| 29 | #include "JSDOMConvertNullable.h" |
| 30 | #include "JSDOMConvertNumbers.h" |
| 31 | #include "JSDOMConvertSequences.h" |
| 32 | #include "JSGPUColor.h" |
| 33 | #include "JSGPULoadOp.h" |
| 34 | #include "JSGPUStoreOp.h" |
| 35 | #include "JSWebGPUTextureView.h" |
| 36 | #include <JavaScriptCore/JSArray.h> |
| 37 | #include <JavaScriptCore/JSCInlines.h> |
| 38 | |
| 39 | |
| 40 | namespace WebCore { |
| 41 | using namespace JSC; |
| 42 | |
| 43 | #if ENABLE(WEBGPU) |
| 44 | |
| 45 | template<> WebGPURenderPassDescriptor convertDictionary<WebGPURenderPassDescriptor>(ExecState& state, JSValue value) |
| 46 | { |
| 47 | VM& vm = state.vm(); |
| 48 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 49 | bool isNullOrUndefined = value.isUndefinedOrNull(); |
| 50 | auto* object = isNullOrUndefined ? nullptr : value.getObject(); |
| 51 | if (UNLIKELY(!isNullOrUndefined && !object)) { |
| 52 | throwTypeError(&state, throwScope); |
| 53 | return { }; |
| 54 | } |
| 55 | WebGPURenderPassDescriptor result; |
| 56 | JSValue colorAttachmentsValue; |
| 57 | if (isNullOrUndefined) |
| 58 | colorAttachmentsValue = jsUndefined(); |
| 59 | else { |
| 60 | colorAttachmentsValue = object->get(&state, Identifier::fromString(&state, "colorAttachments" )); |
| 61 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 62 | } |
| 63 | if (!colorAttachmentsValue.isUndefined()) { |
| 64 | result.colorAttachments = convert<IDLSequence<IDLDictionary<WebGPURenderPassColorAttachmentDescriptor>>>(state, colorAttachmentsValue); |
| 65 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 66 | } else { |
| 67 | throwRequiredMemberTypeError(state, throwScope, "colorAttachments" , "WebGPURenderPassDescriptor" , "sequence" ); |
| 68 | return { }; |
| 69 | } |
| 70 | JSValue depthStencilAttachmentValue; |
| 71 | if (isNullOrUndefined) |
| 72 | depthStencilAttachmentValue = jsUndefined(); |
| 73 | else { |
| 74 | depthStencilAttachmentValue = object->get(&state, Identifier::fromString(&state, "depthStencilAttachment" )); |
| 75 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 76 | } |
| 77 | if (!depthStencilAttachmentValue.isUndefined()) { |
| 78 | result.depthStencilAttachment = convert<IDLNullable<IDLDictionary<WebGPURenderPassDepthStencilAttachmentDescriptor>>>(state, depthStencilAttachmentValue); |
| 79 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 80 | } else |
| 81 | result.depthStencilAttachment = WTF::nullopt; |
| 82 | return result; |
| 83 | } |
| 84 | |
| 85 | #endif |
| 86 | |
| 87 | #if ENABLE(WEBGPU) |
| 88 | |
| 89 | template<> WebGPURenderPassColorAttachmentDescriptor convertDictionary<WebGPURenderPassColorAttachmentDescriptor>(ExecState& state, JSValue value) |
| 90 | { |
| 91 | VM& vm = state.vm(); |
| 92 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 93 | bool isNullOrUndefined = value.isUndefinedOrNull(); |
| 94 | auto* object = isNullOrUndefined ? nullptr : value.getObject(); |
| 95 | if (UNLIKELY(!isNullOrUndefined && !object)) { |
| 96 | throwTypeError(&state, throwScope); |
| 97 | return { }; |
| 98 | } |
| 99 | WebGPURenderPassColorAttachmentDescriptor result; |
| 100 | JSValue attachmentValue; |
| 101 | if (isNullOrUndefined) |
| 102 | attachmentValue = jsUndefined(); |
| 103 | else { |
| 104 | attachmentValue = object->get(&state, Identifier::fromString(&state, "attachment" )); |
| 105 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 106 | } |
| 107 | if (!attachmentValue.isUndefined()) { |
| 108 | result.attachment = convert<IDLInterface<WebGPUTextureView>>(state, attachmentValue); |
| 109 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 110 | } else { |
| 111 | throwRequiredMemberTypeError(state, throwScope, "attachment" , "GPURenderPassColorAttachmentDescriptor" , "WebGPUTextureView" ); |
| 112 | return { }; |
| 113 | } |
| 114 | JSValue clearColorValue; |
| 115 | if (isNullOrUndefined) |
| 116 | clearColorValue = jsUndefined(); |
| 117 | else { |
| 118 | clearColorValue = object->get(&state, Identifier::fromString(&state, "clearColor" )); |
| 119 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 120 | } |
| 121 | if (!clearColorValue.isUndefined()) { |
| 122 | result.clearColor = convert<IDLDictionary<GPUColor>>(state, clearColorValue); |
| 123 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 124 | } |
| 125 | JSValue loadOpValue; |
| 126 | if (isNullOrUndefined) |
| 127 | loadOpValue = jsUndefined(); |
| 128 | else { |
| 129 | loadOpValue = object->get(&state, Identifier::fromString(&state, "loadOp" )); |
| 130 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 131 | } |
| 132 | if (!loadOpValue.isUndefined()) { |
| 133 | result.loadOp = convert<IDLEnumeration<GPULoadOp>>(state, loadOpValue); |
| 134 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 135 | } else { |
| 136 | throwRequiredMemberTypeError(state, throwScope, "loadOp" , "GPURenderPassColorAttachmentDescriptor" , "GPULoadOp" ); |
| 137 | return { }; |
| 138 | } |
| 139 | JSValue storeOpValue; |
| 140 | if (isNullOrUndefined) |
| 141 | storeOpValue = jsUndefined(); |
| 142 | else { |
| 143 | storeOpValue = object->get(&state, Identifier::fromString(&state, "storeOp" )); |
| 144 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 145 | } |
| 146 | if (!storeOpValue.isUndefined()) { |
| 147 | result.storeOp = convert<IDLEnumeration<GPUStoreOp>>(state, storeOpValue); |
| 148 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 149 | } else { |
| 150 | throwRequiredMemberTypeError(state, throwScope, "storeOp" , "GPURenderPassColorAttachmentDescriptor" , "GPUStoreOp" ); |
| 151 | return { }; |
| 152 | } |
| 153 | return result; |
| 154 | } |
| 155 | |
| 156 | #endif |
| 157 | |
| 158 | #if ENABLE(WEBGPU) |
| 159 | |
| 160 | template<> WebGPURenderPassDepthStencilAttachmentDescriptor convertDictionary<WebGPURenderPassDepthStencilAttachmentDescriptor>(ExecState& state, JSValue value) |
| 161 | { |
| 162 | VM& vm = state.vm(); |
| 163 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 164 | bool isNullOrUndefined = value.isUndefinedOrNull(); |
| 165 | auto* object = isNullOrUndefined ? nullptr : value.getObject(); |
| 166 | if (UNLIKELY(!isNullOrUndefined && !object)) { |
| 167 | throwTypeError(&state, throwScope); |
| 168 | return { }; |
| 169 | } |
| 170 | WebGPURenderPassDepthStencilAttachmentDescriptor result; |
| 171 | JSValue attachmentValue; |
| 172 | if (isNullOrUndefined) |
| 173 | attachmentValue = jsUndefined(); |
| 174 | else { |
| 175 | attachmentValue = object->get(&state, Identifier::fromString(&state, "attachment" )); |
| 176 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 177 | } |
| 178 | if (!attachmentValue.isUndefined()) { |
| 179 | result.attachment = convert<IDLInterface<WebGPUTextureView>>(state, attachmentValue); |
| 180 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 181 | } else { |
| 182 | throwRequiredMemberTypeError(state, throwScope, "attachment" , "GPURenderPassDepthStencilAttachmentDescriptor" , "WebGPUTextureView" ); |
| 183 | return { }; |
| 184 | } |
| 185 | JSValue clearDepthValue; |
| 186 | if (isNullOrUndefined) |
| 187 | clearDepthValue = jsUndefined(); |
| 188 | else { |
| 189 | clearDepthValue = object->get(&state, Identifier::fromString(&state, "clearDepth" )); |
| 190 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 191 | } |
| 192 | if (!clearDepthValue.isUndefined()) { |
| 193 | result.clearDepth = convert<IDLFloat>(state, clearDepthValue); |
| 194 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 195 | } else { |
| 196 | throwRequiredMemberTypeError(state, throwScope, "clearDepth" , "GPURenderPassDepthStencilAttachmentDescriptor" , "float" ); |
| 197 | return { }; |
| 198 | } |
| 199 | JSValue depthLoadOpValue; |
| 200 | if (isNullOrUndefined) |
| 201 | depthLoadOpValue = jsUndefined(); |
| 202 | else { |
| 203 | depthLoadOpValue = object->get(&state, Identifier::fromString(&state, "depthLoadOp" )); |
| 204 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 205 | } |
| 206 | if (!depthLoadOpValue.isUndefined()) { |
| 207 | result.depthLoadOp = convert<IDLEnumeration<GPULoadOp>>(state, depthLoadOpValue); |
| 208 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 209 | } else { |
| 210 | throwRequiredMemberTypeError(state, throwScope, "depthLoadOp" , "GPURenderPassDepthStencilAttachmentDescriptor" , "GPULoadOp" ); |
| 211 | return { }; |
| 212 | } |
| 213 | JSValue depthStoreOpValue; |
| 214 | if (isNullOrUndefined) |
| 215 | depthStoreOpValue = jsUndefined(); |
| 216 | else { |
| 217 | depthStoreOpValue = object->get(&state, Identifier::fromString(&state, "depthStoreOp" )); |
| 218 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 219 | } |
| 220 | if (!depthStoreOpValue.isUndefined()) { |
| 221 | result.depthStoreOp = convert<IDLEnumeration<GPUStoreOp>>(state, depthStoreOpValue); |
| 222 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 223 | } else { |
| 224 | throwRequiredMemberTypeError(state, throwScope, "depthStoreOp" , "GPURenderPassDepthStencilAttachmentDescriptor" , "GPUStoreOp" ); |
| 225 | return { }; |
| 226 | } |
| 227 | return result; |
| 228 | } |
| 229 | |
| 230 | #endif |
| 231 | |
| 232 | } // namespace WebCore |
| 233 | |
| 234 | #endif // ENABLE(WEBGPU) |
| 235 | |