mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2024-12-25 14:45:30 +00:00
f4b3c5d0bd
By moving the base fields to a QObjectBase_, QObject can be a type which also has a 'base' field. This allows writing a generic QOBJECT() macro that will work with any QObject type, including QObject itself. The container_of() macro ensures that the object to cast has a QObjectBase_ base field, giving some type safety guarantees. QObject must have no members but QObjectBase_ base, or else QOBJECT() breaks. QObjectBase_ is not a typedef and uses a trailing underscore to make it obvious it is not for normal use and to avoid potential abuse. Backports commit 3d3eacaeccaab718ea0e2ddaa578bfae9e311c59 from qemu
31 lines
607 B
C
31 lines
607 B
C
/*
|
|
* QBool Module
|
|
*
|
|
* Copyright IBM, Corp. 2009
|
|
*
|
|
* Authors:
|
|
* Anthony Liguori <aliguori@us.ibm.com>
|
|
*
|
|
* 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.
|
|
*
|
|
*/
|
|
|
|
#ifndef QBOOL_H
|
|
#define QBOOL_H
|
|
|
|
#include "unicorn/platform.h"
|
|
#include "qapi/qmp/qobject.h"
|
|
|
|
struct QBool {
|
|
struct QObjectBase_ base;
|
|
bool value;
|
|
};
|
|
|
|
QBool *qbool_from_bool(bool value);
|
|
bool qbool_get_bool(const QBool *qb);
|
|
bool qbool_is_equal(const QObject *x, const QObject *y);
|
|
void qbool_destroy_obj(QObject *obj);
|
|
|
|
#endif /* QBOOL_H */
|