glad icon indicating copy to clipboard operation
glad copied to clipboard

Zig generator

Open s5bug opened this issue 3 years ago • 11 comments

Working on resolving #307.

  • [x] Properly handle mx
  • [x] Handle all needed types
  • [x] Handle enumerations
  • [x] Handle function definitions
  • [x] Handle loading

I've currently copied from the Rust generator and am just modifying that as Zig is very similar.

s5bug avatar Feb 07 '21 00:02 s5bug

How do I test whether a pointer should be a single pointer or a multipointer? For example, currently I get an error on gl.GenBuffers because it's defined to accept a *u32 instead of a [*]u32.

s5bug avatar Feb 07 '21 01:02 s5bug

type.is_pointer is actually not a boolean (as you'd expect), it contains the "pointer depth": https://github.com/Dav1dde/glad/blob/glad2/glad/parse.py#L1181

is_array is similar and contains the array length

Dav1dde avatar Feb 07 '21 10:02 Dav1dde

That's not idiomatic.

On February 7, 2021 2:27:25 AM PST, David Herberth [email protected] wrote:

type.is_pointer is actually not a boolean (as you'd expect), it contains the "pointer depth": https://github.com/Dav1dde/glad/blob/glad2/glad/parse.py#L1181

is_array is similar and contains the array length

-- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/Dav1dde/glad/pull/311#issuecomment-774649650

ghost avatar Feb 07 '21 13:02 ghost

type.is_pointer is actually not a boolean (as you'd expect), it contains the "pointer depth": https://github.com/Dav1dde/glad/blob/glad2/glad/parse.py#L1181

is_array is similar and contains the array length

Yes, I understand that, and that is working properly. I'm talking about how Zig has a difference between single element pointers and multi-element pointers, which is a different concept from pointer depth: https://ziglang.org/documentation/master/#Pointers

s5bug avatar Feb 07 '21 17:02 s5bug

Do the same things that exist in the Vulkan sepc exists in the GL spec?

s5bug avatar Feb 07 '21 18:02 s5bug

Live coded with a friend to fix the pointer issues. Also, we've split the generation into subcategories like C does, so that we can have type safety that works better with Zig's typechecker.

I am fairly certain this is ready for review.

s5bug avatar Mar 13 '21 04:03 s5bug

Also, is there anything in the xml that describes whether or not a pointer can be 0? Zig pointers that can or can't be zero are actually different types.

Sirius902 avatar Mar 13 '21 06:03 Sirius902

Never mind. Seems we're still running into issues with certain kinds of pointers. Not ready for review.

s5bug avatar Mar 13 '21 06:03 s5bug

Ok @Sirius902 actually tested the generated code with an existing project this time and it works well. Should be complete for a proper review and ready for merging.

s5bug avatar Mar 16 '21 06:03 s5bug

It seems that GLAD is generating files with Windows newlines (CRLF). Zig prefers LF. How can we make GLAD always generate with LF?

s5bug avatar Mar 19 '21 02:03 s5bug

Glad does generate LF for C and Rust.

Dav1dde avatar Mar 20 '21 01:03 Dav1dde

Closed because of inactivity and can be developped externally as plugin.

Dav1dde avatar Oct 21 '22 15:10 Dav1dde