Skip to content

Commit 7d0d997

Browse files
authored
Merge pull request #7698 from haberman/sync-stage
Integrate from Piper for C++, Java, and Python
2 parents 3e0159a + bd355eb commit 7d0d997

4 files changed

Lines changed: 32 additions & 28 deletions

File tree

gulpfile.js

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,16 @@ gulp.task('genproto_group1_closure', function (cb) {
7171
});
7272
});
7373

74-
gulp.task('genproto_group2_closure', function (cb) {
75-
exec(protoc + ' --experimental_allow_proto3_optional --js_out=library=testproto_libs2,binary:. -I ../src -I . -I commonjs ' + group2Protos.join(' '),
76-
function (err, stdout, stderr) {
77-
console.log(stdout);
78-
console.log(stderr);
79-
cb(err);
80-
});
74+
gulp.task('genproto_group2_closure', function(cb) {
75+
exec(
76+
protoc +
77+
' --experimental_allow_proto3_optional --js_out=library=testproto_libs2,binary:. -I ../src -I . -I commonjs ' +
78+
group2Protos.join(' '),
79+
function(err, stdout, stderr) {
80+
console.log(stdout);
81+
console.log(stderr);
82+
cb(err);
83+
});
8184
});
8285

8386
gulp.task('genproto_well_known_types_commonjs', function (cb) {
@@ -98,13 +101,16 @@ gulp.task('genproto_group1_commonjs', function (cb) {
98101
});
99102
});
100103

101-
gulp.task('genproto_group2_commonjs', function (cb) {
102-
exec('mkdir -p commonjs_out && ' + protoc + ' --experimental_allow_proto3_optional --js_out=import_style=commonjs,binary:commonjs_out -I ../src -I commonjs -I . ' + group2Protos.join(' '),
103-
function (err, stdout, stderr) {
104-
console.log(stdout);
105-
console.log(stderr);
106-
cb(err);
107-
});
104+
gulp.task('genproto_group2_commonjs', function(cb) {
105+
exec(
106+
'mkdir -p commonjs_out && ' + protoc +
107+
' --experimental_allow_proto3_optional --js_out=import_style=commonjs,binary:commonjs_out -I ../src -I commonjs -I . ' +
108+
group2Protos.join(' '),
109+
function(err, stdout, stderr) {
110+
console.log(stdout);
111+
console.log(stderr);
112+
cb(err);
113+
});
108114
});
109115

110116
gulp.task('genproto_commonjs_wellknowntypes', function (cb) {

proto3_test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ describe('proto3Test', function() {
130130
assertEquals(msg.getSingularBytes_asU8().length, 0);
131131
assertEquals(msg.getSingularBytes_asB64(), '');
132132

133-
assertEquals(msg.getSingularForeignEnum(),
134-
proto.jspb.test.Proto3Enum.PROTO3_FOO);
133+
assertEquals(
134+
msg.getSingularForeignEnum(), proto.jspb.test.Proto3Enum.PROTO3_FOO);
135135
assertEquals(msg.getSingularForeignMessage(), undefined);
136136
assertEquals(msg.getSingularForeignMessage(), undefined);
137137

@@ -201,7 +201,7 @@ describe('proto3Test', function() {
201201
assertTrue(msg.hasOptionalInt64());
202202

203203
assertFalse(msg.hasOptionalString());
204-
msg.setOptionalString("");
204+
msg.setOptionalString('');
205205
assertTrue(msg.hasOptionalString());
206206

207207
// Now the proto will have a non-zero size, even though its values are 0.
@@ -224,7 +224,7 @@ describe('proto3Test', function() {
224224
/**
225225
* Test that all fields can be set ,and read via a serialization roundtrip.
226226
*/
227-
it('testProto3FieldSetGet', function () {
227+
it('testProto3FieldSetGet', function() {
228228
var msg = new proto.jspb.test.TestProto3();
229229

230230
msg.setSingularInt32(-42);
@@ -288,8 +288,8 @@ describe('proto3Test', function() {
288288
assertEquals(msg.getSingularString(), 'hello world');
289289
assertEquals(true, bytesCompare(msg.getSingularBytes(), BYTES));
290290
assertEquals(msg.getSingularForeignMessage().getC(), 16);
291-
assertEquals(msg.getSingularForeignEnum(),
292-
proto.jspb.test.Proto3Enum.PROTO3_BAR);
291+
assertEquals(
292+
msg.getSingularForeignEnum(), proto.jspb.test.Proto3Enum.PROTO3_BAR);
293293

294294
assertElementsEquals(msg.getRepeatedInt32List(), [-42]);
295295
assertElementsEquals(msg.getRepeatedInt64List(), [-0x7fffffff00000000]);

proto3_test.proto

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@
3030

3131
syntax = "proto3";
3232

33-
import "testbinary.proto";
34-
3533
package jspb.test;
3634

35+
import "testbinary.proto";
36+
3737
message TestProto3 {
3838
int32 singular_int32 = 1;
3939
int64 singular_int64 = 2;
@@ -71,7 +71,7 @@ message TestProto3 {
7171
optional bytes optional_bytes = 135;
7272

7373
optional ForeignMessage optional_foreign_message = 136;
74-
optional Proto3Enum optional_foreign_enum =137;
74+
optional Proto3Enum optional_foreign_enum = 137;
7575

7676
repeated int32 repeated_int32 = 31;
7777
repeated int64 repeated_int64 = 32;
@@ -92,7 +92,6 @@ message TestProto3 {
9292
repeated ForeignMessage repeated_foreign_message = 49;
9393
repeated Proto3Enum repeated_foreign_enum = 52;
9494

95-
9695
oneof oneof_field {
9796
uint32 oneof_uint32 = 111;
9897
ForeignMessage oneof_foreign_message = 112;

src/google/protobuf/compiler/js/js_generator.cc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2689,8 +2689,7 @@ void Generator::GenerateClassField(const GeneratorOptions& options,
26892689
"\n"
26902690
"\n",
26912691
"index", JSFieldIndex(field), "oneofgroup",
2692-
(InRealOneof(field) ? (", " + JSOneofArray(options, field))
2693-
: ""));
2692+
(InRealOneof(field) ? (", " + JSOneofArray(options, field)) : ""));
26942693

26952694
if (field->is_repeated()) {
26962695
GenerateRepeatedMessageHelperMethods(options, printer, field);
@@ -2995,8 +2994,8 @@ void Generator::GenerateRepeatedMessageHelperMethods(
29952994
"\n"
29962995
"\n",
29972996
"index", JSFieldIndex(field), "oneofgroup",
2998-
(InRealOneof(field) ? (", " + JSOneofArray(options, field)) : ""),
2999-
"ctor", GetMessagePath(options, field->message_type()));
2997+
(InRealOneof(field) ? (", " + JSOneofArray(options, field)) : ""), "ctor",
2998+
GetMessagePath(options, field->message_type()));
30002999
}
30013000

30023001
void Generator::GenerateClassExtensionFieldInfo(const GeneratorOptions& options,

0 commit comments

Comments
 (0)