qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH RFC 0/3] QEMU Object Model
@ 2009-08-06 13:52 Luiz Capitulino
  2009-08-06 13:52 ` [Qemu-devel] [PATCH 1/3] Introduce qobject header file Luiz Capitulino
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: Luiz Capitulino @ 2009-08-06 13:52 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, filip.navara, avi

 Hi guys,

 Before I ago all over the command handlers again, I thought it would be
a good idea to submit _early_ implemention of the two most basic types
for review: QNumber and QString.

 I'm a bit concerned about QNumber, because it has to allow us to drop
the current long type handling in the monitor and work right on any arch.

 The way I'm thinking in doing this is to change GET_TLONG() and
GET_TPHYSADDR() to receive a QNumber as parameter and work with it to
return the appropriate value.

 For Example:

#if TARGET_LONG_BITS == 64
#define GET_TLONG(qnum) qnumber_get_int64(qnum);
#else
#define GET_TLONG(qnum) qnumber_get_int32(qnum);
#endif

 Remeber that the monitor will always work with int64_t for the
'l' argument type.

Thanks.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Qemu-devel] [PATCH 1/3] Introduce qobject header file
  2009-08-06 13:52 [Qemu-devel] [PATCH RFC 0/3] QEMU Object Model Luiz Capitulino
@ 2009-08-06 13:52 ` Luiz Capitulino
  2009-08-06 14:02   ` [Qemu-devel] " Avi Kivity
  2009-08-06 15:54   ` [Qemu-devel] " malc
  2009-08-06 13:52 ` [Qemu-devel] [PATCH 2/3] Introduce QString data type Luiz Capitulino
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 13+ messages in thread
From: Luiz Capitulino @ 2009-08-06 13:52 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, filip.navara, avi

This file contains basic definitions for the QEMU Object Model,
all object implementions must include this file and add its
type code in qtype_t enum.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 qobject.h |   33 +++++++++++++++++++++++++++++++++
 1 files changed, 33 insertions(+), 0 deletions(-)
 create mode 100644 qobject.h

diff --git a/qobject.h b/qobject.h
new file mode 100644
index 0000000..b70e669
--- /dev/null
+++ b/qobject.h
@@ -0,0 +1,33 @@
+/*
+ * QEMU Object Model.
+ *
+ * Copyright (C) 2009 Red Hat Inc.
+ *
+ * Authors:
+ *  Luiz Capitulino <lcapitulino@redhat.com>
+ *
+ * Based on ideas by Avi Kivity <avi@redhat.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.  See
+ * the COPYING file in the top-level directory.
+ */
+#ifndef QOBJECT_H
+#define QOBJECT_H
+
+typedef enum {
+    QTYPE_NONE,
+} qtype_t;
+
+struct QObject;
+
+typedef struct QType {
+    qtype_t code;
+    struct QObject *(*clone)(const struct QObject *);
+    void (*destroy)(struct QObject *);
+} QType;
+
+typedef struct QObject {
+    QType *type;
+} QObject;
+
+#endif /* QOBJECT_H */
-- 
1.6.4.rc3.12.gdf73a

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [Qemu-devel] [PATCH 2/3] Introduce QString data type
  2009-08-06 13:52 [Qemu-devel] [PATCH RFC 0/3] QEMU Object Model Luiz Capitulino
  2009-08-06 13:52 ` [Qemu-devel] [PATCH 1/3] Introduce qobject header file Luiz Capitulino
