Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
filnet committed Jun 2, 2022
1 parent f260d82 commit e4bc4ca
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 63 deletions.
2 changes: 1 addition & 1 deletion src/analysis/conversion_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl ConversionType {
IntPtr => ConversionType::Direct,
UIntPtr => ConversionType::Direct,
Bool => ConversionType::Direct,
Vulkan(_) => ConversionType::Direct,
Typedef(_) => ConversionType::Direct,
Unsupported => ConversionType::Unknown,
},
Alias(alias) if alias.c_identifier == "GQuark" => ConversionType::Scalar,
Expand Down
2 changes: 1 addition & 1 deletion src/analysis/rust_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ impl<'env> RustTypeBuilder<'env> {
Type => ok_and_use(&use_glib_type(self.env, "types::Type")),
Char => ok_and_use(&use_glib_type(self.env, "Char")),
UChar => ok_and_use(&use_glib_type(self.env, "UChar")),
Vulkan(name) => ok_and_use(&format!("ash::vk::{}", name)),
Typedef(name) => ok_and_use(name),
Unsupported => err("Unsupported"),
_ => err(&format!("Basic: {:?}", fund)),
}
Expand Down
2 changes: 1 addition & 1 deletion src/codegen/sys/ffi_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ fn ffi_inner(env: &Env, tid: library::TypeId, mut inner: String) -> Result {
UIntPtr => "uintptr_t",
Bool => "bool",
Unsupported => return Err(TypeError::Unimplemented(inner)),
Vulkan(v) => return Ok(format!("ash::vk::{}", v).into()),
Typedef(name) => return Ok(name.into()),
VarArgs => panic!("Should not reach here"),
};
Ok(inner.into())
Expand Down
19 changes: 19 additions & 0 deletions src/custom_vulkan_namespace.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use crate::library::*;

pub const VULKAN_NAMESPACE_NAME: &str = "Vulkan";

impl Library {
pub fn tweak_vulkan_namespace(&mut self) {
if let Some(ns_id) = self.find_namespace(VULKAN_NAMESPACE_NAME) {
let ns = self.namespace_mut(ns_id);
for typ in &mut ns.types {
if let Some(Type::Record(rec)) = typ {
*typ = Some(Type::Basic(Basic::Typedef(format!(
"ash::vk::{}",
rec.name
))));
}
}
}
}
}
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ mod codegen;
mod config;
mod consts;
mod custom_type_glib_priority;
mod custom_vulkan_namespace;
mod env;
mod file_saver;
pub mod fmt;
Expand Down
62 changes: 2 additions & 60 deletions src/library.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ pub enum Basic {
OsString,
Bool,
Unsupported,
Vulkan(String),
Typedef(String),
}

impl Basic {
Expand Down Expand Up @@ -268,7 +268,7 @@ impl Basic {
| Self::Float
| Self::Double
| Self::Bool
| Self::Vulkan(_)
| Self::Typedef(_)
)
}
}
Expand Down Expand Up @@ -1039,8 +1039,6 @@ impl Namespace {
pub const INTERNAL_NAMESPACE_NAME: &str = "*";
pub const INTERNAL_NAMESPACE: u16 = 0;
pub const MAIN_NAMESPACE: u16 = 1;
pub const VULKAN_NAMESPACE_NAME: &str = "Vulkan";
pub const VULKAN_NAMESPACE: u16 = 2;

#[derive(Debug)]
pub struct Library {
Expand All @@ -1063,62 +1061,6 @@ impl Library {
}
assert_eq!(MAIN_NAMESPACE, library.add_namespace(main_namespace_name));

assert_eq!(
VULKAN_NAMESPACE,
library.add_namespace(VULKAN_NAMESPACE_NAME)
);
// TODO: This should be parseable from gir-files/Vulkan-1.0.gir!
const VULKAN: &[&str] = &[
"AccessFlags",
"Buffer",
"BufferUsageFlags",
"CommandBuffer",
"CommandBufferLevel",
"CommandPool",
"DescriptorPool",
"DescriptorSet",
"Device",
"DeviceMemory",
"DeviceSize",
"Fence",
"Format",
"Image",
"ImageCreateInfo",
"ImageFormatProperties",
"ImageLayout",
"ImageSubresourceRange",
"ImageTiling",
"ImageUsageFlags",
"ImageView",
"ImageViewCreateInfo",
"Instance",
"MemoryAllocateInfo",
"MemoryHeapFlags",
"MemoryPropertyFlags",
"MemoryRequirements",
"PhysicalDevice",
"PhysicalDeviceFeatures",
"PhysicalDeviceMemoryProperties",
"PhysicalDeviceProperties",
"PhysicalDeviceType",
"PipelineStageFlags",
"PresentModeKHR",
"Queue",
"QueueFamilyProperties",
"QueueFlags",
"Result",
"SampleCountFlags",
"Semaphore",
"SurfaceKHR",
];
for v in VULKAN {
library.add_type(
VULKAN_NAMESPACE,
v,
Type::Basic(Basic::Vulkan(v.to_string())),
);
}

//For string_type override
Type::c_array(&mut library, TypeId::tid_utf8(), None, None);
Type::c_array(&mut library, TypeId::tid_filename(), None, None);
Expand Down
1 change: 1 addition & 0 deletions src/library_preprocessing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ use crate::{config::WorkMode, library::*};
impl Library {
pub fn preprocessing(&mut self, work_mode: WorkMode) {
self.add_glib_priority(work_mode);
self.tweak_vulkan_namespace();
}
}

0 comments on commit e4bc4ca

Please sign in to comment.