From 955ea8882b0ce527ff4a83cd92439250ac6b8093 Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Tue, 10 Feb 2026 12:50:32 -0500 Subject: [PATCH] Remove deprecated GObject bindings These were marked as deprecated in a57f6b8e2. Time to remove them Signed-off-by: Cole Robinson --- .github/workflows/main.yml | 4 +- .gitignore | 6 - Makefile.am | 5 +- configure.ac | 14 +- docs/guestfs-building.pod | 6 - docs/guestfs-hacking.pod | 2 - generator/GObject.ml | 1275 -------------------------- generator/GObject.mli | 28 - generator/Makefile.am | 6 - generator/bindtests.ml | 60 -- generator/bindtests.mli | 1 - generator/main.ml | 43 - gobject/.gitignore | 4 - gobject/Makefile.am | 142 --- gobject/Makefile.inc | 216 ----- gobject/TODO.txt | 11 - gobject/bindtests-retvalues.js | 110 --- gobject/guestfs-gobject.pod | 68 -- gobject/libguestfs-gobject-1.0.deps | 2 - gobject/libguestfs-gobject-1.0.pc.in | 11 - gobject/run-live-tests | 27 - gobject/run-tests | 34 - gobject/run-tests-retvalues | 28 - gobject/tests-misc.js | 74 -- m4/guestfs-gobject.m4 | 61 -- po-docs/podfiles | 1 - po/POTFILES | 95 -- run.in | 6 - 28 files changed, 11 insertions(+), 2329 deletions(-) delete mode 100644 generator/GObject.ml delete mode 100644 generator/GObject.mli delete mode 100644 gobject/.gitignore delete mode 100644 gobject/Makefile.am delete mode 100644 gobject/Makefile.inc delete mode 100644 gobject/TODO.txt delete mode 100644 gobject/bindtests-retvalues.js delete mode 100644 gobject/guestfs-gobject.pod delete mode 100644 gobject/libguestfs-gobject-1.0.deps delete mode 100644 gobject/libguestfs-gobject-1.0.pc.in delete mode 100755 gobject/run-live-tests delete mode 100755 gobject/run-tests delete mode 100755 gobject/run-tests-retvalues delete mode 100644 gobject/tests-misc.js delete mode 100644 m4/guestfs-gobject.m4 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d7f2872dc..276c17da8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -59,7 +59,7 @@ jobs: - name: Compile the code run: | autoreconf -fiv - ./configure --disable-gobject --enable-werror + ./configure --enable-werror make -j - name: Run the quick test @@ -136,7 +136,7 @@ jobs: run: | su -c ' autoreconf -fiv && - ./configure CFLAGS="-fPIC -g -O2" --disable-gobject --enable-werror && + ./configure CFLAGS="-fPIC -g -O2" --enable-werror && make -j ' guestfs diff --git a/.gitignore b/.gitignore index c8a8312fa..26f93f3a2 100644 --- a/.gitignore +++ b/.gitignore @@ -209,12 +209,6 @@ Makefile.in /generator/stamp-generator /.gitattributes /.git-module-status -/gobject/bindtests.js -/gobject/Guestfs-1.0.gir -/gobject/Guestfs-1.0.typelib -/gobject/guestfs-gobject.3 -/gobject/libguestfs-gobject-1.0.vapi -/gobject/stamp-guestfs-gobject.pod /golang/bindtests/bindtests.go /golang/examples/guestfs-golang.3 /golang/examples/stamp-guestfs-golang.pod diff --git a/Makefile.am b/Makefile.am index 8accc463c..cf66473d7 100644 --- a/Makefile.am +++ b/Makefile.am @@ -88,9 +88,6 @@ endif if HAVE_LUA SUBDIRS += lua lua/examples endif -if HAVE_GOBJECT -SUBDIRS += gobject -endif if HAVE_GOLANG SUBDIRS += golang golang/examples endif @@ -214,7 +211,7 @@ dist-hook: docs/C_SOURCE_FILES po/POTFILES docs/C_SOURCE_FILES: configure.ac rm -f $@ $@-t find $(DIST_SUBDIRS) -name '*.[ch]' | \ - grep -v -E '^(builder/index-parse\.|builder/index-scan\.|examples/|gobject/|java/com_redhat_et_libguestfs|perl/|php/extension/config\.h|ruby/ext/guestfs/extconf\.h|tests/|test-data/)' | \ + grep -v -E '^(builder/index-parse\.|builder/index-scan\.|examples/|java/com_redhat_et_libguestfs|perl/|php/extension/config\.h|ruby/ext/guestfs/extconf\.h|tests/|test-data/)' | \ grep -v -E '/(guestfs|rc)_protocol\.' | \ grep -v -E '.*/errnostring\.' | \ grep -v -E '.*-gperf\.' | \ diff --git a/configure.ac b/configure.ac index 7a66160b7..e0d118033 100644 --- a/configure.ac +++ b/configure.ac @@ -156,10 +156,16 @@ HEADING([Checking for Lua]) m4_include([m4/guestfs-lua.m4]) HEADING([Checking for Go]) m4_include([m4/guestfs-golang.m4]) -HEADING([Checking for GObject Introspection]) -m4_include([m4/guestfs-gobject.m4]) HEADING([Checking for Rust]) m4_include([m4/guestfs-rust.m4]) +HEADING([Checking for GObject Introspection]) +dnl GObject introspection is needed for Vala bindings. +m4_ifdef([GOBJECT_INTROSPECTION_CHECK], [ + GOBJECT_INTROSPECTION_CHECK([1.30.0]) +],[ + AM_CONDITIONAL([HAVE_INTROSPECTION], [false]) +]) + HEADING([Checking for Vala]) VAPIGEN_CHECK @@ -239,8 +245,6 @@ AC_CONFIG_FILES([Makefile fuse/Makefile generator/Makefile gnulib/lib/Makefile - gobject/libguestfs-gobject-1.0.pc - gobject/Makefile golang/Makefile golang/examples/Makefile haskell/Makefile @@ -334,8 +338,6 @@ feature "PHP bindings" test "x$HAVE_PHP_TRUE" = "x" feature "Erlang bindings" test "x$HAVE_ERLANG_TRUE" = "x" feature "Lua bindings" test "x$HAVE_LUA_TRUE" = "x" feature "Go bindings" test "x$HAVE_GOLANG_TRUE" = "x" -feature "gobject bindings" test "x$HAVE_GOBJECT_TRUE" = "x" -feature "gobject introspection" test "x$HAVE_INTROSPECTION_TRUE" = "x" feature "Vala bindings" test "x$ENABLE_VAPIGEN_TRUE" = "x" feature "bash completion" test "x$HAVE_BASH_COMPLETION_TRUE" = "x" feature "Rust bindings" test "x$HAVE_RUST_TRUE" = "x" diff --git a/docs/guestfs-building.pod b/docs/guestfs-building.pod index 97effd2db..05ab3978b 100644 --- a/docs/guestfs-building.pod +++ b/docs/guestfs-building.pod @@ -307,10 +307,6 @@ Optional. Used to build the PHP bindings. =item gobject-introspection -=item gjs - -Optional. Used to build and test the GObject bindings. - =item vala Optional. Used to build the Vala bindings. @@ -502,8 +498,6 @@ See L below. =item B<--disable-erlang> -=item B<--disable-gobject> - =item B<--disable-golang> =item B<--disable-haskell> diff --git a/docs/guestfs-hacking.pod b/docs/guestfs-hacking.pod index 6828f11f9..35094421a 100644 --- a/docs/guestfs-hacking.pod +++ b/docs/guestfs-hacking.pod @@ -324,8 +324,6 @@ The L website files. =item F -=item F - =item F =item F diff --git a/generator/GObject.ml b/generator/GObject.ml deleted file mode 100644 index 19e0370f8..000000000 --- a/generator/GObject.ml +++ /dev/null @@ -1,1275 +0,0 @@ -(* libguestfs - * Copyright (C) 2012-2025 Red Hat Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - *) - -(* Please read generator/README first. *) - -(* NB: This is missing support for OStringList. *) - -open Printf - -open Std_utils -open Actions -open Docstrings -open Events -open Pr -open Structs -open Types -open Utils - -let generate_header = generate_header ~inputs:["generator/gobject.ml"] - -let camel_of_name { camel_name } = "Guestfs" ^ camel_name - -let generate_gobject_proto name ?(single_line = true) - (ret, args, optargs) f = - let spacer = if single_line then " " else "\n" in - let ptr_spacer = if single_line then "" else "\n" in - (match ret with - | RErr -> - pr "gboolean%s" spacer - | RInt _ -> - pr "gint32%s" spacer - | RInt64 _ -> - pr "gint64%s" spacer - | RBool _ -> - pr "gint8%s" spacer - | RConstString _ - | RConstOptString _ -> - pr "const gchar *%s" ptr_spacer - | RString _ -> - pr "gchar *%s" ptr_spacer - | RStringList _ -> - pr "gchar **%s" ptr_spacer - | RStruct (_, typ) -> - let name = camel_name_of_struct typ in - pr "Guestfs%s *%s" name ptr_spacer - | RStructList (_, typ) -> - let name = camel_name_of_struct typ in - pr "Guestfs%s **%s" name ptr_spacer - | RHashtable _ -> - pr "GHashTable *%s" ptr_spacer - | RBufferOut _ -> - pr "guint8 *%s" ptr_spacer - ); - pr "guestfs_session_%s (GuestfsSession *session" name; - List.iter ( - fun arg -> - pr ", "; - match arg with - | Bool n -> - pr "gboolean %s" n - | Int n -> - pr "gint32 %s" n - | Int64 n-> - pr "gint64 %s" n - | String (_, n) - | OptString n -> - pr "const gchar *%s" n - | StringList (_, n) -> - pr "gchar *const *%s" n - | BufferIn n -> - pr "const guint8 *%s, gsize %s_size" n n - | Pointer (t, n) -> - pr "void * /* %s */ %s" t n - ) args; - if optargs <> [] then ( - pr ", %s *optargs" (camel_of_name f) - ); - (match ret with - | RBufferOut _ -> - pr ", gsize *size_r" - | _ -> ()); - if f.cancellable then - pr ", GCancellable *cancellable"; - pr ", GError **err"; - pr ")" - -let filenames = - "session" :: "tristate" :: - - (* structs *) - List.map (fun { s_name = typ } -> "struct-" ^ typ) external_structs @ - - (* optargs *) - List.map (function { name } -> "optargs-" ^ name) ( - List.filter ( - function - | { style = _, _, (_::_) } -> true - | { style = _, _, [] } -> false - ) (actions |> external_functions |> sort) - ) - -let header_start filename = - generate_header CStyle GPLv2plus; - let guard = Str.global_replace (Str.regexp "-") "_" filename in - let guard = "GUESTFS_GOBJECT_" ^ String.uppercase_ascii guard ^ "_H__" in - pr "#ifndef %s\n" guard; - pr "#define %s\n" guard; - pr {| -#include -#include - -#include - -G_BEGIN_DECLS -|} - -and header_end filename = - let guard = Str.global_replace (Str.regexp "-") "_" filename in - let guard = "GUESTFS_GOBJECT_" ^ String.uppercase_ascii guard ^ "_H__" in - pr {| -G_END_DECLS - -#endif /* %s */ -|} guard - -let source_start ?title ?shortdesc ?longdesc filename = - generate_header CStyle GPLv2plus; - - pr "#include \n\n"; - pr "#include \"guestfs-gobject.h\"\n\n"; - pr "/**\n"; - pr " * SECTION:%s\n" filename; - - (match title with - | Some title -> - pr " * @title: %s\n" title - | _ -> ()); - - (match shortdesc with - | Some desc -> - pr " * @short_description: %s\n" desc; - | _ -> ()); - - pr " * @include: guestfs-gobject.h\n"; - - (match longdesc with - | Some desc -> - pr " *\n"; - pr " %s\n" desc - | _ -> ()); - - pr " */\n" - -let generate_gobject_makefile () = - generate_header HashStyle GPLv2plus; - let headers = - List.map - (function n -> sprintf "include/guestfs-gobject/%s.h" n) filenames - in - let sources = - List.map (function n -> sprintf "src/%s.c" n) filenames - in - pr "guestfs_gobject_headers= \\\n include/guestfs-gobject.h \\\n %s\n\n" - (String.concat " \\\n " headers); - pr "guestfs_gobject_sources= \\\n %s\n" (String.concat " \\\n " sources) - -let generate_gobject_header () = - generate_header CStyle GPLv2plus; - List.iter - (function f -> pr "#include \n" f) - filenames - -let generate_gobject_struct_header filename typ cols () = - header_start filename; - - let camel = camel_name_of_struct typ in - - pr "\n"; - - pr "/**\n"; - pr " * Guestfs%s:\n" camel; - List.iter ( - function - | n, FChar -> - pr " * @%s: A character\n" n - | n, FUInt32 -> - pr " * @%s: An unsigned 32-bit integer\n" n - | n, FInt32 -> - pr " * @%s: A signed 32-bit integer\n" n - | n, (FUInt64|FBytes) -> - pr " * @%s: An unsigned 64-bit integer\n" n - | n, FInt64 -> - pr " * @%s: A signed 64-bit integer\n" n - | n, (FString|FDevice) -> - pr " * @%s: A NULL-terminated string\n" n - | n, FBuffer -> - pr " * @%s: A GByteArray\n" n - | n, FUUID -> - pr " * @%s: A 32 byte UUID. Note that this is not NULL-terminated\n" n - | n, FOptPercent -> - pr " * @%s: A floating point number. A value between 0 and 100 " n; - pr "represents a percentage. A value of -1 represents 'not present'\n" - ) cols; - pr " */\n"; - pr "typedef struct _Guestfs%s Guestfs%s;\n" camel camel; - pr "struct _Guestfs%s {\n" camel; - List.iter ( - function - | n, FChar -> - pr " gchar %s;\n" n - | n, FUInt32 -> - pr " guint32 %s;\n" n - | n, FInt32 -> - pr " gint32 %s;\n" n - | n, (FUInt64|FBytes) -> - pr " guint64 %s;\n" n - | n, FInt64 -> - pr " gint64 %s;\n" n - | n, (FString|FDevice) -> - pr " gchar *%s;\n" n - | n, FBuffer -> - pr " GByteArray *%s;\n" n - | n, FUUID -> - pr " /* The next field is NOT nul-terminated, be careful when printing it: */\n"; - pr " gchar %s[32];\n" n - | n, FOptPercent -> - pr " /* The next field is [0..100] or -1 meaning 'not present': */\n"; - pr " gfloat %s;\n" n - ) cols; - pr "};\n"; - pr "GType guestfs_%s_get_type (void);\n" typ; - - header_end filename - -let generate_gobject_struct_source filename typ () = - let title = "Guestfs" ^ camel_name_of_struct typ in - source_start ~title filename; - - let name = "guestfs_" ^ typ in - let camel_name = "Guestfs" ^ camel_name_of_struct typ in - - pr "\n"; - - pr "static %s *\n" camel_name; - pr "%s_copy (%s *src)\n" name camel_name; - pr "{\n"; - pr " return g_slice_dup (%s, src);\n" camel_name; - pr "}\n\n"; - - pr "static void\n"; - pr "%s_free (%s *src)\n" name camel_name; - pr "{\n"; - pr " g_slice_free (%s, src);\n" camel_name; - pr "}\n\n"; - - pr "G_DEFINE_BOXED_TYPE (%s, %s, %s_copy, %s_free)\n" - camel_name name name name - -let generate_gobject_optargs_header filename name f () = - header_start filename; - let uc_name = String.uppercase_ascii name in - let camel_name = camel_of_name f in - let type_define = "GUESTFS_TYPE_" ^ uc_name in - - pr "\n"; - - pr "#define %s " type_define; - pr "(guestfs_%s_get_type ())\n" name; - - pr "#define GUESTFS_%s(obj) " uc_name; - pr "(G_TYPE_CHECK_INSTANCE_CAST ((obj), %s, %s))\n" type_define camel_name; - - pr "#define GUESTFS_%s_CLASS(klass) " uc_name; - pr "(G_TYPE_CHECK_CLASS_CAST ((klass), %s, %sClass))\n" type_define camel_name; - - pr "#define GUESTFS_IS_%s(obj) " uc_name; - pr "(G_TYPE_CHECK_INSTANCE_TYPE ((klass), %s))\n" type_define; - - pr "#define GUESTFS_IS_%s_CLASS(klass) " uc_name; - pr "(G_TYPE_CHECK_CLASS_TYPE ((klass), %s))\n" type_define; - - pr "#define GUESTFS_%s_GET_CLASS(obj) " uc_name; - pr "(G_TYPE_INSTANCE_GET_CLASS ((obj), %s, %sClass))\n" type_define camel_name; - - pr "\n"; - pr "typedef struct _%sPrivate %sPrivate;\n" camel_name camel_name; - pr "\n"; - - pr "/**\n"; - pr " * %s:\n" camel_name; - pr " *\n"; - pr " * An object encapsulating optional arguments for guestfs_session_%s.\n" name; - pr " */\n"; - pr "typedef struct _%s %s;\n" camel_name camel_name; - pr "struct _%s {\n" camel_name; - pr " GObject parent;\n"; - pr " %sPrivate *priv;\n" camel_name; - pr "};\n\n"; - - pr "/**\n"; - pr " * %sClass:\n" camel_name; - pr " * @parent_class: The superclass of %sClass\n" camel_name; - pr " *\n"; - pr " * A class metadata object for %s.\n" camel_name; - pr " */\n"; - pr "typedef struct _%sClass %sClass;\n" camel_name camel_name; - pr "struct _%sClass {\n" camel_name; - pr " GObjectClass parent_class;\n"; - pr "};\n\n"; - - pr "GType guestfs_%s_get_type (void);\n" name; - pr "%s *guestfs_%s_new (void);\n" camel_name name; - header_end filename - -let generate_gobject_optargs_source filename name optargs f () = - let desc = - "An object encapsulating optional arguments for guestfs_session_" ^ name in - source_start ~shortdesc:desc ~longdesc:desc filename; - - let uc_name = String.uppercase_ascii name in - let camel_name = camel_of_name f in - let type_define = "GUESTFS_TYPE_" ^ uc_name in - - pr "\n"; - pr "#include \n\n"; - - pr "struct _%sPrivate {\n" camel_name; - List.iter ( - function - | OBool n -> pr " GuestfsTristate %s;\n" n - | OInt n -> pr " gint %s;\n" n - | OInt64 n -> pr " gint64 %s;\n" n - | OString n -> pr " gchar *%s;\n" n - | OStringList _ -> pr " /* OStringList not implemented yet */\n" - ) optargs; - pr "};\n\n"; - - pr "G_DEFINE_TYPE_WITH_CODE (%s, guestfs_%s, G_TYPE_OBJECT,\n" - camel_name name; - pr " G_ADD_PRIVATE (%s));\n\n" camel_name; - - pr "enum {\n"; - pr " PROP_GUESTFS_%s_PROP0" uc_name; - List.iter ( - fun optargt -> - let uc_optname = String.uppercase_ascii (name_of_optargt optargt) in - pr ",\n PROP_GUESTFS_%s_%s" uc_name uc_optname; - ) optargs; - pr "\n};\n\n"; - - pr "static void\nguestfs_%s_set_property" name; - pr "(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)\n"; - pr "{\n"; - pr " %s *self = GUESTFS_%s (object);\n" camel_name uc_name; - pr " %sPrivate *priv = self->priv;\n\n" camel_name; - - pr " switch (property_id) {\n"; - List.iter ( - function OStringList _ -> () (* XXX *) - | optargt -> - let optname = name_of_optargt optargt in - let uc_optname = String.uppercase_ascii optname in - pr " case PROP_GUESTFS_%s_%s:\n" uc_name uc_optname; - (match optargt with - | OString n -> - pr " g_free (priv->%s);\n" n; - | OBool _ | OInt _ | OInt64 _ -> () - | OStringList _ -> () (* XXX *)); - (match optargt with - | OBool n -> pr " priv->%s = g_value_get_enum (value);\n" n - | OInt n -> pr " priv->%s = g_value_get_int (value);\n" n - | OInt64 n -> pr " priv->%s = g_value_get_int64 (value);\n" n - | OString n -> pr " priv->%s = g_value_dup_string (value);\n" n - | OStringList _ -> () - ); - pr " break;\n\n"; - ) optargs; - pr " default:\n"; - pr " /* Invalid property */\n"; - pr " G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);\n"; - pr " }\n"; - pr "}\n\n"; - - pr "static void\nguestfs_%s_get_property" name; - pr "(GObject *object, guint property_id, GValue *value, GParamSpec *pspec)\n"; - pr "{\n"; - pr " %s *self = GUESTFS_%s (object);\n" camel_name uc_name; - pr " %sPrivate *priv = self->priv;\n\n" camel_name; - - pr " switch (property_id) {\n"; - List.iter ( - function OStringList _ -> () (* XXX *) - | optargt -> - let optname = name_of_optargt optargt in - let uc_optname = String.uppercase_ascii optname in - pr " case PROP_GUESTFS_%s_%s:\n" uc_name uc_optname; - let set_value_func = match optargt with - | OBool _ -> "enum" - | OInt _ -> "int" - | OInt64 _ -> "int64" - | OString _ -> "string" - | OStringList _ -> "" (* XXX *) - in - pr " g_value_set_%s (value, priv->%s);\n" set_value_func optname; - pr " break;\n\n"; - ) optargs; - pr " default:\n"; - pr " /* Invalid property */\n"; - pr " G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);\n"; - pr " }\n"; - pr "}\n\n"; - - pr "static void\nguestfs_%s_finalize (GObject *object)\n" name; - pr "{\n"; - - let needs_priv = List.exists (function - | OString _ -> true - | OStringList _ | OBool _ | OInt _ | OInt64 _ -> false - ) optargs in - - if needs_priv then ( - pr " %s *self = GUESTFS_%s (object);\n" camel_name uc_name; - pr " %sPrivate *priv = self->priv;\n" camel_name; - pr "\n"; - ); - - List.iter ( - function - | OString n -> - pr " g_free (priv->%s);\n" n - | OStringList n -> () (* XXX *) - | OBool _ | OInt _ | OInt64 _ -> () - ) optargs; - - pr " G_OBJECT_CLASS (guestfs_%s_parent_class)->finalize (object);\n" name; - pr "}\n\n"; - - pr "static void\nguestfs_%s_class_init (%sClass *klass)\n" name camel_name; - pr "{\n"; - pr " GObjectClass *object_class = G_OBJECT_CLASS (klass);\n"; - - pr " object_class->set_property = guestfs_%s_set_property;\n" name; - pr " object_class->get_property = guestfs_%s_get_property;\n\n" name; - - List.iter ( - function OStringList _ -> () (* XXX *) - | optargt -> - let optname = name_of_optargt optargt in - let type_spec, type_init, type_desc = - match optargt with - | OBool n -> - "enum", "GUESTFS_TYPE_TRISTATE, GUESTFS_TRISTATE_NONE", "A boolean." - | OInt n -> - "int", "G_MININT32, G_MAXINT32, -1", "A 32-bit integer." - | OInt64 n -> - "int64", "G_MININT64, G_MAXINT64, -1", "A 64-bit integer." - | OString n -> - "string", "NULL", "A string." - | OStringList n -> "", "", "" (* XXX *) - in - pr " /**\n"; - pr " * %s:%s:\n" camel_name optname; - pr " *\n"; - pr " * %s\n" type_desc; - pr " */\n"; - pr " g_object_class_install_property (\n"; - pr " object_class,\n"; - pr " PROP_GUESTFS_%s_%s,\n" uc_name (String.uppercase_ascii optname); - pr " g_param_spec_%s (\n" type_spec; - pr " \"%s\",\n" optname; - pr " \"%s\",\n" optname; - pr " \"%s\",\n" type_desc; - pr " %s,\n" type_init; - pr " G_PARAM_CONSTRUCT | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS\n"; - pr " )\n"; - pr " );\n\n"; - - ) optargs; - - pr " object_class->finalize = guestfs_%s_finalize;\n" name; - pr "}\n\n"; - - pr "static void\nguestfs_%s_init (%s *o)\n" name camel_name; - pr "{\n"; - pr " o->priv = guestfs_%s_get_instance_private (o);\n" name; - pr " /* XXX: Find out if gobject already zeroes private structs */\n"; - pr " memset (o->priv, 0, sizeof (%sPrivate));\n" camel_name; - pr "}\n\n"; - - pr "/**\n"; - pr " * guestfs_%s_new:\n" name; - pr " *\n"; - pr " * Create a new %s object\n" camel_name; - pr " *\n"; - pr " * Returns: (transfer full): a new %s object\n" camel_name; - pr " */\n"; - pr "%s *\n" camel_name; - pr "guestfs_%s_new (void)\n" name; - pr "{\n"; - pr " return GUESTFS_%s (g_object_new (%s, NULL));\n" uc_name type_define; - pr "}\n" - -let generate_gobject_tristate_header () = - let filename = "tristate" in - header_start filename; - pr {| -/** - * GuestfsTristate: - * @GUESTFS_TRISTATE_FALSE: False - * @GUESTFS_TRISTATE_TRUE: True - * @GUESTFS_TRISTATE_NONE: Unset - * - * An object representing a tristate: i.e. true, false, or unset. If a language - * binding has a native concept of true and false which also correspond to the - * integer values 1 and 0 respectively, these will also correspond to - * GUESTFS_TRISTATE_TRUE and GUESTFS_TRISTATE_FALSE. - */ -typedef enum -{ - GUESTFS_TRISTATE_FALSE, - GUESTFS_TRISTATE_TRUE, - GUESTFS_TRISTATE_NONE -} GuestfsTristate; - -GType guestfs_tristate_get_type (void); -#define GUESTFS_TYPE_TRISTATE (guestfs_tristate_get_type ()) -|}; - header_end filename - -let generate_gobject_tristate_source () = - let filename = "tristate" in - let title = "GuestfsTristate" in - let shortdesc = "An object representing a tristate value" in - source_start ~title ~shortdesc filename; - pr {| -GType -guestfs_tristate_get_type (void) -{ - static GType etype = 0; - if (etype == 0) { - static const GEnumValue values[] = { - { GUESTFS_TRISTATE_FALSE, "GUESTFS_TRISTATE_FALSE", "false" }, - { GUESTFS_TRISTATE_TRUE, "GUESTFS_TRISTATE_TRUE", "true" }, - { GUESTFS_TRISTATE_NONE, "GUESTFS_TRISTATE_NONE", "none" }, - { 0, NULL, NULL } - }; - etype = g_enum_register_static ("GuestfsTristate", values); - } - return etype; -} -|} - -let generate_gobject_session_header () = - let filename = "session" in - header_start filename; - pr {| -/* GuestfsSessionEvent */ - -/** - * GuestfsSessionEvent: -|}; - - List.iter ( - fun (name, _) -> - pr " * @GUESTFS_SESSION_EVENT_%s: The %s event\n" - (String.uppercase_ascii name) name; - ) events; - - pr {| * - * For more detail on libguestfs events, see "SETTING CALLBACKS TO HANDLE - * EVENTS" in guestfs(3). - */ -typedef enum {|}; - - List.iter ( - fun (name, _) -> - pr "\n GUESTFS_SESSION_EVENT_%s," (String.uppercase_ascii name); - ) events; - - pr {| -} GuestfsSessionEvent; -GType guestfs_session_event_get_type (void); -#define GUESTFS_TYPE_SESSION_EVENT (guestfs_session_event_get_type ()) - -/* GuestfsSessionEventParams */ - -/** - * GuestfsSessionEventParams: - * @event: The event - * @flags: Unused - * @buf: A message buffer. This buffer can contain arbitrary 8 bit data, - * including NUL bytes - * @array: An array of 64-bit unsigned integers - * @array_len: The length of @array - */ -typedef struct _GuestfsSessionEventParams GuestfsSessionEventParams; -struct _GuestfsSessionEventParams { - GuestfsSessionEvent event; - guint flags; - GByteArray *buf; - /* The libguestfs array has no fixed length, although it is currently only - * ever empty or length 4. We fix the length of the array here as there is - * currently no way for an arbitrary length array to be introspected in a - * boxed object. - */ - guint64 array[16]; - size_t array_len; -}; -GType guestfs_session_event_params_get_type (void); - -/* GuestfsSession object definition */ -#define GUESTFS_TYPE_SESSION (guestfs_session_get_type ()) -#define GUESTFS_SESSION(obj) (G_TYPE_CHECK_INSTANCE_CAST ( (obj), GUESTFS_TYPE_SESSION, GuestfsSession)) -#define GUESTFS_SESSION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ( (klass), GUESTFS_TYPE_SESSION, GuestfsSessionClass)) -#define GUESTFS_IS_SESSION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ( (obj), GUESTFS_TYPE_SESSION)) -#define GUESTFS_IS_SESSION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ( (klass), GUESTFS_TYPE_SESSION)) -#define GUESTFS_SESSION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ( (obj), GUESTFS_TYPE_SESSION, GuestfsSessionClass)) - -typedef struct _GuestfsSessionPrivate GuestfsSessionPrivate; - -/** - * GuestfsSession: - * - * A libguestfs session, encapsulating a single libguestfs handle. - */ -typedef struct _GuestfsSession GuestfsSession; -struct _GuestfsSession -{ - GObject parent; - GuestfsSessionPrivate *priv; -}; - -/** - * GuestfsSessionClass: - * @parent_class: The superclass of GuestfsSession - * - * A class metadata object for GuestfsSession. - */ -typedef struct _GuestfsSessionClass GuestfsSessionClass; -struct _GuestfsSessionClass -{ - GObjectClass parent_class; -}; - -GType guestfs_session_get_type (void); -GuestfsSession *guestfs_session_new (void); -gboolean guestfs_session_close (GuestfsSession *session, GError **err); - -|}; - - List.iter ( - fun ({ name; style } as f) -> - generate_gobject_proto name style f; - pr ";\n"; - ) (actions |> external_functions |> sort); - - header_end filename - -let generate_gobject_session_source () = - let filename = "session" in - let shortdesc = "A libguestfs session" in - source_start ~shortdesc filename; - - pr {| -/* It is safe to call deprecated functions from this file. */ -#define GUESTFS_NO_WARN_DEPRECATED -#undef GUESTFS_NO_DEPRECATED - - #include - #include - #include - #include - #include - #include - #include - -/* Error quark */ - -#define GUESTFS_ERROR guestfs_error_quark () - -static GQuark -guestfs_error_quark (void) -{ - return g_quark_from_static_string ("guestfs"); -} - -/* Cancellation handler */ -static void -cancelled_handler (gpointer data) -{ - guestfs_h *g = (guestfs_h *)data; - guestfs_user_cancel (g); -} - -/* GuestfsSessionEventParams */ -static GuestfsSessionEventParams * -guestfs_session_event_params_copy (GuestfsSessionEventParams *src) -{ - return g_slice_dup (GuestfsSessionEventParams, src); -} - -static void -guestfs_session_event_params_free (GuestfsSessionEventParams *src) -{ - g_slice_free (GuestfsSessionEventParams, src); -} - -G_DEFINE_BOXED_TYPE (GuestfsSessionEventParams, - guestfs_session_event_params, - guestfs_session_event_params_copy, - guestfs_session_event_params_free) - -/* Event callback */ -|}; - - pr "static guint signals[%i] = { 0 };\n" (List.length events); - -pr {| -static GuestfsSessionEvent -guestfs_session_event_from_guestfs_event (uint64_t event) -{ - switch (event) {|}; - - List.iter ( - fun (name, _) -> - let enum_name = "GUESTFS_SESSION_EVENT_" ^ String.uppercase_ascii name in - let guestfs_name = "GUESTFS_EVENT_" ^ String.uppercase_ascii name in - pr "\n case %s: return %s;" guestfs_name enum_name; - ) events; - -pr {| - } - - g_warning ("guestfs_session_event_from_guestfs_event: invalid event %%" PRIu64, - event); - return UINT32_MAX; -} - -static void -event_callback (guestfs_h *g, void *opaque, - uint64_t event, int event_handle, - int flags, - const char *buf, size_t buf_len, - const uint64_t *array, size_t array_len) -{ - GuestfsSessionEventParams *params = g_slice_new0 (GuestfsSessionEventParams); - - params->event = guestfs_session_event_from_guestfs_event (event); - params->flags = flags; - - params->buf = g_byte_array_sized_new (buf_len); - g_byte_array_append (params->buf, (const guint8 *) buf, buf_len); - - for (size_t i = 0; i < array_len && i < 4; i++) { - if (array_len > 4) { - array_len = 4; - } - memcpy (params->array, array, sizeof (array[0]) * array_len); - } - params->array_len = array_len; - - GuestfsSession *session = (GuestfsSession *) opaque; - - g_signal_emit (session, signals[params->event], 0, params); - - guestfs_session_event_params_free (params); -} - -/* GuestfsSessionEvent */ - -GType -guestfs_session_event_get_type (void) -{ - static GType etype = 0; - if (etype == 0) { - static const GEnumValue values[] = {|}; - - List.iter ( - fun (name, _) -> - let enum_name = "GUESTFS_SESSION_EVENT_" ^ String.uppercase_ascii name in - pr "\n { %s, \"%s\", \"%s\" }," enum_name enum_name name - ) events; - - pr {| - }; - etype = g_enum_register_static ("GuestfsSessionEvent", values); - } - return etype; -} - -/* GuestfsSession */ - -struct _GuestfsSessionPrivate -{ - guestfs_h *g; - int event_handle; -}; - -G_DEFINE_TYPE_WITH_CODE (GuestfsSession, guestfs_session, G_TYPE_OBJECT, - G_ADD_PRIVATE (GuestfsSession)); - -static void -guestfs_session_finalize (GObject *object) -{ - GuestfsSession *session = GUESTFS_SESSION (object); - GuestfsSessionPrivate *priv = session->priv; - - if (priv->g) guestfs_close (priv->g); - - G_OBJECT_CLASS (guestfs_session_parent_class)->finalize (object); -} - -static void -guestfs_session_class_init (GuestfsSessionClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - object_class->finalize = guestfs_session_finalize;|}; - - List.iter ( - fun (name, _) -> - pr "\n\n"; - pr " /**\n"; - pr " * GuestfsSession::%s:\n" name; - pr " * @session: The session which emitted the signal\n"; - pr " * @params: An object containing event parameters\n"; - pr " *\n"; - pr " * See \"SETTING CALLBACKS TO HANDLE EVENTS\" in guestfs(3) for\n"; - pr " * more details about this event.\n"; - pr " */\n"; - pr " signals[GUESTFS_SESSION_EVENT_%s] =\n" - (String.uppercase_ascii name); - pr " g_signal_new (g_intern_static_string (\"%s\"),\n" name; - pr " G_OBJECT_CLASS_TYPE (object_class),\n"; - pr " G_SIGNAL_RUN_LAST,\n"; - pr " 0,\n"; - pr " NULL, NULL,\n"; - pr " NULL,\n"; - pr " G_TYPE_NONE,\n"; - pr " 1, guestfs_session_event_params_get_type ());"; - ) events; - - pr {| -} - -static void -guestfs_session_init (GuestfsSession *session) -{ - session->priv = guestfs_session_get_instance_private (session); - session->priv->g = guestfs_create (); - - guestfs_h *g = session->priv->g; - - session->priv->event_handle = - guestfs_set_event_callback (g, event_callback, GUESTFS_EVENT_ALL, - 0, session); -} - -/** - * guestfs_session_new: - * - * Create a new libguestfs session. - * - * Returns: (transfer full): a new guestfs session object - */ -GuestfsSession * -guestfs_session_new (void) -{ - return GUESTFS_SESSION (g_object_new (GUESTFS_TYPE_SESSION, NULL)); -} - -/** - * guestfs_session_close: - * @session: (transfer none): A GuestfsSession object - * @err: A GError object to receive any generated errors - * - * Close a libguestfs session. - * - * Returns: true on success, false on error - */ -gboolean -guestfs_session_close (GuestfsSession *session, GError **err) -{ - guestfs_h *g = session->priv->g; - - if (g == NULL) { - g_set_error_literal (err, GUESTFS_ERROR, 0, "session is already closed"); - return FALSE; - } - - guestfs_close (g); - session->priv->g = NULL; - - return TRUE; -}|}; - - let urls = Str.regexp {|L<\(https?\)://\([^>]*\)>|} in - let bz = Str.regexp {|RHBZ#\([0-9]+\)|} in - let cve = Str.regexp {|\(\s\)\(CVE-[0-9]+-[0-9]+\)|} in - let api_crossref = Str.regexp {|C|} in - let nonapi_crossref = Str.regexp {|C<\([-_0-9a-zA-Z]+\)>|} in - let escaped = Str.regexp {|E<\([0-9a-zA-Z]+\)>|} in - let literal = Str.regexp "\\(^\\|\n\\)[ \t]+\\([^\n]*\\)\\(\n\\|$\\)" in - - List.iter ( - fun ({ name; style = (ret, args, optargs as style); - cancellable; c_function; c_optarg_prefix; - shortdesc; longdesc; - deprecated_by } as f) -> - pr "\n"; - - let longdesc = Str.global_substitute urls ( - fun s -> - let scheme = Str.matched_group 1 s in - let url = Str.matched_group 2 s in - (* The spaces below are deliberate: they give pod2text somewhere to - split that isn't the middle of a URL. *) - " http://" ^ url ^ " " - ) longdesc in - let longdesc = Str.global_substitute bz ( - fun s -> - let bz = Str.matched_group 1 s in - (* The spaces below are deliberate: they give pod2text somewhere to - split that isn't the middle of a URL. *) - " RHBZ#" ^ bz ^ " " - ) longdesc in - let longdesc = Str.global_substitute cve ( - fun s -> - let space_lead = Str.matched_group 1 s in - let cve = Str.matched_group 2 s in - (* The spaces below are deliberate: they give pod2text somewhere to - split that isn't the middle of a URL. *) - space_lead ^ - " " ^ cve ^ " " - ) longdesc in - let longdesc = Str.global_substitute api_crossref ( - fun s -> - "guestfs_session_" ^ Str.matched_group 1 s ^ "()" - ) longdesc in - let longdesc = Str.global_substitute nonapi_crossref ( - fun s -> - "@" ^ Str.matched_group 1 s - ) longdesc in - let longdesc = Str.global_substitute escaped ( - fun s -> - "&" ^ Str.matched_group 1 s ^ ";" - ) longdesc in - let longdesc = Str.global_substitute literal ( - fun s -> - "\n \n" - ) longdesc in - let doc = pod2text ~width:76 name longdesc in - let doc = String.concat "\n * " doc in - let camel_name = camel_of_name f in - let is_RBufferOut = match ret with RBufferOut _ -> true | _ -> false in - let gobject_error_return = match ret with - | RErr -> - "FALSE" - | RInt _ | RInt64 _ | RBool _ -> - "-1" - | RConstString _ | RString _ | RStringList _ | RHashtable _ - | RBufferOut _ | RStruct _ | RStructList _ -> - "NULL" - | RConstOptString _ -> - "NULL" (* NULL is a valid return for RConstOptString. Error is - indicated by also setting *err to a non-NULL value *) - in - - (* The comment header, including GI annotations for arguments and the - return value *) - - pr "/**\n"; - pr " * guestfs_session_%s:\n" name; - pr " * @session: (transfer none): A GuestfsSession object\n"; - - List.iter ( - fun argt -> - pr " * @%s:" (name_of_argt argt); - (match argt with - | Bool _ -> - pr " (type gboolean):" - | Int _ -> - pr " (type gint32):" - | Int64 _ -> - pr " (type gint64):" - | String ((PlainString|Key|GUID), _) -> - pr " (transfer none) (type utf8):" - | OptString _ -> - pr " (transfer none) (type utf8) (allow-none):" - | String ((Device|Mountable|Pathname|Filename - |Dev_or_Path|Mountable_or_Path|FileIn|FileOut), _) -> - pr " (transfer none) (type filename):" - | StringList ((PlainString|Key|GUID), _) -> - pr " (transfer none) (array zero-terminated=1) (element-type utf8): an array of strings" - | StringList ((Device|Mountable|Pathname|Filename - |Dev_or_Path|Mountable_or_Path|FileIn|FileOut), _) -> - pr " (transfer none) (array zero-terminated=1) (element-type filename): an array of strings" - | BufferIn n -> - pr " (transfer none) (array length=%s_size) (element-type guint8): an array of binary data\n" n; - pr " * @%s_size: The size of %s, in bytes" n n; - | Pointer _ -> - pr "pointer (not implemented in gobject bindings)" - ); - pr "\n"; - ) args; - if optargs <> [] then - pr " * @optargs: (transfer none) (allow-none): a %s containing optional arguments\n" camel_name; - (match ret with - | RBufferOut _ -> - pr " * @size_r: The size of the returned buffer, in bytes\n"; - | _ -> ()); - if cancellable then ( - pr " * @cancellable: A GCancellable object\n"; - ); - pr " * @err: A GError object to receive any generated errors\n"; - pr " *\n"; - - pr " * %s\n" shortdesc; - pr " *\n"; - pr " * %s\n" doc; - - (match f.optional with - | None -> () - | Some opt -> - pr " * This function depends on the feature \"%s\".\n" opt; - pr " * See also guestfs_session_feature_available().\n"; - pr " *\n"; - ); - - pr " * Returns: "; - (match ret with - | RErr -> - pr "true on success, false on error" - | RInt _ | RInt64 _ | RBool _ -> - pr "the returned value, or -1 on error" - | RConstString _ -> - pr "(transfer none): the returned string, or NULL on error" - | RConstOptString _ -> - pr "(transfer none): the returned string. Note that NULL does not indicate error" - | RString _ -> - pr "(transfer full): the returned string, or NULL on error" - | RStringList _ -> - pr "(transfer full) (array zero-terminated=1) (element-type utf8): an array of returned strings, or NULL on error" - | RHashtable _ -> - pr "(transfer full) (element-type utf8 utf8): a GHashTable of results, or NULL on error" - | RBufferOut _ -> - pr "(transfer full) (array length=size_r) (element-type guint8): an array of binary data, or NULL on error" - | RStruct (_, typ) -> - let name = camel_name_of_struct typ in - pr "(transfer full): a %s object, or NULL on error" name - | RStructList (_, typ) -> - let name = camel_name_of_struct typ in - pr "(transfer full) (array zero-terminated=1) (element-type Guestfs%s): an array of %s objects, or NULL on error" name name - ); - pr "\n"; - (match deprecated_by with - | Not_deprecated -> () - | Replaced_by alt -> - pr " * Deprecated: In new code, use guestfs_session_%s() instead\n" alt - | Deprecated_no_replacement -> - pr " * Deprecated: There is no documented replacement\n" - ); - (match version_added f with - | None -> () - | Some version -> pr " * Since: %s\n" version - ); - pr " */\n"; - - (* The function body *) - - generate_gobject_proto ~single_line:false name style f; - pr "\n{\n"; - - if cancellable then ( - pr " /* Check we haven't already been cancelled */\n"; - pr " if (g_cancellable_set_error_if_cancelled (cancellable, err))\n"; - pr " return %s;\n\n" gobject_error_return; - ); - - (* Get the guestfs handle, and ensure it isn't closed *) - - pr " guestfs_h *g = session->priv->g;\n"; - pr " if (g == NULL) {\n"; - pr " g_set_error (err, GUESTFS_ERROR, 0,\n"; - pr " \"attempt to call %%s after the session has been closed\",\n"; - pr " \"%s\");\n" name; - pr " return %s;\n" gobject_error_return; - pr " }\n\n"; - - (* Optargs *) - - if optargs <> [] then ( - pr " struct %s argv;\n" c_function; - pr " struct %s *argvp = NULL;\n\n" c_function; - - pr " if (optargs) {\n"; - pr " argv.bitmask = 0;\n\n"; - let set_property name typ v_typ get_typ unset = - let uc_name = String.uppercase_ascii name in - pr " GValue %s_v = {0, };\n" name; - pr " g_value_init (&%s_v, %s);\n" name v_typ; - pr " g_object_get_property (G_OBJECT (optargs), \"%s\", &%s_v);\n" name name; - pr " %s%s = g_value_get_%s (&%s_v);\n" typ name get_typ name; - pr " if (%s != %s) {\n" name unset; - pr " argv.bitmask |= %s_%s_BITMASK;\n" c_optarg_prefix uc_name; - pr " argv.%s = %s;\n" name name; - pr " }\n" - in - List.iter ( - function - | OBool n -> - set_property n "GuestfsTristate " "GUESTFS_TYPE_TRISTATE" "enum" "GUESTFS_TRISTATE_NONE" - | OInt n -> - set_property n "gint32 " "G_TYPE_INT" "int" "-1" - | OInt64 n -> - set_property n "gint64 " "G_TYPE_INT64" "int64" "-1" - | OString n -> - set_property n "const gchar *" "G_TYPE_STRING" "string" "NULL" - | OStringList n -> - () (* XXX *) - ) optargs; - pr " argvp = &argv;\n"; - pr " }\n" - ); - - (* libguestfs call *) - - if cancellable then ( - pr " gulong id = 0;\n"; - pr " if (cancellable) {\n"; - pr " id = g_cancellable_connect (cancellable,\n"; - pr " G_CALLBACK (cancelled_handler),\n"; - pr " g, NULL);\n"; - pr " }\n\n"; - ); - - pr " "; - (match ret with - | RErr | RInt _ | RBool _ -> - pr "int " - | RInt64 _ -> - pr "int64_t " - | RConstString _ | RConstOptString _ -> - pr "const char *" - | RString _ | RBufferOut _ -> - pr "char *" - | RStringList _ | RHashtable _ -> - pr "char **" - | RStruct (_, typ) -> - pr "struct guestfs_%s *" typ - | RStructList (_, typ) -> - pr "struct guestfs_%s_list *" typ - ); - pr "ret = %s (g" c_function; - List.iter ( - fun argt -> - pr ", "; - match argt with - | BufferIn n -> - pr "(const char *) %s, %s_size" n n - | Bool n | Int n | Int64 n - | String (_, n) - | OptString n - | StringList (_, n) -> - pr "%s" n - | Pointer (_, n) -> - pr "%s" n - ) args; - if is_RBufferOut then pr ", size_r"; - if optargs <> [] then pr ", argvp"; - pr ");\n"; - - if cancellable then - pr " g_cancellable_disconnect (cancellable, id);\n"; - - (* Check return, throw error if necessary, marshall return value *) - - (match errcode_of_ret ret with - | `CannotReturnError -> () - | _ -> - pr " if (ret == %s) {\n" - (match errcode_of_ret ret with - | `CannotReturnError -> assert false - | `ErrorIsMinusOne -> "-1" - | `ErrorIsNULL -> "NULL"); - pr " g_set_error_literal (err, GUESTFS_ERROR, 0, guestfs_last_error (g));\n"; - pr " return %s;\n" gobject_error_return; - pr " }\n"; - ); - pr "\n"; - - let gen_copy_struct indent src dst typ = - List.iter ( - function - | n, (FChar|FUInt32|FInt32|FUInt64|FBytes|FInt64|FOptPercent) -> - pr "%s%s%s = %s%s;\n" indent dst n src n - | n, FUUID -> - pr "%smemcpy (%s%s, %s%s, sizeof (%s%s));\n" - indent dst n src n dst n - | n, (FString|FDevice) -> - pr "%sif (%s%s) %s%s = g_strdup (%s%s);\n" - indent src n dst n src n - | n, FBuffer -> - pr "%sif (%s%s) {\n" indent src n; - pr "%s %s%s = g_byte_array_sized_new (%s%s_len);\n" - indent dst n src n; - pr "%s g_byte_array_append (%s%s, (const guint8 *) %s%s, %s%s_len);\n" - indent dst n src n src n; - pr "%s}\n" indent - ) (cols_of_struct typ) - in - (match ret with - | RErr -> - pr " return TRUE;\n" - - | RInt _ | RInt64 _ | RBool _ - | RConstString _ | RConstOptString _ - | RString _ | RStringList _ -> - pr " return ret;\n" - - | RBufferOut _ -> - pr " return (guint8 *) ret;\n" - - | RHashtable _ -> - pr " GHashTable *h = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);\n"; - pr " char **i = ret;\n"; - pr " while (*i) {\n"; - pr " char *key = *i; i++;\n"; - pr " char *value = *i; i++;\n"; - pr " g_hash_table_insert (h, key, value);\n"; - pr " };\n"; - pr " g_free (ret);\n"; - pr " return h;\n" - - | RStruct (_, typ) -> - let struct_name = "Guestfs" ^ camel_name_of_struct typ in - pr " %s *s = g_slice_new0 (%s);\n" struct_name struct_name; - gen_copy_struct " " "ret->" "s->" typ; - pr " guestfs_free_%s (ret);\n" typ; - pr " return s;\n"; - - | RStructList (_, typ) -> - let struct_name = "Guestfs" ^ camel_name_of_struct typ in - pr " %s **l = g_malloc (sizeof (%s*) * (ret->len + 1));\n" - struct_name struct_name; - pr " gsize i;\n"; - pr " for (i = 0; i < ret->len; i++) {\n"; - pr " l[i] = g_slice_new0 (%s);\n" struct_name; - gen_copy_struct " " "ret->val[i]." "l[i]->" typ; - pr " }\n"; - pr " guestfs_free_%s_list (ret);\n" typ; - pr " l[i] = NULL;\n"; - pr " return l;\n"; - ); - - pr "}\n"; - ) (actions |> external_functions |> sort) diff --git a/generator/GObject.mli b/generator/GObject.mli deleted file mode 100644 index faf48a85d..000000000 --- a/generator/GObject.mli +++ /dev/null @@ -1,28 +0,0 @@ -(* libguestfs - * Copyright (C) 2009-2025 Red Hat Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - *) - -val generate_gobject_header : unit -> unit -val generate_gobject_makefile : unit -> unit -val generate_gobject_optargs_header : string -> string -> Types.action -> unit -> unit -val generate_gobject_optargs_source : string -> string -> Types.optargt list -> Types.action -> unit -> unit -val generate_gobject_session_header : unit -> unit -val generate_gobject_session_source : unit -> unit -val generate_gobject_struct_header : string -> string -> (string * Types.field) list -> unit -> unit -val generate_gobject_struct_source : string -> string -> unit -> unit -val generate_gobject_tristate_header : unit -> unit -val generate_gobject_tristate_source : unit -> unit diff --git a/generator/Makefile.am b/generator/Makefile.am index d26116287..94823643b 100644 --- a/generator/Makefile.am +++ b/generator/Makefile.am @@ -73,8 +73,6 @@ sources = \ fish.mli \ fish_commands.ml \ fish_commands.mli \ - GObject.ml \ - GObject.mli \ golang.ml \ golang.mli \ haskell.ml \ @@ -164,7 +162,6 @@ objects = \ php.cmo \ erlang.cmo \ lua.cmo \ - GObject.cmo \ golang.cmo \ rust.cmo \ bindtests.cmo \ @@ -209,9 +206,6 @@ stamp-generator: generator mkdir -p $(top_srcdir)/ruby/ext/guestfs mkdir -p $(top_srcdir)/java/com/redhat/et/libguestfs mkdir -p $(top_srcdir)/csharp - mkdir -p $(top_srcdir)/gobject/src - mkdir -p $(top_srcdir)/gobject/include - mkdir -p $(top_srcdir)/gobject/include/guestfs-gobject cd $(top_srcdir) && $(abs_builddir)/generator touch $@ diff --git a/generator/bindtests.ml b/generator/bindtests.ml index 082f27169..b3efd5510 100644 --- a/generator/bindtests.ml +++ b/generator/bindtests.ml @@ -639,66 +639,6 @@ main = do pr " putStrLn \"EOF\"\n" -and generate_gobject_js_bindtests () = - generate_header CPlusPlusStyle GPLv2plus; - - pr {|const Guestfs = imports.gi.Guestfs; - -var g = new Guestfs.Session(); -var o; - -|}; - - let mkoptargs = function - | Some optargs -> - "o = new Guestfs.InternalTest({" ^ - ( - String.concat ", " ( - List.map ( - function - | CallOBool (n, v) -> n ^ ": " ^ (if v then "true" else "false") - | CallOInt (n, v) -> n ^ ": " ^ (string_of_int v) - | CallOInt64 (n, v) -> n ^ ": " ^ Int64.to_string v - | CallOString (n, v) -> n ^ ": \"" ^ v ^ "\"" - | CallOStringList (n, xs) -> "" (* not implemented XXX *) -(* - | CallOStringList (n, xs) -> - n ^ ": " ^ - "[" ^ String.concat "," (List.map (sprintf "\"%s\"") xs) ^ "]" -*) - ) optargs - ) - ) ^ - "});" - | None -> - "o = null;" - in - - let mkargs args = - String.concat ", " ( - (List.map ( - function - | CallString s -> "\"" ^ s ^ "\"" - | CallOptString None -> "null" - | CallOptString (Some s) -> "\"" ^ s ^ "\"" - | CallStringList xs -> - "[" ^ String.concat "," (List.map (sprintf "\"%s\"") xs) ^ "]" - | CallInt i -> string_of_int i - | CallInt64 i -> Int64.to_string i - | CallBool true -> "true" - | CallBool false -> "false" - | CallBuffer s -> "\"" ^ c_quote s ^ "\"" - ) args) - @ ["o"; "null"] - ) - in - generate_lang_bindtests ( - fun f args optargs -> - pr "%s\ng.%s(%s);\n" (mkoptargs optargs) f (mkargs args) - ); - - pr "\nprint(\"EOF\");\n" - and generate_erlang_bindtests () = pr "#!/usr/bin/env escript\n"; pr "%%! -smp enable -sname create_disk debug verbose\n"; diff --git a/generator/bindtests.mli b/generator/bindtests.mli index f1759b48c..5862c0005 100644 --- a/generator/bindtests.mli +++ b/generator/bindtests.mli @@ -19,7 +19,6 @@ val generate_bindtests : unit -> unit val generate_erlang_bindtests : unit -> unit val generate_golang_bindtests : unit -> unit -val generate_gobject_js_bindtests : unit -> unit val generate_haskell_bindtests : unit -> unit val generate_java_bindtests : unit -> unit val generate_lua_bindtests : unit -> unit diff --git a/generator/main.ml b/generator/main.ml index 57285003b..0f96c744e 100644 --- a/generator/main.ml +++ b/generator/main.ml @@ -302,49 +302,6 @@ Run it from the top source directory using the command output_to "golang/bindtests/bindtests.go" Bindtests.generate_golang_bindtests; - output_to "gobject/bindtests.js" - Bindtests.generate_gobject_js_bindtests; - output_to "gobject/Makefile.inc" - GObject.generate_gobject_makefile; - output_to "gobject/include/guestfs-gobject.h" - GObject.generate_gobject_header; - List.iter ( - fun { s_name = typ; s_cols = cols } -> - let short = sprintf "struct-%s" typ in - let filename = - sprintf "gobject/include/guestfs-gobject/%s.h" short in - output_to filename - (GObject.generate_gobject_struct_header short typ cols); - let filename = sprintf "gobject/src/%s.c" short in - output_to filename - (GObject.generate_gobject_struct_source short typ) - ) external_structs; - delete_except_generated "gobject/include/guestfs-gobject/struct-*.h"; - delete_except_generated "gobject/src/struct-*.c"; - List.iter ( - function - | ({ name; style = (_, _, (_::_ as optargs)) } as f) -> - let short = sprintf "optargs-%s" name in - let filename = - sprintf "gobject/include/guestfs-gobject/%s.h" short in - output_to filename - (GObject.generate_gobject_optargs_header short name f); - let filename = sprintf "gobject/src/%s.c" short in - output_to filename - (GObject.generate_gobject_optargs_source short name optargs f) - | { style = _, _, [] } -> () - ) (actions |> external_functions |> sort); - delete_except_generated "gobject/include/guestfs-gobject/optargs-*.h"; - delete_except_generated "gobject/src/optargs-*.c"; - output_to "gobject/include/guestfs-gobject/tristate.h" - GObject.generate_gobject_tristate_header; - output_to "gobject/src/tristate.c" - GObject.generate_gobject_tristate_source; - output_to "gobject/include/guestfs-gobject/session.h" - GObject.generate_gobject_session_header; - output_to "gobject/src/session.c" - GObject.generate_gobject_session_source; - (* mlcustomize may not be shipped in this source. *) if is_regular_file "common/mlcustomize/Makefile.am" then ( output_to "common/mlcustomize/customize_cmdline.mli" diff --git a/gobject/.gitignore b/gobject/.gitignore deleted file mode 100644 index 1afffa061..000000000 --- a/gobject/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -# Generated sources -/include -/libguestfs-gobject-1.0.pc -/src diff --git a/gobject/Makefile.am b/gobject/Makefile.am deleted file mode 100644 index 761a744c1..000000000 --- a/gobject/Makefile.am +++ /dev/null @@ -1,142 +0,0 @@ -# libguestfs -# Copyright (C) 2012 Red Hat Inc. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -include $(top_srcdir)/subdir-rules.mk - -include $(srcdir)/Makefile.inc - -generator_built = \ - $(guestfs_gobject_headers) \ - $(guestfs_gobject_sources) \ - bindtests.js - -BUILT_SOURCES = $(generator_built) - -EXTRA_DIST = \ - $(generator_built) \ - TODO.txt \ - .gitignore \ - bindtests-retvalues.js \ - guestfs-gobject.pod \ - libguestfs-gobject-1.0.deps \ - tests-misc.js \ - run-tests \ - run-tests-retvalues \ - run-live-tests - -# Remove the old generated files which were directly in the gobject/ -# directory. These have now moved into gobject/src/ -CLEANFILES += \ - guestfs-gobject*.c - -libname = libguestfs-gobject-1.0.la - -lib_LTLIBRARIES = $(libname) - -libguestfs_gobject_1_0_ladir = $(includedir)/guestfs-gobject - -libguestfs_gobject_1_0_la_HEADERS = $(guestfs_gobject_headers) -libguestfs_gobject_1_0_la_SOURCES = $(guestfs_gobject_sources) -libguestfs_gobject_1_0_la_CFLAGS = -I$(top_srcdir)/lib \ - -I$(top_srcdir)/include \ - -I$(srcdir)/include \ - -DGUESTFS_PRIVATE=1 \ - $(GOBJECT_CFLAGS) -libguestfs_gobject_1_0_la_LDFLAGS = $(LDFLAGS) -L$(top_builddir)/lib -libguestfs_gobject_1_0_la_LIBADD = $(top_builddir)/lib/libguestfs.la $(GOBJECT_LIBS) $(GIO_LIBS) - -pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = libguestfs-gobject-1.0.pc - -# All the headers except should be installed -# in the subdirectory. -install-data-hook: - rm $(DESTDIR)$(includedir)/guestfs-gobject/guestfs-gobject.h - install -m 0644 $(srcdir)/include/guestfs-gobject.h $(DESTDIR)$(includedir) - --include $(INTROSPECTION_MAKEFILE) -INTROSPECTION_GIRS = -INTROSPECTION_SCANNER_ARGS = --add-include-path=$(srcdir) --warn-all -INTROSPECTION_COMPILER_ARGS = --includedir=$(srcdir) - -if HAVE_INTROSPECTION - -introspection_sources = \ - $(libguestfs_gobject_1_0_la_HEADERS) \ - $(libguestfs_gobject_1_0_la_SOURCES) - -Guestfs-1.0.gir: $(libname) -Guestfs_1_0_gir_INCLUDES = GObject-2.0 Gio-2.0 -Guestfs_1_0_gir_CFLAGS = $(INCLUDES) -I$(srcdir)/include -Guestfs_1_0_gir_LIBS = $(libname) $(top_builddir)/lib/libguestfs.la -Guestfs_1_0_gir_FILES = $(patsubst %,$(srcdir)/%,$(introspection_sources)) -INTROSPECTION_GIRS += Guestfs-1.0.gir - -girdir = $(datadir)/gir-1.0 -gir_DATA = $(INTROSPECTION_GIRS) - -typelibdir = $(libdir)/girepository-1.0 -typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib) - -# Tests. - -TESTS = \ - run-tests \ - run-tests-retvalues - -if ENABLE_APPLIANCE -TESTS += run-live-tests -endif ENABLE_APPLIANCE - -TESTS_ENVIRONMENT = $(top_builddir)/run --test - -$(TESTS): $(typelib_DATA) - -CLEANFILES += $(gir_DATA) $(typelib_DATA) - -if ENABLE_VAPIGEN --include $(VAPIGEN_MAKEFILE) - -libguestfs-gobject-1.0.vapi: Guestfs-1.0.gir libguestfs-gobject-1.0.deps - -VAPIGEN_VAPIS = libguestfs-gobject-1.0.vapi - -libguestfs_gobject_1_0_vapi_DEPS = gobject-2.0 gio-2.0 -libguestfs_gobject_1_0_vapi_METADATADIRS = $(srcdir) -libguestfs_gobject_1_0_vapi_FILES = Guestfs-1.0.gir - -vapidir = $(datadir)/vala/vapi -vapi_DATA = $(VAPIGEN_VAPIS) $(VAPIGEN_VAPIS:.vapi=.deps) -endif - -endif HAVE_INTROSPECTION - -# Documentation. - -man_MANS = guestfs-gobject.3 -noinst_DATA = $(top_builddir)/website/guestfs-gobject.3.html - -guestfs-gobject.3 $(top_builddir)/website/guestfs-gobject.3.html: stamp-guestfs-gobject.pod - -stamp-guestfs-gobject.pod: guestfs-gobject.pod - $(PODWRAPPER) \ - --section 3 \ - --man guestfs-gobject.3 \ - --html $(top_builddir)/website/guestfs-gobject.3.html \ - --license examples \ - $< - touch $@ diff --git a/gobject/Makefile.inc b/gobject/Makefile.inc deleted file mode 100644 index 00eeac4e1..000000000 --- a/gobject/Makefile.inc +++ /dev/null @@ -1,216 +0,0 @@ -# libguestfs generated file -# WARNING: THIS FILE IS GENERATED FROM THE FOLLOWING FILES: -# generator/gobject.ml -# and from the code in the generator/ subdirectory. -# ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. -# -# Copyright (C) 2009-2025 Red Hat Inc. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -guestfs_gobject_headers= \ - include/guestfs-gobject.h \ - include/guestfs-gobject/session.h \ - include/guestfs-gobject/tristate.h \ - include/guestfs-gobject/struct-application.h \ - include/guestfs-gobject/struct-application2.h \ - include/guestfs-gobject/struct-btrfsbalance.h \ - include/guestfs-gobject/struct-btrfsqgroup.h \ - include/guestfs-gobject/struct-btrfsscrub.h \ - include/guestfs-gobject/struct-btrfssubvolume.h \ - include/guestfs-gobject/struct-dirent.h \ - include/guestfs-gobject/struct-hivex_node.h \ - include/guestfs-gobject/struct-hivex_value.h \ - include/guestfs-gobject/struct-inotify_event.h \ - include/guestfs-gobject/struct-int_bool.h \ - include/guestfs-gobject/struct-isoinfo.h \ - include/guestfs-gobject/struct-lvm_lv.h \ - include/guestfs-gobject/struct-lvm_pv.h \ - include/guestfs-gobject/struct-lvm_vg.h \ - include/guestfs-gobject/struct-mdstat.h \ - include/guestfs-gobject/struct-partition.h \ - include/guestfs-gobject/struct-stat.h \ - include/guestfs-gobject/struct-statns.h \ - include/guestfs-gobject/struct-statvfs.h \ - include/guestfs-gobject/struct-tsk_dirent.h \ - include/guestfs-gobject/struct-utsname.h \ - include/guestfs-gobject/struct-version.h \ - include/guestfs-gobject/struct-xattr.h \ - include/guestfs-gobject/struct-xfsinfo.h \ - include/guestfs-gobject/struct-yara_detection.h \ - include/guestfs-gobject/optargs-add_domain.h \ - include/guestfs-gobject/optargs-add_drive.h \ - include/guestfs-gobject/optargs-add_drive_scratch.h \ - include/guestfs-gobject/optargs-add_libvirt_dom.h \ - include/guestfs-gobject/optargs-aug_transform.h \ - include/guestfs-gobject/optargs-btrfs_filesystem_defragment.h \ - include/guestfs-gobject/optargs-btrfs_filesystem_resize.h \ - include/guestfs-gobject/optargs-btrfs_fsck.h \ - include/guestfs-gobject/optargs-btrfs_image.h \ - include/guestfs-gobject/optargs-btrfs_scrub_full.h \ - include/guestfs-gobject/optargs-btrfs_subvolume_create.h \ - include/guestfs-gobject/optargs-btrfs_subvolume_snapshot.h \ - include/guestfs-gobject/optargs-compress_device_out.h \ - include/guestfs-gobject/optargs-compress_out.h \ - include/guestfs-gobject/optargs-copy_attributes.h \ - include/guestfs-gobject/optargs-copy_device_to_device.h \ - include/guestfs-gobject/optargs-copy_device_to_file.h \ - include/guestfs-gobject/optargs-copy_file_to_device.h \ - include/guestfs-gobject/optargs-copy_file_to_file.h \ - include/guestfs-gobject/optargs-cpio_out.h \ - include/guestfs-gobject/optargs-cryptsetup_open.h \ - include/guestfs-gobject/optargs-disk_create.h \ - include/guestfs-gobject/optargs-download_blocks.h \ - include/guestfs-gobject/optargs-e2fsck.h \ - include/guestfs-gobject/optargs-fstrim.h \ - include/guestfs-gobject/optargs-glob_expand.h \ - include/guestfs-gobject/optargs-grep.h \ - include/guestfs-gobject/optargs-hivex_open.h \ - include/guestfs-gobject/optargs-inspect_get_icon.h \ - include/guestfs-gobject/optargs-internal_test.h \ - include/guestfs-gobject/optargs-internal_test_63_optargs.h \ - include/guestfs-gobject/optargs-internal_test_only_optargs.h \ - include/guestfs-gobject/optargs-is_blockdev.h \ - include/guestfs-gobject/optargs-is_chardev.h \ - include/guestfs-gobject/optargs-is_dir.h \ - include/guestfs-gobject/optargs-is_fifo.h \ - include/guestfs-gobject/optargs-is_file.h \ - include/guestfs-gobject/optargs-is_socket.h \ - include/guestfs-gobject/optargs-md_create.h \ - include/guestfs-gobject/optargs-mke2fs.h \ - include/guestfs-gobject/optargs-mkfs.h \ - include/guestfs-gobject/optargs-mkfs_btrfs.h \ - include/guestfs-gobject/optargs-mksquashfs.h \ - include/guestfs-gobject/optargs-mkswap.h \ - include/guestfs-gobject/optargs-mktemp.h \ - include/guestfs-gobject/optargs-mount_9p.h \ - include/guestfs-gobject/optargs-mount_local.h \ - include/guestfs-gobject/optargs-ntfs_chmod.h \ - include/guestfs-gobject/optargs-ntfsclone_out.h \ - include/guestfs-gobject/optargs-ntfsfix.h \ - include/guestfs-gobject/optargs-ntfsresize.h \ - include/guestfs-gobject/optargs-remount.h \ - include/guestfs-gobject/optargs-rsync.h \ - include/guestfs-gobject/optargs-rsync_in.h \ - include/guestfs-gobject/optargs-rsync_out.h \ - include/guestfs-gobject/optargs-selinux_relabel.h \ - include/guestfs-gobject/optargs-set_e2attrs.h \ - include/guestfs-gobject/optargs-setfiles.h \ - include/guestfs-gobject/optargs-syslinux.h \ - include/guestfs-gobject/optargs-tar_in.h \ - include/guestfs-gobject/optargs-tar_out.h \ - include/guestfs-gobject/optargs-tune2fs.h \ - include/guestfs-gobject/optargs-umount.h \ - include/guestfs-gobject/optargs-umount_local.h \ - include/guestfs-gobject/optargs-xfs_admin.h \ - include/guestfs-gobject/optargs-xfs_growfs.h \ - include/guestfs-gobject/optargs-xfs_repair.h - -guestfs_gobject_sources= \ - src/session.c \ - src/tristate.c \ - src/struct-application.c \ - src/struct-application2.c \ - src/struct-btrfsbalance.c \ - src/struct-btrfsqgroup.c \ - src/struct-btrfsscrub.c \ - src/struct-btrfssubvolume.c \ - src/struct-dirent.c \ - src/struct-hivex_node.c \ - src/struct-hivex_value.c \ - src/struct-inotify_event.c \ - src/struct-int_bool.c \ - src/struct-isoinfo.c \ - src/struct-lvm_lv.c \ - src/struct-lvm_pv.c \ - src/struct-lvm_vg.c \ - src/struct-mdstat.c \ - src/struct-partition.c \ - src/struct-stat.c \ - src/struct-statns.c \ - src/struct-statvfs.c \ - src/struct-tsk_dirent.c \ - src/struct-utsname.c \ - src/struct-version.c \ - src/struct-xattr.c \ - src/struct-xfsinfo.c \ - src/struct-yara_detection.c \ - src/optargs-add_domain.c \ - src/optargs-add_drive.c \ - src/optargs-add_drive_scratch.c \ - src/optargs-add_libvirt_dom.c \ - src/optargs-aug_transform.c \ - src/optargs-btrfs_filesystem_defragment.c \ - src/optargs-btrfs_filesystem_resize.c \ - src/optargs-btrfs_fsck.c \ - src/optargs-btrfs_image.c \ - src/optargs-btrfs_scrub_full.c \ - src/optargs-btrfs_subvolume_create.c \ - src/optargs-btrfs_subvolume_snapshot.c \ - src/optargs-compress_device_out.c \ - src/optargs-compress_out.c \ - src/optargs-copy_attributes.c \ - src/optargs-copy_device_to_device.c \ - src/optargs-copy_device_to_file.c \ - src/optargs-copy_file_to_device.c \ - src/optargs-copy_file_to_file.c \ - src/optargs-cpio_out.c \ - src/optargs-cryptsetup_open.c \ - src/optargs-disk_create.c \ - src/optargs-download_blocks.c \ - src/optargs-e2fsck.c \ - src/optargs-fstrim.c \ - src/optargs-glob_expand.c \ - src/optargs-grep.c \ - src/optargs-hivex_open.c \ - src/optargs-inspect_get_icon.c \ - src/optargs-internal_test.c \ - src/optargs-internal_test_63_optargs.c \ - src/optargs-internal_test_only_optargs.c \ - src/optargs-is_blockdev.c \ - src/optargs-is_chardev.c \ - src/optargs-is_dir.c \ - src/optargs-is_fifo.c \ - src/optargs-is_file.c \ - src/optargs-is_socket.c \ - src/optargs-md_create.c \ - src/optargs-mke2fs.c \ - src/optargs-mkfs.c \ - src/optargs-mkfs_btrfs.c \ - src/optargs-mksquashfs.c \ - src/optargs-mkswap.c \ - src/optargs-mktemp.c \ - src/optargs-mount_9p.c \ - src/optargs-mount_local.c \ - src/optargs-ntfs_chmod.c \ - src/optargs-ntfsclone_out.c \ - src/optargs-ntfsfix.c \ - src/optargs-ntfsresize.c \ - src/optargs-remount.c \ - src/optargs-rsync.c \ - src/optargs-rsync_in.c \ - src/optargs-rsync_out.c \ - src/optargs-selinux_relabel.c \ - src/optargs-set_e2attrs.c \ - src/optargs-setfiles.c \ - src/optargs-syslinux.c \ - src/optargs-tar_in.c \ - src/optargs-tar_out.c \ - src/optargs-tune2fs.c \ - src/optargs-umount.c \ - src/optargs-umount_local.c \ - src/optargs-xfs_admin.c \ - src/optargs-xfs_growfs.c \ - src/optargs-xfs_repair.c diff --git a/gobject/TODO.txt b/gobject/TODO.txt deleted file mode 100644 index a3115d15c..000000000 --- a/gobject/TODO.txt +++ /dev/null @@ -1,11 +0,0 @@ -Tasks required before the GObject bindings can be considered complete: - -* Fix the problem of inspect_get_type - - This is addressed here: https://bugzilla.gnome.org/show_bug.cgi?id=671218 - The fix will hopefully make it upstream soon. No changes are required in - libguestfs. -* Bind the libguestfs events API - -Tasks which would improve the usability of the GObject bindings: - -* Implement _async versions of all apis diff --git a/gobject/bindtests-retvalues.js b/gobject/bindtests-retvalues.js deleted file mode 100644 index d7bbe5fd0..000000000 --- a/gobject/bindtests-retvalues.js +++ /dev/null @@ -1,110 +0,0 @@ -// libguestfs manually written gobject binding tests -// Copyright (C) 2012 Red Hat Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License along -// with this program; if not, write to the Free Software Foundation, Inc., -// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -const Guestfs = imports.gi.Guestfs; - -var fail = false; - -function check_error(f) { - var threw = false; - - try { - g[f](); - } catch (error) { - threw = true; - if (!error.message.match(/error$/)) { - print(f + " threw unexpected error: " + error.message); - fail = true; - } - } - if (!threw) { - print(f + " failed to throw an error"); - fail = true; - } -} - -function eq_fail(f, v) { - print(f + " returned unexpected value: " + v); - fail = true; -} - -var g = new Guestfs.Session(); - -var v; -var eq; - -v = g.internal_test_rint('1'); -v == 1 || eq_fail('internal_test_rint', v); -check_error('internal_test_rinterr'); - -v = g.internal_test_rint64('1'); -v == 1 || eq_fail('internal_test_rint64', v); -check_error('internal_test_rint64err'); - -v = g.internal_test_rbool('true'); -v == 1 || eq_fail('internal_test_rbool', v); -check_error('internal_test_rboolerr'); - -v = g.internal_test_rconststring('1'); -v == 'static string' || eq_fail('internal_test_rconststring', v); -check_error('internal_test_rconststringerr'); - -v = g.internal_test_rconstoptstring('1'); -v == 'static string' || eq_fail('internal_test_rconstoptstring', v); -//check_error('internal_test_rconstoptstringerr'); - -v = g.internal_test_rstring('string'); -v == 'string' || eq_fail('internal_test_rstring', v); -check_error('internal_test_rstringerr'); - -v = g.internal_test_rstringlist('5'); -eq = v.length == 5; -for (var i = 0; eq && i < 5; i++) { - if (v[i] != i) eq = false; -} -eq || eq_fail('internal_test_rstringlist', v.join(' ')); -check_error('internal_test_rstringlisterr'); - -v = g.internal_test_rstruct('1'); -v.pv_size == 0 || eq_fail('internal_test_rstruct', v); -check_error('internal_test_rstructerr'); - -v = g.internal_test_rstructlist('5'); -eq = v.length == 5; -for (var i = 0; eq && i < 5; i++) { - if (v[i].pv_size != i) eq = false; -} -eq || eq_fail('internal_test_rstructlist', v); -check_error('internal_test_rstructlisterr'); - -v = g.internal_test_rhashtable('5'); -eq = true; -for (var i = 0; eq && i < 5; i++) { - if (v[i] != i) eq = false; -} -eq || eq_fail('internal_test_rhashtable', v); -check_error('internal_test_rhashtableerr'); - -v = g.internal_test_rbufferout("01234"); -eq = v.length == 5; -for (var i = 0; i < v.length; i++) { - if (v[i] != 48 + i) eq = false; // 48 = ascii '0' -} -eq || eq_fail('internal_test_rbufferout', v); -check_error('internal_test_rbufferouterr'); - -fail ? 1 : 0; diff --git a/gobject/guestfs-gobject.pod b/gobject/guestfs-gobject.pod deleted file mode 100644 index f4e13a976..000000000 --- a/gobject/guestfs-gobject.pod +++ /dev/null @@ -1,68 +0,0 @@ -=head1 NAME - -guestfs-gobject - How to use libguestfs with the GObject bindings - -=head1 DEPRECATED - -These bindings are deprecated and will be removed in libguestfs 1.58. - -=head1 SYNOPSIS - -From Javascript using gjs: - - const Guestfs = imports.gi.Guestfs; - var g = new Guestfs.Session(); - g.add_drive('disk.img', null); - g.launch(); - g.close(); - -=head1 DESCRIPTION - -This manual page documents how to call libguestfs using GObject -bindings, especially from Javascript. - -Note that the GObject bindings have problems handling 64 bit values. -You should not use the GObject bindings if there are native bindings -for your language. For example, to use libguestfs from Python you are -strongly advised to use the Python native bindings instead (see -L). - -This page just documents the differences from the C API and gives some -examples. If you are not familiar with using libguestfs, you also -need to read L. - -=head1 JAVASCRIPT - -Using gjs, you can write a C<.js> file containing: - - const Guestfs = imports.gi.Guestfs; - var g = new Guestfs.Session(); - g.add_drive('disk.img', null); - g.launch(); - g.close(); - -and then run it using: - - gjs program.js - -=head1 SEE ALSO - -L, -L, -L, -L, -L, -L, -L, -L, -L, -L, -L. - -=head1 AUTHORS - -Richard W.M. Jones (C) - -=head1 COPYRIGHT - -Copyright (C) 2012-2025 Red Hat Inc. diff --git a/gobject/libguestfs-gobject-1.0.deps b/gobject/libguestfs-gobject-1.0.deps deleted file mode 100644 index d4db05933..000000000 --- a/gobject/libguestfs-gobject-1.0.deps +++ /dev/null @@ -1,2 +0,0 @@ -gobject-2.0 -gio-2.0 diff --git a/gobject/libguestfs-gobject-1.0.pc.in b/gobject/libguestfs-gobject-1.0.pc.in deleted file mode 100644 index 8effad76b..000000000 --- a/gobject/libguestfs-gobject-1.0.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: libguestfs-gobject-1.0 -Version: @VERSION@ -Description: gobject bindings for the libguestfs library -Requires: libguestfs,gobject-2.0,gio-2.0 -Cflags: -I${includedir} -Libs: -L${libdir} -lguestfs-gobject-1.0 diff --git a/gobject/run-live-tests b/gobject/run-live-tests deleted file mode 100755 index 3ad672cc7..000000000 --- a/gobject/run-live-tests +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash - -# libguestfs GObject bindings -# Copyright (C) 2012 Red Hat Inc. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -source ../tests/functions.sh -set -e -set -x - -skip_if_skipped -skip_unless_environment_variable_set GJS -skip_unless_phony_guest fedora.img - -$GJS $srcdir/tests-misc.js diff --git a/gobject/run-tests b/gobject/run-tests deleted file mode 100755 index cb34aa6af..000000000 --- a/gobject/run-tests +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash - -# libguestfs GObject bindings -# Copyright (C) 2012 Red Hat Inc. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -source ../tests/functions.sh -set -e -set -x - -skip_if_skipped -skip_unless_environment_variable_set GJS - -# This test is disabled until we fix 64 bit support. -skip_because "Int64, OInt64 and OStringList are all broken" - -rm -f bindtests.tmp - -$GJS $srcdir/bindtests.js > bindtests.tmp -diff -u ${srcdir}/../bindtests bindtests.tmp - -rm bindtests.tmp diff --git a/gobject/run-tests-retvalues b/gobject/run-tests-retvalues deleted file mode 100755 index 86d2ada55..000000000 --- a/gobject/run-tests-retvalues +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash - -# libguestfs GObject bindings -# Copyright (C) 2012-2025 Red Hat Inc. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -source ../tests/functions.sh -set -e -set -x - -skip_if_skipped -skip_unless_environment_variable_set GJS - -skip_because "deprecated and currently broken" - -$GJS $srcdir/bindtests-retvalues.js diff --git a/gobject/tests-misc.js b/gobject/tests-misc.js deleted file mode 100644 index b17dda655..000000000 --- a/gobject/tests-misc.js +++ /dev/null @@ -1,74 +0,0 @@ -// libguestfs miscellaneous gobject binding tests -// Copyright (C) 2012 Red Hat Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License along -// with this program; if not, write to the Free Software Foundation, Inc., -// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -const Guestfs = imports.gi.Guestfs; - -var fail = false; - -var g = new Guestfs.Session(); - -var progress_detected = false; -var trace_detected = false; - -// Test events -g.connect('progress', function(session, params) { - if (params.array_len == 4) { - // Look for the final progress notification where position = total - if (params.array[2] == params.array[3] && params.array[2] != 0) { - progress_detected = true; - } - } -}); -g.connect('trace', function(session, params) { - if (params.buf == 'launch') { - trace_detected = true; - } -}); - -g.add_drive('../test-data/phony-guests/fedora.img', null); -g.set_trace(true); -g.launch(); -// Fake progress messages for a 5 second event. We do this as launch() will not -// generate any progress messages unless it takes at least 5 seconds. -g.debug('progress', ['5']); -if (!trace_detected) { - print("failed to detect trace message for launch"); - fail = true; -} -if (!progress_detected) { - print("failed to detect progress message for launch"); - fail = true; -} - -// Test close() -g.close(); -var threw = false; -try { - var v = g.internal_test_rconstoptstring('1'); -} catch (error) { - threw = true; - if (!error.message.match(/closed/)) { - print("call after close threw unexpected error: " + error.message); - fail = true; - } -} -if (!threw) { - print("call after closed failed to throw an error"); - fail = true; -} - -fail ? 1 : 0; diff --git a/m4/guestfs-gobject.m4 b/m4/guestfs-gobject.m4 deleted file mode 100644 index 6fc9541aa..000000000 --- a/m4/guestfs-gobject.m4 +++ /dev/null @@ -1,61 +0,0 @@ -# libguestfs -# Copyright (C) 2009-2025 Red Hat Inc. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -dnl gobject library -AC_ARG_ENABLE([gobject], - AS_HELP_STRING([--disable-gobject], [disable GObject bindings]), - [], - [enable_gobject=yes]) -AS_IF([test "x$enable_gobject" != "xno"],[ - PKG_CHECK_MODULES([GOBJECT], [gobject-2.0 >= 2.26.0],[ - AC_SUBST([GOBJECT_CFLAGS]) - AC_SUBST([GOBJECT_LIBS]) - AC_DEFINE([HAVE_GOBJECT],[1], - [GObject library found at compile time.]) - ], - [AC_MSG_WARN([gobject library not found, gobject binding will be disabled])]) - - PKG_CHECK_MODULES([GIO], [gio-2.0 >= 2.26.0],[ - AC_SUBST([GIO_CFLAGS]) - AC_SUBST([GIO_LIBS]) - AC_DEFINE([HAVE_GIO],[1], - [gio library found at compile time.]) - ], - [AC_MSG_WARN([gio library not found, gobject binding will be disabled])]) -]) -AM_CONDITIONAL([HAVE_GOBJECT], - [test "x$GOBJECT_LIBS" != "x" -a "x$GIO_LIBS" != "x"]) - -AC_CHECK_PROG([GJS],[gjs],[gjs]) -AS_IF([test "x$GJS" = "x"], - [AC_MSG_WARN([gjs not found, gobject bindtests will not run])]) - -dnl gobject introspection -m4_ifdef([GOBJECT_INTROSPECTION_CHECK], [ - GOBJECT_INTROSPECTION_CHECK([1.30.0]) - - dnl The above check automatically sets HAVE_INTROSPECTION, but we - dnl want this to be conditional on gobject also being - dnl available. We can't move the above check inside the gobject if - dnl block above or HAVE_INTROSPECTION ends up undefined, so we - dnl recheck it here. - AM_CONDITIONAL([HAVE_INTROSPECTION], - [test "x$HAVE_INTROSPECTION_TRUE" = "x" && - test "x$HAVE_GOBJECT_TRUE" = "x"]) -],[ - AM_CONDITIONAL([HAVE_INTROSPECTION], [false]) -]) diff --git a/po-docs/podfiles b/po-docs/podfiles index 45dc9417a..fee0a2ab1 100644 --- a/po-docs/podfiles +++ b/po-docs/podfiles @@ -58,7 +58,6 @@ fish/virt-tar-in.pod fish/virt-tar-out.pod fuse/guestmount.pod fuse/guestunmount.pod -gobject/guestfs-gobject.pod golang/examples/guestfs-golang.pod java/examples/guestfs-java.pod lib/guestfs-actions.pod diff --git a/po/POTFILES b/po/POTFILES index eaff0af49..9447f0f6e 100644 --- a/po/POTFILES +++ b/po/POTFILES @@ -222,101 +222,6 @@ gnulib/lib/xstrtoll.c gnulib/lib/xstrtoul.c gnulib/lib/xstrtoull.c gnulib/lib/xstrtoumax.c -gobject/src/optargs-add_domain.c -gobject/src/optargs-add_drive.c -gobject/src/optargs-add_drive_scratch.c -gobject/src/optargs-add_libvirt_dom.c -gobject/src/optargs-aug_transform.c -gobject/src/optargs-btrfs_filesystem_defragment.c -gobject/src/optargs-btrfs_filesystem_resize.c -gobject/src/optargs-btrfs_fsck.c -gobject/src/optargs-btrfs_image.c -gobject/src/optargs-btrfs_scrub_full.c -gobject/src/optargs-btrfs_subvolume_create.c -gobject/src/optargs-btrfs_subvolume_snapshot.c -gobject/src/optargs-compress_device_out.c -gobject/src/optargs-compress_out.c -gobject/src/optargs-copy_attributes.c -gobject/src/optargs-copy_device_to_device.c -gobject/src/optargs-copy_device_to_file.c -gobject/src/optargs-copy_file_to_device.c -gobject/src/optargs-copy_file_to_file.c -gobject/src/optargs-cpio_out.c -gobject/src/optargs-cryptsetup_open.c -gobject/src/optargs-disk_create.c -gobject/src/optargs-download_blocks.c -gobject/src/optargs-e2fsck.c -gobject/src/optargs-fstrim.c -gobject/src/optargs-glob_expand.c -gobject/src/optargs-grep.c -gobject/src/optargs-hivex_open.c -gobject/src/optargs-inspect_get_icon.c -gobject/src/optargs-internal_test.c -gobject/src/optargs-internal_test_63_optargs.c -gobject/src/optargs-internal_test_only_optargs.c -gobject/src/optargs-is_blockdev.c -gobject/src/optargs-is_chardev.c -gobject/src/optargs-is_dir.c -gobject/src/optargs-is_fifo.c -gobject/src/optargs-is_file.c -gobject/src/optargs-is_socket.c -gobject/src/optargs-md_create.c -gobject/src/optargs-mke2fs.c -gobject/src/optargs-mkfs.c -gobject/src/optargs-mkfs_btrfs.c -gobject/src/optargs-mksquashfs.c -gobject/src/optargs-mkswap.c -gobject/src/optargs-mktemp.c -gobject/src/optargs-mount_9p.c -gobject/src/optargs-mount_local.c -gobject/src/optargs-ntfs_chmod.c -gobject/src/optargs-ntfsclone_out.c -gobject/src/optargs-ntfsfix.c -gobject/src/optargs-ntfsresize.c -gobject/src/optargs-remount.c -gobject/src/optargs-rsync.c -gobject/src/optargs-rsync_in.c -gobject/src/optargs-rsync_out.c -gobject/src/optargs-selinux_relabel.c -gobject/src/optargs-set_e2attrs.c -gobject/src/optargs-setfiles.c -gobject/src/optargs-syslinux.c -gobject/src/optargs-tar_in.c -gobject/src/optargs-tar_out.c -gobject/src/optargs-tune2fs.c -gobject/src/optargs-umount.c -gobject/src/optargs-umount_local.c -gobject/src/optargs-xfs_admin.c -gobject/src/optargs-xfs_growfs.c -gobject/src/optargs-xfs_repair.c -gobject/src/session.c -gobject/src/struct-application.c -gobject/src/struct-application2.c -gobject/src/struct-btrfsbalance.c -gobject/src/struct-btrfsqgroup.c -gobject/src/struct-btrfsscrub.c -gobject/src/struct-btrfssubvolume.c -gobject/src/struct-dirent.c -gobject/src/struct-hivex_node.c -gobject/src/struct-hivex_value.c -gobject/src/struct-inotify_event.c -gobject/src/struct-int_bool.c -gobject/src/struct-isoinfo.c -gobject/src/struct-lvm_lv.c -gobject/src/struct-lvm_pv.c -gobject/src/struct-lvm_vg.c -gobject/src/struct-mdstat.c -gobject/src/struct-partition.c -gobject/src/struct-stat.c -gobject/src/struct-statns.c -gobject/src/struct-statvfs.c -gobject/src/struct-tsk_dirent.c -gobject/src/struct-utsname.c -gobject/src/struct-version.c -gobject/src/struct-xattr.c -gobject/src/struct-xfsinfo.c -gobject/src/struct-yara_detection.c -gobject/src/tristate.c java/actions-0.c java/actions-1.c java/actions-2.c diff --git a/run.in b/run.in index 9f7a30d2e..7b02538c0 100755 --- a/run.in +++ b/run.in @@ -107,10 +107,8 @@ prepend PATH "$b/tools" export PATH # Set LD_LIBRARY_PATH and DYLD_LIBRARY_PATH to contain library. -prepend LD_LIBRARY_PATH "$b/gobject/.libs" prepend LD_LIBRARY_PATH "$b/java/.libs" prepend LD_LIBRARY_PATH "$b/lib/.libs" -prepend DYLD_LIBRARY_PATH "$b/gobject/.libs" prepend DYLD_LIBRARY_PATH "$b/java/.libs" prepend DYLD_LIBRARY_PATH "$b/lib/.libs" export LD_LIBRARY_PATH @@ -208,10 +206,6 @@ else fi export RUSTFLAGS -# For GObject, Javascript and friends. -export GJS="@GJS@" -prepend GI_TYPELIB_PATH "$b/gobject" -export GI_TYPELIB_PATH # Be friendly to valgrind (https://live.gnome.org/Valgrind) export G_SLICE=always-malloc export G_DEBUG=gc-friendly