Struct vk_generator::GenConfig [] [src]

pub struct GenConfig<'a> {
    pub remove_type_prefix: bool,
    pub remove_vk_result_prefix: bool,
    pub remove_command_prefix: bool,
    pub remove_variant_padding: bool,
    pub remove_bitmask_prefix: bool,
    pub snake_case_commands: bool,
    pub camel_case_variants: bool,
    pub snake_case_members: bool,
    pub debug_c_strings: bool,
    pub wrap_bitmasks: bool,
    pub use_libc_types: bool,
    pub extern_type_overrides: &'a [(&'a str, &'a str)],
}

Configuration options fot the Vulkan generator

Fields

remove_type_prefix
remove_vk_result_prefix
remove_command_prefix
remove_variant_padding
remove_bitmask_prefix
snake_case_commands
camel_case_variants
snake_case_members
debug_c_strings
wrap_bitmasks
use_libc_types
extern_type_overrides

Methods

impl<'a> GenConfig<'a>

fn new() -> GenConfig<'a>

Create a new generator config. Is identical to Default::default().

fn remove_type_prefix(self, remove_type_prefix: bool) -> GenConfig<'a>

Whether or not to remove the Vk prefix on structs, enums, and typedefs.

As an example, take the struct VkInstanceCreateInfo. If this is set to true, the generator will turn that into InstanceCreateInfo.

Defaults to false.

fn remove_vk_result_prefix(self, remove_vk_result_prefix: bool) -> GenConfig<'a>

Whether or not to remove the Vk prefix from the VkResult enum, IF AND ONLY IF remove_type_prefix is also set to true. This flag exists primarily because Rust already contains a type named Result and one might desire to remove any ambiguity the VkResult type may cause.

Defaults to true.

fn remove_command_prefix(self, remove_command_prefix: bool) -> GenConfig<'a>

Whether or not to remove the vk prefix from Vulkan commands.

For example, if we have the command vkCreateInstance setting this flag to true will turn that into createInstance.

Defaults to true.

fn remove_variant_padding(self, remove_variant_padding: bool) -> GenConfig<'a>

Whether or not to remove the padding from enum variants.

For example, the Vulkan xml registry defines the enum VkPresentModeKHR, with a variant VK_PRESENT_MODE_IMMEDIATE_KHR. If this is true, VK_PRSESNT_MODE_ and _KHR will be will be removed from start and end respectively, resulting in the variant name IMMEDIATE. If the variant does not have a suffix this will only remove the prefix.

Defaults to true.

fn remove_bitmask_prefix(self, remove_bitmask_prefix: bool) -> GenConfig<'a>

Whether or not to remove the VK_ prefix from bitmask variants.

For example, the xml registry defines the bitmask VkQueueFlagBits with the flag VK_QUEUE_GRAPHICS_BIT. If this is true, this will result in the variant being turned into QUEUE_GRAPHICS_BIT.

Defaults to true.

fn snake_case_commands(self, snake_case_commands: bool) -> GenConfig<'a>

Whether or not to transform Vulkan command identifiers to be a Rust-y snake_case.

For example, the registry defines the command vkCreateInstance. If this is true, that command will be turned into vk_create_instance. This, and the other name-style-altering options, primarily exists for the purpose of having Vulkan code integrate more cleanly into native Rust code.

Defaults to true.

fn camel_case_variants(self, camel_case_variants: bool) -> GenConfig<'a>

Whether or not to transform enum variants into CamelCase.

For example, if we look at VkStructureType's VK_STRUCTURE_TYPE_APPLICATION_INFO setting this to true would result in the variant being turned into VkStructureTypeApplicationInfo.

Defaults to true.

fn snake_case_members(self, snake_case_members: bool) -> GenConfig<'a>

Whether or not to transform struct/union members and command parameters into snake_case.

For example, if we look at the VkApplicationInfo struct's applicationVersion field, setting this to true would result in the field being turned into application_version.

Defaults to true.

fn debug_c_strings(self, debug_c_strings: bool) -> GenConfig<'a>

When printing structs with fields that are arrays of c_chars, whether to print them as arrays of bytes or as a string.

Defaults to true.

fn wrap_bitmasks(self, wrap_bitmasks: bool) -> GenConfig<'a>

Whether or not to wrap bitmasks with a set of convenience functions similar to the bitflags crate.

Defaults to true.

fn use_libc_types(self, use_libc_types: bool) -> GenConfig<'a>

The Vulkan library uses a lot of C types, as per it's nature of exposing a C ABI. There are a few ways we can handle using those types: either we can define the typedefs ourself or we can use the types provided by libc. Because libc isn't implicitly included in crates we default to defining the types ourself. Setting this to true makes the generated file import types from libc instead of defining them itself.

fn extern_type_overrides(self, extern_type_overrides: &'a [(&'a str, &'a str)]) -> GenConfig<'a>

This defines a set of type overrides, primarily intended for use with the WSI extensions. It takes a slice of (&str, &str) tuples, with the left side being the name of the type and the right side being the new definition of the type.

For an example let's look at the Windows WSI extension, which includes the struct VkWin32SurfaceCreateInfoKHR. That struct takes a HWND and a HINSTANCE in order to let Vulkan draw to windows; however, the generator is unaware of both HWND and HINSTANCE, which are defined in winapi. Because it has no idea what those types should be the generator defaults to type HWND = *const (), which isn't what HWNDs are defined as in winapi. So we call this:

GenConfig::new()
    .extern_type_overrides(&[("HWND", "winapi::HWND"),
                             ("HINSTANCE", "winapi::HINSTANCE")]);

This tells the generator to use the winapi defintions of HWND instead of the blind definition, making the generator produce these for the type defintions:

type HWND = winapi::HWND;
type HINSTANCE = winapi::HINSTANCE;

Trait Implementations

impl<'a> Default for GenConfig<'a>

fn default() -> GenConfig<'a>

Derived Implementations

impl<'a> Eq for GenConfig<'a>

impl<'a> PartialEq for GenConfig<'a>

fn eq(&self, __arg_0: &GenConfig<'a>) -> bool

fn ne(&self, __arg_0: &GenConfig<'a>) -> bool

impl<'a> Copy for GenConfig<'a>

impl<'a> Clone for GenConfig<'a>

fn clone(&self) -> GenConfig<'a>

1.0.0fn clone_from(&mut self, source: &Self)

impl<'a> Debug for GenConfig<'a>

fn fmt(&self, __arg_0: &mut Formatter) -> Result