Commit 9270a99d authored by kenton@google.com's avatar kenton@google.com

Make DLLs work again.

parent e6607e39
...@@ -107,6 +107,6 @@ int main(int argc, char* argv[]) { ...@@ -107,6 +107,6 @@ int main(int argc, char* argv[]) {
google::protobuf::TestUtilLite::ExpectPackedExtensionsClear(message); google::protobuf::TestUtilLite::ExpectPackedExtensionsClear(message);
} }
cout << "PASS"; cout << "PASS" << endl;
return 0; return 0;
} }
...@@ -69,10 +69,10 @@ void RepeatedPtrFieldBase::Swap(RepeatedPtrFieldBase* other) { ...@@ -69,10 +69,10 @@ void RepeatedPtrFieldBase::Swap(RepeatedPtrFieldBase* other) {
} }
} }
string* StringTypeHandler::New() { string* StringTypeHandlerBase::New() {
return new string; return new string;
} }
void StringTypeHandler::Delete(string* value) { void StringTypeHandlerBase::Delete(string* value) {
delete value; delete value;
} }
......
...@@ -262,19 +262,30 @@ inline void GenericTypeHandler<MessageLite>::Merge( ...@@ -262,19 +262,30 @@ inline void GenericTypeHandler<MessageLite>::Merge(
to->CheckTypeAndMergeFrom(from); to->CheckTypeAndMergeFrom(from);
} }
class LIBPROTOBUF_EXPORT StringTypeHandler { // HACK: If a class is declared as DLL-exported in MSVC, it insists on
// generating copies of all its methods -- even inline ones -- to include
// in the DLL. But SpaceUsed() calls StringSpaceUsedExcludingSelf() which
// isn't in the lite library, therefore the lite library cannot link if
// StringTypeHandler is exported. So, we factor out StringTypeHandlerBase,
// export that, then make StringTypeHandler be a subclass which is NOT
// exported.
// TODO(kenton): There has to be a better way.
class LIBPROTOBUF_EXPORT StringTypeHandlerBase {
public: public:
typedef string Type; typedef string Type;
static string* New(); static string* New();
static void Delete(string* value); static void Delete(string* value);
static void Clear(string* value) { value->clear(); } static void Clear(string* value) { value->clear(); }
static void Merge(const string& from, string* to) { *to = from; } static void Merge(const string& from, string* to) { *to = from; }
};
class StringTypeHandler : public StringTypeHandlerBase {
public:
static int SpaceUsed(const string& value) { static int SpaceUsed(const string& value) {
return sizeof(value) + StringSpaceUsedExcludingSelf(value); return sizeof(value) + StringSpaceUsedExcludingSelf(value);
} }
}; };
} // namespace internal } // namespace internal
// RepeatedPtrField is like RepeatedField, but used for repeated strings or // RepeatedPtrField is like RepeatedField, but used for repeated strings or
......
...@@ -42,7 +42,6 @@ ...@@ -42,7 +42,6 @@
#include <google/protobuf/io/coded_stream.h> #include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/io/zero_copy_stream.h> #include <google/protobuf/io/zero_copy_stream.h>
#include <google/protobuf/io/zero_copy_stream_impl.h> #include <google/protobuf/io/zero_copy_stream_impl.h>
#include <google/protobuf/unknown_field_set.h>
namespace google { namespace google {
namespace protobuf { namespace protobuf {
......
...@@ -36,7 +36,8 @@ build libprotobuf and libprotoc as DLLs if you really want. To do this, ...@@ -36,7 +36,8 @@ build libprotobuf and libprotoc as DLLs if you really want. To do this,
do the following: do the following:
1) Open protobuf.sln in MSVC. 1) Open protobuf.sln in MSVC.
2) For each of the projects libprotobuf and libprotoc, do the following: 2) For each of the projects libprotobuf, libprotobuf-lite, and libprotoc, do
the following:
2a) Right-click the project and choose "properties". 2a) Right-click the project and choose "properties".
2b) From the side bar, choose "General", under "Configuration Properties". 2b) From the side bar, choose "General", under "Configuration Properties".
2c) Change the "Configuration Type" to "Dynamic Library (.dll)". 2c) Change the "Configuration Type" to "Dynamic Library (.dll)".
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment