Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
134 commits
Select commit Hold shift + click to select a range
6e9258f
Initial
var-const Oct 23, 2019
b3050b8
Wip
var-const Oct 23, 2019
344d12c
wip
var-const Oct 23, 2019
10060e7
short class name
var-const Oct 23, 2019
570003e
Stash
var-const Oct 23, 2019
6eda997
Has works... in a horrible way
var-const Oct 24, 2019
dc450a2
Beginnings of indentation
var-const Oct 24, 2019
302a6af
oneof wip
var-const Oct 24, 2019
120b260
Cleanup wip
var-const Oct 24, 2019
96ef073
Works, except for oneofs
var-const Oct 24, 2019
57550ee
Oneoffs work, need cleanup
var-const Oct 25, 2019
d344059
Oneoffs really work, need cleanup
var-const Oct 25, 2019
722f4f1
Quick fixes to indentation
var-const Oct 25, 2019
ad77d37
Small compatibility fix
var-const Oct 25, 2019
47ebb4c
Omit zeroed primitives
var-const Oct 25, 2019
9888218
Print short names for oneofs; oneof is not properly recursive at the …
var-const Oct 25, 2019
b9fd54c
Sort by field, plus small fixes
var-const Oct 25, 2019
07b2644
Only print the name of the root proto
var-const Oct 25, 2019
e1cc8b7
Move more printing logic to C++
var-const Oct 25, 2019
d135716
small cleanup
var-const Oct 25, 2019
80b8d57
Forgotten -- omit empty arrays
var-const Oct 25, 2019
1ff2bc2
Forgotten -- omit empty arrays
var-const Oct 25, 2019
74ce60e
Can print simple messages conformingly
var-const Oct 25, 2019
460a128
Try new printer on more message types
var-const Oct 25, 2019
b6eea9d
Hacky way to avoid printing empty ("unset") nested messages
var-const Oct 25, 2019
816f86a
Add TODOs
var-const Oct 25, 2019
8b28d73
Print bytes correctly
var-const Oct 25, 2019
17c1aea
Enums wip
var-const Oct 25, 2019
c21d306
is_root
var-const Oct 25, 2019
91a9268
is_root
var-const Oct 26, 2019
522e89c
Enums work
var-const Oct 26, 2019
44f8f4b
Omit empty fields
var-const Oct 27, 2019
af922a2
Print arrays in a compatible way
var-const Oct 27, 2019
5e7720d
Diffing
var-const Oct 27, 2019
061ff8b
Compatibility wip
var-const Oct 27, 2019
28e32f0
Remove obsolete function
var-const Oct 27, 2019
2ccea68
Compatibility 1 -- generted descriptions always have the same size
var-const Oct 28, 2019
66b6d12
Better diffing, down to 10 non-compatible logs
var-const Oct 28, 2019
b567612
Fix empty messages, need to fix nested enums
var-const Oct 28, 2019
d36094b
stash
var-const Oct 28, 2019
3cc183a
Refactoring wip
var-const Oct 28, 2019
1719a16
Move function definitions to source file wip
var-const Oct 28, 2019
b0c8485
Move function definitions to source file wip
var-const Oct 28, 2019
df75f50
Refactor enums
var-const Oct 28, 2019
c319561
Down to 5 differing log messages
var-const Oct 28, 2019
ef4a8d5
Remove some cruft
var-const Oct 28, 2019
04011b0
Full compatibility!
var-const Oct 28, 2019
1e2d84f
Cleanup/simplify C++
var-const Oct 28, 2019
cb6345d
small cleanup
var-const Oct 28, 2019
ac49646
Refactor indent
var-const Oct 28, 2019
ed09eba
Refactoring long methods
var-const Oct 28, 2019
c050cd1
wip
var-const Oct 28, 2019
7b20acf
Use helper functions in C++ code
var-const Oct 28, 2019
a1e1ce2
Use kwargs
var-const Oct 28, 2019
b6810e3
Move indentation down
var-const Oct 28, 2019
4d09f41
Wrap lines
var-const Oct 28, 2019
ac90f8e
Fix formatting
var-const Oct 28, 2019
1e86112
Small changes to formatting
var-const Oct 28, 2019
2326154
Comments and renamings
var-const Oct 29, 2019
71306f0
Refactor oneoffs
var-const Oct 29, 2019
bb4c31a
Function comments
var-const Oct 29, 2019
5a39435
Format
var-const Oct 29, 2019
67ecea7
Fixup
var-const Oct 29, 2019
cd4fe2a
Comments and small cleanup
var-const Oct 29, 2019
5bea8ba
Comment
var-const Oct 29, 2019
df20f2c
Use new code for pretty-printing of Messages
var-const Oct 29, 2019
121fda6
Quick fix
var-const Oct 29, 2019
4795b1a
Merge branch 'master' into varconst/nanopb-pretty-printing3
var-const Oct 29, 2019
70ebf0a
Fix newlines
var-const Oct 29, 2019
e4f27d6
Fix newlines
var-const Oct 29, 2019
3794243
Small fixes
var-const Oct 29, 2019
4ee63bf
Remove extra include
var-const Oct 29, 2019
53b5775
Revert accidental
var-const Oct 29, 2019
1ceabfa
Linter
var-const Oct 29, 2019
e0f011c
Wip
var-const Oct 29, 2019
d6d50d0
Remove remaining test dependencies
var-const Oct 29, 2019
5ea5adb
Fix CMake build
var-const Oct 29, 2019
759eaee
Merge branch 'varconst/nanopb-pretty-printing3' into varconst/remove-…
var-const Oct 29, 2019
29338bf
Fix CMake build
var-const Oct 29, 2019
446c0c4
Fix fuzz build and remove its dependency on ProtoCompiler
var-const Oct 29, 2019
ecb801c
Merge branch 'master' into varconst/nanopb-pretty-printing3
var-const Oct 29, 2019
89dab1c
Merge branch 'varconst/nanopb-pretty-printing3' into varconst/remove-…
var-const Oct 29, 2019
2b1aba5
Fix fuzz build
var-const Oct 29, 2019
82347d2
Review feedback 1
var-const Oct 30, 2019
691eb37
Enums
var-const Oct 30, 2019
4608eb4
Renamings
var-const Oct 30, 2019
6a09576
FileGenerationRequest
var-const Oct 30, 2019
b0b0fcf
Stash
var-const Oct 30, 2019
2e12bfc
Restructuring wip
var-const Oct 31, 2019
e721096
Moved everything to the new file
var-const Oct 31, 2019
bbc3874
Refactoring
var-const Oct 31, 2019
ada2332
Comments
var-const Oct 31, 2019
fd041ab
Comments 2
var-const Oct 31, 2019
4781d40
Move C++ file, add comments
var-const Nov 1, 2019
07a1217
Merge branch 'master' into varconst/nanopb-pretty-printing3
var-const Nov 1, 2019
a786650
Add a link to protobuf comments
var-const Nov 1, 2019
a6f5579
Dedent 1
var-const Nov 1, 2019
227a40c
Format?
var-const Nov 1, 2019
fbf6fb6
Use format throughout?
var-const Nov 1, 2019
29e6d64
style.sh equivalent
var-const Nov 1, 2019
3bfa48f
Merge branch 'varconst/nanopb-pretty-printing3' into varconst/remove-…
var-const Nov 1, 2019
9c3999f
Comment
var-const Nov 1, 2019
1cd73be
Merge branch 'varconst/nanopb-pretty-printing3' into varconst/remove-…
var-const Nov 1, 2019
63a4daf
3 tests left
var-const Nov 2, 2019
ed89a80
All printing tests
var-const Nov 2, 2019
e4694c1
style.sh
var-const Nov 2, 2019
f9491a5
Fix EnumToMember declaration formatting
var-const Nov 2, 2019
6d9bac1
Split out pretty-printing testing
var-const Nov 2, 2019
7812ab2
Merge branch 'varconst/nanopb-pretty-printing3' into varconst/remove-…
var-const Nov 2, 2019
5fe253c
Fix
var-const Nov 2, 2019
19ae83a
Merge branch 'varconst/nanopb-pretty-printing3' into varconst/remove-…
var-const Nov 2, 2019
75a5a54
Review feedback
var-const Nov 2, 2019
90f82d2
Put generated protos into nanopb namespace
var-const Nov 6, 2019
41ed526
Revert "Put generated protos into nanopb namespace"
var-const Nov 6, 2019
59aff6f
Put pretty-printing support into nanopb namespace
var-const Nov 6, 2019
362b518
Test matcher
var-const Nov 6, 2019
67a7bc7
Review feedback 1
var-const Nov 6, 2019
1d39ae2
Review feedback 2 -- nicer linebreaks
var-const Nov 6, 2019
8e1a83f
Review feedback 3
var-const Nov 6, 2019
ed50e68
Unreindent
var-const Nov 6, 2019
ef70790
Rename Python file
var-const Nov 6, 2019
1c0d7c0
Remove Generator
var-const Nov 7, 2019
3d0a213
Added a test
var-const Nov 7, 2019
5b4df7c
Merge branch 'master' into varconst/nanopb-pretty-printing3
var-const Nov 7, 2019
259b055
Merge branch 'varconst/nanopb-pretty-printing3' into varconst/remove-…
var-const Nov 7, 2019
2c165dd
Require explicitly calling `ToString` on messages in pretty-printing
var-const Nov 7, 2019
6b88e58
Some forgotten renamings
var-const Nov 7, 2019
80d1dbd
Restore accidentally reverted
var-const Nov 7, 2019
46b0cd9
Fix previous commit
var-const Nov 7, 2019
421b704
Merge branch 'master' into varconst/nanopb-pretty-printing3
var-const Nov 7, 2019
d928591
Add a TODO on floating point precision
var-const Nov 7, 2019
8fc3ae1
Merge branch 'master' into varconst/nanopb-pretty-printing3
var-const Nov 7, 2019
948bd5b
Merge branch 'varconst/nanopb-pretty-printing3' into varconst/remove-…
var-const Nov 8, 2019
86a19b7
Merge branch 'master' into varconst/remove-objc-proto
var-const Nov 8, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions FirebaseFirestore.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ Google Cloud Firestore is a NoSQL document database built for automatic scaling,

