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_bitmask_prefix: bool,
    pub remove_const_prefix: bool,
    pub variant_padding: VariantPaddingConfig,
    pub snake_case_commands: bool,
    pub camel_case_variants: bool,
    pub snake_case_members: bool,
    pub debug_c_strings: bool,
    pub use_native_enums: bool,
    pub use_native_unions: 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

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.

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.

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.

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.

Whether or not to remove the VK_ prefix from constant names.

For example, the xml registry defines the constant VK_MAX_EXTENSION_NAME_SIZE. If this is true, this will result in the constant being turned into MAX_EXTENSION_NAME_SIZE.

Defaults to true.

How to handle enum variants, see VariantPaddingConfig for details.

Defaults to VariantPaddingConfig::Strip.

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.

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.

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.

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.

Whether or not to use the enum keyword to create native tagged unions.

Defaults to true.

Whether or not to use the unstable union keyword to create native untagged unions. Currently relies on the untagged_unions feature.

Defaults to false.

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

Defaults to true.

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.

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:

let config = GenConfig {
    extern_type_overrides: &[
        ("HWND", "winapi::HWND"),
        ("HINSTANCE", "winapi::HINSTANCE")
    ],
    ..GenConfig::default()
};

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;

Methods

impl<'a> GenConfig<'a>
[src]

[src]

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

Trait Implementations

impl<'a> Debug for GenConfig<'a>
[src]

[src]

Formats the value using the given formatter.

impl<'a> Clone for GenConfig<'a>
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl<'a> Copy for GenConfig<'a>
[src]

impl<'a> PartialEq for GenConfig<'a>
[src]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

[src]

This method tests for !=.

impl<'a> Eq for GenConfig<'a>
[src]

impl<'a> Default for GenConfig<'a>
[src]

[src]

Returns the "default value" for a type. Read more