aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAutumn! <autumnull@posteo.net>2023-05-24 20:37:00 +0000
committerDrew DeVault <sir@cmpwn.com>2023-06-04 09:23:18 +0200
commit3ca5d97376151d6f1a4a1787b6609c470a05a82c (patch)
tree624e7cdf0711f30512b9ce03c67fd9356073b1ad
parentadded some missing bindings (diff)
downloadhare-chip8-3ca5d97376151d6f1a4a1787b6609c470a05a82c.tar.gz
Use types::c:: instead of char and strings::
Signed-off-by: Autumn! <autumnull@posteo.net>
-rw-r--r--sdl2/errors.ha8
-rw-r--r--sdl2/events.ha8
-rw-r--r--sdl2/gl.ha4
-rw-r--r--sdl2/image/image.ha10
-rw-r--r--sdl2/keyboard.ha8
-rw-r--r--sdl2/rwops.ha6
-rw-r--r--sdl2/video.ha8
7 files changed, 28 insertions, 24 deletions
diff --git a/sdl2/errors.ha b/sdl2/errors.ha
index 52d23a0..b386ebe 100644
--- a/sdl2/errors.ha
+++ b/sdl2/errors.ha
@@ -1,4 +1,4 @@
-use strings;
+use types::c;
// Returned when an error occurs in an SDL function.
export type error = !str;
@@ -8,7 +8,7 @@ export fn strerror(err: error) str = {
return err: str;
};
-@symbol("SDL_GetError") fn SDL_GetError() const *char;
+@symbol("SDL_GetError") fn SDL_GetError() const *c::char;
export fn wrapvoid(ret: int) (void | error) = {
wrapint(ret)?;
@@ -16,7 +16,7 @@ export fn wrapvoid(ret: int) (void | error) = {
export fn wrapint(ret: int) (int | error) = {
if (ret < 0) {
- return strings::fromc(SDL_GetError()): error;
+ return c::tostr(SDL_GetError()): error;
};
return ret;
};
@@ -26,6 +26,6 @@ export fn wrapptr(ret: nullable *void) (*void | error) = {
case let v: *void =>
return v;
case null =>
- return strings::fromc(SDL_GetError()): error;
+ return c::tostr(SDL_GetError()): error;
};
};
diff --git a/sdl2/events.ha b/sdl2/events.ha
index 1003af1..beb1343 100644
--- a/sdl2/events.ha
+++ b/sdl2/events.ha
@@ -1,3 +1,5 @@
+use types::c;
+
export type SDL_EventType = enum u32 {
FIRSTEVENT = 0,
@@ -116,7 +118,7 @@ export def TEXTEDITINGEVENT_TEXT_SIZE: size = 32;
export type SDL_TextEditingEvent = struct {
SDL_CommonEvent,
window_id: u32,
- text: [TEXTEDITINGEVENT_TEXT_SIZE]char,
+ text: [TEXTEDITINGEVENT_TEXT_SIZE]c::char,
start: i32,
length: i32,
};
@@ -128,7 +130,7 @@ export def TEXTINPUTEVENT_TEXT_SIZE: size = 32;
export type SDL_TextInputEvent = struct {
SDL_CommonEvent,
window_id: u32,
- text: [TEXTINPUTEVENT_TEXT_SIZE]char,
+ text: [TEXTINPUTEVENT_TEXT_SIZE]c::char,
};
// Mouse motion event structure (event.motion.*)
@@ -294,7 +296,7 @@ export type SDL_DollarGestureEvent = struct {
// If this event is enabled, you must free the filename in the event.
export type SDL_DropEvent = struct {
SDL_CommonEvent,
- file: *char,
+ file: *c::char,
window_id: u32,
};
diff --git a/sdl2/gl.ha b/sdl2/gl.ha
index 023a62f..6599da8 100644
--- a/sdl2/gl.ha
+++ b/sdl2/gl.ha
@@ -1,3 +1,5 @@
+use types::c;
+
export type SDL_GLContext = void;
export type SDL_GLprofile = enum int {
@@ -39,7 +41,7 @@ export type SDL_GLattr = enum {
export @symbol("SDL_GL_CreateContext") fn SDL_GL_CreateContext(
window: *SDL_Window) *SDL_GLContext;
export @symbol("SDL_GL_GetProcAddress") fn SDL_GL_GetProcAddress(
- proc: *const char) *void;
+ proc: *const c::char) *void;
export @symbol("SDL_GL_SetAttribute") fn SDL_GL_SetAttribute(
attr: SDL_GLattr, value: int) *void;
export @symbol("SDL_GL_SwapWindow") fn SDL_GL_SwapWindow(window: *SDL_Window) void;
diff --git a/sdl2/image/image.ha b/sdl2/image/image.ha
index 8684f83..32f8f3d 100644
--- a/sdl2/image/image.ha
+++ b/sdl2/image/image.ha
@@ -1,7 +1,7 @@
// TODO: Flesh me out
// TODO: SDL_RWops
use sdl2;
-use strings;
+use types::c;
// Flags for [[IMG_Init]].
export type IMG_InitFlags = enum int {
@@ -23,24 +23,24 @@ export fn IMG_Init(flags: IMG_InitFlags) (void | sdl2::error) = {
// Unloads libraries loaded with [[IMG_Init]]
export @symbol("IMG_Quit") fn IMG_Quit() void;
-@symbol("IMG_Load") fn _IMG_Load(file: const *char) nullable *sdl2::SDL_Surface;
+@symbol("IMG_Load") fn _IMG_Load(file: const *c::char) nullable *sdl2::SDL_Surface;
// Load an image from a file path.
export fn IMG_Load(file: str) (*sdl2::SDL_Surface | sdl2::error) = {
- const file = strings::to_c(file);
+ const file = c::fromstr(file);
defer free(file);
return sdl2::wrapptr(_IMG_Load(file))?: *sdl2::SDL_Surface;
};
@symbol("IMG_LoadTexture") fn _IMG_LoadTexture(SDL_Renderer: *sdl2::SDL_Renderer,
- file: const *char) nullable *sdl2::SDL_Texture;
+ file: const *c::char) nullable *sdl2::SDL_Texture;
// Load an image directly into a render texture.
export fn IMG_LoadTexture(
SDL_Renderer: *sdl2::SDL_Renderer,
file: str,
) (*sdl2::SDL_Texture | sdl2::error) = {
- const file = strings::to_c(file);
+ const file = c::fromstr(file);
defer free(file);
return sdl2::wrapptr(_IMG_LoadTexture(SDL_Renderer, file))?: *sdl2::SDL_Texture;
};
diff --git a/sdl2/keyboard.ha b/sdl2/keyboard.ha
index eb38afd..d42fa8a 100644
--- a/sdl2/keyboard.ha
+++ b/sdl2/keyboard.ha
@@ -1,4 +1,4 @@
-use strings;
+use types::c;
export type SDL_Scancode = enum uint {
UNKNOWN = 0,
@@ -632,14 +632,14 @@ export type SDL_Keysym = struct {
unused: u32,
};
-@symbol("SDL_GetKeyFromName") fn _SDL_GetKeyFromName(name: *const char) SDL_Keycode;
+@symbol("SDL_GetKeyFromName") fn _SDL_GetKeyFromName(name: *const c::char) SDL_Keycode;
export fn SDL_GetKeyFromName(name: str) (SDL_Keycode | error) = {
- const name = strings::to_c(name);
+ const name = c::fromstr(name);
defer free(name);
const sym = _SDL_GetKeyFromName(name);
if (sym == SDL_Keycode::UNKNOWN) {
- return strings::fromc(SDL_GetError()): error;
+ return c::tostr(SDL_GetError()): error;
};
return sym;
};
diff --git a/sdl2/rwops.ha b/sdl2/rwops.ha
index ec961a2..9b9a190 100644
--- a/sdl2/rwops.ha
+++ b/sdl2/rwops.ha
@@ -1,5 +1,5 @@
use io;
-use strings;
+use types::c;
// RWops types
export type rwops_type = enum u32 {
@@ -39,8 +39,8 @@ export type SDL_RWops = struct {
};
@symbol("SDL_RWFromFile") fn _rw_from_file(
- file: const *char,
- mode: const *char,
+ file: const *c::char,
+ mode: const *c::char,
) *SDL_RWops;
// Returns the size of an [[SDL_RWops]], or 0 if unknown or error.
diff --git a/sdl2/video.ha b/sdl2/video.ha
index bfcb3d0..f60d915 100644
--- a/sdl2/video.ha
+++ b/sdl2/video.ha
@@ -1,5 +1,5 @@
// TODO: Flesh me out
-use strings;
+use types::c;
// The type used to identify a window. (Opaque)
export type SDL_Window = void;
@@ -33,12 +33,12 @@ export type SDL_WindowFlags = enum u32 {
export def SDL_WINDOWPOS_UNDEFINED: int = 0x1FFF0000;
export def SDL_WINDOWPOS_CENTERED: int = 0x2FFF0000;
-@symbol("SDL_CreateWindow") fn _SDL_CreateWindow(title: const *char,
+@symbol("SDL_CreateWindow") fn _SDL_CreateWindow(title: const *c::char,
x: int, y: int, w: int, h: int, flags: SDL_WindowFlags) nullable *SDL_Window;
// Create a window with the specified position, dimensions, and flags.
//
-// 'title' is the title of the window, in UTF-8 encoding. See [[strings::to_c]]
+// 'title' is the title of the window, in UTF-8 encoding. See [[types::c::fromstr]]
// to prepare a suitable string.
//
// 'x' and 'y' set the position of the window, or use [[SDL_WINDOWPOS_CENTERED]] or
@@ -78,7 +78,7 @@ export fn SDL_CreateWindow(
h: int,
flags: SDL_WindowFlags,
) (*SDL_Window | error) = {
- let title = strings::to_c(title);
+ let title = c::fromstr(title);
defer free(title);
return wrapptr(_SDL_CreateWindow(title, x, y, w, h, flags))?: *SDL_Window;
};