diff --git a/deno_webgpu/adapter.rs b/deno_webgpu/adapter.rs index e731c2287..711a7190c 100644 --- a/deno_webgpu/adapter.rs +++ b/deno_webgpu/adapter.rs @@ -13,6 +13,7 @@ use deno_core::V8TaskSpawner; use deno_core::WebIDL; use super::device::GPUDevice; +use crate::error::GPUGenericError; use crate::webidl::features_to_feature_names; use crate::webidl::GPUFeatureName; use crate::Instance; @@ -68,6 +69,12 @@ impl GarbageCollected for GPUAdapter { #[op2] impl GPUAdapter { + #[constructor] + #[cppgc] + fn constructor(_: bool) -> Result { + Err(GPUGenericError::InvalidConstructor) + } + #[getter] #[global] fn info(&self, scope: &mut v8::HandleScope) -> v8::Global { @@ -223,6 +230,12 @@ impl GarbageCollected for GPUSupportedLimits { #[op2] impl GPUSupportedLimits { + #[constructor] + #[cppgc] + fn constructor(_: bool) -> Result { + Err(GPUGenericError::InvalidConstructor) + } + #[getter] fn maxTextureDimension1D(&self) -> u32 { self.0.max_texture_dimension_1d @@ -401,6 +414,12 @@ impl GPUSupportedFeatures { #[op2] impl GPUSupportedFeatures { + #[constructor] + #[cppgc] + fn constructor(_: bool) -> Result { + Err(GPUGenericError::InvalidConstructor) + } + #[global] #[symbol("setlike_set")] fn set(&self) -> v8::Global { @@ -422,6 +441,12 @@ impl GarbageCollected for GPUAdapterInfo { #[op2] impl GPUAdapterInfo { + #[constructor] + #[cppgc] + fn constructor(_: bool) -> Result { + Err(GPUGenericError::InvalidConstructor) + } + #[getter] #[string] fn vendor(&self) -> String { diff --git a/deno_webgpu/bind_group.rs b/deno_webgpu/bind_group.rs index 3cd658056..d003ede44 100644 --- a/deno_webgpu/bind_group.rs +++ b/deno_webgpu/bind_group.rs @@ -15,6 +15,7 @@ use deno_core::GarbageCollected; use deno_core::WebIDL; use crate::buffer::GPUBuffer; +use crate::error::GPUGenericError; use crate::sampler::GPUSampler; use crate::texture::GPUTextureView; use crate::Instance; @@ -43,6 +44,12 @@ impl GarbageCollected for GPUBindGroup { #[op2] impl GPUBindGroup { + #[constructor] + #[cppgc] + fn constructor(_: bool) -> Result { + Err(GPUGenericError::InvalidConstructor) + } + #[getter] #[string] fn label(&self) -> String { diff --git a/deno_webgpu/bind_group_layout.rs b/deno_webgpu/bind_group_layout.rs index 7b50e6e05..79b7bbe0b 100644 --- a/deno_webgpu/bind_group_layout.rs +++ b/deno_webgpu/bind_group_layout.rs @@ -4,6 +4,7 @@ use deno_core::op2; use deno_core::GarbageCollected; use deno_core::WebIDL; +use crate::error::GPUGenericError; use crate::texture::GPUTextureViewDimension; use crate::Instance; @@ -31,6 +32,12 @@ impl GarbageCollected for GPUBindGroupLayout { #[op2] impl GPUBindGroupLayout { + #[constructor] + #[cppgc] + fn constructor(_: bool) -> Result { + Err(GPUGenericError::InvalidConstructor) + } + #[getter] #[string] fn label(&self) -> String { diff --git a/deno_webgpu/buffer.rs b/deno_webgpu/buffer.rs index e2ef511f3..bff429dfe 100644 --- a/deno_webgpu/buffer.rs +++ b/deno_webgpu/buffer.rs @@ -13,6 +13,7 @@ use deno_core::WebIDL; use deno_error::JsErrorBox; use wgpu_core::device::HostMap as MapMode; +use crate::error::GPUGenericError; use crate::Instance; #[derive(WebIDL)] @@ -80,6 +81,12 @@ impl GarbageCollected for GPUBuffer { #[op2] impl GPUBuffer { + #[constructor] + #[cppgc] + fn constructor(_: bool) -> Result { + Err(GPUGenericError::InvalidConstructor) + } + #[getter] #[string] fn label(&self) -> String { diff --git a/deno_webgpu/command_buffer.rs b/deno_webgpu/command_buffer.rs index 9b3ad5cfa..6ad6dbc09 100644 --- a/deno_webgpu/command_buffer.rs +++ b/deno_webgpu/command_buffer.rs @@ -4,6 +4,7 @@ use deno_core::op2; use deno_core::GarbageCollected; use deno_core::WebIDL; +use crate::error::GPUGenericError; use crate::Instance; pub struct GPUCommandBuffer { @@ -30,6 +31,12 @@ impl GarbageCollected for GPUCommandBuffer { #[op2] impl GPUCommandBuffer { + #[constructor] + #[cppgc] + fn constructor(_: bool) -> Result { + Err(GPUGenericError::InvalidConstructor) + } + #[getter] #[string] fn label(&self) -> String { diff --git a/deno_webgpu/command_encoder.rs b/deno_webgpu/command_encoder.rs index 6587b23d3..91ea14aea 100644 --- a/deno_webgpu/command_encoder.rs +++ b/deno_webgpu/command_encoder.rs @@ -16,6 +16,7 @@ use wgpu_types::{BufferAddress, TexelCopyBufferInfo}; use crate::buffer::GPUBuffer; use crate::command_buffer::GPUCommandBuffer; use crate::compute_pass::GPUComputePassEncoder; +use crate::error::GPUGenericError; use crate::queue::GPUTexelCopyTextureInfo; use crate::render_pass::GPULoadOp; use crate::render_pass::GPURenderPassEncoder; @@ -44,6 +45,12 @@ impl GarbageCollected for GPUCommandEncoder { #[op2] impl GPUCommandEncoder { + #[constructor] + #[cppgc] + fn constructor(_: bool) -> Result { + Err(GPUGenericError::InvalidConstructor) + } + #[getter] #[string] fn label(&self) -> String { diff --git a/deno_webgpu/compute_pass.rs b/deno_webgpu/compute_pass.rs index 9dd617968..9fae680fb 100644 --- a/deno_webgpu/compute_pass.rs +++ b/deno_webgpu/compute_pass.rs @@ -13,6 +13,7 @@ use deno_core::webidl::WebIdlError; use deno_core::GarbageCollected; use deno_core::WebIDL; +use crate::error::GPUGenericError; use crate::Instance; pub struct GPUComputePassEncoder { @@ -31,6 +32,12 @@ impl GarbageCollected for GPUComputePassEncoder { #[op2] impl GPUComputePassEncoder { + #[constructor] + #[cppgc] + fn constructor(_: bool) -> Result { + Err(GPUGenericError::InvalidConstructor) + } + #[getter] #[string] fn label(&self) -> String { diff --git a/deno_webgpu/compute_pipeline.rs b/deno_webgpu/compute_pipeline.rs index 1803c4b68..bd7a96959 100644 --- a/deno_webgpu/compute_pipeline.rs +++ b/deno_webgpu/compute_pipeline.rs @@ -8,6 +8,7 @@ use deno_core::WebIDL; use indexmap::IndexMap; use crate::bind_group_layout::GPUBindGroupLayout; +use crate::error::GPUGenericError; use crate::shader::GPUShaderModule; use crate::webidl::GPUPipelineLayoutOrGPUAutoLayoutMode; use crate::Instance; @@ -38,6 +39,12 @@ impl GarbageCollected for GPUComputePipeline { #[op2] impl GPUComputePipeline { + #[constructor] + #[cppgc] + fn constructor(_: bool) -> Result { + Err(GPUGenericError::InvalidConstructor) + } + #[getter] #[string] fn label(&self) -> String { diff --git a/deno_webgpu/device.rs b/deno_webgpu/device.rs index 186bb13f1..aef52607f 100644 --- a/deno_webgpu/device.rs +++ b/deno_webgpu/device.rs @@ -30,7 +30,7 @@ use crate::adapter::GPUAdapterInfo; use crate::adapter::GPUSupportedFeatures; use crate::adapter::GPUSupportedLimits; use crate::command_encoder::GPUCommandEncoder; -use crate::error::GPUError; +use crate::error::{GPUError, GPUGenericError}; use crate::query_set::GPUQuerySet; use crate::render_bundle::GPURenderBundleEncoder; use crate::render_pipeline::GPURenderPipeline; @@ -75,6 +75,12 @@ impl GarbageCollected for GPUDevice { // EventTarget is extended in JS #[op2] impl GPUDevice { + #[constructor] + #[cppgc] + fn constructor(_: bool) -> Result { + Err(GPUGenericError::InvalidConstructor) + } + #[getter] #[string] fn label(&self) -> String { @@ -909,6 +915,12 @@ impl GarbageCollected for GPUDeviceLostInfo { #[op2] impl GPUDeviceLostInfo { + #[constructor] + #[cppgc] + fn constructor(_: bool) -> Result { + Err(GPUGenericError::InvalidConstructor) + } + #[getter] #[string] fn reason(&self) -> &'static str { diff --git a/deno_webgpu/error.rs b/deno_webgpu/error.rs index 2f727f2cc..57bfd1445 100644 --- a/deno_webgpu/error.rs +++ b/deno_webgpu/error.rs @@ -372,3 +372,10 @@ impl From for GPUError { GPUError::from_webgpu(err) } } + +#[derive(Debug, thiserror::Error, deno_error::JsError)] +pub enum GPUGenericError { + #[class(type)] + #[error("Illegal constructor")] + InvalidConstructor, +} diff --git a/deno_webgpu/lib.rs b/deno_webgpu/lib.rs index 8ab4f5b87..2b6dfcfee 100644 --- a/deno_webgpu/lib.rs +++ b/deno_webgpu/lib.rs @@ -15,6 +15,8 @@ pub use wgpu_core; pub use wgpu_types; use wgpu_types::PowerPreference; +use crate::error::GPUGenericError; + mod adapter; mod bind_group; mod bind_group_layout; @@ -138,6 +140,12 @@ impl GarbageCollected for GPU { #[op2] impl GPU { + #[constructor] + #[cppgc] + fn constructor(_: bool) -> Result { + Err(GPUGenericError::InvalidConstructor) + } + #[async_method] #[cppgc] async fn request_adapter( diff --git a/deno_webgpu/pipeline_layout.rs b/deno_webgpu/pipeline_layout.rs index 15c9b4d4f..1d71a9902 100644 --- a/deno_webgpu/pipeline_layout.rs +++ b/deno_webgpu/pipeline_layout.rs @@ -6,6 +6,7 @@ use deno_core::webidl::WebIdlInterfaceConverter; use deno_core::GarbageCollected; use deno_core::WebIDL; +use crate::error::GPUGenericError; use crate::Instance; pub struct GPUPipelineLayout { @@ -32,6 +33,12 @@ impl GarbageCollected for GPUPipelineLayout { #[op2] impl GPUPipelineLayout { + #[constructor] + #[cppgc] + fn constructor(_: bool) -> Result { + Err(GPUGenericError::InvalidConstructor) + } + #[getter] #[string] fn label(&self) -> String { diff --git a/deno_webgpu/query_set.rs b/deno_webgpu/query_set.rs index c23186883..c726ad605 100644 --- a/deno_webgpu/query_set.rs +++ b/deno_webgpu/query_set.rs @@ -6,6 +6,7 @@ use deno_core::GarbageCollected; use deno_core::WebIDL; use deno_error::JsErrorBox; +use crate::error::GPUGenericError; use crate::Instance; pub struct GPUQuerySet { @@ -34,6 +35,12 @@ impl GarbageCollected for GPUQuerySet { #[op2] impl GPUQuerySet { + #[constructor] + #[cppgc] + fn constructor(_: bool) -> Result { + Err(GPUGenericError::InvalidConstructor) + } + #[getter] #[string] fn label(&self) -> String { diff --git a/deno_webgpu/queue.rs b/deno_webgpu/queue.rs index 379729333..89a153c87 100644 --- a/deno_webgpu/queue.rs +++ b/deno_webgpu/queue.rs @@ -14,6 +14,7 @@ use deno_error::JsErrorBox; use crate::buffer::GPUBuffer; use crate::command_buffer::GPUCommandBuffer; +use crate::error::GPUGenericError; use crate::texture::GPUTexture; use crate::texture::GPUTextureAspect; use crate::webidl::GPUExtent3D; @@ -44,6 +45,12 @@ impl GarbageCollected for GPUQueue { #[op2] impl GPUQueue { + #[constructor] + #[cppgc] + fn constructor(_: bool) -> Result { + Err(GPUGenericError::InvalidConstructor) + } + #[getter] #[string] fn label(&self) -> String { diff --git a/deno_webgpu/render_bundle.rs b/deno_webgpu/render_bundle.rs index ba6cb7170..4dd19b9a9 100644 --- a/deno_webgpu/render_bundle.rs +++ b/deno_webgpu/render_bundle.rs @@ -17,6 +17,7 @@ use deno_core::WebIDL; use deno_error::JsErrorBox; use crate::buffer::GPUBuffer; +use crate::error::GPUGenericError; use crate::texture::GPUTextureFormat; use crate::Instance; @@ -45,6 +46,12 @@ impl GarbageCollected for GPURenderBundleEncoder { #[op2] impl GPURenderBundleEncoder { + #[constructor] + #[cppgc] + fn constructor(_: bool) -> Result { + Err(GPUGenericError::InvalidConstructor) + } + #[getter] #[string] fn label(&self) -> String { @@ -419,6 +426,12 @@ impl GarbageCollected for GPURenderBundle { #[op2] impl GPURenderBundle { + #[constructor] + #[cppgc] + fn constructor(_: bool) -> Result { + Err(GPUGenericError::InvalidConstructor) + } + #[getter] #[string] fn label(&self) -> String { diff --git a/deno_webgpu/render_pass.rs b/deno_webgpu/render_pass.rs index 5cfa57606..b33b4e280 100644 --- a/deno_webgpu/render_pass.rs +++ b/deno_webgpu/render_pass.rs @@ -15,6 +15,7 @@ use deno_core::GarbageCollected; use deno_core::WebIDL; use crate::buffer::GPUBuffer; +use crate::error::GPUGenericError; use crate::render_bundle::GPURenderBundle; use crate::texture::GPUTextureView; use crate::webidl::GPUColor; @@ -36,6 +37,12 @@ impl GarbageCollected for GPURenderPassEncoder { #[op2] impl GPURenderPassEncoder { + #[constructor] + #[cppgc] + fn constructor(_: bool) -> Result { + Err(GPUGenericError::InvalidConstructor) + } + #[getter] #[string] fn label(&self) -> String { diff --git a/deno_webgpu/render_pipeline.rs b/deno_webgpu/render_pipeline.rs index 84f1477fb..1a0fc2210 100644 --- a/deno_webgpu/render_pipeline.rs +++ b/deno_webgpu/render_pipeline.rs @@ -9,6 +9,7 @@ use deno_core::WebIDL; use indexmap::IndexMap; use crate::bind_group_layout::GPUBindGroupLayout; +use crate::error::GPUGenericError; use crate::sampler::GPUCompareFunction; use crate::shader::GPUShaderModule; use crate::texture::GPUTextureFormat; @@ -41,6 +42,12 @@ impl GarbageCollected for GPURenderPipeline { #[op2] impl GPURenderPipeline { + #[constructor] + #[cppgc] + fn constructor(_: bool) -> Result { + Err(GPUGenericError::InvalidConstructor) + } + #[getter] #[string] fn label(&self) -> String { diff --git a/deno_webgpu/sampler.rs b/deno_webgpu/sampler.rs index 2af3f9d42..c6dd44339 100644 --- a/deno_webgpu/sampler.rs +++ b/deno_webgpu/sampler.rs @@ -5,6 +5,7 @@ use deno_core::webidl::WebIdlInterfaceConverter; use deno_core::GarbageCollected; use deno_core::WebIDL; +use crate::error::GPUGenericError; use crate::Instance; pub struct GPUSampler { @@ -31,6 +32,12 @@ impl GarbageCollected for GPUSampler { #[op2] impl GPUSampler { + #[constructor] + #[cppgc] + fn constructor(_: bool) -> Result { + Err(GPUGenericError::InvalidConstructor) + } + #[getter] #[string] fn label(&self) -> String { diff --git a/deno_webgpu/shader.rs b/deno_webgpu/shader.rs index b449a6534..2718826f5 100644 --- a/deno_webgpu/shader.rs +++ b/deno_webgpu/shader.rs @@ -8,6 +8,7 @@ use deno_core::GarbageCollected; use deno_core::WebIDL; use wgpu_core::pipeline; +use crate::error::GPUGenericError; use crate::Instance; pub struct GPUShaderModule { @@ -35,6 +36,12 @@ impl GarbageCollected for GPUShaderModule { #[op2] impl GPUShaderModule { + #[constructor] + #[cppgc] + fn constructor(_: bool) -> Result { + Err(GPUGenericError::InvalidConstructor) + } + #[getter] #[string] fn label(&self) -> String { diff --git a/deno_webgpu/surface.rs b/deno_webgpu/surface.rs index 0a042a954..0d6e7d07f 100644 --- a/deno_webgpu/surface.rs +++ b/deno_webgpu/surface.rs @@ -12,6 +12,7 @@ use deno_error::JsErrorBox; use wgpu_types::SurfaceStatus; use crate::device::GPUDevice; +use crate::error::GPUGenericError; use crate::texture::GPUTexture; use crate::texture::GPUTextureFormat; @@ -55,6 +56,12 @@ impl GarbageCollected for GPUCanvasContext { #[op2] impl GPUCanvasContext { + #[constructor] + #[cppgc] + fn constructor(_: bool) -> Result { + Err(GPUGenericError::InvalidConstructor) + } + #[getter] #[global] fn canvas(&self) -> v8::Global { diff --git a/deno_webgpu/texture.rs b/deno_webgpu/texture.rs index af876bc4b..09b4cac38 100644 --- a/deno_webgpu/texture.rs +++ b/deno_webgpu/texture.rs @@ -13,6 +13,7 @@ use wgpu_types::TextureDimension; use wgpu_types::TextureFormat; use wgpu_types::TextureViewDimension; +use crate::error::GPUGenericError; use crate::Instance; #[derive(WebIDL)] @@ -71,6 +72,12 @@ impl GarbageCollected for GPUTexture { #[op2] impl GPUTexture { + #[constructor] + #[cppgc] + fn constructor(_: bool) -> Result { + Err(GPUGenericError::InvalidConstructor) + } + #[getter] #[string] fn label(&self) -> String { @@ -256,6 +263,12 @@ impl GarbageCollected for GPUTextureView { #[op2] impl GPUTextureView { + #[constructor] + #[cppgc] + fn constructor(_: bool) -> Result { + Err(GPUGenericError::InvalidConstructor) + } + #[getter] #[string] fn label(&self) -> String {