Skip to content

Commit

Permalink
Make genVerifyKey actually generate conditions for 32bit values and b…
Browse files Browse the repository at this point in the history
…ool, fixes #546
  • Loading branch information
dcodeIO committed Dec 12, 2016
1 parent 01365ba commit 28a1d26
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 52 deletions.
45 changes: 4 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ import * as protobuf from "protobufjs";

Module Structure
----------------
The library exports a flat `protobuf` namespace with the following members, ordered by category:
The library exports a flat `protobuf` namespace including but not restricted to the following members, ordered by category:

### Parser

Expand All @@ -225,49 +225,19 @@ The library exports a flat `protobuf` namespace with the following members, orde
* **loadSync(filename: `string|string[]`, [root: `Root`]): `Root`** [[source](https://github.com/dcodeIO/protobuf.js/blob/master/src/index.js)]<br />
Synchronously loads one or multiple .proto or preprocessed .json files into a common root namespace (node only).

* **tokenize(source: `string`): `Object`** [[source](https://github.com/dcodeIO/protobuf.js/blob/master/src/tokenize.js)]<br />
Tokenizes the given .proto source and returns an object with useful utility functions.

* **parse(source: `string`): `Object`** [[source](https://github.com/dcodeIO/protobuf.js/blob/master/src/parse.js)]<br />
Parses the given .proto source and returns an object with the parsed contents.

* **package: `string|undefined`**<br />
The package name, if declared.

* **imports: `string[]|undefined`**<br />
File names of imported files, if any.

* **weakImports: `string[]|undefined`**<br />
File names of weakly imported files, if any.

* **syntax: `string|undefined`**<br />
Source syntax, if defined.

* **root: `Root`**<br />
The root namespace.

### Serialization

* **Writer** [[source](https://github.com/dcodeIO/protobuf.js/blob/master/src/writer.js)]<br />
Wire format writer using `Uint8Array` if available, otherwise `Array`.

* **BufferWriter** _extends **Writer**_ [[source](https://github.com/dcodeIO/protobuf.js/blob/master/src/writer.js)]<br />
Wire format writer using node buffers.

* **Reader** [[source](https://github.com/dcodeIO/protobuf.js/blob/master/src/reader.js)]<br />
Wire format reader using `Uint8Array` if available, otherwise `Array`.

* **BufferReader** _extends **Reader**_ [[source](https://github.com/dcodeIO/protobuf.js/blob/master/src/reader.js)]<br />
Wire format reader using node buffers.

* **codegen** [[source](https://github.com/dcodeIO/protobuf.js/blob/master/src/codegen.js)]<br />
A closure for generating functions programmatically.

### Reflection

* **ReflectionObject** [[source](https://github.com/dcodeIO/protobuf.js/blob/master/src/object.js)]<br />
Base class of all reflection objects.

* **Namespace** _extends **ReflectionObject**_ [[source](https://github.com/dcodeIO/protobuf.js/blob/master/src/namespace.js)]<br />
Base class of all reflection objects containing nested objects.

Expand Down Expand Up @@ -302,18 +272,11 @@ The library exports a flat `protobuf` namespace with the following members, orde

### Utility

* **types: `Object`** [[source](https://github.com/dcodeIO/protobuf.js/blob/master/src/types.js)]<br />
Common type constants.

* **common(name: `string`, json: `Object`)** [[source](https://github.com/dcodeIO/protobuf.js/blob/master/src/common.js)]<br />
Provides common type definitions.

* **rpc: `Object`** [[source](https://github.com/dcodeIO/protobuf.js/blob/master/src/rpc.js)]<br />
Streaming RPC helpers.

* **util: `Object`** [[source](https://github.com/dcodeIO/protobuf.js/blob/master/src/util.js)]<br />
* **util** [[source](https://github.com/dcodeIO/protobuf.js/blob/master/src/util.js)]<br />
Various utility functions.

For less common members, see the API documentation.

Documentation
-------------

Expand Down
7 changes: 7 additions & 0 deletions cli/wrappers/es6.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import * as $protobuf from "protobufjs";

%OUTPUT%

$protobuf.roots[%ROOT%] = $root;

export default $root;
6 changes: 3 additions & 3 deletions dist/protobuf.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/protobuf.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/protobuf.min.js

Large diffs are not rendered by default.

Binary file modified dist/protobuf.min.js.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion dist/protobuf.min.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,11 @@ function genVerifyKey(gen, field, ref) {
case "uint32":
case "sint32":
case "fixed32":
case "sfixed32":
case "sfixed32": gen
("if(!/^-?(?:0|[1-9]\\d*)$/.test(%s))", ref)
("return%j", invalid(field, "integer key"));
break;
case "bool":
case "bool": gen
("if(!/^true|false|0|1$/.test(%s))", ref)
("return%j", invalid(field, "boolean key"));
break;
Expand Down
2 changes: 1 addition & 1 deletion types/protobuf.js.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* protobuf.js v6.1.0 TypeScript definitions
* Generated Sun, 11 Dec 2016 23:22:51 UTC
* Generated Mon, 12 Dec 2016 00:01:07 UTC
*/
declare module "protobufjs" {

Expand Down

0 comments on commit 28a1d26

Please sign in to comment.