Received: from eggs.gnu.org ([2001:4830:134:3::10]:45881) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zi2s8-0002nB-Sv for qemu-devel@nongnu.org; Fri, 02 Oct 2015 12:07:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zi2s2-0006TP-Qo for qemu-devel@nongnu.org; Fri, 02 Oct 2015 12:07:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52178) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zi2s2-0006TJ-LW for qemu-devel@nongnu.org; Fri, 02 Oct 2015 12:07:42 -0400 From: Markus Armbruster References: <1443760312-656-1-git-send-email-eblake@redhat.com> <1443760312-656-6-git-send-email-eblake@redhat.com> <87eghdfy5m.fsf@blackfin.pond.sub.org> <560E8F86.7060305@redhat.com> Date: Fri, 02 Oct 2015 18:07:39 +0200 In-Reply-To: <560E8F86.7060305@redhat.com> (Eric Blake's message of "Fri, 2 Oct 2015 08:07:02 -0600") Message-ID: <877fn5s184.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v6 05/12] qapi: Track location that created an implicit type List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: Michael Roth , marcandre.lureau@redhat.com, qemu-devel@nongnu.org, ehabkost@redhat.com Eric Blake writes: > On 10/02/2015 02:54 AM, Markus Armbruster wrote: >> Eric Blake writes: >> >>> A future patch will enable deferred error detection in the >>> various QAPISchema*.check() methods (rather than the current >>> ad hoc parse checks). >> >> What's "deferred" about them? > > With ad hoc parse checks, we validate the .json before calling > QAPISchemaEntity constructors. With QAPISchemaEntity.check(), the > constructor is called on various strings, but the strings may not > resolve; we don't know about the problem until check() is called. I guess I'd say something like A future patch will move some error checking from the parser to the various QAPISchema*.check() methods. These run only after parsing completes. >> >> Perhaps simply: A future patch will move error checking into the various >> QAPISchema*.check() methods. >> >>> But that means the user can request >>> a QAPI entity that will only fail validation after it has >>> been initialized. >> >> I'm not sure I get this sentence. > > Trying to point out that while pre-patch, the check() method was only > run on well-formed entities, now post-patch it can raise errors that we > chose not to detect prior to __init__ time. > >>> RFC: I used a class-level static flag to track whether we expected >>> 'info is None' when creating a QAPISchemaEntity. This is gross, >>> because the flag will only be set on the first QAPISchema() instance >>> (it works because none of our client scripts ever instantiate more >>> than one schema). But the only other thing I could think of would >>> be passing the QAPISchema instance into the constructor for each >>> QAPISchemaEntity, which is a lot of churn. Any better ideas on how >>> best to do the assertion, or should I just drop it? >>> >>> Signed-off-by: Eric Blake >> >> I'd check in QAPISchema._def_entity(). > > Ah, instead of an assert in QAPISchemaEntity.__init__() (which requires > a leaky abstraction), instead write the assert into QAPISchema (so the > flag can now be instance-local). Makes sense; I'll play with the idea. :)