@ 2009-08-06 13:52 ` Luiz Capitulino
  2009-08-06 13:52 ` [Qemu-devel] [PATCH 3/3] Introduce QNumber " Luiz Capitulino
  2009-08-06 14:06 ` [Qemu-devel] Re: [PATCH RFC 0/3] QEMU Object Model Avi Kivity
  3 siblings, 0 replies; 13+ messages in thread
From: Luiz Capitulino @ 2009-08-06 13:52 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, filip.navara, avi

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 Makefile  |    2 +-
 qobject.h |    1 +
 qstring.c |   89 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 qstring.h |   17 +++++++++++
 4 files changed, 108 insertions(+), 1 deletions(-)
 create mode 100644 qstring.c
 create mode 100644 qstring.h

diff --git a/Makefile b/Makefile
index 2ce539f..9e3faec 100644
--- a/Makefile
+++ b/Makefile
@@ -104,7 +104,7 @@ obj-y += buffered_file.o migration.o migration-tcp.o net.o qemu-sockets.o
 obj-y += qemu-char.o aio.o net-checksum.o savevm.o
 obj-y += msmouse.o ps2.o
 obj-y += qdev.o qdev-properties.o ssi.o
-obj-y += qdict.o
+obj-y += qdict.o qstring.o
 
 obj-$(CONFIG_BRLAPI) += baum.o
 
diff --git a/qobject.h b/qobject.h
index b70e669..d3378b1 100644
--- a/qobject.h
+++ b/qobject.h
@@ -16,6 +16,7 @@
 
 typedef enum {
     QTYPE_NONE,
+    QTYPE_QSTRING,
 } qtype_t;
 
 struct QObject;
diff --git a/qstring.c b/qstring.c
new file mode 100644
index 0000000..b1ddf7b
--- /dev/null
+++ b/qstring.c
@@ -0,0 +1,89 @@
+/*
+ * QString data type.
+ *
+ * Copyright (C) 2009 Red Hat Inc.
+ *
+ * Authors:
+ *  Luiz Capitulino <lcapitulino@redhat.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.  See
+ * the COPYING file in the top-level directory.
+ */
+#include "qobject.h"
+#include "qstring.h"
+#include "qemu-common.h"
+
+static QType qstring_type;
+
+/**
+ * qstring_from_str(): Create a new QString from a regular C string
+ *
+ * return new QString.
+ */
+QString *qstring_from_str(const char *str)
+{
+    QString *qstring;
+
+    qstring = qemu_mallocz(sizeof(*qstring));
+    qstring->string = qemu_strdup(str);
+    qstring->base.type = &qstring_type;
+
+    return qstring;
+}
+
+/**
+ * qstring_to_str(): Export QString to regular C string
+ *
+ * Return a pointer to a *copy* of the string.
+ */
+char *qstring_to_str(const QString *qstring)
+{
+    return qemu_strdup(qstring->string);
+}
+
+/**
+ * qstring_size(): Return QString string size
+ */
+size_t qstring_size(const QString *qstring)
+{
+    return strlen(qstring->string);
+}
+
+/**
+ * qstring_destroy(): Free all memory allocated by a QString
+ * object
+ */
+void qstring_destroy(QString *qstring)
+{
+    qemu_free(qstring->string);
+    qemu_free(qstring);
+}
+
+/**
+ * qstring_clone_obj(): Clone a QString object
+ *
+ * return a copy of the provided QString object.
+ */
+static QObject *qstring_clone_obj(const QObject *obj)
+{
+    QString *old, *new;
+
+    old = container_of(obj, QString, base);
+    new = qstring_from_str(old->string);
+    return &new->base;
+}
+
+/**
+ * qstring_destroy_obj(): Destroy a QString object
+ */
+static void qstring_destroy_obj(QObject *obj)
+{
+    QString *qstring = container_of(obj, QString, base);
+    qstring_destroy(qstring);
+}
+
+static QType qstring_type = {
+    .code = QTYPE_QSTRING,
+    .clone = qstring_clone_obj,
+    .destroy = qstring_destroy_obj,
+};
diff --git a/qstring.h b/qstring.h
new file mode 100644
index 0000000..1856a12
--- /dev/null
+++ b/qstring.h
@@ -0,0 +1,17 @@
+#ifndef QSTRING_H
+#define QSTRING_H
+
+#include <stddef.h>
+#include "qobject.h"
+
+typedef struct QString {
+    QObject base;
+    char *string;
+} QString;
+
+QString *qstring_from_str(const char *str);
+char *qstring_to_str(const QString *qstring);
+size_t qstring_size(const QString *qstring);
+void qstring_destroy(QString *qstring);
+
+#endif /* QSTRING_H */
-- 
1.6.4.rc3.12.gdf73a

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [Qemu-devel] [PATCH 3/3] Introduce QNumber data type
  2009-08-06 13:52 [Qemu-devel] [PATCH RFC 0/3] QEMU Object Model Luiz Capitulino
  2009-08-06 13:52 ` [Qemu-devel] [PATCH 1/3] Introduce qobject header file Luiz Capitulino
  2009-08-06 13:52 ` [Qemu-devel] [PATCH 2/3] Introduce QString data type Luiz Capitulino
@ 2009-08-06 13:52 ` Luiz Capitulino
  2009-08-06 14:04   ` [Qemu-devel] " Avi Kivity
  2009-08-06 14:06 ` [Qemu-devel] Re: [PATCH RFC 0/3] QEMU Object Model Avi Kivity
  3 siblings, 1 reply; 13+ messages in thread
