summary refs log tree commit diff stats
path: root/qobject/qobject.c
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2015-12-17 11:50:46 +0000
committerPeter Maydell <peter.maydell@linaro.org>2015-12-17 11:50:46 +0000
commitc1a5f950cdeeaea6a835b2b33f040a0e62c18662 (patch)
tree1ed3aec2cd6480d626b30082ff3230c2c117014e /qobject/qobject.c
parentfc77eb20d78e303ef11482288e185d856431f02f (diff)
parentbac5429ccb4f41d421ec641b11f1852c8420fdb7 (diff)
downloadfocaccia-qemu-c1a5f950cdeeaea6a835b2b33f040a0e62c18662.tar.gz
focaccia-qemu-c1a5f950cdeeaea6a835b2b33f040a0e62c18662.zip
Merge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2015-12-17' into staging
QAPI patches for 2015-12-17

# gpg: Signature made Thu 17 Dec 2015 07:33:41 GMT using RSA key ID EB918653
# gpg: Good signature from "Markus Armbruster <armbru@redhat.com>"
# gpg:                 aka "Markus Armbruster <armbru@pond.sub.org>"

* remotes/armbru/tags/pull-qapi-2015-12-17: (40 commits)
  qapi: Detect base class loops
  qapi: Move duplicate collision checks to schema check()
  qapi: Enforce (or whitelist) case conventions on qapi members
  qapi: Track enum values by QAPISchemaMember, not string
  qapi: Prepare new QAPISchemaMember base class
  qapi: Shorter visits of optional fields
  qapi: Simplify visits of optional fields
  qapi: Fix alternates that accept 'number' but not 'int'
  qapi: Inline _make_implicit_tag()
  qapi-types: Drop unnedeed ._fwdefn
  qapi: Simplify visiting of alternate types
  qapi: Convert QType into QAPI built-in enum type
  qobject: Rename qtype_code to QType
  qobject: Simplify QObject
  qapi: Change munging of CamelCase enum values
  qapi: Add alias for ErrorClass
  cpu: Convert CpuInfo into flat union
  qapi: Remove obsolete tests for MAX collision
  qapi: Don't let implicit enum MAX member collide
  qapi: Tighten the regex on valid names
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'qobject/qobject.c')
-rw-r--r--qobject/qobject.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/qobject/qobject.c b/qobject/qobject.c
new file mode 100644
index 0000000000..a3ef14eb55
--- /dev/null
+++ b/qobject/qobject.c
@@ -0,0 +1,34 @@
+/*
+ * QObject
+ *
+ * Copyright (C) 2015 Red Hat, Inc.
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2.1
+ * or later.  See the COPYING.LIB file in the top-level directory.
+ */
+
+#include "qemu-common.h"
+#include "qapi/qmp/qbool.h"
+#include "qapi/qmp/qdict.h"
+#include "qapi/qmp/qfloat.h"
+#include "qapi/qmp/qint.h"
+#include "qapi/qmp/qlist.h"
+#include "qapi/qmp/qstring.h"
+
+static void (*qdestroy[QTYPE__MAX])(QObject *) = {
+    [QTYPE_NONE] = NULL,               /* No such object exists */
+    [QTYPE_QNULL] = NULL,              /* qnull_ is indestructible */
+    [QTYPE_QINT] = qint_destroy_obj,
+    [QTYPE_QSTRING] = qstring_destroy_obj,
+    [QTYPE_QDICT] = qdict_destroy_obj,
+    [QTYPE_QLIST] = qlist_destroy_obj,
+    [QTYPE_QFLOAT] = qfloat_destroy_obj,
+    [QTYPE_QBOOL] = qbool_destroy_obj,
+};
+
+void qobject_destroy(QObject *obj)
+{
+    assert(!obj->refcnt);
+    assert(QTYPE_QNULL < obj->type && obj->type < QTYPE__MAX);
+    qdestroy[obj->type](obj);
+}