554 Commits

Author SHA1 Message Date
Robert Edmonds
53bf6c0b7c Bump version to 1.3.1 2018-08-13 23:18:25 -04:00
Robert Edmonds
4176920e6b
Merge pull request #334 from protobuf-c/edmonds/ax_cxx_compile_stdcxx
Use AX_CXX_COMPILE_STDCXX macro to enable C++11 support in old compilers
2018-08-13 23:11:57 -04:00
Robert Edmonds
defc6f044b Revert ".travis.yml: Force C++ standard language version"
This reverts commit 0585e053a8723fbdea4deefe17b6a6512274cde5.

Now that we autodetect any needed flags to enable C++11 support with the
AX_CXX_COMPILE_STDCXX macro, we no longer need to force this in
.travis.yml.
2018-08-13 22:39:31 -04:00
Robert Edmonds
9becc1b66f configure.ac: Use AX_CXX_COMPILE_STDCXX to enable C++11 support in old compilers
This commit enables use of the AX_CXX_COMPILE_STDCXX macro from the
autoconf-archive (added in the previous commit), which automatically
adds needed flags to the CXX variable to enable C++11 support. This only
works and is only required on compilers that are both new enough to have
C++11 support and old enough to not enable it by default.

We call it with "noext" as the second argument (so that we get the "std"
C++11 variant on GCC) and "mandatory" as the third argument, since we
now rely on C++11 features as of 83c59e705f461cc08e5844d62514dff27c33a74f.

Note that this macro is only called when we are building the compiler
(i.e., without --disable-protoc) so that the library can still be built
on ancient C compilers.
2018-08-13 22:38:19 -04:00
Robert Edmonds
42612b4ba4 m4/ax_cxx_compile_stdcxx.m4: Import from autoconf-archive (serial 10) 2018-08-13 22:23:25 -04:00
Robert Edmonds
f3102ed227
Merge pull request #290 from matthid/master
fix mingw compilation
2018-08-13 22:10:38 -04:00
Sam Collinson
9b899c9d3b Check the return value of int_range_lookup before using as an array index; it can return -1 2018-08-13 22:07:17 -04:00
Robert Edmonds
8073f6ee23
Merge pull request #333 from protobuf-c/edmonds/protobuf-scoped_ptr-removal
Convert uses of protobuf's scoped_ptr.h to C++11 std::unique_ptr
2018-08-13 22:06:26 -04:00
Robert Edmonds
83c59e705f Convert uses of protobuf's scoped_ptr.h to C++11 std::unique_ptr
Upstream protobuf removed scoped_ptr.h, which provided the scoped_ptr
that we depended on, in commit 67952fab2c766ac5eacc15bb78e5af4039a3d398
(67952fab2c).

This commit converts uses of scoped_ptr type to idiomatic C++11
std::unique_ptr, similar to the changes in the protobuf commit.