From: Luiz Capitulino @ 2009-08-06 13:52 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, filip.navara, avi

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 Makefile  |    2 +-
 qnumber.c |  108 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 qnumber.h |   20 +++++++++++
 qobject.h |    1 +
 4 files changed, 130 insertions(+), 1 deletions(-)
 create mode 100644 qnumber.c
 create mode 100644 qnumber.h

diff --git a/Makefile b/Makefile
index 9e3faec..c4cbbaf 100644
--- a/Makefile
+++ b/Makefile
@@ -104,7 +104,7 @@ obj-y += buffered_file.o migration.o migration-tcp.o net.o qemu-sockets.o
 obj-y += qemu-char.o aio.o net-checksum.o savevm.o
 obj-y += msmouse.o ps2.o
 obj-y += qdev.o qdev-properties.o ssi.o
-obj-y += qdict.o qstring.o
+obj-y += qdict.o qstring.o qnumber.o
 
 obj-$(CONFIG_BRLAPI) += baum.o
 
diff --git a/qnumber.c b/qnumber.c
new file mode 100644
index 0000000..cd30150
--- /dev/null
+++ b/qnumber.c
@@ -0,0 +1,108 @@
+/*
+ * QNumber data type.
+ *
+ * Copyright (C) 2009 Red Hat Inc.
+ *
+ * Authors:
+ *  Luiz Capitulino <lcapitulino@redhat.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.  See
+ * the COPYING file in the top-level directory.
+ */
+#include "qobject.h"
+#include "qnumber.h"
+#include "qemu-common.h"
+
+static QType qnumber_type;
+
+
+/**
+ * qnumber_alloc(): Allocate a new QNumber
+ */
+static QNumber *qnumber_alloc(void)
+{
+    QNumber *qnum;
+
+    qnum = qemu_mallocz(sizeof(*qnum));
+    qnum->base.type = &qnumber_type;
+
+    return qnum;
+}
+
+/**
+ * qnumber_from_int(): Create a new QNumber from an int
+ *
+ * return new QNumber.
+ */
+QNumber *qnumber_from_int(int value)
+{
+    QNumber *qnum;
+
+    qnum = qnumber_alloc();
+    qnum->number.n_int = value;
+
+    return qnum;
+}
+
+/**
+ * qnumber_from_int64(): Create a new QNumber from an int64_t
+ *
+ * return new QNumber.
+ */
+QNumber *qnumber_from_int64(int64_t value)
+{
+    QNumber *qnum;
+
+    qnum = qnumber_alloc();
+    qnum->number.n_int64 = value;
+
+    return qnum;
+}
+
+/**
+ * qnumber_destroy(): Free all memory allocated by a QNumber
+ * object
+ */
+void qnumber_destroy(QNumber *qnum)
+{
+    qemu_free(qnum);
+}
+
+/**
+ * qnumber_to_int(): Export QNumber to int type
+ */
+int qnumber_to_int(const QNumber *qnum)
+{
+    return qnum->number.n_int;
+}
+
+/**
+ * qnumber_destroy_obj(): Destroy a QNumber object
+ */
+static void qnumber_destroy_obj(QObject *obj)
+{
+    QNumber *qnum = container_of(obj, QNumber, base);
+    qnumber_destroy(qnum);
+}
+
+/**
+ * qnumber_clone_obj(): Clone a QNumber object
+ *
+ * return a copy of the provided QNumber object.
+ */
+static QObject *qnumber_clone_obj(const QObject *obj)
+{
+    QNumber *old, *new;
+
+    new = qemu_malloc(sizeof(*new));
+    old = container_of(obj, QNumber, base);
+    memcpy(new, old, sizeof(*new));
+
+    return &new->base;
+}
+
+static QType qnumber_type = {
+    .code = QTYPE_QNUMBER,
+    .clone = qnumber_clone_obj,
+    .destroy = qnumber_destroy_obj,
+};
diff --git a/qnumber.h b/qnumber.h
new file mode 100644
index 0000000..918637d
--- /dev/null
+++ b/qnumber.h
@@ -0,0 +1,20 @@
+#ifndef QNUMBER_H
+#define QNUMBER_H
+
+#include "qobject.h"
+#include <stdint.h>
+
+typedef struct QNumber {
+    QObject base;
+    union {
+        int n_int;
+        int64_t n_int64;
+    } number;
+} QNumber;
+
+QNumber *qnumber_from_int(int value);
+QNumber *qnumber_from_int64(int64_t value);
+void qnumber_destroy(QNumber *qnum);
+int qnumber_to_int(const QNumber *qnum);
+
+#endif /* QNUMBER_H */
diff --git a/qobject.h b/qobject.h
index d3378b1..20b9a99 100644
--- a/qobject.h
+++ b/qobject.h
@@ -17,6 +17,7 @@
 typedef enum {
     QTYPE_NONE,
     QTYPE_QSTRING,
+    QTYPE_QNUMBER,
 } qtype_t;
 
 struct QObject;
-- 
1.6.4.rc3.12.gdf73a

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [Qemu-devel] Re: [PATCH 1/3] Introduce qobject header file
  2009-08-06 13:52 ` [Qemu-devel] [PATCH 1/3] Introduce qobject header file Luiz Capitulino
@ 2009-08-06 14:02   ` Avi Kivity
  2009-08-06 14:07     ` Luiz Capitulino
  2009-08-06 15:54   ` [Qemu-devel] " malc
  1 sibling, 1 reply; 13+ messages in thread
From: Avi Kivity @ 2009-08-06 14:02 UTC (permalink / raw)
  To: Luiz Capitulino; +Cc: aliguori, filip.navara, qemu-devel

On 08/06/2009 04:52 PM, Luiz Capitulino wrote:
> This file contains basic definitions for the QEMU Object Model,
> all object implementions must include this file and add its
> type code in qtype_t enum.
>
>
> +
> +typedef enum {
> +    QTYPE_NONE,
> +} qtype_t;
> +
> +struct QObject;
> +
> +typedef struct QType {
> +    qtype_t code;
>    

Is this really needed?  You can check if an object is a particular type 
by checking its ->type agains whatever you're interested in.  Of course 
you should refrain from doing so unless there's no choice.

-- 
error compiling committee.c: too many arguments to function

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Qemu-devel] Re: [PATCH 3/3] Introduce QNumber data type
  2009-08-06 13:52 ` [Qemu-devel] [PATCH 3/3] Introduce QNumber " Luiz Capitulino
@ 2009-08-06 14:04   ` Avi Kivity
  2009-08-06 14:05     ` François Revol
                       ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Avi Kivity @ 2009-08-06 14:04 UTC (permalink / raw)
  To: Luiz Capitulino; +Cc: aliguori, filip.navara, qemu-devel

On 08/06/2009 04:52 PM, Luiz Capitulino wrote:
> +
> +typedef struct QNumber {
> +    QObject base;
> +    union {
> +        int n_int;
> +        int64_t n_int64;
> +    } number;
> +} QNumber;
>    

Why not have an int64_t exclusively?

Also, we need floating point support.  So probably need to split this 
into QInt and QFloat.

-- 
error compiling committee.c: too many arguments to function

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] Re: [PATCH 3/3] Introduce QNumber data type
  2009-08-06 14:04   ` [Qemu-devel] " Avi Kivity
@ 2009-08-06 14:05     ` François Revol
  2009-08-06 14:48       ` Avi Kivity
  2009-08-06 14:10     ` Luiz Capitulino
  2009-08-06 21:21     ` Luiz Capitulino
  2 siblings, 1 reply; 13+ messages in thread
From: François Revol @ 2009-08-06 14:05 UTC (permalink / raw)
  To: Avi Kivity; +Cc: aliguori, lcapitulino, filip.navara, qemu-devel

> On 08/06/2009 04:52 PM, Luiz Capitulino wrote:
> > +
> > +typedef struct QNumber {
> > +    QObject base;
> > +    union {
> > +        int n_int;
> > +        int64_t n_int64;
> > +    } number;
> > +} QNumber;
> >
>
> Why not have an int64_t exclusively?
>
> Also, we need floating point support.  So probably need to split this
> into QInt and QFloat.

Aw you sure all this won't clash with some Qt class if some fold tries
to mix both?
Now, I use the BeAPI so I don't really care, but still.

And I still wonder why not just use a real OO language instead of
faking.

François.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Qemu-devel] Re: [PATCH RFC 0/3] QEMU Object Model
  2009-08-06 13:52 [Qemu-devel] [PATCH RFC 0/3] QEMU Object Model Luiz Capitulino
                   ` (2 preceding siblings ...)
  2009-08-06 13:52 ` [Qemu-devel] [PATCH 3/3] Introduce QNumber " Luiz Capitulino
