From 100753a060bebb9ad33a2b56722a4e83faba3fea Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Fri, 21 Mar 2025 10:40:06 +0100 Subject: Move bindings from bindings/gi => gi Signed-off-by: Drew DeVault --- Makefile | 28 ++++++++-------------------- bindings/gi/glib/types.ha | 10 ---------- bindings/gi/gobject/types.ha | 13 ------------- bindings/types/libc/types.ha | 32 -------------------------------- cmd/hare-gi/emit.ha | 2 +- gi/glib/types.ha | 10 ++++++++++ gi/gobject/types.ha | 13 +++++++++++++ gi/libc/types.ha | 32 ++++++++++++++++++++++++++++++++ scripts/generate3 | 2 +- scripts/generate4 | 2 +- 10 files changed, 66 insertions(+), 78 deletions(-) delete mode 100644 bindings/gi/glib/types.ha delete mode 100644 bindings/gi/gobject/types.ha delete mode 100644 bindings/types/libc/types.ha create mode 100644 gi/glib/types.ha create mode 100644 gi/gobject/types.ha create mode 100644 gi/libc/types.ha diff --git a/Makefile b/Makefile index 1250439..1456f25 100644 --- a/Makefile +++ b/Makefile @@ -10,9 +10,8 @@ SRCDIR = $(PREFIX)/src HARESRCDIR = $(SRCDIR)/hare THIRDPARTYDIR = $(HARESRCDIR)/third-party -BINDINGS_DIR = bindings MODULES_CORE = \ - types/libc \ + gi/libc \ gi/glib \ gi/gobject \ gi/gio \ @@ -57,14 +56,14 @@ install-gtk3: .gen @for mod in $(MODULES_GTK3); do \ printf "installing %s\n" "$$mod"; \ mkdir -p "$(DESTDIR)$(THIRDPARTYDIR)/$$mod"; \ - install -m644 "$(BINDINGS_DIR)/$$mod"/* "$(DESTDIR)$(THIRDPARTYDIR)/$$mod"; \ + install -m644 "$$mod"/* "$(DESTDIR)$(THIRDPARTYDIR)/$$mod"; \ done install-gtk4: .gen @for mod in $(MODULES_GTK4); do \ printf "installing %s\n" "$$mod"; \ mkdir -p "$(DESTDIR)$(THIRDPARTYDIR)/$$mod"; \ - install -m644 "$(BINDINGS_DIR)/$$mod"/* "$(DESTDIR)$(THIRDPARTYDIR)/$$mod"; \ + install -m644 "$$mod"/* "$(DESTDIR)$(THIRDPARTYDIR)/$$mod"; \ done uninstall: uninstall3 uninstall4 @@ -81,25 +80,14 @@ uninstall4: rm -r "$(DESTDIR)$(THIRDPARTYDIR)/$$mod"; \ done -HAREPATH_ENV_CMD = hare version -vv | grep '^HAREPATH' +demo3: .gen + hare build $(LIBS_3) -o demo3 cmd/demo3 -# hare version -vv returns the value of HAREPATH in form -# HAREPATH= -# -# Using eval on that line will set the HAREPATH variable in the environment to -# the unquoted value, which makes it easy to add the bindings directory to the -# path - -demo3: - eval "$$($(HAREPATH_ENV_CMD))" && env HAREPATH="$(BINDINGS_DIR):$$HAREPATH" \ - hare build $(LIBS_3) -o demo3 cmd/demo3 - -demo4: - eval "$$($(HAREPATH_ENV_CMD))" && env HAREPATH="$(BINDINGS_DIR):$$HAREPATH" \ - hare build $(LIBS_4) -o demo4 cmd/demo4 +demo4: .gen + hare build $(LIBS_4) -o demo4 cmd/demo4 clean: - rm -f hare-gi xmltree demo3 demo4 bindings/gi/*/_generate.ha + rm -f hare-gi xmltree demo3 demo4 gi/*/_generate.ha .PHONY: all clean .PHONY: install install-gtk3 install-gtk4 diff --git a/bindings/gi/glib/types.ha b/bindings/gi/glib/types.ha deleted file mode 100644 index 2492c4e..0000000 --- a/bindings/gi/glib/types.ha +++ /dev/null @@ -1,10 +0,0 @@ -export type Type = size; - -// Boolean type used by GLib and related libraries, equivalent to gboolean in C. -export type boolean = uint; - -// True value of [[boolean]]. -export def TRUE: boolean = 1; - -// False value of [[boolean]]. -export def FALSE: boolean = 0; diff --git a/bindings/gi/gobject/types.ha b/bindings/gi/gobject/types.ha deleted file mode 100644 index 570fe30..0000000 --- a/bindings/gi/gobject/types.ha +++ /dev/null @@ -1,13 +0,0 @@ -use types::c; - -export type ValueUnion = union { - v_int: int, - v_uint: uint, - v_long: c::long, - v_ulong: c::ulong, - v_int64: i64, - v_uint64: u64, - v_float: f32, - v_double: f64, - v_pointer: *opaque, -}; diff --git a/bindings/types/libc/types.ha b/bindings/types/libc/types.ha deleted file mode 100644 index 94959b7..0000000 --- a/bindings/types/libc/types.ha +++ /dev/null @@ -1,32 +0,0 @@ -use types::c; - -export type time_t = i64; - -export type utimbuf = struct { - actime: time_t, - modtime: time_t, -}; - -export type tm = struct { - tm_sec: int, - tm_min: int, - tm_hour: int, - tm_mday: int, - tm_mon: int, - tm_year: int, - tm_wday: int, - tm_yday: int, - tm_isdst: int, -}; - -export type FILE = opaque; - -export type passwd = struct { - pw_name: *c::char, - pw_passwd: *c::char, - pw_uid: uint, - pw_gid: uint, - pw_gecos: *c::char, - pw_dir: *c::char, - pw_shell: *c::char, -}; diff --git a/cmd/hare-gi/emit.ha b/cmd/hare-gi/emit.ha index bec5b4a..5f137ed 100644 --- a/cmd/hare-gi/emit.ha +++ b/cmd/hare-gi/emit.ha @@ -672,7 +672,7 @@ fn emit_c_type(ctx: *context, type_: ctype, flags: ctype_flag...) (void | io::er const (mod, id) = special; switch (mod) { case cmodule::LIBC => - add_import(ctx.current, ["types", "libc"]); + add_import(ctx.current, ["gi", "libc"]); fmt::fprintf(ctx.current.output, "libc::{}", id)?; case cmodule::GLIB => emit_object(ctx, ctx.glib, id)?; diff --git a/gi/glib/types.ha b/gi/glib/types.ha new file mode 100644 index 0000000..2492c4e --- /dev/null +++ b/gi/glib/types.ha @@ -0,0 +1,10 @@ +export type Type = size; + +// Boolean type used by GLib and related libraries, equivalent to gboolean in C. +export type boolean = uint; + +// True value of [[boolean]]. +export def TRUE: boolean = 1; + +// False value of [[boolean]]. +export def FALSE: boolean = 0; diff --git a/gi/gobject/types.ha b/gi/gobject/types.ha new file mode 100644 index 0000000..570fe30 --- /dev/null +++ b/gi/gobject/types.ha @@ -0,0 +1,13 @@ +use types::c; + +export type ValueUnion = union { + v_int: int, + v_uint: uint, + v_long: c::long, + v_ulong: c::ulong, + v_int64: i64, + v_uint64: u64, + v_float: f32, + v_double: f64, + v_pointer: *opaque, +}; diff --git a/gi/libc/types.ha b/gi/libc/types.ha new file mode 100644 index 0000000..94959b7 --- /dev/null +++ b/gi/libc/types.ha @@ -0,0 +1,32 @@ +use types::c; + +export type time_t = i64; + +export type utimbuf = struct { + actime: time_t, + modtime: time_t, +}; + +export type tm = struct { + tm_sec: int, + tm_min: int, + tm_hour: int, + tm_mday: int, + tm_mon: int, + tm_year: int, + tm_wday: int, + tm_yday: int, + tm_isdst: int, +}; + +export type FILE = opaque; + +export type passwd = struct { + pw_name: *c::char, + pw_passwd: *c::char, + pw_uid: uint, + pw_gid: uint, + pw_gecos: *c::char, + pw_dir: *c::char, + pw_shell: *c::char, +}; diff --git a/scripts/generate3 b/scripts/generate3 index 18a834b..bf57ff5 100755 --- a/scripts/generate3 +++ b/scripts/generate3 @@ -1,6 +1,6 @@ #!/bin/sh -BIND=./bindings/gi +BIND=./gi NS=gi:: mkdir -p "$BIND"/glib "$BIND"/gobject "$BIND"/gio "$BIND"/gmodule "$BIND"/atk \ diff --git a/scripts/generate4 b/scripts/generate4 index 0c75b61..c285a4e 100755 --- a/scripts/generate4 +++ b/scripts/generate4 @@ -1,6 +1,6 @@ #!/bin/sh -BIND=./bindings/gi +BIND=./gi NS=gi:: mkdir -p "$BIND"/glib "$BIND"/gobject "$BIND"/gio "$BIND"/gmodule "$BIND"/atk \ -- cgit 1.3.0-6-gf8a5