s.dependency 'gRPC-C++', '0.0.9'
s.dependency 'leveldb-library', '~> 1.22'
s.dependency 'Protobuf', '~> 3.9', '>= 3.9.2'
s.dependency 'nanopb', '~> 0.3.901'

s.ios.frameworks = 'MobileCoreServices', 'SystemConfiguration'
Expand All @@ -86,7 +85,6 @@ Google Cloud Firestore is a NoSQL document database built for automatic scaling,
'GCC_C_LANGUAGE_STANDARD' => 'c99',
'GCC_PREPROCESSOR_DEFINITIONS' =>
"FIRFirestore_VERSION=#{s.version} " +
'GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1 ' +
# The nanopb pod sets these defs, so we must too. (We *do* require 16bit
# (or larger) fields, so we'd have to set at least PB_FIELD_16BIT
# anyways.)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@
# XCode build target Firestore_FuzzTests_iOS that executes this script. XCode
# defines these environment variables and makes them available to the script.

if ! [ -x "$(command -v protoc)" ]; then
echo "This scripts needs the protoc command to be on the PATH."
echo "Please install protobuf (e.g., \`brew install protobuf\` on Mac)."
exit 1
fi

# Directory that contains the text protos to convert to binary protos.
text_protos_dir="${SCRIPT_INPUT_FILE_0}"

