glfw: deduplicate @cImport for type equivalence
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
74e2bddf93
commit
b76e8d02f2
14 changed files with 31 additions and 13 deletions
|
|
@ -3,7 +3,7 @@
|
|||
const std = @import("std");
|
||||
const mem = std.mem;
|
||||
const testing = std.testing;
|
||||
const c = @cImport(@cInclude("GLFW/glfw3.h"));
|
||||
const c = @import("c.zig").c;
|
||||
|
||||
pub const Error = @import("errors.zig").Error;
|
||||
const getError = @import("errors.zig").getError;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
const std = @import("std");
|
||||
const mem = std.mem;
|
||||
const testing = std.testing;
|
||||
const c = @cImport(@cInclude("GLFW/glfw3.h"));
|
||||
const c = @import("c.zig").c;
|
||||
|
||||
pub const Error = @import("errors.zig").Error;
|
||||
const getError = @import("errors.zig").getError;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
//! Key and button actions
|
||||
|
||||
const c = @cImport(@cInclude("GLFW/glfw3.h"));
|
||||
const c = @import("c.zig").c;
|
||||
|
||||
/// The key or mouse button was released.
|
||||
pub const release = C.GLFW_RELEASE;
|
||||
|
|
|
|||
18
glfw/src/c.zig
Normal file
18
glfw/src/c.zig
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
//! The GLFW C import
|
||||
//!
|
||||
//! This is declared centrally in this module and imported in all usage locations, as otherwise
|
||||
//! the underlying C import would be generated multiple times and e.g. struct types would be
|
||||
//! incompatible, e.g.:
|
||||
//!
|
||||
//! ```
|
||||
//! ./src/Monitor.zig:207:46: error: expected type '.cimport:8:11.struct_GLFWvidmode', found '.cimport:6:11.struct_GLFWvidmode'
|
||||
//! slice[i] = VideoMode{ .handle = modes[i] };
|
||||
//! ^
|
||||
//! ./zig-cache/o/07cfe6253b7dceb60e4bf24e3426d444/cimport.zig:783:32: note: .cimport:8:11.struct_GLFWvidmode declared here
|
||||
//! pub const struct_GLFWvidmode = extern struct {
|
||||
//! ^
|
||||
//! ./zig-cache/o/07cfe6253b7dceb60e4bf24e3426d444/cimport.zig:783:32: note: .cimport:6:11.struct_GLFWvidmode declared here
|
||||
//! pub const struct_GLFWvidmode = extern struct {
|
||||
//! ^
|
||||
//! ```
|
||||
pub const c = @cImport(@cInclude("GLFW/glfw3.h"));
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
//! General constants
|
||||
|
||||
const c = @cImport(@cInclude("GLFW/glfw3.h"));
|
||||
const c = @import("c.zig").c;
|
||||
|
||||
// Input focus window hint and attribute
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
//! Errors
|
||||
|
||||
const c = @cImport(@cInclude("GLFW/glfw3.h"));
|
||||
const c = @import("c.zig").c;
|
||||
|
||||
/// Errors that GLFW can produce.
|
||||
pub const Error = error{
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
//!
|
||||
//! See glfw.getGamepadState for how these are used.
|
||||
|
||||
const c = @cImport(@cInclude("GLFW/glfw3.h"));
|
||||
const c = @import("c.zig").c;
|
||||
|
||||
pub const left_x = C.GLFW_GAMEPAD_AXIS_LEFT_X;
|
||||
pub const left_y = C.GLFW_GAMEPAD_AXIS_LEFT_Y;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
//!
|
||||
//! See glfw.getGamepadState for how these are used.
|
||||
|
||||
const c = @cImport(@cInclude("GLFW/glfw3.h"));
|
||||
const c = @import("c.zig").c;
|
||||
|
||||
pub const a = C.GLFW_GAMEPAD_BUTTON_A;
|
||||
pub const b = C.GLFW_GAMEPAD_BUTTON_B;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
//!
|
||||
//! See glfw.getJoystickHats for how these are used.
|
||||
|
||||
const c = @cImport(@cInclude("GLFW/glfw3.h"));
|
||||
const c = @import("c.zig").c;
|
||||
|
||||
pub const centered = C.GLFW_HAT_CENTERED;
|
||||
pub const up = C.GLFW_HAT_UP;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
//!
|
||||
//! See glfw.setJoystickCallback for how these are used.
|
||||
|
||||
const c = @cImport(@cInclude("GLFW/glfw3.h"));
|
||||
const c = @import("c.zig").c;
|
||||
|
||||
pub const one = C.GLFW_JOYSTICK_1;
|
||||
pub const two = C.GLFW_JOYSTICK_2;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
const std = @import("std");
|
||||
const testing = std.testing;
|
||||
|
||||
const c = @cImport(@cInclude("GLFW/glfw3.h"));
|
||||
const c = @import("c.zig").c;
|
||||
|
||||
pub usingnamespace @import("consts.zig");
|
||||
pub const Error = @import("errors.zig").Error;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
//!
|
||||
//! See glfw.setKeyCallback for how these are used.
|
||||
|
||||
const c = @cImport(@cInclude("GLFW/glfw3.h"));
|
||||
const c = @import("c.zig").c;
|
||||
|
||||
/// If this bit is set one or more Shift keys were held down.
|
||||
pub const shift = C.GLFW_MOD_SHIFT;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
//!
|
||||
//! See glfw.setMouseButtonCallback for how these are used.
|
||||
|
||||
const c = @cImport(@cInclude("GLFW/glfw3.h"));
|
||||
const c = @import("c.zig").c;
|
||||
|
||||
pub const one = C.GLFW_MOUSE_BUTTON_1;
|
||||
pub const two = C.GLFW_MOUSE_BUTTON_2;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
//! GLFW version info
|
||||
|
||||
const c = @cImport(@cInclude("GLFW/glfw3.h"));
|
||||
const c = @import("c.zig").c;
|
||||
|
||||
/// The major version number of the GLFW library.
|
||||
///
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue