diff options
author | Max Cai <maxtroy@google.com> | 2013-09-18 17:50:27 +0100 |
---|---|---|
committer | Max Cai <maxtroy@google.com> | 2013-09-20 18:42:11 +0100 |
commit | ee4410d551c43d800e821ffd220cc69535fef19e (patch) | |
tree | 3aacf0c67417abff9e14e00613bcbb3f9d915d81 /src/google/protobuf/compiler/javanano/javanano_helpers.h | |
parent | 71766127eb51a89fd0b2aee24d76dccf0da7e2eb (diff) |
Add some bitfield helper methods from 2.4
Change-Id: Ib9bb549602f71a451d2107fb04de17877553860e
Diffstat (limited to 'src/google/protobuf/compiler/javanano/javanano_helpers.h')
-rw-r--r-- | src/google/protobuf/compiler/javanano/javanano_helpers.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/google/protobuf/compiler/javanano/javanano_helpers.h b/src/google/protobuf/compiler/javanano/javanano_helpers.h index 430969bf..03fd4347 100644 --- a/src/google/protobuf/compiler/javanano/javanano_helpers.h +++ b/src/google/protobuf/compiler/javanano/javanano_helpers.h @@ -138,6 +138,31 @@ string EmptyArrayName(const Params& params, const FieldDescriptor* field); string DefaultValue(const Params& params, const FieldDescriptor* field); + +// Methods for shared bitfields. + +// Gets the name of the shared bitfield for the given index. +string GetBitFieldName(int index); + +// Gets the name of the shared bitfield for the given bit index. +// Effectively, GetBitFieldName(bit_index / 32) +string GetBitFieldNameForBit(int bit_index); + +// Generates the java code for the expression that returns the boolean value +// of the bit of the shared bitfields for the given bit index. +// Example: "((bitField1_ & 0x04) == 0x04)" +string GenerateGetBit(int bit_index); + +// Generates the java code for the expression that sets the bit of the shared +// bitfields for the given bit index. +// Example: "bitField1_ = (bitField1_ | 0x04)" +string GenerateSetBit(int bit_index); + +// Generates the java code for the expression that clears the bit of the shared +// bitfields for the given bit index. +// Example: "bitField1_ = (bitField1_ & ~0x04)" +string GenerateClearBit(int bit_index); + } // namespace javanano } // namespace compiler } // namespace protobuf |