diff --git a/CHANGES.txt b/CHANGES.txt index ed7ed33b4b..945423ebc0 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,5 +1,5 @@ -2008-09-24 version 2.0.2: - +2008-09-29 version 2.0.2: + General * License changed from Apache 2.0 to New BSD. * It is now possible to define custom "options", which are basically @@ -28,12 +28,12 @@ predictable among other things. * TextFormat will no longer accept messages which contain multiple instances of a singular field. Previously, the latter instance - would overwrite the former. + would overwrite the former. * Now works on systems that don't have hash_map. - Java - * Print @Override annotation in generated code where appropriate. - + Java + * Print @Override annotation in generated code where appropriate. + Python * Strings now use the "unicode" type rather than the "str" type. String fields may still be assigned ASCII "str" values; they will @@ -42,55 +42,59 @@ raises an exception. For example: # No longer works (and never should have). message.some_repeated_field.foo = 1 - + + Windows + * We now build static libraries rather than DLLs by default on MSVC. + See vsprojects/readme.txt for more information. + 2008-08-15 version 2.0.1: - - protoc - * New flags --encode and --decode can be used to convert between protobuf text - format and binary format from the command-line. - * New flag --descriptor_set_out can be used to write FileDescriptorProtos for - all parsed files directly into a single output file. This is particularly - useful if you wish to parse .proto files from programs written in languages - other than C++: just run protoc as a background process and have it output - a FileDescriptorList, then parse that natively. - * Improved error message when an enum value's name conflicts with another - symbol defined in the enum type's scope, e.g. if two enum types declared - in the same scope have values with the same name. This is disallowed for + + protoc + * New flags --encode and --decode can be used to convert between protobuf text + format and binary format from the command-line. + * New flag --descriptor_set_out can be used to write FileDescriptorProtos for + all parsed files directly into a single output file. This is particularly + useful if you wish to parse .proto files from programs written in languages + other than C++: just run protoc as a background process and have it output + a FileDescriptorList, then parse that natively. + * Improved error message when an enum value's name conflicts with another + symbol defined in the enum type's scope, e.g. if two enum types declared + in the same scope have values with the same name. This is disallowed for compatibility with C++, but this wasn't clear from the error. - * Fixed absolute output paths on Windows. + * Fixed absolute output paths on Windows. * Allow trailing slashes in --proto_path mappings. - - C++ - * Reflection objects are now per-class rather than per-instance. To make this - possible, the Reflection interface had to be changed such that all methods - take the Message instance as a parameter. This change improves performance - significantly in memory-bandwidth-limited use cases, since it makes the - message objects smaller. Note that source-incompatible interface changes - like this will not be made again after the library leaves beta. + + C++ + * Reflection objects are now per-class rather than per-instance. To make this + possible, the Reflection interface had to be changed such that all methods + take the Message instance as a parameter. This change improves performance + significantly in memory-bandwidth-limited use cases, since it makes the + message objects smaller. Note that source-incompatible interface changes + like this will not be made again after the library leaves beta. * Heuristically detect sub-messages when printing unknown fields. - * Fix static initialization ordering bug that caused crashes at startup when + * Fix static initialization ordering bug that caused crashes at startup when compiling on Mac with static linking. - * Fixed TokenizerTest when compiling with -DNDEBUG on Linux. - * Fixed incorrect definition of kint32min. + * Fixed TokenizerTest when compiling with -DNDEBUG on Linux. + * Fixed incorrect definition of kint32min. * Fix bytes type setter to work with byte sequences with embedded NULLs. * Other irrelevant tweaks. - Java - * Fixed UnknownFieldSet's parsing of varints larger than 32 bits. - * Fixed TextFormat's parsing of "inf" and "nan". - * Fixed TextFormat's parsing of comments. - * Added info to Java POM that will be required when we upload the + Java + * Fixed UnknownFieldSet's parsing of varints larger than 32 bits. + * Fixed TextFormat's parsing of "inf" and "nan". + * Fixed TextFormat's parsing of comments. + * Added info to Java POM that will be required when we upload the package to a Maven repo. - Python - * MergeFrom(message) and CopyFrom(message) are now implemented. - * SerializeToString() raises an exception if the message is missing required - fields. - * Code organization improvements. - * Fixed doc comments for RpcController and RpcChannel, which had somehow been + Python + * MergeFrom(message) and CopyFrom(message) are now implemented. + * SerializeToString() raises an exception if the message is missing required + fields. + * Code organization improvements. + * Fixed doc comments for RpcController and RpcChannel, which had somehow been swapped. - * Fixed text_format_test on Windows where floating-point exponents sometimes - contain extra zeros. + * Fixed text_format_test on Windows where floating-point exponents sometimes + contain extra zeros. * Fix Python service CallMethod() implementation. Other diff --git a/src/google/protobuf/compiler/cpp/cpp_file.cc b/src/google/protobuf/compiler/cpp/cpp_file.cc index 70b434dd96..6487979fc6 100644 --- a/src/google/protobuf/compiler/cpp/cpp_file.cc +++ b/src/google/protobuf/compiler/cpp/cpp_file.cc @@ -59,7 +59,8 @@ FileGenerator::FileGenerator(const FileDescriptor* file, service_generators_( new scoped_ptr[file->service_count()]), extension_generators_( - new scoped_ptr[file->extension_count()]) { + new scoped_ptr[file->extension_count()]), + dllexport_decl_(dllexport_decl) { for (int i = 0; i < file->message_type_count(); i++) { message_generators_[i].reset( @@ -146,11 +147,13 @@ void FileGenerator::GenerateHeader(io::Printer* printer) { // declare it to be a friend of each class. printer->Print( "\n" - "// Internal implementation detail -- do not call this.\n" + "// Internal implementation detail -- do not call these.\n" + "void $dllexport_decl$ $builddescriptorsname$();\n" "void $builddescriptorsname$_AssignGlobalDescriptors(\n" " ::google::protobuf::FileDescriptor* file);\n" "\n", - "builddescriptorsname", GlobalBuildDescriptorsName(file_->name())); + "builddescriptorsname", GlobalBuildDescriptorsName(file_->name()), + "dllexport_decl", dllexport_decl_); // Generate forward declarations of classes. for (int i = 0; i < file_->message_type_count(); i++) { @@ -235,31 +238,6 @@ void FileGenerator::GenerateSource(io::Printer* printer) { "#include \n", "basename", StripProto(file_->name())); - // For each dependency, write a prototype for that dependency's - // BuildDescriptors() function. We don't expose these in the header because - // they are internal implementation details, and since this is generated code - // we don't have the usual risks involved with declaring external functions - // within a .cc file. - for (int i = 0; i < file_->dependency_count(); i++) { - const FileDescriptor* dependency = file_->dependency(i); - // Open the dependency's namespace. - vector dependency_package_parts; - SplitStringUsing(dependency->package(), ".", &dependency_package_parts); - for (int i = 0; i < dependency_package_parts.size(); i++) { - printer->Print("namespace $name$ { ", - "name", dependency_package_parts[i]); - } - // Declare its BuildDescriptors() function. - printer->Print( - "void $function$();", - "function", GlobalBuildDescriptorsName(dependency->name())); - // Close the namespace. - for (int i = 0; i < dependency_package_parts.size(); i++) { - printer->Print(" }"); - } - printer->Print("\n"); - } - GenerateNamespaceOpeners(printer); printer->Print( diff --git a/src/google/protobuf/compiler/cpp/cpp_file.h b/src/google/protobuf/compiler/cpp/cpp_file.h index fc3d98cf83..b4e012857d 100644 --- a/src/google/protobuf/compiler/cpp/cpp_file.h +++ b/src/google/protobuf/compiler/cpp/cpp_file.h @@ -85,6 +85,8 @@ class FileGenerator { // E.g. if the package is foo.bar, package_parts_ is {"foo", "bar"}. vector package_parts_; + string dllexport_decl_; + GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FileGenerator); }; diff --git a/src/google/protobuf/descriptor.pb.h b/src/google/protobuf/descriptor.pb.h index 420f178d6a..4bc315e24d 100644 --- a/src/google/protobuf/descriptor.pb.h +++ b/src/google/protobuf/descriptor.pb.h @@ -25,7 +25,8 @@ namespace google { namespace protobuf { -// Internal implementation detail -- do not call this. +// Internal implementation detail -- do not call these. +void LIBPROTOBUF_EXPORT protobuf_BuildDesc_google_2fprotobuf_2fdescriptor_2eproto(); void protobuf_BuildDesc_google_2fprotobuf_2fdescriptor_2eproto_AssignGlobalDescriptors( ::google::protobuf::FileDescriptor* file); diff --git a/src/google/protobuf/stubs/common.h b/src/google/protobuf/stubs/common.h index 3744a58526..9309b6be5f 100644 --- a/src/google/protobuf/stubs/common.h +++ b/src/google/protobuf/stubs/common.h @@ -56,7 +56,7 @@ using namespace std; // Don't do this at home, kids. TypeName(const TypeName&); \ void operator=(const TypeName&) -#ifdef _MSC_VER +#if defined(_MSC_VER) && defined(PROTOBUF_USE_DLLS) #ifdef LIBPROTOBUF_EXPORTS #define LIBPROTOBUF_EXPORT __declspec(dllexport) #else diff --git a/vsprojects/libprotobuf.vcproj b/vsprojects/libprotobuf.vcproj index a680896860..6edd845363 100644 --- a/vsprojects/libprotobuf.vcproj +++ b/vsprojects/libprotobuf.vcproj @@ -19,7 +19,7 @@ Name="Debug|Win32" OutputDirectory="Debug" IntermediateDirectory="Debug" - ConfigurationType="2" + ConfigurationType="4" > - @@ -81,9 +74,6 @@ - @@ -92,7 +82,7 @@ Name="Release|Win32" OutputDirectory="Release" IntermediateDirectory="Release" - ConfigurationType="2" + ConfigurationType="4" > - @@ -153,9 +134,6 @@ - diff --git a/vsprojects/libprotoc.vcproj b/vsprojects/libprotoc.vcproj index b1a6b984e8..4f686d02ae 100644 --- a/vsprojects/libprotoc.vcproj +++ b/vsprojects/libprotoc.vcproj @@ -19,7 +19,7 @@ Name="Debug|Win32" OutputDirectory="Debug" IntermediateDirectory="Debug" - ConfigurationType="2" + ConfigurationType="4" > - @@ -81,9 +74,6 @@ - @@ -92,7 +82,7 @@ Name="Release|Win32" OutputDirectory="Release" IntermediateDirectory="Release" - ConfigurationType="2" + ConfigurationType="4" > - @@ -153,9 +134,6 @@ - diff --git a/vsprojects/readme.txt b/vsprojects/readme.txt index b79f6006d7..a0f5bc865f 100644 --- a/vsprojects/readme.txt +++ b/vsprojects/readme.txt @@ -24,27 +24,37 @@ Compiling and Installing build of libprotobuf.dll. Similarly, release builds must link against release DLLs. -DLLs and Distribution -===================== +DLLs vs. static linking +======================= + +Static linking is now the default for the Protocol Buffer libraries. Due to +issues with Win32's use of a separate heap for each DLL, as well as binary +compatibility issues between different versions of MSVC's STL library, it is +recommended that you use static linkage only. However, it is possible to +build libprotobuf and libprotoc as DLLs if you really want. To do this, +do the following: + + 1) Open protobuf.sln in MSVC. + 2) For each of the projects libprotobuf and libprotoc, do the following: + 2a) Right-click the project and choose "properties". + 2b) From the side bar, choose "General", under "Configuration Properties". + 2c) Change the "Configuration Type" to "Dynamic Library (.dll)". + 2d) From the side bar, choose "Preprocessor", under "C/C++". + 2e) Add PROTOBUF_USE_DLLS to the list of preprocessor defines. + 3) When compiling your project, make sure to #define PROTOBUF_USE_DLLS. When distributing your software to end users, we strongly recommend that you do NOT install libprotobuf.dll or libprotoc.dll to any shared location. Instead, keep these libraries next to your binaries, in your application's own install directory. C++ makes it very difficult to maintain binary compatibility between releases, so it is likely that future versions of these -libraries will *not* be usable as drop-in replacements. The only reason we -provide these libraries as DLLs rather than static libs is so that a program -which is itself split into multiple DLLs can safely pass protocol buffer -objects between them. +libraries will *not* be usable as drop-in replacements. If your project is itself a DLL intended for use by third-party software, we recommend that you do NOT expose protocol buffer objects in your library's public interface, and that you statically link protocol buffers into your library. -TODO(kenton): This sounds kind of scary. Maybe we should only provide static - libraries? - Notes on Compiler Warnings ========================== @@ -63,7 +73,8 @@ C4355 - 'this' : used in base member initializer list C4800 - 'type' : forcing value to bool 'true' or 'false' (performance warning) C4996 - 'function': was declared deprecated -C4251 is of particular note. The protocol buffer library uses templates in +C4251 is of particular note, if you are compiling the Protocol Buffer library +as a DLL (see previous section). The protocol buffer library uses templates in its public interfaces. MSVC does not provide any reasonable way to export template classes from a DLL. However, in practice, it appears that exporting templates is not necessary anyway. Since the complete definition of any diff --git a/vsprojects/tests.vcproj b/vsprojects/tests.vcproj index 9530557ba8..4148016398 100644 --- a/vsprojects/tests.vcproj +++ b/vsprojects/tests.vcproj @@ -262,6 +262,10 @@ RelativePath=".\google\protobuf\unittest_embed_optimize_for.pb.h" > + + + + @@ -563,6 +571,30 @@ /> + + + + + + + +