From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:50998) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SbwW3-000876-IK for qemu-devel@nongnu.org; Tue, 05 Jun 2012 12:22:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SbwVx-0003VX-OT for qemu-devel@nongnu.org; Tue, 05 Jun 2012 12:21:55 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:41937) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SbwVx-0003VC-Ed for qemu-devel@nongnu.org; Tue, 05 Jun 2012 12:21:49 -0400 Received: by pbbro12 with SMTP id ro12so8312457pbb.4 for ; Tue, 05 Jun 2012 09:21:47 -0700 (PDT) Sender: fluxion Date: Tue, 5 Jun 2012 11:21:41 -0500 From: Michael Roth Message-ID: <20120605162141.GK2916@illuin> References: <1338858018-17189-1-git-send-email-mdroth@linux.vnet.ibm.com> <1338858018-17189-2-git-send-email-mdroth@linux.vnet.ibm.com> <4FCDD06D.2050003@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4FCDD06D.2050003@redhat.com> Subject: Re: [Qemu-devel] [PATCH 01/17] qidl: add QEMU IDL processor List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: aliguori@us.ibm.com, yamahata@valinux.co.jp, quintela@redhat.com, qemu-devel@nongnu.org, owasserm@redhat.com, pbonzini@redhat.com, akong@redhat.com, afaerber@suse.de On Tue, Jun 05, 2012 at 11:25:01AM +0200, Kevin Wolf wrote: > Am 05.06.2012 03:00, schrieb Michael Roth: > > This is an import of Anthony's qidl compiler, with some changes squashed > > in to add support for doing the visitor generation via QEMU's qapi code > > generators rather than directly. > > > > Documentation has been imported as well, as is also viewable at: > > > > https://github.com/aliguori/qidl/blob/master/qc.md > > > > This will be used to add annotations to device structs to aid in > > generating visitors that can be used to serialize/unserialize them. > > > > Signed-off-by: Michael Roth > > --- > > scripts/qc.md | 331 ++++++++++++++++++++++++++++++++++++++ > > scripts/qc.py | 494 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > > 2 files changed, 825 insertions(+), 0 deletions(-) > > create mode 100644 scripts/qc.md > > create mode 100755 scripts/qc.py > > > > diff --git a/scripts/qc.md b/scripts/qc.md > > new file mode 100644 > > index 0000000..4cf4b21 > > --- /dev/null > > +++ b/scripts/qc.md > > I think docs/ would be a better place than scripts/ > > > +Getting Started > > +--------------- > > + > > +The first step is to move your device struct definition to a header file. This > > +header file should only contain the struct definition and any preprocessor > > +declarations you need to define the structure. This header file will act as > > +the source for the QC IDL compiler. > > + > > +Do not include any function declarations in this header file as QC does not > > +understand function declarations. > > Couldn't we use a header file (or even source file) that has some magic > markers for the IDL compiler? Like: > > ... random stuff ... > > /* QIDL START */ > struct Foo { > ... > }; > /* QIDL END */ > > ... random stuff ... > > Adding a new header file for each device really doesn't look like a > desirable thing, and this way it could be avoided. We could always make the compiler smarter (Anthony has already done so apparently), and in the version posted here the compiler actually scans line-by-line for the "qc_declaration" annotation before it begins processing the annotated structure, so it behaves much like you're suggestion. The main reason device state needs to be moved to a seperate file is because the generated visitors need to access that device state. The only way I can think of getting around this is to do nasty things like adding an #include "qapi-generated/mc146818rtc-qapi-visit.c"; in hw/mc146818rtc.c.