commit | f690d4d8a47d4ce800cf14cedfdc4d4fc4ab1838 | [log] [tgz] |
---|---|---|
author | Todd Wang <toddw@google.com> | Tue Apr 26 10:53:41 2016 -0700 |
committer | Todd Wang <toddw@google.com> | Tue Apr 26 10:53:41 2016 -0700 |
tree | d20010d47df170561652408173f0662f5e6ab015 | |
parent | 5003ebb68b5de000d5be78aab741c77301297b04 [diff] |
Update VDLIsZero and native zero semantics. This CL adds extra configuration to vdltool.Config to describe native types. We add a Kind field to specify what kind of type the native type is, which is useful when generating zero values, and will also be useful in the future if we choose to support pointer or interface native types. We also add a Zero field to to specify zero semantics. This lets us avoid wire/native conversions when checking zero values, and also lets us use the Go zero value when setting zero values, both of which should give us a speedup. Even more importantly, for checking zero values we require that we can either compare directly against the Go zero value, or an IsZero field or method is specified; we no longer support wire/native conversions for zero checking in generated code. This simplifies the code generation, and is easily satisfied by all current native types. Future native types can also easily satisfy this constraint, by adding an IsZero method or function as appropriate. Related to these changes, we remove the error return argument from VDLIsZero, so we're left with the simpler method: VDLIsZero() bool This also simplifies code generation, and also provides a more intuitive API for the user. The only downside is that users can't return errors if the native representation is invalid; they should just return false in this case, and let the actual native conversion report the error. Also fixed a bug in the VDLWrite codegen for optional and any types. We'd screwed up the handling of StartValue/FinishValue. The resulting code and codegen logic are both simpler. MultiPart: 1/5 Change-Id: I723d75e60722d2f02467cedc894a068ad6526d97
This repository defines the Go APIs of Vanadium.