@ 2009-08-06 14:06 ` Avi Kivity
  3 siblings, 0 replies; 13+ messages in thread
From: Avi Kivity @ 2009-08-06 14:06 UTC (permalink / raw)
  To: Luiz Capitulino; +Cc: aliguori, filip.navara, qemu-devel

On 08/06/2009 04:52 PM, Luiz Capitulino wrote:
> #if TARGET_LONG_BITS == 64
> #define GET_TLONG(qnum) qnumber_get_int64(qnum);
> #else
> #define GET_TLONG(qnum) qnumber_get_int32(qnum);
> #endif
>
>    

#define GET_TLONG(qnum) ((target_ulong_t)qnumber_get_uint64(qnum))

That doesn't warn on overflow though.

-- 
error compiling committee.c: too many arguments to function

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Qemu-devel] Re: [PATCH 1/3] Introduce qobject header file
  2009-08-06 14:02   ` [Qemu-devel] " Avi Kivity
@ 2009-08-06 14:07     ` Luiz Capitulino
  0 siblings, 0 replies; 13+ messages in thread
From: Luiz Capitulino @ 2009-08-06 14:07 UTC (permalink / raw)
  To: Avi Kivity; +Cc: aliguori, filip.navara, qemu-devel

On Thu, 06 Aug 2009 17:02:48 +0300
Avi Kivity <avi@redhat.com> wrote:

> On 08/06/2009 04:52 PM, Luiz Capitulino wrote:
> > This file contains basic definitions for the QEMU Object Model,
> > all object implementions must include this file and add its
> > type code in qtype_t enum.
> >
> >
> > +
> > +typedef enum {
> > +    QTYPE_NONE,
> > +} qtype_t;
> > +
> > +struct QObject;
> > +
> > +typedef struct QType {
> > +    qtype_t code;
> >    
> 
> Is this really needed?  You can check if an object is a particular type 
> by checking its ->type agains whatever you're interested in.  Of course 
> you should refrain from doing so unless there's no choice.

 Each QType definition is private to each type's module, I would have
to make them public then.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Qemu-devel] Re: [PATCH 3/3] Introduce QNumber data type
  2009-08-06 14:04   ` [Qemu-devel] " Avi Kivity
  2009-08-06 14:05     ` François Revol
@ 2009-08-06 14:10     ` Luiz Capitulino
  2009-08-06 21:21     ` Luiz Capitulino
  2 siblings, 0 replies; 13+ messages in thread
From: Luiz Capitulino @ 2009-08-06 14:10 UTC (permalink / raw)
  To: Avi Kivity; +Cc: aliguori, filip.navara, qemu-devel

On Thu, 06 Aug 2009 17:04:50 +0300
Avi Kivity <avi@redhat.com> wrote:

> On 08/06/2009 04:52 PM, Luiz Capitulino wrote:
> > +
> > +typedef struct QNumber {
> > +    QObject base;
> > +    union {
> > +        int n_int;
> > +        int64_t n_int64;
> > +    } number;
> > +} QNumber;
> >    
> 
> Why not have an int64_t exclusively?
> 
> Also, we need floating point support.  So probably need to split this 
> into QInt and QFloat.

 Right, we can have QInt with int64_t.

 But the monitor doesn't use floats, so QFloat doesn't seem
needed, at least for now.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] Re: [PATCH 3/3] Introduce QNumber data type
  2009-08-06 14:05     ` François Revol
@ 2009-08-06 14:48       ` Avi Kivity
  0 siblings, 0 replies; 13+ messages in thread
From: Avi Kivity @ 2009-08-06 14:48 UTC (permalink / raw)
  To: François Revol; +Cc: aliguori, lcapitulino, filip.navara, qemu-devel

On 08/06/2009 05:05 PM, François Revol wrote:
>> Also, we need floating point support.  So probably need to split this
>> into QInt and QFloat.
>>      
>
> Aw you sure all this won't clash with some Qt class if some fold tries
> to mix both?
>    

We can address that when it happens.

> And I still wonder why not just use a real OO language instead of
> faking.
>    

I'm all for it.

-- 
error compiling committee.c: too many arguments to function

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [PATCH 1/3] Introduce qobject header file
  2009-08-06 13:52 ` [Qemu-devel] [PATCH 1/3] Introduce qobject header file Luiz Capitulino
  2009-08-06 14:02   ` [Qemu-devel] " Avi Kivity
@ 2009-08-06 15:54   ` malc
  1 sibling, 0 replies; 13+ messages in thread
