Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
c3480926
Commit
c3480926
authored
May 21, 2015
by
Paul Yang
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #402 from thomasvl/objc_on_win
Getting the ObjC generator building on Windows.
parents
3668a224
ce55ff94
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
125 additions
and
103 deletions
+125
-103
check_version_stamps.sh
objectivec/DevTools/check_version_stamps.sh
+1
-1
objectivec_extension.cc
...ogle/protobuf/compiler/objectivec/objectivec_extension.cc
+0
-1
objectivec_field.cc
src/google/protobuf/compiler/objectivec/objectivec_field.cc
+1
-5
objectivec_file.cc
src/google/protobuf/compiler/objectivec/objectivec_file.cc
+4
-3
objectivec_generator.cc
...ogle/protobuf/compiler/objectivec/objectivec_generator.cc
+0
-4
objectivec_helpers.cc
...google/protobuf/compiler/objectivec/objectivec_helpers.cc
+10
-79
objectivec_helpers.h
src/google/protobuf/compiler/objectivec/objectivec_helpers.h
+2
-5
objectivec_helpers_unittest.cc
...otobuf/compiler/objectivec/objectivec_helpers_unittest.cc
+2
-2
objectivec_message.cc
...google/protobuf/compiler/objectivec/objectivec_message.cc
+3
-2
objectivec_primitive_field.cc
...rotobuf/compiler/objectivec/objectivec_primitive_field.cc
+6
-1
libprotoc.vcproj
vsprojects/libprotoc.vcproj
+96
-0
No files found.
objectivec/DevTools/check_version_stamps.sh
View file @
c3480926
...
...
@@ -25,7 +25,7 @@ readonly ConstantName=GOOGLE_PROTOBUF_OBJC_GEN_VERSION
readonly
PluginSrc
=
"
${
ProtoRootDir
}
/src/google/protobuf/compiler/objectivec/objectivec_file.cc"
readonly
PluginVersion
=
$(
\
cat
"
${
PluginSrc
}
"
\
|
sed
-n
-e
"s:const int32
_t
${
ConstantName
}
=
\(
[0-9]*
\)
;:
\1
:p"
|
sed
-n
-e
"s:const int32
${
ConstantName
}
=
\(
[0-9]*
\)
;:
\1
:p"
)
if
[[
-z
"
${
PluginVersion
}
"
]]
;
then
...
...
src/google/protobuf/compiler/objectivec/objectivec_extension.cc
View file @
c3480926
...
...
@@ -77,7 +77,6 @@ ExtensionGenerator::ExtensionGenerator(const string& root_class_name,
ExtensionGenerator
::~
ExtensionGenerator
()
{}
void
ExtensionGenerator
::
GenerateMembersHeader
(
io
::
Printer
*
printer
)
{
WriteClassNameToClassList
(
root_class_and_method_name_
);
if
(
IsFiltered
())
{
printer
->
Print
(
"// $filter_reason$
\n\n
"
,
"filter_reason"
,
filter_reason_
);
return
;
...
...
src/google/protobuf/compiler/objectivec/objectivec_field.cc
View file @
c3480926
...
...
@@ -39,10 +39,6 @@
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/strutil.h>
#ifndef htonl
#include <netinet/in.h>
#endif
namespace
google
{
namespace
protobuf
{
namespace
compiler
{
...
...
@@ -107,7 +103,7 @@ void SetCommonFieldVariables(const FieldDescriptor* descriptor,
string
field_options
=
descriptor
->
options
().
SerializeAsString
();
// Must convert to a standard byte order for packing length into
// a cstring.
uint32
_t
length
=
htonl
(
field_options
.
length
());
uint32
length
=
g
htonl
(
field_options
.
length
());
if
(
length
>
0
)
{
string
bytes
((
const
char
*
)
&
length
,
sizeof
(
length
));
bytes
.
append
(
field_options
);
...
...
src/google/protobuf/compiler/objectivec/objectivec_file.cc
View file @
c3480926
...
...
@@ -40,13 +40,14 @@
#include <google/protobuf/stubs/strutil.h>
#include <sstream>
namespace
google
{
namespace
protobuf
{
// This is also found in GPBBootstrap.h, and needs to be kept in sync. It
// is the version check done to ensure generated code works with the current
// runtime being used.
const
int32
_t
GOOGLE_PROTOBUF_OBJC_GEN_VERSION
=
30000
;
const
int32
GOOGLE_PROTOBUF_OBJC_GEN_VERSION
=
30000
;
namespace
google
{
namespace
protobuf
{
namespace
compiler
{
namespace
objectivec
{
FileGenerator
::
FileGenerator
(
const
FileDescriptor
*
file
)
...
...
src/google/protobuf/compiler/objectivec/objectivec_generator.cc
View file @
c3480926
...
...
@@ -82,10 +82,6 @@ bool ObjectiveCGenerator::Generate(const FileDescriptor* file,
file_generator
.
GenerateSource
(
&
printer
);
}
if
(
!
WriteClassList
(
error
))
{
return
false
;
}
return
true
;
}
...
...
src/google/protobuf/compiler/objectivec/objectivec_helpers.cc
View file @
c3480926
...
...
@@ -28,12 +28,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <arpa/inet.h>
#include <errno.h>
#include <limits.h>
#include <stdlib.h>
#include <unistd.h>
#include <fstream>
#include <iostream>
#include <sstream>
...
...
@@ -46,14 +40,6 @@
#include <google/protobuf/descriptor.pb.h>
#include <google/protobuf/stubs/strutil.h>
#ifndef htonl
#include <netinet/in.h>
#endif
#ifndef O_EXLOCK
#include <sys/file.h>
#endif
// NOTE: src/google/protobuf/compiler/plugin.cc makes use of cerr for some
// error case, so it seem to be ok to use as a back door for errors.
...
...
@@ -65,7 +51,6 @@ namespace objectivec {
namespace
{
hash_set
<
string
>
gClassWhitelist
;
stringstream
gClassListStream
;
// islower()/isupper()/tolower()/toupper() change based on locale.
...
...
@@ -754,7 +739,7 @@ string DefaultValue(const FieldDescriptor* field) {
// Must convert to a standard byte order for packing length into
// a cstring.
uint32
_t
length
=
htonl
(
default_string
.
length
());
uint32
length
=
g
htonl
(
default_string
.
length
());
string
bytes
((
const
char
*
)
&
length
,
sizeof
(
length
));
bytes
.
append
(
default_string
);
return
"(NSData*)
\"
"
+
CEscape
(
bytes
)
+
"
\"
"
;
...
...
@@ -809,60 +794,6 @@ string BuildCommentsString(const SourceLocation& location) {
return
final_comments
;
}
bool
WriteClassList
(
string
*
error
)
{
const
char
*
file_name
=
getenv
(
"GPB_CLASSLIST_PATH"
);
if
(
file_name
!=
NULL
)
{
#ifndef O_EXLOCK
int
fd
=
open
(
file_name
,
O_WRONLY
|
O_APPEND
|
O_CREAT
,
(
S_IRUSR
|
S_IWUSR
|
S_IRGRP
|
S_IROTH
));
#else
int
fd
=
open
(
file_name
,
O_WRONLY
|
O_APPEND
|
O_EXLOCK
|
O_CREAT
,
(
S_IRUSR
|
S_IWUSR
|
S_IRGRP
|
S_IROTH
));
#endif
if
(
fd
==
-
1
)
{
if
(
error
!=
NULL
)
{
stringstream
err_stream
;
err_stream
<<
endl
<<
file_name
<<
":0:0: error:"
<<
"Unable to open ("
<<
errno
<<
")"
;
*
error
=
err_stream
.
str
();
}
return
false
;
}
#ifndef O_EXLOCK
if
(
flock
(
fd
,
LOCK_EX
)
<
0
)
{
if
(
error
!=
NULL
)
{
stringstream
err_stream
;
err_stream
<<
endl
<<
file_name
<<
":0:0: error:"
<<
"Unable to lock ("
<<
errno
<<
")"
;
*
error
=
err_stream
.
str
();
}
return
false
;
}
#endif
// Need a local to hold the list so the cstring stays valid for the
// write call.
const
string
&
class_list_str
=
gClassListStream
.
str
();
int
write_out
=
write
(
fd
,
class_list_str
.
c_str
(),
class_list_str
.
length
());
int
close_out
=
close
(
fd
);
if
(
write_out
==
-
1
||
close_out
==
-
1
)
{
if
(
error
!=
NULL
)
{
stringstream
err_stream
;
err_stream
<<
endl
<<
file_name
<<
":0:0: error:"
<<
"Unable to write ("
<<
errno
<<
")"
;
*
error
=
err_stream
.
str
();
}
return
false
;
}
}
return
true
;
}
void
WriteClassNameToClassList
(
const
string
&
name
)
{
if
(
gClassListStream
.
good
())
{
gClassListStream
<<
name
<<
'\n'
;
}
}
bool
InitializeClassWhitelist
(
string
*
error
)
{
const
char
*
env_var_value
=
getenv
(
"GPB_OBJC_CLASS_WHITELIST_PATHS"
);
if
(
env_var_value
==
NULL
)
{
...
...
@@ -917,7 +848,7 @@ bool FilterClass(const string& name) {
return
gClassWhitelist
.
size
()
>
0
;
}
void
TextFormatDecodeData
::
AddString
(
int32
_t
key
,
void
TextFormatDecodeData
::
AddString
(
int32
key
,
const
string
&
input_for_decode
,
const
string
&
desired_output
)
{
for
(
vector
<
DataEntry
>::
const_iterator
i
=
entries_
.
begin
();
...
...
@@ -973,14 +904,14 @@ class DecodeDataBuilder {
}
private
:
static
const
uint8
_t
kAddUnderscore
=
0
b1000000
0
;
static
const
uint8
kAddUnderscore
=
0x8
0
;
static
const
uint8
_t
kOpAsIs
=
0
b000000
00
;
static
const
uint8
_t
kOpFirstUpper
=
0
b0100000
0
;
static
const
uint8
_t
kOpFirstLower
=
0
b0010000
0
;
static
const
uint8
_t
kOpAllUpper
=
0
b0110000
0
;
static
const
uint8
kOpAsIs
=
0x
00
;
static
const
uint8
kOpFirstUpper
=
0x4
0
;
static
const
uint8
kOpFirstLower
=
0x2
0
;
static
const
uint8
kOpAllUpper
=
0x6
0
;
static
const
int
kMaxSegmentLen
=
0
b00011111
;
static
const
int
kMaxSegmentLen
=
0x1f
;
void
AddChar
(
const
char
desired
)
{
++
segment_len_
;
...
...
@@ -988,7 +919,7 @@ class DecodeDataBuilder {
}
void
Push
()
{
uint8
_t
op
=
(
op_
|
segment_len_
);
uint8
op
=
(
op_
|
segment_len_
);
if
(
need_underscore_
)
op
|=
kAddUnderscore
;
if
(
op
!=
0
)
{
decode_data_
+=
(
char
)
op
;
...
...
@@ -1020,7 +951,7 @@ class DecodeDataBuilder {
bool
need_underscore_
;
bool
is_all_upper_
;
uint8
_t
op_
;
uint8
op_
;
int
segment_len_
;
string
decode_data_
;
...
...
src/google/protobuf/compiler/objectivec/objectivec_helpers.h
View file @
c3480926
...
...
@@ -142,9 +142,6 @@ string BuildFlagsString(const vector<string>& strings);
string
BuildCommentsString
(
const
SourceLocation
&
location
);
bool
WriteClassList
(
string
*
error
);
void
WriteClassNameToClassList
(
const
string
&
name
);
bool
InitializeClassWhitelist
(
string
*
error
);
bool
FilterClass
(
const
string
&
name
);
...
...
@@ -154,7 +151,7 @@ class TextFormatDecodeData {
public
:
TextFormatDecodeData
()
{}
void
AddString
(
int32
_t
key
,
const
string
&
input_for_decode
,
void
AddString
(
int32
key
,
const
string
&
input_for_decode
,
const
string
&
desired_output
);
size_t
num_entries
()
const
{
return
entries_
.
size
();
}
string
Data
()
const
;
...
...
@@ -165,7 +162,7 @@ class TextFormatDecodeData {
private
:
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS
(
TextFormatDecodeData
);
typedef
std
::
pair
<
int32
_t
,
string
>
DataEntry
;
typedef
std
::
pair
<
int32
,
string
>
DataEntry
;
vector
<
DataEntry
>
entries_
;
};
...
...
src/google/protobuf/compiler/objectivec/objectivec_helpers_unittest.cc
View file @
c3480926
...
...
@@ -150,7 +150,7 @@ TEST(ObjCHelper, TextFormatDecodeData_RawStrings) {
EXPECT_EQ
(
4
,
decode_data
.
num_entries
());
uint8
_t
expected_data
[]
=
{
uint8
expected_data
[]
=
{
0x4
,
0x1
,
0x0
,
'z'
,
'b'
,
'c'
,
'd'
,
'e'
,
'f'
,
'g'
,
'h'
,
'I'
,
'J'
,
0x0
,
0x3
,
0x0
,
'a'
,
'b'
,
'c'
,
'd'
,
'e'
,
'z'
,
'g'
,
'h'
,
'I'
,
'J'
,
0x0
,
...
...
@@ -175,7 +175,7 @@ TEST(ObjCHelper, TextFormatDecodeData_ByteCodes) {
EXPECT_EQ
(
5
,
decode_data
.
num_entries
());
uint8
_t
expected_data
[]
=
{
uint8
expected_data
[]
=
{
0x5
,
// All as is (00 op)
0x1
,
0x0A
,
0x0
,
...
...
src/google/protobuf/compiler/objectivec/objectivec_message.cc
View file @
c3480926
...
...
@@ -119,6 +119,9 @@ int OrderGroupForFieldDescriptor(const FieldDescriptor* descriptor) {
case
FieldDescriptor
:
:
TYPE_BOOL
:
return
1
;
}
GOOGLE_LOG
(
FATAL
)
<<
"Can't get here."
;
return
0
;
}
struct
FieldOrderingByStorageSize
{
...
...
@@ -303,8 +306,6 @@ void MessageGenerator::GenerateMessageHeader(io::Printer* printer) {
return
;
}
WriteClassNameToClassList
(
class_name_
);
if
(
IsFiltered
())
{
printer
->
Print
(
"// $filter_reason$
\n\n
"
,
"filter_reason"
,
filter_reason_
);
...
...
src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc
View file @
c3480926
...
...
@@ -76,6 +76,9 @@ const char* PrimitiveTypeName(const FieldDescriptor* descriptor) {
case
OBJECTIVECTYPE_MESSAGE
:
return
NULL
;
}
GOOGLE_LOG
(
FATAL
)
<<
"Can't get here."
;
return
NULL
;
}
const
char
*
PrimitiveArrayTypeName
(
const
FieldDescriptor
*
descriptor
)
{
...
...
@@ -104,6 +107,9 @@ const char* PrimitiveArrayTypeName(const FieldDescriptor* descriptor) {
case
OBJECTIVECTYPE_MESSAGE
:
return
""
;
// Want NSArray
}
GOOGLE_LOG
(
FATAL
)
<<
"Can't get here."
;
return
NULL
;
}
void
SetPrimitiveVariables
(
const
FieldDescriptor
*
descriptor
,
...
...
@@ -155,7 +161,6 @@ void RepeatedPrimitiveFieldGenerator::FinishInitialization(void) {
}
}
}
// namespace objectivec
}
// namespace compiler
}
// namespace protobuf
...
...
vsprojects/libprotoc.vcproj
View file @
c3480926
...
...
@@ -371,6 +371,54 @@
<File
RelativePath=
"..\src\google\protobuf\compiler\javanano\javanano_message.h"
></File>
<File
RelativePath=
"..\src\google\protobuf\compiler\javanano\javanano_params.h"
></File>
<File
RelativePath=
"..\src\google\protobuf\compiler\javanano\javanano_primitive_field.h"
></File>
<File
RelativePath=
"..\src\google\protobuf\compiler\objectivec\objectivec_enum.h"
>
</File>
<File
RelativePath=
"..\src\google\protobuf\compiler\objectivec\objectivec_enum_field.h"
>
</File>
<File
RelativePath=
"..\src\google\protobuf\compiler\objectivec\objectivec_extension.h"
>
</File>
<File
RelativePath=
"..\src\google\protobuf\compiler\objectivec\objectivec_field.h"
>
</File>
<File
RelativePath=
"..\src\google\protobuf\compiler\objectivec\objectivec_file.h"
>
</File>
<File
RelativePath=
"..\src\google\protobuf\compiler\objectivec\objectivec_generator.h"
>
</File>
<File
RelativePath=
"..\src\google\protobuf\compiler\objectivec\objectivec_helpers.h"
>
</File>
<File
RelativePath=
"..\src\google\protobuf\compiler\objectivec\objectivec_map_field.h"
>
</File>
<File
RelativePath=
"..\src\google\protobuf\compiler\objectivec\objectivec_message.h"
>
</File>
<File
RelativePath=
"..\src\google\protobuf\compiler\objectivec\objectivec_message_field.h"
>
</File>
<File
RelativePath=
"..\src\google\protobuf\compiler\objectivec\objectivec_oneof.h"
>
</File>
<File
RelativePath=
"..\src\google\protobuf\compiler\objectivec\objectivec_primitive_field.h"
>
</File>
<File
RelativePath=
"..\src\google\protobuf\compiler\python\python_generator.h"
>
...
...
@@ -635,6 +683,54 @@
RelativePath=
"..\src\google\protobuf\compiler\javanano\javanano_primitive_field.cc"
>
</File>
<File
RelativePath=
"..\src\google\protobuf\compiler\objectivec\objectivec_enum.cc"
>
</File>
<File
RelativePath=
"..\src\google\protobuf\compiler\objectivec\objectivec_enum_field.cc"
>
</File>
<File
RelativePath=
"..\src\google\protobuf\compiler\objectivec\objectivec_extension.cc"
>
</File>
<File
RelativePath=
"..\src\google\protobuf\compiler\objectivec\objectivec_field.cc"
>
</File>
<File
RelativePath=
"..\src\google\protobuf\compiler\objectivec\objectivec_file.cc"
>
</File>
<File
RelativePath=
"..\src\google\protobuf\compiler\objectivec\objectivec_generator.cc"
>
</File>
<File
RelativePath=
"..\src\google\protobuf\compiler\objectivec\objectivec_helpers.cc"
>
</File>
<File
RelativePath=
"..\src\google\protobuf\compiler\objectivec\objectivec_map_field.cc"
>
</File>
<File
RelativePath=
"..\src\google\protobuf\compiler\objectivec\objectivec_message.cc"
>
</File>
<File
RelativePath=
"..\src\google\protobuf\compiler\objectivec\objectivec_message_field.cc"
>
</File>
<File
RelativePath=
"..\src\google\protobuf\compiler\objectivec\objectivec_oneof.cc"
>
</File>
<File
RelativePath=
"..\src\google\protobuf\compiler\objectivec\objectivec_primitive_field.cc"
>
</File>
<File
RelativePath=
"..\src\google\protobuf\compiler\plugin.cc"
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment