Client: cpp
Patch: Diwaker Gupta
In CPP, all optional fields are guarded by the isset helper struct. On Java, however, the generated code takes advantage of nullable types: for containers, structs, exceptions, enums, and, notably, strings, the generator elides explicit use of an "isset" bit vector and instead emits checks of the form "field null". This leads to varying behavior between the two languages: an optional string field with a default value will have {{isset[fieldid]}} false on C, but the equivalent test in Java will be true.
git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1236529 13f79535-47bb-0310-9956-ffa450edef68
- Add a new method to t_java_generator that generates a .equals() method.
- Add a correct but useless implementation of hashCode for structs.
(This is required by conventino when overriding .equals().)
- Add java_package to DebugProtoTest and OptionalRequiredTest.
- Add a new structure to OptionalRequiredTest to assist testing the behavior
of .equals() with respect to null and unset fields.
- Clean up test/java/build.xml a bit. (It still has a ways to go.)
- Add EqualityTest.java to test .equals().
- Add IdentityTest.java to test that writing and reading a structure
preserves equality.
Tested by runnint atn test.
I also looked at the generated code for OptionalRequiredTest.thrift.
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665541 13f79535-47bb-0310-9956-ffa450edef68
- Make the C++ generator use program->get_namespace("cpp")
instead of program->get_cpp_namespace()
- Eliminate the explicit "cpp_namespace" in t_program.
- Deprecate the cpp_namespace token.
- Update example .thrift files and syntax files.
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665513 13f79535-47bb-0310-9956-ffa450edef68
Summary:
Add a Makefile.am in the test directory that runs some of the test programs
when "make check" is executed. Also removed some obsolete comments.
Reviewed By: mcslee
Test Plan:
Ran make check, saw all tests pass.
Ran make install, saw no test programs installed.
Ran ./cleanup.sh, saw a pristine workspace.
Revert Plan: ok
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665458 13f79535-47bb-0310-9956-ffa450edef68
Summary:
- TDenseProtocol now includes a part of the struct fingerprint in
the serialized message, to protect from unserialzing trash.
- A lot of cleanups and commenting for TDenseProtocol.
- A lot of test cases for same.
Reviewed By: mcslee
Test Plan: test/DenseProtoTest.cpp
Revert Plan: ok
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665257 13f79535-47bb-0310-9956-ffa450edef68
Summary:
TMemoryBuffer already has the necessary plubming to work with C++ strings.
This revision implements that functionality with a few wrapper methods.
Removed TStringBuffer as it should no longer be required (and it is tricky
to safely inherit from a class that has a non-virtual destructor).
Also refactored the TMemoryBuffer constructors a bit.
Reviewed By: aditya, yunfang
Test Plan:
test/TMemoryBufferTest.cpp
Revert Plan: ok
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665213 13f79535-47bb-0310-9956-ffa450edef68
Summary:
Merging a patch from Andy Lutomirsky.
- Allow fields to be marked "required" or "optional" (only affects C++).
- Thrift structs now have operator ==.
Reviewed By: mcslee
Test Plan: test/OptionalRequiredTest.cpp
Revert Plan: ok
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665202 13f79535-47bb-0310-9956-ffa450edef68