Expand Down Expand Up @@ -51,7 +57,7 @@ for text_proto_file in "${text_protos_dir}"/*; do
# Run the conversion.
echo "Converting file: ${file_name} (type: ${message_type})"
echo "${file_content}" \
| "${SRCROOT}/Pods/!ProtoCompiler/protoc" \
| protoc \
-I"${SRCROOT}/../../Firestore/Protos/protos" \
--encode=google.firestore.v1."${message_type}" \
google/firestore/v1/document.proto > "${binary_protos_dir}/${file_name}"
Expand Down
1 change: 0 additions & 1 deletion Firestore/Example/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ if is_platform(:ios)
platform :ios, '9.0'

pod 'LibFuzzer', :podspec => 'LibFuzzer.podspec', :inhibit_warnings => true
pod '!ProtoCompiler'
end
end
end
Expand Down
40 changes: 20 additions & 20 deletions Firestore/Example/Tests/Local/FSTLevelDBMigrationsTests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@
#include <string>
#include <vector>

#import "Firestore/Protos/objc/firestore/local/Mutation.pbobjc.h"
#import "Firestore/Protos/objc/firestore/local/Target.pbobjc.h"

#include "Firestore/Protos/nanopb/firestore/local/mutation.nanopb.h"
#include "Firestore/core/src/firebase/firestore/local/leveldb_key.h"
#include "Firestore/core/src/firebase/firestore/local/leveldb_migrations.h"
#include "Firestore/core/src/firebase/firestore/local/leveldb_query_cache.h"
#include "Firestore/core/src/firebase/firestore/nanopb/message.h"
#include "Firestore/core/src/firebase/firestore/util/ordered_code.h"
#include "Firestore/core/src/firebase/firestore/util/path.h"
#include "Firestore/core/test/firebase/firestore/local/persistence_testing.h"
Expand All @@ -37,7 +36,8 @@
NS_ASSUME_NONNULL_BEGIN

using firebase::firestore::Error;
using firebase::firestore::firestore_client_TargetGlobal;
using firebase::firestore::firestore_client_MutationQueue;
using firebase::firestore::firestore_client_WriteBatch;
using firebase::firestore::local::LevelDbCollectionParentKey;
using firebase::firestore::local::LevelDbDir;
using firebase::firestore::local::LevelDbDocumentMutationKey;
Expand Down Expand Up @@ -272,25 +272,25 @@ - (void)testRemovesMutationBatches {
{
LevelDbTransaction transaction(_db.get(), "Setup Foo");
// User 'foo' has two acknowledged mutations and one that is pending.
FSTPBMutationQueue *fooQueue = [[FSTPBMutationQueue alloc] init];
fooQueue.lastAcknowledgedBatchId = 2;
Message<firestore_client_MutationQueue> fooQueue;
fooQueue->last_acknowledged_batch_id = 2;
std::string fooKey = LevelDbMutationQueueKey::Key("foo");
transaction.Put(fooKey, fooQueue);

FSTPBWriteBatch *fooBatch1 = [[FSTPBWriteBatch alloc] init];
fooBatch1.batchId = 1;
Message<firestore_client_WriteBatch> fooBatch1;
fooBatch1->batch_id = 1;
std::string fooBatchKey1 = LevelDbMutationKey::Key("foo", 1);
transaction.Put(fooBatchKey1, fooBatch1);
transaction.Put(LevelDbDocumentMutationKey::Key("foo", testWriteFoo, 1), emptyBuffer);

FSTPBWriteBatch *fooBatch2 = [[FSTPBWriteBatch alloc] init];
fooBatch2.batchId = 2;
Message<firestore_client_WriteBatch> fooBatch2;
fooBatch2->batch_id = 2;
std::string fooBatchKey2 = LevelDbMutationKey::Key("foo", 2);
transaction.Put(fooBatchKey2, fooBatch2);
transaction.Put(LevelDbDocumentMutationKey::Key("foo", testWriteFoo, 2), emptyBuffer);

FSTPBWriteBatch *fooBatch3 = [[FSTPBWriteBatch alloc] init];
fooBatch3.batchId = 5;
Message<firestore_client_WriteBatch> fooBatch3;
fooBatch3->batch_id = 5;
std::string fooBatchKey3 = LevelDbMutationKey::Key("foo", 5);
transaction.Put(fooBatchKey3, fooBatch3);
transaction.Put(LevelDbDocumentMutationKey::Key("foo", testWritePending, 5), emptyBuffer);
Expand All @@ -301,20 +301,20 @@ - (void)testRemovesMutationBatches {
{
LevelDbTransaction transaction(_db.get(), "Setup Bar");
// User 'bar' has one acknowledged mutation and one that is pending
FSTPBMutationQueue *barQueue = [[FSTPBMutationQueue alloc] init];
barQueue.lastAcknowledgedBatchId = 3;
Message<firestore_client_MutationQueue> barQueue;
barQueue->last_acknowledged_batch_id = 3;
std::string barKey = LevelDbMutationQueueKey::Key("bar");
transaction.Put(barKey, barQueue);

FSTPBWriteBatch *barBatch1 = [[FSTPBWriteBatch alloc] init];
barBatch1.batchId = 3;
Message<firestore_client_WriteBatch> barBatch1;
barBatch1->batch_id = 3;
std::string barBatchKey1 = LevelDbMutationKey::Key("bar", 3);
transaction.Put(barBatchKey1, barBatch1);
transaction.Put(LevelDbDocumentMutationKey::Key("bar", testWriteBar, 3), emptyBuffer);
transaction.Put(LevelDbDocumentMutationKey::Key("bar", testWriteBaz, 3), emptyBuffer);

FSTPBWriteBatch *barBatch2 = [[FSTPBWriteBatch alloc] init];
barBatch2.batchId = 4;
Message<firestore_client_WriteBatch> barBatch2;
barBatch2->batch_id = 4;
std::string barBatchKey2 = LevelDbMutationKey::Key("bar", 4);
transaction.Put(barBatchKey2, barBatch2);
transaction.Put(LevelDbDocumentMutationKey::Key("bar", testWritePending, 4), emptyBuffer);
Expand All @@ -325,8 +325,8 @@ - (void)testRemovesMutationBatches {
{
LevelDbTransaction transaction(_db.get(), "Setup Empty");
// User 'empty' has no mutations
FSTPBMutationQueue *emptyQueue = [[FSTPBMutationQueue alloc] init];
emptyQueue.lastAcknowledgedBatchId = -1;
Message<firestore_client_MutationQueue> emptyQueue;
emptyQueue->last_acknowledged_batch_id = -1;
std::string emptyKey = LevelDbMutationQueueKey::Key("empty");
transaction.Put(emptyKey, emptyQueue);
transaction.Commit();
Expand Down
37 changes: 22 additions & 15 deletions Firestore/Example/Tests/Local/FSTLevelDBTransactionTests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,27 @@
// TODO(wilhuff): move this to the top once the test filename matches
#include "Firestore/core/src/firebase/firestore/local/leveldb_transaction.h"

#import "Firestore/Protos/objc/firestore/local/Mutation.pbobjc.h"
#import "Firestore/Protos/objc/firestore/local/Target.pbobjc.h"

#include "Firestore/Protos/nanopb/firestore/local/mutation.nanopb.h"
#include "Firestore/Protos/nanopb/firestore/local/target.nanopb.h"
#include "Firestore/core/src/firebase/firestore/local/leveldb_key.h"
#include "Firestore/core/src/firebase/firestore/nanopb/byte_string.h"
#include "Firestore/core/src/firebase/firestore/nanopb/message.h"
#include "Firestore/core/src/firebase/firestore/nanopb/reader.h"
#include "Firestore/core/src/firebase/firestore/util/path.h"
#include "Firestore/core/test/firebase/firestore/local/persistence_testing.h"
#include "absl/strings/string_view.h"
#include "leveldb/db.h"

NS_ASSUME_NONNULL_BEGIN

using firebase::firestore::firestore_client_Target;
using firebase::firestore::firestore_client_WriteBatch;
using firebase::firestore::local::LevelDbDir;
using firebase::firestore::local::LevelDbMutationKey;
using firebase::firestore::local::LevelDbTransaction;
using firebase::firestore::nanopb::ByteString;
using firebase::firestore::nanopb::Message;
using firebase::firestore::nanopb::StringReader;
using firebase::firestore::util::Path;
using leveldb::DB;
using leveldb::Options;
Expand Down Expand Up @@ -199,22 +206,22 @@ - (void)testMutateDeleted {
- (void)testProtobufSupport {
LevelDbTransaction transaction(_db.get(), "testProtobufSupport");

FSTPBTarget *target = [FSTPBTarget message];
target.targetId = 1;
target.lastListenSequenceNumber = 2;
Message<firestore_client_Target> target;
target->target_id = 1;
target->last_listen_sequence_number = 2;

std::string key("theKey");
transaction.Put(key, target);

std::string value;
Status status = transaction.Get("theKey", &value);
NSData *result = [[NSData alloc] initWithBytesNoCopy:(void *)value.data()
length:value.size()
freeWhenDone:NO];
NSError *error;
FSTPBTarget *parsed = [FSTPBTarget parseFromData:result error:&error];
XCTAssertNil(error);
XCTAssertTrue([target isEqual:parsed]);

ByteString bytes{value};
StringReader reader{bytes};
auto parsed = Message<firestore_client_Target>::TryParse(&reader);
XCTAssertTrue(reader.ok());
XCTAssertEqual(target->target_id, parsed->target_id);
XCTAssertEqual(target->last_listen_sequence_number, parsed->last_listen_sequence_number);
}

- (void)testCanIterateAndDelete {
Expand Down Expand Up @@ -286,8 +293,8 @@ - (void)testDeletingAheadOfAnIterator {

- (void)testToString {
std::string key = LevelDbMutationKey::Key("user1", 42);
FSTPBWriteBatch *message = [FSTPBWriteBatch message];
message.batchId = 42;
Message<firestore_client_WriteBatch> message;
message->batch_id = 42;

LevelDbTransaction transaction(_db.get(), "testToString");
std::string description = transaction.ToString();
Expand Down
Loading