Integrate review comments.

pull/1215/head
Josh Haberman 9 years ago
parent 5195b7f296
commit 7726cd207c
  1. 4
      js/README.md
  2. 2
      js/binary/utils_test.js
  3. 6
      js/commonjs/export.js
  4. 4
      js/commonjs/export_asserts.js
  5. 8
      js/commonjs/rewrite_tests_for_commonjs.js

@ -22,7 +22,9 @@ To use Protocol Buffers with JavaScript, you need two main components:
`npm install google-protobuf`, or use the files in this directory. `npm install google-protobuf`, or use the files in this directory.
2. The Protocol Compiler `protoc`. This translates `.proto` files 2. The Protocol Compiler `protoc`. This translates `.proto` files
into `.js` files. The compiler is not currently available via into `.js` files. The compiler is not currently available via
npm -- you must download and compile it from GitHub or a tarball. npm, but you can download a pre-built binary
[on GitHub](https://github.com/google/protobuf/releases)
(look for the `protoc-*.zip` files under **Downloads**).
Setup Setup

@ -39,7 +39,7 @@
goog.require('goog.crypt.base64'); goog.require('goog.crypt.base64');
goog.require('goog.testing.asserts'); goog.require('goog.testing.asserts');
// CommonJS-LoadFromFile: google_protobuf // CommonJS-LoadFromFile: googleProtobuf
goog.require('jspb.BinaryConstants'); goog.require('jspb.BinaryConstants');
goog.require('jspb.BinaryWriter'); goog.require('jspb.BinaryWriter');
goog.require('jspb.utils'); goog.require('jspb.utils');

@ -5,6 +5,12 @@
* the google-protobuf.js file that we build at distribution time. * the google-protobuf.js file that we build at distribution time.
*/ */
goog.require('goog.object');
goog.require('jspb.BinaryReader');
goog.require('jspb.BinaryWriter');
goog.require('jspb.ExtensionFieldInfo');
goog.require('jspb.Message');
exports.Message = jspb.Message; exports.Message = jspb.Message;
exports.BinaryReader = jspb.BinaryReader; exports.BinaryReader = jspb.BinaryReader;
exports.BinaryWriter = jspb.BinaryWriter; exports.BinaryWriter = jspb.BinaryWriter;

@ -30,4 +30,8 @@ for (var key in global) {
} }
} }
// The COMPILED variable is set by Closure compiler to "true" when it compiles
// JavaScript, so in practice this is equivalent to "exports.COMPILED = true".
// This will disable some debugging functionality in debug.js. We could
// investigate whether this can/should be enabled in CommonJS builds.
exports.COMPILED = COMPILED exports.COMPILED = COMPILED

@ -46,21 +46,21 @@ lineReader.on('line', function(line) {
if (module) { // Skip goog.require() lines before the first directive. if (module) { // Skip goog.require() lines before the first directive.
var full_sym = is_require[1]; var full_sym = is_require[1];
var sym = tryStripPrefix(full_sym, pkg); var sym = tryStripPrefix(full_sym, pkg);
console.log("google_protobuf.exportSymbol('" + full_sym + "', " + module + sym + ', global);'); console.log("googleProtobuf.exportSymbol('" + full_sym + "', " + module + sym + ', global);');
} }
} else if (is_loadfromfile) { } else if (is_loadfromfile) {
if (!module) { if (!module) {
console.log("var google_protobuf = require('google-protobuf');"); console.log("var googleProtobuf = require('google-protobuf');");
console.log("var asserts = require('closure_asserts_commonjs');"); console.log("var asserts = require('closure_asserts_commonjs');");
console.log("var global = Function('return this')();"); console.log("var global = Function('return this')();");
console.log(""); console.log("");
console.log("// Bring asserts into the global namespace."); console.log("// Bring asserts into the global namespace.");
console.log("google_protobuf.object.extend(global, asserts);"); console.log("googleProtobuf.object.extend(global, asserts);");
} }
module = is_loadfromfile[1].replace("-", "_"); module = is_loadfromfile[1].replace("-", "_");
pkg = is_loadfromfile[2]; pkg = is_loadfromfile[2];
if (module != "google_protobuf") { // We unconditionally require this in the header. if (module != "googleProtobuf") { // We unconditionally require this in the header.
console.log("var " + module + " = require('" + is_loadfromfile[1] + "');"); console.log("var " + module + " = require('" + is_loadfromfile[1] + "');");
} }
} else { } else {

Loading…
Cancel
Save