Skip to content

Commit 7746d63

Browse files
committed
fixup
1 parent f260d82 commit 7746d63

8 files changed

+27
-63
lines changed

src/analysis/conversion_type.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ impl ConversionType {
7878
IntPtr => ConversionType::Direct,
7979
UIntPtr => ConversionType::Direct,
8080
Bool => ConversionType::Direct,
81-
Vulkan(_) => ConversionType::Direct,
81+
Typedef(_) => ConversionType::Direct,
8282
Unsupported => ConversionType::Unknown,
8383
},
8484
Alias(alias) if alias.c_identifier == "GQuark" => ConversionType::Scalar,

src/analysis/rust_type.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ impl<'env> RustTypeBuilder<'env> {
303303
Type => ok_and_use(&use_glib_type(self.env, "types::Type")),
304304
Char => ok_and_use(&use_glib_type(self.env, "Char")),
305305
UChar => ok_and_use(&use_glib_type(self.env, "UChar")),
306-
Vulkan(name) => ok_and_use(&format!("ash::vk::{}", name)),
306+
Typedef(name) => ok_and_use(name),
307307
Unsupported => err("Unsupported"),
308308
_ => err(&format!("Basic: {:?}", fund)),
309309
}

src/codegen/sys/ffi_type.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ fn ffi_inner(env: &Env, tid: library::TypeId, mut inner: String) -> Result {
110110
UIntPtr => "uintptr_t",
111111
Bool => "bool",
112112
Unsupported => return Err(TypeError::Unimplemented(inner)),
113-
Vulkan(v) => return Ok(format!("ash::vk::{}", v).into()),
113+
Typedef(name) => return Ok(name.into()),
114114
VarArgs => panic!("Should not reach here"),
115115
};
116116
Ok(inner.into())

src/custom_vulkan_namespace.rs

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
use crate::library::*;
2+
3+
pub const VULKAN_NAMESPACE_NAME: &str = "Vulkan";
4+
5+
impl Library {
6+
pub fn tweak_vulkan_namespace(&mut self) {
7+
if let Some(ns_id) = self.find_namespace(VULKAN_NAMESPACE_NAME) {
8+
let ns = self.namespace_mut(ns_id);
9+
for typ in &mut ns.types {
10+
if let Some(Type::Record(rec)) = typ {
11+
*typ = Some(Type::Basic(Basic::Typedef(format!(
12+
"ash::vk::{}",
13+
rec.name
14+
))));
15+
}
16+
}
17+
}
18+
}
19+
}

src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ mod codegen;
2424
mod config;
2525
mod consts;
2626
mod custom_type_glib_priority;
27+
mod custom_vulkan_namespace;
2728
mod env;
2829
mod file_saver;
2930
pub mod fmt;

src/library.rs

+2-60
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ pub enum Basic {
240240
OsString,
241241
Bool,
242242
Unsupported,
243-
Vulkan(String),
243+
Typedef(String),
244244
}
245245

246246
impl Basic {
@@ -268,7 +268,7 @@ impl Basic {
268268
| Self::Float
269269
| Self::Double
270270
| Self::Bool
271-
| Self::Vulkan(_)
271+
| Self::Typedef(_)
272272
)
273273
}
274274
}
@@ -1039,8 +1039,6 @@ impl Namespace {
10391039
pub const INTERNAL_NAMESPACE_NAME: &str = "*";
10401040
pub const INTERNAL_NAMESPACE: u16 = 0;
10411041
pub const MAIN_NAMESPACE: u16 = 1;
1042-
pub const VULKAN_NAMESPACE_NAME: &str = "Vulkan";
1043-
pub const VULKAN_NAMESPACE: u16 = 2;
10441042

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

1066-
assert_eq!(
1067-
VULKAN_NAMESPACE,
1068-
library.add_namespace(VULKAN_NAMESPACE_NAME)
1069-
);
1070-
// TODO: This should be parseable from gir-files/Vulkan-1.0.gir!
1071-
const VULKAN: &[&str] = &[
1072-
"AccessFlags",
1073-
"Buffer",
1074-
"BufferUsageFlags",
1075-
"CommandBuffer",
1076-
"CommandBufferLevel",
1077-
"CommandPool",
1078-
"DescriptorPool",
1079-
"DescriptorSet",
1080-
"Device",
1081-
"DeviceMemory",
1082-
"DeviceSize",
1083-
"Fence",
1084-
"Format",
1085-
"Image",
1086-
"ImageCreateInfo",
1087-
"ImageFormatProperties",
1088-
"ImageLayout",
1089-
"ImageSubresourceRange",
1090-
"ImageTiling",
1091-
"ImageUsageFlags",
1092-
"ImageView",
1093-
"ImageViewCreateInfo",
1094-
"Instance",
1095-
"MemoryAllocateInfo",
1096-
"MemoryHeapFlags",
1097-
"MemoryPropertyFlags",
1098-
"MemoryRequirements",
1099-
"PhysicalDevice",
1100-
"PhysicalDeviceFeatures",
1101-
"PhysicalDeviceMemoryProperties",
1102-
"PhysicalDeviceProperties",
1103-
"PhysicalDeviceType",
1104-
"PipelineStageFlags",
1105-
"PresentModeKHR",
1106-
"Queue",
1107-
"QueueFamilyProperties",
1108-
"QueueFlags",
1109-
"Result",
1110-
"SampleCountFlags",
1111-
"Semaphore",
1112-
"SurfaceKHR",
1113-
];
1114-
for v in VULKAN {
1115-
library.add_type(
1116-
VULKAN_NAMESPACE,
1117-
v,
1118-
Type::Basic(Basic::Vulkan(v.to_string())),
1119-
);
1120-
}
1121-
11221064
//For string_type override
11231065
Type::c_array(&mut library, TypeId::tid_utf8(), None, None);
11241066
Type::c_array(&mut library, TypeId::tid_filename(), None, None);

src/library_preprocessing.rs

+1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ use crate::{config::WorkMode, library::*};
33
impl Library {
44
pub fn preprocessing(&mut self, work_mode: WorkMode) {
55
self.add_glib_priority(work_mode);
6+
self.tweak_vulkan_namespace();
67
}
78
}

src/parser.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::{
2+
analysis::types::IsIncomplete,
23
library::*,
34
version::Version,
45
xmlparser::{Element, XmlParser},

0 commit comments

Comments
 (0)