Explorar el Código

Integrate review comments.

Josh Haberman hace 9 años
padre
commit
7726cd207c

+ 3 - 1
js/README.md

@@ -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.
 2. The Protocol Compiler `protoc`.  This translates `.proto` files
    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

+ 1 - 1
js/binary/utils_test.js

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

+ 6 - 0
js/commonjs/export.js

@@ -5,6 +5,12 @@
  * 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.BinaryReader = jspb.BinaryReader;
 exports.BinaryWriter = jspb.BinaryWriter;

+ 4 - 0
js/commonjs/export_asserts.js

@@ -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

+ 4 - 4
js/commonjs/rewrite_tests_for_commonjs.js

@@ -46,21 +46,21 @@ lineReader.on('line', function(line) {
     if (module) {  // Skip goog.require() lines before the first directive.
       var full_sym = is_require[1];
       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) {
     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 global = Function('return this')();");
       console.log("");
       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("-", "_");
     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] + "');");
     }
   } else {