From d94d45cd801b6de34786d862a7e4c35320422b69 Mon Sep 17 00:00:00 2001 From: grovesNL Date: Sat, 22 Sep 2018 20:54:42 -0600 Subject: [PATCH] Target C for header generation --- wgpu-bindings/bindings.h | 47 ++++++++++++++++++--------------------- wgpu-bindings/src/main.rs | 1 + 2 files changed, 23 insertions(+), 25 deletions(-) diff --git a/wgpu-bindings/bindings.h b/wgpu-bindings/bindings.h index 30143c2a77..fcf9468ec4 100644 --- a/wgpu-bindings/bindings.h +++ b/wgpu-bindings/bindings.h @@ -1,54 +1,51 @@ -#include -#include +#include +#include +#include -enum class PowerPreference { +typedef enum { Default = 0, LowPower = 1, HighPerformance = 2, -}; +} PowerPreference; -struct ShaderModuleDescriptor; +typedef struct ShaderModuleDescriptor ShaderModuleDescriptor; -using Id = uint32_t; +typedef uint32_t Id; -using DeviceId = Id; +typedef Id DeviceId; -using AdapterId = Id; +typedef Id AdapterId; -struct Extensions { +typedef struct { bool anisotropic_filtering; -}; +} Extensions; -struct DeviceDescriptor { +typedef struct { Extensions extensions; -}; +} DeviceDescriptor; -using ComputePassId = Id; +typedef Id ComputePassId; -using RenderPassId = Id; +typedef Id RenderPassId; -using CommandBufferId = Id; +typedef Id CommandBufferId; -using InstanceId = Id; +typedef Id InstanceId; -using ShaderModuleId = Id; +typedef Id ShaderModuleId; -struct AdapterDescriptor { +typedef struct { PowerPreference power_preference; -}; - -extern "C" { +} AdapterDescriptor; DeviceId adapter_create_device(AdapterId adapter_id, DeviceDescriptor desc); -ComputePassId command_buffer_begin_compute_pass(); +ComputePassId command_buffer_begin_compute_pass(void); RenderPassId command_buffer_begin_render_pass(CommandBufferId command_buffer); -InstanceId create_instance(); +InstanceId create_instance(void); ShaderModuleId device_create_shader_module(DeviceId device_id, ShaderModuleDescriptor desc); AdapterId instance_get_adapter(InstanceId instance_id, AdapterDescriptor desc); - -} // extern "C" diff --git a/wgpu-bindings/src/main.rs b/wgpu-bindings/src/main.rs index 20a94bb3ee..627f0aeafc 100644 --- a/wgpu-bindings/src/main.rs +++ b/wgpu-bindings/src/main.rs @@ -8,6 +8,7 @@ fn main() { cbindgen::Builder::new() .with_crate(crate_dir) + .with_language(cbindgen::Language::C) .generate() .expect("Unable to generate bindings") .write_to_file("bindings.h");