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: 5/5
Change-Id: I61c390eefd1584c4683fb06647f9ae11d6dddb2f
1 file changed
tree: 197fc51334975ed2d309897ea7f5b1498f2b8e47
  1. go/
  2. .gitignore
  3. AUTHORS
  4. CONTRIBUTING.md
  5. CONTRIBUTORS
  6. LICENSE
  7. PATENTS
  8. VERSION