js.core: Fix native type consts, and gen 0 values for all types.

We had a TODO to fix consts with native types, since they didn't
work at all.  The strategy is to create the 0-valued wire type,
and call vdl.Convert to convert to the native type.  We inline a
func literal to do this for us, which means we can call it in the
natural spot without creating temporary variables.  The downside
is that the generated code looks a little ugly.

We use this functionality to generate zero values for all types
defined in each package.  This will be useful for Benj's FromZero
changes, and was also useful in spotting weird behavior.

Also changed typeGoInternal to be typeGoWire.  The idea is that
sometimes we want to force the wire type to be generated, but
only for the top-level type, so it makes more sense to split the
functions into wire / non-wire versions, rather than passing a
bool around that we ignore everywhere except the top level.

And fixed the isNativeType logic.  I should have spotted this in
an earlier review; we should never call vdl.SplitIdent in the
codegen package, since we have the full compile.Env, and can just
look up anything we need.

And finally - changed the unnamed targets to use an incrementing
number with a unique prefix, rather than the hex hash of the
type.  This is much more readable, and the hex hashes were really
long and annoying.

MultiPart: 4/6

Change-Id: Idaadfadc6994151d0371f228213c7ac267c7b47e
2 files changed
tree: db5f0826e9c60fa45537dcc4492acd18e3637f2e
  1. extension/
  2. go/
  3. jsdocs/
  4. src/
  5. test/
  6. .gitattributes
  7. .gitignore
  8. .jshintignore
  9. .jshintrc
  10. .npmignore
  11. AUTHORS
  12. CONTRIBUTING.md
  13. CONTRIBUTORS
  14. LICENSE
  15. Makefile
  16. package.json
  17. PATENTS
  18. README.md
  19. VERSION
README.md

Vanadium JavaScript

This repository defines the JavaScript API for Vanadium. The client and server APIs defined here work both in Node.js and the browser.

Install

npm install --save vanadium/js

Usage

The entry point to the API is through a module called vanadium, everything else is considered private and should not be accessed by the users of the API.

The vanadium module is exported as a global in the browser JavaScript library and for Browserify and Node.js the “main” property in the package.json points to /src/vanadium making it the index module and therefore Browserify and Node.js users can gain access to the API with:

var vanadium = require("vanadium");

One of the goals of this project is to only write the code once and have it run in both Node.js and browsers. Therefore, specific build and testing steps have been designed in the project to ensure this goal.

When run in a browser, vanadium.js expects that the vanadium extension will be installed.

Bugs and feature requests

Bugs and feature requests should be filed in the Vanadium issue tracker.

Building and testing

GNU Make is used to build and test Vanadium.

Build everything:

make build

Test everything:

make test

Run a specific test suite:

make test-unit
make test-unit-node
make test-unit-browser

make test-integration
make test-integration-node
make test-integration-browser

Remove all build and testing artifacts:

make clean