This has been tested on protobuf 3.0.0 (the version currently in Debian)
as well as the latest protobuf 3.6.1 release.
2018-08-13 21:26:00 -04:00
Robert Edmonds
26a836423c
Merge pull request #309 from iveqy/add_std
Add std:: to some types
2018-08-13 20:57:46 -04:00
Robert Edmonds
3bcca236c9
Merge pull request #332 from protobuf-c/edmonds/travis-updates
Update Travis to use xenial, protobuf 3.6.1
2018-08-13 20:46:31 -04:00
Robert Edmonds
0585e053a8 .travis.yml: Force C++ standard language version
The xenial Travis-CI environment uses a g++ version that is old enough
that it doesn't use C++11 or newer by default, so we have to force it by
setting CXX to "g++ -std=c++11".
2018-08-13 20:24:05 -04:00
Robert Edmonds
3b7ba77c4d .travis.yml: Bump protobuf version to 3.6.1 2018-08-13 19:40:30 -04:00
Robert Edmonds
fe36c1677a .travis.yml: Update to xenial
This commit updates the base Travis-CI image from trusty to xenial,
which ships with a slightly more modern compiler.
2018-08-13 19:40:04 -04:00
Fredrik Gustafsson
034e603d2a Add std:: to some types
This is required for compilation to succeed on debian jessie with g++
6.3.0.
2018-03-11 08:57:46 +01:00
Matthias Dittrich
71273f3919 fix mingw compilation 2017-09-25 18:38:24 +02:00
Robert Edmonds
4912c5a574 Merge pull request #285 from protobuf-c/edmonds/protobuf-2.x-compatibility
Restore protobuf-2.x compatibility
2017-08-14 15:36:00 -04:00
Robert Edmonds
4302266b45 Restore protobuf-2.x compatibility
The change in commit 712154b912de824741381c0bb26c2fbed54515a3 ("Bump
minimum required header version for proto3 syntax") uses functionality
only exposed by protobuf-3.x, breaking the build when compiling against
protobuf-2.x.

Since we still want to support building against protobuf-2.x, this
commit makes the proto3 syntax check in the file generator dependent on
building against protobuf-3.x.
2017-08-07 12:31:55 -04:00
Robert Edmonds
dac1a65fea Merge pull request #283 from protobuf-c/edmonds/changelog/1.3.0
ChangeLog: 1.3.0
v1.3.0
2017-08-05 17:41:36 -04:00
Robert Edmonds
cd573da538 ChangeLog: 1.3.0 2017-08-05 16:46:57 -04:00
Robert Edmonds
ab599cfae8 Merge pull request #282 from protobuf-c/edmonds/proto3-bump-min_header_version
Bump minimum required header version for proto3 syntax
2017-07-30 22:51:25 -04:00
Robert Edmonds
712154b912 Bump minimum required header version for proto3 syntax
The changes in #274 (proto3: make strings default to "" instead of NULL)
add a new symbol to the library and add an 'extern' declaration to the
protobuf-c header file.

Since the compiler may generate files that depend on that new
'protobuf_c_empty_string' declaration in protobuf-c.h, we need to bump
the min_header_version value that is written into generated header
files. But since the 'protobuf_c_empty_string' symbol can only be
referenced when generating proto3 syntax files, we only need to use the
stricter min_header_version value when processing a proto3 file.
2017-07-29 20:16:22 -04:00
Robert Edmonds
631dbd0db7 .gitignore: t/generated-code3/test-generated-code3 2017-07-29 19:44:07 -04:00
Robert Edmonds
aee115c92b Merge pull request #281 from protobuf-c/edmonds/version/1.3.0
Bump version to 1.3.0
2017-07-29 19:43:41 -04:00
Robert Edmonds
25cb6e2bdf Bump version to 1.3.0 2017-07-29 19:30:36 -04:00
Robert Edmonds
d7189b6940 Merge pull request #280 from protobuf-c/edmonds/fix-namespace-errors
Fix namespace errors when compiled with latest protobuf
2017-07-29 19:10:00 -04:00
Robert Edmonds
582cad8bff Fix namespace errors when compiled with latest protobuf
The protobuf project removed "using namespace std" namespace pollution
from their stubs/common.h header file. This caused build failures for us
since we relied on their namespace pollution.

This commit updates protobuf-c to convert:

 'map' → 'std::map'
 'set' → 'std::set'
 'back_insert_iterator' → 'std::back_insert_iterator'
2017-07-29 18:52:28 -04:00
Robert Edmonds
858ce990e8 Merge pull request #274 from pbor/wip/empty-string
proto3: make strings default to "" instead of NULL
2017-07-29 18:17:15 -04:00
Paolo Borelli
2a46af4278 proto3: make strings default to "" instead of NULL
The spec talks about "empty string" and other languages like C#
return a zero length string and not null.
This is useful because when moving from proto2's "required string"
to a proto3's plain string we will be guaranteed that we
never get a null pointer.
The tradeoff is adding a special case to the library but avoiding
a lot of null checks in the calling code.
The current code is already special casing "" in pack_string.
2017-06-12 09:32:39 +02:00
Robert Edmonds
a8921fe7dc Merge pull request #267 from pbor/wip/zeroish
Rework is_zeroish one more time
2017-04-10 08:40:51 -07:00
Robert Edmonds
5464067168 Merge pull request #266 from alex85k/next
Update CMakeLists.txt
2017-04-10 08:27:05 -07:00
Paolo Borelli
4ca344ed9f Rework is_zeroish one more time
The "member" param cannot be NULL, so last patch was not correct.
However to be valgrind clean we need to cast to the right size.
2017-04-10 17:21:25 +02:00
alex85k
58a4514164 fixing tests building in CMake 2017-04-10 18:42:59 +05:00
Robert Edmonds
0014b7c046 Merge pull request #265 from pbor/wip/cleanup
Small cleanup in oneof handling
2017-04-09 09:44:46 -07:00
Robert Edmonds
448dba28d9 Merge pull request #264 from pbor/wip/zeroish
Fix proto3 "is zeroish" evaluation
2017-04-09 09:44:35 -07:00
Paolo Borelli
6bbcc433d5 Cleanup oneof handling
Small cleanups: pass the oneof case param by value instead of by
reference and use an early return if the case does not match.
2017-04-09 14:36:49 +02:00
Paolo Borelli
13b6e1fd00 Improve proto3 unit test
Make sure we actually include the proto3 generated header and
test nested submessages
2017-04-09 10:54:58 +02:00
Paolo Borelli
1c8805a780 Fix "is zeroish" evaluation for proto3
In proto3 the default value is zero (NULL for pointers and 0 for
scalars). However when checking we still need to test by type
because poinetr types have an extra indirection.
2017-04-09 10:54:34 +02:00
Robert Edmonds
39967de734 Merge pull request #258 from pbor/fixup
Remove leftover FIXME comment
2017-02-27 14:26:20 -08:00
Paolo Borelli
7c114269d7 Remove leftover FIXME comment 2017-02-26 10:39:35 +01:00
Robert Edmonds
56f4709945 Merge pull request #257 from protobuf-c/edmonds/strict-warnings
Add warning flags to my_CFLAGS
2017-02-25 15:33:11 -08:00
Robert Edmonds
c5c236b42e protobuf_c_message_unpack(): Remove a shadowed variable
Here 'j' is used as a loop index and there's no need to re-declare it
inside this block.

Found with -Wshadow.
2017-02-25 18:18:49 -05:00
Robert Edmonds
6eb0b271ae configure.ac: Add warning flags to my_CFLAGS 2017-02-25 18:18:12 -05:00
Robert Edmonds
1b71214c02 m4/ax_check_compile_flag.m4: Import from autoconf-archive (serial 5) 2017-02-25 17:31:13 -05:00
Robert Edmonds
bd32c297c5 Merge pull request #245 from Qix-/patch-1
CMAKE_SOURCE_DIR -> CMAKE_CURRENT_SOURCE_DIR
2017-02-25 14:26:07 -08:00
Robert Edmonds
6627548a93 Merge pull request #243 from cam029/next
Static build for Windows MSVC
2017-02-25 14:25:49 -08:00
Robert Edmonds
9aa47285b0 protobuf-c.h: Fix typo " " -> " " 2017-02-25 17:21:01 -05:00
Robert Edmonds
c48d932003 Merge pull request #228 from pbor/wip/proto3
proto3 support
2017-02-25 14:20:04 -08:00
Robert Edmonds
0973be46d2 Merge pull request #256 from protobuf-c/issue/251
Fix "Bad enums with multiple oneofs" (#251)
2017-02-25 13:03:16 -08:00
Robert Edmonds
1442642234 t/issue251/: Add test case for #251 2017-02-25 15:52:39 -05:00
Robert Edmonds
638c54d4db GenerateStructDefinition(): Reset vars["opt_comma"] when processing multiple oneofs
This commit fixes #251, which causes incorrect code to be generated when
there are multiple oneofs in the same message.

In #221, we added code to force int-sizing for oneof enums, but we only
set vars["opt_comma"] initially, before entering the loop over the
message's oneofs. This caused commas to be omitted when generating the
enums for subsequent oneofs after the first oneof.

This commit resets vars["opt_comma"] every time through the loop that
generates the enum declarations for the message's oneofs.
2017-02-25 15:52:39 -05:00
Robert Edmonds
956ea86712 GenerateStructDefinition(): Append oneof name when forcing enums to be int size
This commit fixes a problem identified in #251. When generating the
PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE directive at the end of the enum
values generated for a oneof, we inadvertently only included the
protobuf class name in the call to the directive. This breaks if there
is more than one oneof per protobuf class, which causes duplicate enum
names to be generated.

This issue is fixed by also appending the oneof's name to the protobuf
class name when generating the PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE
directive, which should cause unique enum names to be generated.

This changes the enum name that is generated, but these names are
implementation details since they are sentinel values that only exist to
force the compiler to size the enum type correctly.

(The test case for #220 is updated since that test relies on the
oneof implementation details in the code generator.)
2017-02-25 15:52:39 -05:00
Robert Edmonds
424c498728 Merge pull request #255 from ewxrjk/free-null
Document and extend the effect of passing NULL to ..._free_unpacked functions
2017-02-25 12:49:38 -08:00
Richard Kettlewell
c23065e4b1 Allowing <type>__free_unpacked(NULL, ...)
This makes __free_unpacked() consistent with free(), and simplifies
callers by allowing them to indiscriminately free message objects
without regard to whether they have been allocated or not.
2017-02-25 19:59:17 +00:00
Richard Kettlewell
f06a172a91 Document that protobuf_c_message_free_unpacked(NULL, ...) is allowed 2017-02-25 19:59:17 +00:00
Robert Edmonds
581e2cb1bf Merge pull request #254 from protobuf-c/test/220
Add test case for #220
2017-02-25 11:56:30 -08:00
Robert Edmonds
d89895de3c t/issue220/: Add test case for #220 2017-02-25 14:49:09 -05:00
Josh
cfbe34f6f4 CMAKE_SOURCE_DIR -> CMAKE_CURRENT_SOURCE_DIR
This tells CMake to refer to the currently executed `CMakeLists.txt`'s directory instead of the root project directory. This allows protobuf-c to be included as a subdirectory (via `include_subdirectory`) while being innocuous for those that build protobuf-c by itself.
2016-12-04 18:48:47 -08:00
AlexMilich
0656a9ac35 Static build for Windows MSVC 2016-11-27 12:39:37 +02:00
Paolo Borelli
29b25869fa bump protobuf version in travis to 3.0.2
protobuf does not provide configured tarballs anymore, so we need
to run autogen.sh ourselves.
2016-10-30 11:20:47 +01:00
Paolo Borelli
2f22519f58 Add basic proto3 test
Same code of the proto2 test but with the corresponding proto3 file
2016-10-30 10:06:52 +01:00
Paolo Borelli
8194f4d91a proto3 support
This is a first cut at adding proto3 support.

As far as I understand protobuf-c already has pretty much everything
needed once it is built using a new version of protobuf itself.
The only missing thing is that in proto3 all fields are optional and
having to manually set has_foo is inconvenient.

This patch special cases the proto3 syntax files so that structs for the
bytes, enum and primitive fields do not emit the has_ field.

It also adds PROTOBUF_C_LABEL_NONE to the label enum that is used for
proto3 fields. When a fields has this label, the quantifier is not
consulted and instead the field is packed/unpacked depending on
whether it has a value different from NULL/0.
2016-10-30 10:06:52 +01:00
Robert Edmonds
9c4c8f6366 Merge pull request #236 from tkoecker/const_init_value
Make init_value const
2016-09-07 12:20:39 -07:00
Robert Edmonds
d5e1b3843e Merge pull request #234 from tkoecker/solaris_rm_args
rm argument fix for solaris
2016-09-07 12:19:09 -07:00
Robert Edmonds
fcb1bdd25c Merge pull request #233 from ben-farnham/change_configure_to_work_with_autom4te_v2_63
Relax autoconf constraint from v2.64 -> v2.63 (so that it works on SL6)
2016-09-07 12:17:58 -07:00
Thomas Köckerbauer
f73cc06d1e make init_value const 2016-09-07 15:18:41 +02:00
Thomas Köckerbauer
3ddc7c62ca rm argument fix for solaris 2016-09-07 10:33:38 +02:00
Ben Farnham
d0b0dbaeeb relax constraint slightly from v2.64 -> v2.63 (so that it works on scientific linux 6) 2016-09-07 09:07:12 +02:00
Robert Edmonds
d6ede8125e Merge pull request #232 from gdetal/master
protobuf-c: fix: make dist
2016-08-24 20:20:50 -07:00
Robert Edmonds
6503d2fb0f Merge pull request #231 from udnaan/next
fixed cmake build if built as  part of an external project
2016-08-24 20:18:13 -07:00
Gregory Detal
5306fc9329 protobuf-c: fix: make dist
remove .pb.{cc,h} in distdir instead of top_distdir in order to
prevent removing files from other projects when protobuf-c is
included as an autotools subproject.

Signed-off-by: Gregory Detal <gregory.detal@tessares.net>
2016-08-24 14:38:49 +02:00
Adnan
03205837fe fixed cmake build if built as part of an external project 2016-08-10 16:26:31 -07:00
Robert Edmonds
8bfe960293 Merge pull request #221 from protobuf-c/issue220
protoc-c/c_message.cc: Force int size on oneof enums
2016-07-04 14:29:10 -04:00
Ilya Lipnitskiy
651ec8f512 .travis.yml: Remove clang check for now
http://lists.llvm.org/pipermail/llvm-foundation/2016-May/000020.html

travis-ci/travis-ci#6120
2016-06-17 00:27:34 -07:00
Ilya Lipnitskiy
bb6553c397 protoc-c/c_message.cc: Force int size on oneof enums
Fixes #220. Patch by Dave Benson from the mailing list thread.
2016-06-17 00:27:34 -07:00
Robert Edmonds
c22b2a106b Merge pull request #215 from twasilczyk/next
Fix bigendian -Wunused-label warning
2016-05-05 19:10:28 -07:00
Tomasz Wasilczyk
3c214bce79 Fix bigendian -Wunused-label warning 2016-05-02 14:13:38 +01:00
Robert Edmonds
9f4cbec908 Merge pull request #214 from twasilczyk/next
Fix ISO C90 -Wdeclaration-after-statement warnings
2016-04-30 00:07:41 -04:00
Tomasz Wasilczyk
eb899168b8 Fix ISO C90 -Wdeclaration-after-statement warnings 2016-04-27 23:33:09 +01:00
Robert Edmonds
26186b63e6 Merge pull request #213 from twasilczyk/next
Fix -Wsign-compare warnings in int32_size()
2016-04-27 17:24:50 -04:00
Tomasz Wasilczyk
534afc5997 Fix -Wsign-compare warnings 2016-04-27 21:57:39 +01:00
Robert Edmonds
bd9cd96e81 CONTRIBUTING.md: New 2016-04-26 16:40:49 -04:00
Robert Edmonds
4f13ec7abb .gitignore: protoc-c/protoc-gen-c 2016-04-26 16:35:22 -04:00
Robert Edmonds
171ccd222b Merge remote-tracking branch 'pbor/wip/plugin' into next 2016-04-25 21:40:37 -04:00
Ilya Lipnitskiy
2ea8fc7087 test-generated-code2.c: Add default value test 2016-04-22 11:35:14 -07:00
Ilya Lipnitskiy
258eb7d4dc protoc-c/c_enum_field.cc: Fix default enum values
From https://developers.google.com/protocol-buffers/docs/proto#optional:
If the default value is not specified for an optional element, a
type-specific default value is used instead: for strings, the default
value is the empty string. For bools, the default value is false. For
numeric types, the default value is zero. For enums, the default value
is the first value listed in the enum's type definition. This means care
must be taken when adding a value to the beginning of an enum value
list.

Prior to this change, protoc-c set the default enum value to 0, whether
or not 0 was the first value listed in the enum's type definition (or if
it even was listed at all).
2016-04-22 11:12:15 -07:00
Paolo Borelli
af2120aa55 Turn the compiler into a protoc plugin
Using the old "protoc-c" command directly is still supported
through a symlink.
2016-02-17 10:58:43 +01:00
Robert Edmonds
006d69bd84 ChangeLog: 1.2.1 v1.2.1 2016-02-02 15:09:01 -05:00
Robert Edmonds
4560136675 Bump version to 1.2.1 2016-02-02 15:03:53 -05:00
Robert Edmonds
bb3cf5a887 Merge branch 'branches/pulls/205' into next 2016-02-02 15:00:51 -05:00
Robert Edmonds
58b03b6b1b ChangeLog update 2016-02-02 15:00:17 -05:00
Paolo Borelli
af613f932a Fix union initialization
Using {} as an initializer fails on MSVC

Signed-off-by: Paolo Borelli <pborelli@gnome.org>
2016-02-02 14:45:29 -05:00
Robert Edmonds
1d4aff9648 ChangeLog: 1.2.0 v1.2.0 2016-01-29 19:52:28 -05:00
Robert Edmonds
25d5e51db7 Bump version to 1.2.0 2016-01-29 19:52:28 -05:00
Robert Edmonds
3f4a5f6718 LICENSE: 2016 2016-01-29 19:52:28 -05:00
Zex
d6ac08c8ba skip protoc-c tests on cross-compiling 2016-01-29 18:53:04 -05:00
Diego Elio Pettenò
4013655890 Update link to Autotools Mythbuster to canonical site
I've moved the guide to its own domain some time ago, fix the reference to avoid the redirects.
2016-01-09 17:39:27 -05:00
Ilya Lipnitskiy
a8d746a27c t: Add coverage
Remove a redundant test and add two large number test cases.
2015-12-12 22:06:41 -08:00
Ilya Lipnitskiy
6fc4e97bf0 protobuf-c.c: Replace other bitwise shifts with 1UL
This change helps keep protobuf-c compatible with systems where int is
less than 4 bytes long. This change also makes left shifts more
consistent.
2015-12-12 21:55:32 -08:00
Peter Leschev
7b4c18a082 Fixes #196 2015-12-12 20:36:35 -08:00