mirror of
https://github.com/gfx-rs/wgpu.git
synced 2025-12-08 21:26:17 +00:00
[deno] add illegal constructor errors
(cherry-picked from denoland/deno#30500)
This commit is contained in:
parent
492fb59648
commit
67f7a4ea3b
@ -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<GPUAdapter, GPUGenericError> {
|
||||
Err(GPUGenericError::InvalidConstructor)
|
||||
}
|
||||
|
||||
#[getter]
|
||||
#[global]
|
||||
fn info(&self, scope: &mut v8::HandleScope) -> v8::Global<v8::Object> {
|
||||
@ -223,6 +230,12 @@ impl GarbageCollected for GPUSupportedLimits {
|
||||
|
||||
#[op2]
|
||||
impl GPUSupportedLimits {
|
||||
#[constructor]
|
||||
#[cppgc]
|
||||
fn constructor(_: bool) -> Result<GPUSupportedLimits, GPUGenericError> {
|
||||
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<GPUSupportedFeatures, GPUGenericError> {
|
||||
Err(GPUGenericError::InvalidConstructor)
|
||||
}
|
||||
|
||||
#[global]
|
||||
#[symbol("setlike_set")]
|
||||
fn set(&self) -> v8::Global<v8::Value> {
|
||||
@ -422,6 +441,12 @@ impl GarbageCollected for GPUAdapterInfo {
|
||||
|
||||
#[op2]
|
||||
impl GPUAdapterInfo {
|
||||
#[constructor]
|
||||
#[cppgc]
|
||||
fn constructor(_: bool) -> Result<GPUAdapterInfo, GPUGenericError> {
|
||||
Err(GPUGenericError::InvalidConstructor)
|
||||
}
|
||||
|
||||
#[getter]
|
||||
#[string]
|
||||
fn vendor(&self) -> String {
|
||||
|
||||
@ -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<GPUBindGroup, GPUGenericError> {
|
||||
Err(GPUGenericError::InvalidConstructor)
|
||||
}
|
||||
|
||||
#[getter]
|
||||
#[string]
|
||||
fn label(&self) -> String {
|
||||
|
||||
@ -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<GPUBindGroupLayout, GPUGenericError> {
|
||||
Err(GPUGenericError::InvalidConstructor)
|
||||
}
|
||||
|
||||
#[getter]
|
||||
#[string]
|
||||
fn label(&self) -> String {
|
||||
|
||||
@ -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<GPUBuffer, GPUGenericError> {
|
||||
Err(GPUGenericError::InvalidConstructor)
|
||||
}
|
||||
|
||||
#[getter]
|
||||
#[string]
|
||||
fn label(&self) -> String {
|
||||
|
||||
@ -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<GPUCommandBuffer, GPUGenericError> {
|
||||
Err(GPUGenericError::InvalidConstructor)
|
||||
}
|
||||
|
||||
#[getter]
|
||||
#[string]
|
||||
fn label(&self) -> String {
|
||||
|
||||
@ -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<GPUCommandEncoder, GPUGenericError> {
|
||||
Err(GPUGenericError::InvalidConstructor)
|
||||
}
|
||||
|
||||
#[getter]
|
||||
#[string]
|
||||
fn label(&self) -> String {
|
||||
|
||||
@ -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<GPUComputePassEncoder, GPUGenericError> {
|
||||
Err(GPUGenericError::InvalidConstructor)
|
||||
}
|
||||
|
||||
#[getter]
|
||||
#[string]
|
||||
fn label(&self) -> String {
|
||||
|
||||
@ -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<GPUComputePipeline, GPUGenericError> {
|
||||
Err(GPUGenericError::InvalidConstructor)
|
||||
}
|
||||
|
||||
#[getter]
|
||||
#[string]
|
||||
fn label(&self) -> String {
|
||||
|
||||
@ -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<GPUDevice, GPUGenericError> {
|
||||
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<GPUDeviceLostInfo, GPUGenericError> {
|
||||
Err(GPUGenericError::InvalidConstructor)
|
||||
}
|
||||
|
||||
#[getter]
|
||||
#[string]
|
||||
fn reason(&self) -> &'static str {
|
||||
|
||||
@ -372,3 +372,10 @@ impl From<ConfigureSurfaceError> for GPUError {
|
||||
GPUError::from_webgpu(err)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, thiserror::Error, deno_error::JsError)]
|
||||
pub enum GPUGenericError {
|
||||
#[class(type)]
|
||||
#[error("Illegal constructor")]
|
||||
InvalidConstructor,
|
||||
}
|
||||
|
||||
@ -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<GPU, GPUGenericError> {
|
||||
Err(GPUGenericError::InvalidConstructor)
|
||||
}
|
||||
|
||||
#[async_method]
|
||||
#[cppgc]
|
||||
async fn request_adapter(
|
||||
|
||||
@ -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<GPUPipelineLayout, GPUGenericError> {
|
||||
Err(GPUGenericError::InvalidConstructor)
|
||||
}
|
||||
|
||||
#[getter]
|
||||
#[string]
|
||||
fn label(&self) -> String {
|
||||
|
||||
@ -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<GPUQuerySet, GPUGenericError> {
|
||||
Err(GPUGenericError::InvalidConstructor)
|
||||
}
|
||||
|
||||
#[getter]
|
||||
#[string]
|
||||
fn label(&self) -> String {
|
||||
|
||||
@ -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<GPUQueue, GPUGenericError> {
|
||||
Err(GPUGenericError::InvalidConstructor)
|
||||
}
|
||||
|
||||
#[getter]
|
||||
#[string]
|
||||
fn label(&self) -> String {
|
||||
|
||||
@ -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<GPURenderBundleEncoder, GPUGenericError> {
|
||||
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<GPURenderBundle, GPUGenericError> {
|
||||
Err(GPUGenericError::InvalidConstructor)
|
||||
}
|
||||
|
||||
#[getter]
|
||||
#[string]
|
||||
fn label(&self) -> String {
|
||||
|
||||
@ -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<GPURenderPassEncoder, GPUGenericError> {
|
||||
Err(GPUGenericError::InvalidConstructor)
|
||||
}
|
||||
|
||||
#[getter]
|
||||
#[string]
|
||||
fn label(&self) -> String {
|
||||
|
||||
@ -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<GPURenderPipeline, GPUGenericError> {
|
||||
Err(GPUGenericError::InvalidConstructor)
|
||||
}
|
||||
|
||||
#[getter]
|
||||
#[string]
|
||||
fn label(&self) -> String {
|
||||
|
||||
@ -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<GPUSampler, GPUGenericError> {
|
||||
Err(GPUGenericError::InvalidConstructor)
|
||||
}
|
||||
|
||||
#[getter]
|
||||
#[string]
|
||||
fn label(&self) -> String {
|
||||
|
||||
@ -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<GPUShaderModule, GPUGenericError> {
|
||||
Err(GPUGenericError::InvalidConstructor)
|
||||
}
|
||||
|
||||
#[getter]
|
||||
#[string]
|
||||
fn label(&self) -> String {
|
||||
|
||||
@ -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<GPUCanvasContext, GPUGenericError> {
|
||||
Err(GPUGenericError::InvalidConstructor)
|
||||
}
|
||||
|
||||
#[getter]
|
||||
#[global]
|
||||
fn canvas(&self) -> v8::Global<v8::Object> {
|
||||
|
||||
@ -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<GPUTexture, GPUGenericError> {
|
||||
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<GPUTextureView, GPUGenericError> {
|
||||
Err(GPUGenericError::InvalidConstructor)
|
||||
}
|
||||
|
||||
#[getter]
|
||||
#[string]
|
||||
fn label(&self) -> String {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user