mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
Generate structs and struct lists generically.
This modifies the way that struct and struct lists are generated (for return values) so that there is no need to add an explicit new type when adding a new structure. All tests pass, and the C API should be compatible. I have also inspected the changes that are made to the generated code by hand.
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -86,6 +86,7 @@ java/com/redhat/et/libguestfs/Dirent.java
|
||||
java/com_redhat_et_libguestfs_GuestFS.c
|
||||
java/com_redhat_et_libguestfs_GuestFS.h
|
||||
java/com/redhat/et/libguestfs/GuestFS.java
|
||||
java/com/redhat/et/libguestfs/IntBool.java
|
||||
java/com/redhat/et/libguestfs/LV.java
|
||||
java/com/redhat/et/libguestfs/PV.java
|
||||
java/com/redhat/et/libguestfs/Stat.java
|
||||
|
||||
@@ -122,21 +122,21 @@ do_aug_defvar (char *name, char *expr)
|
||||
#endif
|
||||
}
|
||||
|
||||
guestfs_aug_defnode_ret *
|
||||
guestfs_int_int_bool *
|
||||
do_aug_defnode (char *name, char *expr, char *val)
|
||||
{
|
||||
#ifdef HAVE_AUG_DEFNODE
|
||||
static guestfs_aug_defnode_ret r;
|
||||
static guestfs_int_int_bool r;
|
||||
int created;
|
||||
|
||||
NEED_AUG (NULL);
|
||||
|
||||
r.nrnodes = aug_defnode (aug, name, expr, val, &created);
|
||||
if (r.nrnodes == -1) {
|
||||
r.i = aug_defnode (aug, name, expr, val, &created);
|
||||
if (r.i == -1) {
|
||||
reply_with_error ("Augeas defnode failed");
|
||||
return NULL;
|
||||
}
|
||||
r.created = created;
|
||||
r.b = created;
|
||||
return &r;
|
||||
#else
|
||||
reply_with_error ("%s is not available", __func__);
|
||||
|
||||
@@ -67,9 +67,9 @@ extern int root_mounted;
|
||||
|
||||
/*-- in stubs.c (auto-generated) --*/
|
||||
extern void dispatch_incoming_message (XDR *);
|
||||
extern guestfs_lvm_int_pv_list *parse_command_line_pvs (void);
|
||||
extern guestfs_lvm_int_vg_list *parse_command_line_vgs (void);
|
||||
extern guestfs_lvm_int_lv_list *parse_command_line_lvs (void);
|
||||
extern guestfs_int_lvm_pv_list *parse_command_line_pvs (void);
|
||||
extern guestfs_int_lvm_vg_list *parse_command_line_vgs (void);
|
||||
extern guestfs_int_lvm_lv_list *parse_command_line_lvs (void);
|
||||
|
||||
/*-- in proto.c --*/
|
||||
extern void main_loop (int sock);
|
||||
|
||||
@@ -152,19 +152,19 @@ do_lvs (void)
|
||||
* the code. That code is in stubs.c, and it is generated as usual
|
||||
* by generator.ml.
|
||||
*/
|
||||
guestfs_lvm_int_pv_list *
|
||||
guestfs_int_lvm_pv_list *
|
||||
do_pvs_full (void)
|
||||
{
|
||||
return parse_command_line_pvs ();
|
||||
}
|
||||
|
||||
guestfs_lvm_int_vg_list *
|
||||
guestfs_int_lvm_vg_list *
|
||||
do_vgs_full (void)
|
||||
{
|
||||
return parse_command_line_vgs ();
|
||||
}
|
||||
|
||||
guestfs_lvm_int_lv_list *
|
||||
guestfs_int_lvm_lv_list *
|
||||
do_lvs_full (void)
|
||||
{
|
||||
return parse_command_line_lvs ();
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
/* libguestfs Java bindings
|
||||
* Copyright (C) 2009 Red Hat Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package com.redhat.et.libguestfs;
|
||||
|
||||
/**
|
||||
* A pair (int, boolean)
|
||||
*
|
||||
* @author rjones
|
||||
* @see Exception
|
||||
*/
|
||||
public class IntBool {
|
||||
public int i;
|
||||
public boolean b;
|
||||
}
|
||||
1918
src/generator.ml
1918
src/generator.ml
File diff suppressed because it is too large
Load Diff
@@ -1490,44 +1490,6 @@ guestfs_end_busy (guestfs_h *g)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Structure-freeing functions. These rely on the fact that the
|
||||
* structure format is identical to the XDR format. See note in
|
||||
* generator.ml.
|
||||
*/
|
||||
void
|
||||
guestfs_free_int_bool (struct guestfs_int_bool *x)
|
||||
{
|
||||
free (x);
|
||||
}
|
||||
|
||||
void
|
||||
guestfs_free_lvm_pv_list (struct guestfs_lvm_pv_list *x)
|
||||
{
|
||||
xdr_free ((xdrproc_t) xdr_guestfs_lvm_int_pv_list, (char *) x);
|
||||
free (x);
|
||||
}
|
||||
|
||||
void
|
||||
guestfs_free_lvm_vg_list (struct guestfs_lvm_vg_list *x)
|
||||
{
|
||||
xdr_free ((xdrproc_t) xdr_guestfs_lvm_int_vg_list, (char *) x);
|
||||
free (x);
|
||||
}
|
||||
|
||||
void
|
||||
guestfs_free_lvm_lv_list (struct guestfs_lvm_lv_list *x)
|
||||
{
|
||||
xdr_free ((xdrproc_t) xdr_guestfs_lvm_int_lv_list, (char *) x);
|
||||
free (x);
|
||||
}
|
||||
|
||||
void
|
||||
guestfs_free_dirent_list (struct guestfs_dirent_list *x)
|
||||
{
|
||||
xdr_free ((xdrproc_t) xdr_guestfs_int_dirent_list, (char *) x);
|
||||
free (x);
|
||||
}
|
||||
|
||||
/* We don't know if stdout_event or sock_read_event will be the
|
||||
* first to receive EOF if the qemu process dies. This function
|
||||
* has the common cleanup code for both.
|
||||
|
||||
@@ -52,13 +52,6 @@ extern guestfs_abort_cb guestfs_get_out_of_memory_handler (guestfs_h *g);
|
||||
#include <guestfs-structs.h>
|
||||
#include <guestfs-actions.h>
|
||||
|
||||
/* Free up return values. */
|
||||
extern void guestfs_free_int_bool (struct guestfs_int_bool *);
|
||||
extern void guestfs_free_lvm_pv_list (struct guestfs_lvm_pv_list *);
|
||||
extern void guestfs_free_lvm_vg_list (struct guestfs_lvm_vg_list *);
|
||||
extern void guestfs_free_lvm_lv_list (struct guestfs_lvm_lv_list *);
|
||||
extern void guestfs_free_dirent_list (struct guestfs_dirent_list *);
|
||||
|
||||
/* Low-level event API. */
|
||||
typedef void (*guestfs_send_cb) (guestfs_h *g, void *data);
|
||||
typedef void (*guestfs_reply_cb) (guestfs_h *g, void *data, XDR *xdr);
|
||||
|
||||
Reference in New Issue
Block a user