From: malc @ 2009-08-06 15:54 UTC (permalink / raw)
  To: Luiz Capitulino; +Cc: aliguori, filip.navara, qemu-devel, avi

On Thu, 6 Aug 2009, Luiz Capitulino wrote:

> This file contains basic definitions for the QEMU Object Model,
> all object implementions must include this file and add its
> type code in qtype_t enum.
> 
> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
> ---
>  qobject.h |   33 +++++++++++++++++++++++++++++++++
>  1 files changed, 33 insertions(+), 0 deletions(-)
>  create mode 100644 qobject.h
> 
> diff --git a/qobject.h b/qobject.h
> new file mode 100644
> index 0000000..b70e669
> --- /dev/null
> +++ b/qobject.h
> @@ -0,0 +1,33 @@
> +/*
> + * QEMU Object Model.
> + *
> + * Copyright (C) 2009 Red Hat Inc.
> + *
> + * Authors:
> + *  Luiz Capitulino <lcapitulino@redhat.com>
> + *
> + * Based on ideas by Avi Kivity <avi@redhat.com>
> + *
> + * This work is licensed under the terms of the GNU GPL, version 2.  See
> + * the COPYING file in the top-level directory.
> + */
> +#ifndef QOBJECT_H
> +#define QOBJECT_H
> +
> +typedef enum {
> +    QTYPE_NONE,
> +} qtype_t;

Please do not use _t suffix.

> +
> +struct QObject;
> +
> +typedef struct QType {
> +    qtype_t code;
> +    struct QObject *(*clone)(const struct QObject *);
> +    void (*destroy)(struct QObject *);
> +} QType;
> +
> +typedef struct QObject {
> +    QType *type;
> +} QObject;
> +
> +#endif /* QOBJECT_H */
> 

-- 
mailto:av1474@comtv.ru

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Qemu-devel] Re: [PATCH 3/3] Introduce QNumber data type
  2009-08-06 14:04   ` [Qemu-devel] " Avi Kivity
  2009-08-06 14:05     ` François Revol
  2009-08-06 14:10     ` Luiz Capitulino
@ 2009-08-06 21:21     ` Luiz Capitulino
  2 siblings, 0 replies; 13+ messages in thread
From: Luiz Capitulino @ 2009-08-06 21:21 UTC (permalink / raw)
  To: Avi Kivity; +Cc: aliguori, filip.navara, qemu-devel

On Thu, 06 Aug 2009 17:04:50 +0300
Avi Kivity <avi@redhat.com> wrote:

> On 08/06/2009 04:52 PM, Luiz Capitulino wrote:
> > +
> > +typedef struct QNumber {
> > +    QObject base;
> > +    union {
> > +        int n_int;
> > +        int64_t n_int64;
> > +    } number;
> > +} QNumber;
> >    
> 
> Why not have an int64_t exclusively?

 Something I was wondering: why does get_expr() use int64_t
instead of uint64_t?

 As far as I can understand it uses strtoull() and strtoul() to
convert from the user's string and command handlers use 64-bits
values only for addresses and (signed) 32-bits for anything else.

 We are doing some int64_t to uint64_t conversions today...

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2009-08-06 21:21 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-06 13:52 [Qemu-devel] [PATCH RFC 0/3] QEMU Object Model Luiz Capitulino
2009-08-06 13:52 ` [Qemu-devel] [PATCH 1/3] Introduce qobject header file Luiz Capitulino
2009-08-06 14:02   ` [Qemu-devel] " Avi Kivity
2009-08-06 14:07     ` Luiz Capitulino
2009-08-06 15:54   ` [Qemu-devel] " malc
2009-08-06 13:52 ` [Qemu-devel] [PATCH 2/3] Introduce QString data type Luiz Capitulino
2009-08-06 13:52 ` [Qemu-devel] [PATCH 3/3] Introduce QNumber " Luiz Capitulino
2009-08-06 14:04   ` [Qemu-devel] " Avi Kivity
2009-08-06 14:05     ` François Revol
2009-08-06 14:48       ` Avi Kivity
2009-08-06 14:10     ` Luiz Capitulino
2009-08-06 21:21     ` Luiz Capitulino
2009-08-06 14:06 ` [Qemu-devel] Re: [PATCH RFC 0/3] QEMU Object Model Avi Kivity

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).