500 Commits

Author SHA1 Message Date
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
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
Ilya Lipnitskiy
7634c0e6e6 protobuf-c.c: Pack negative enum values correctly
Fix a few casts where ints were cast to uints unnecessarily

Fixes #199. Previously, enums were treated as uint32's, but they need to
be treated as int32's instead.

t: Add a few test cases with negative enum values
2015-12-12 20:36:35 -08:00
Ilya Lipnitskiy
8debedbc3c test-generated-code2.c: Don't call memcmp with a NULL pointer 2015-12-12 17:43:01 -08:00
Ilya Lipnitskiy
e2d45cbe84 protobuf-c.c: Fix undefined code in zigzag functions 2015-12-12 17:41:38 -08:00
Ilya Lipnitskiy
565f42d300 .travis.yml: Add sanitizer checks
Add support for multiple versions of GCC and clang by using a build
matrix. Switch Travis VM to be based on Ubuntu 14.04
2015-12-12 17:05:05 -08:00
Ilya Lipnitskiy
0e2d3c09e2 Rename LITE_RUNTIME to CODE_SIZE 2015-10-30 15:54:00 -07:00
Ilya Lipnitskiy
4eb49206ff protobuf-c.h: Document the new LITE_RUNTIME behavior 2015-03-15 20:01:03 -07:00
Ilya Lipnitskiy
be99a7ac31 t: Add tests for the LITE_RUNTIME optimization option 2015-03-15 20:01:03 -07:00
Ilya Lipnitskiy
603e431864 protoc-c: Support the optimize_for = LITE_RUNTIME file option
Adds support for the LITE_RUNTIME optimization option to the protobuf-c
compiler. Enabling this option would generate lighter weight message,
enum, and service descriptors that contain NO strings. As a result,
calls to lookup descriptors via the *_get_{field,value,method}_by_name
API will return NULL.

Default compiler behavior (when optimize_for is not specified or is not
set to LITE_RUNTIME) is unchanged.
2015-03-15 20:01:03 -07:00
Ilya Lipnitskiy
8601458e5c protobuf-c.c: Don't crash when *_by_name fields in descriptors are NULL 2015-03-15 20:00:11 -07:00
Robert Edmonds
3b7d27a462 ChangeLog: 1.1.1 v1.1.1 2015-03-14 17:00:57 -04:00
Robert Edmonds
9983a190a0 Bump version to 1.1.1 2015-03-14 17:00:57 -04:00
Robert Edmonds
21dead9e19 Bump copyright year to 2015 2015-03-14 17:00:57 -04:00
Robert Edmonds
a5a802641a .travis.yml: Update protobuf dependency to 2.6.1 2015-03-14 16:08:10 -04:00
Andrey Myznikov
812ecf9326 Fix incorrect 'Short version of service name' generation for ProtobufCServiceDescriptor 2015-03-14 16:00:28 -04:00
Robert Edmonds
cbe7b84a14 Merge remote-tracking branch 'github/protoc_c_comments' into next 2015-03-13 12:42:51 -04:00
Ilya Lipnitskiy
c89cd01189 .travis.yml: Exclude protoc-c from the coveralls report 2015-02-14 20:45:04 -08:00
Oleg Efimov
0a29317348 .travis.yml: exclude downloaded protobuf sources from coveralls report 2015-02-14 20:40:07 -08:00
Ilya Lipnitskiy
ce6cc2350f TODO: Remove items that have been completed 2015-02-14 19:32:54 -08:00
Ilya Lipnitskiy
b64f6c1f68 protoc-c/c_enum.cc: Make enum_values_{by_name,by_number} structs static 2015-02-14 19:21:29 -08:00
Ilya Lipnitskiy
617fa7ef6f test-generated-code2.c: Cosmetic change 2015-02-14 17:28:36 -08:00
Ilya Lipnitskiy
8f42a69f86 protoc-c/c_helpers.cc: Enhance comment string parsing
Certain protobuf comments could generate invalid C comments
and inadvertently close the comment block. This commit removes '/'
signs in such comments.

One example of a .proto file containing such comments is a commonly
included descriptor.proto from the protobuf library.
2015-01-30 20:11:34 -08:00
Oleg Efimov
5238d655b9 protobuf-c.c: Better input checks in protobuf_c_message_free_unpacked
Check for NULL pointer for repeated fields passed to protobuf_c_message_free_unpacked

Closes #177
2015-01-18 22:09:15 +03:00
Oleg Efimov
24182d859f protobuf-c.c: Better input checks in protobuf_c_message_free_unpacked
Check for NULL message pointer passed to protobuf_c_message_free_unpacked

Closes #177
2015-01-18 22:09:15 +03:00
Oleg Efimov
f49fabead4 t: fix compile warnings about pointers of different types assignments
warning: assigning to 'uint8_t *' (aka 'unsigned char *')
from 'char *' converts between pointers to integer types
with different sign [-Wpointer-sign]
2015-01-06 22:48:00 +03:00
Robert Edmonds
b0b0e874a4 ChangeLog: 1.1.0 v1.1.0 2015-01-05 16:25:09 -05:00
Robert Edmonds
287c916f9d bump version to 1.1.0 2015-01-05 15:54:02 -05:00
Robert Edmonds
a57204d867 ChangeLog: Document recent changes 2015-01-05 15:36:28 -05:00
Ilya Lipnitskiy
35ec2e2f9c protoc-c: Print comments for generated enum, message, and field definitions 2014-12-16 18:12:54 -08:00
Ilya Lipnitskiy
8eec9c90e6 protobuf-c.h: Add docs for generated message init macro and function 2014-12-06 22:53:05 -08:00
Robert Edmonds
c23348a14e Fix PROTOBUF_C_VERSION, PROTOBUF_C_VERSION_NUMBER 2014-11-24 16:38:22 -05:00
Robert Edmonds
e0841a957e configure.ac: next has 1.1.0 in development 2014-11-24 16:23:08 -05:00
Robert Edmonds
0ba0fe6aab ChangeLog: oneof support 2014-11-24 16:20:23 -05:00
Robert Edmonds
453f39e692 Merge oneof support 2014-11-24 16:18:56 -05:00
Robert Edmonds
8f23163f68 ChangeLog: Document fix in previous commit 2014-11-24 16:18:04 -05:00
Ilya Lipnitskiy
6090d9a924 t: Add tests for oneoffs
Add test cases for parsing multiple fields of the same oneof from the wire
Add more tests for submessage merging, including oneofs
2014-11-19 23:07:23 -08:00
Ilya Lipnitskiy
9db84a3b90 protoc-c: Implement oneofs 2014-11-19 23:07:23 -08:00
Ilya Lipnitskiy
2e465cfdc7 configure.ac: Bump min protobuf version to 2.6.0 for oneof parsing support 2014-11-19 22:06:21 -08:00
Ilya Lipnitskiy
791b0458bf protobuf-c.{c,h}: Implement oneof support
Add a field flag and functions to pack/unpack oneofs
Add logic to parse multiple fields for the same oneof
Add logic for merging submessages that contain oneofs
2014-11-19 22:06:21 -08:00
Ilya Lipnitskiy
060c071209 protobuf-c.c: Fix a bug when merging optional byte fields 2014-11-18 23:52:15 -08:00
Ilya Lipnitskiy
c6a950c53c README.md: Add a Documentation section 2014-11-15 01:00:43 -08:00
Ilya Lipnitskiy
24dd502094 .commit_docs.sh: initial version of the documentation update script 2014-11-15 00:27:50 -08:00
Robert Edmonds
0481c71e06 ChangeLog: finalize 1.0.2 v1.0.2 2014-09-12 16:32:42 -04:00
Robert Edmonds
57bdb38886 ChangeLog: alex85k -> Alexei Kasatkin 2014-09-10 14:33:20 -04:00
Robert Edmonds
151d48d956 ChangeLog: 1.0.2 2014-09-08 17:48:31 -04:00
Robert Edmonds
58f764ecfe bump version to 1.0.2 2014-09-08 17:07:47 -04:00
Robert Edmonds
cb7498b0a7 Makefile.am: distribute build-cmake/CMakeLists.txt
Ironically, we need to tell automake to distribute the CMakeLists.txt
file in the tarball...
2014-09-08 17:05:05 -04:00
Robert Edmonds
b0e0430d57 build-cmake/: add a new CMakeLists.txt file as a fallback
For certain platforms where autotools is not the preferred build system,
provide a fallback cmake file that can compile protoc-c and a static
library of libprotobuf-c.

Based on the file from alex85k's protobuf-c repository.

(Issue #168.)
2014-09-08 17:05:05 -04:00
Natanael Copa
b0bb563033 Makefile.am: fix parallel build of t/generated-code2/cxx-generate-packed-data
The object file name is not what is expected when building with
automake's "subdir-objects" option. Rather than expecting automake to
generate a specific filename, we simply make the generated header a
dependency of all objects for cxx-generate-packed-data.

(Issue #156, #169.)
2014-09-08 17:04:39 -04:00
Robert Edmonds
d80856c3f5 protobuf-c: 'inline' workaround for microsoft compilers
Per http://msdn.microsoft.com/en-us/library/z8y1yy88(v=vs.71).aspx,
Microsoft compilers do not support the Standard C keyword 'inline',
instead preferring the implementation-specific '__inline', so add a
workaround for these specific compilers.

Based on a patch from alex85k (#167).
2014-09-08 16:00:38 -04:00
Robert Edmonds
faf6244ef5 .travis.yml: fetch the protobuf tarball from GitHub instead of Google Code
Per the protobuf developers,

    We will from everything away from Google Code eventually. We haven't
    decided where to put future release packages yet but as it seems github
    supports this well chances are we'll use github as the canonical location
    for all downloads.
2014-09-05 17:18:18 -04:00
Robert Edmonds
51b8da1589 .travis.yml: bump protobuf version to 2.6.0
Build with the latest protobuf release, in preparation for adding
"oneof" support.
2014-09-05 17:17:24 -04:00
Robert Edmonds
6d275c5691 protobuf-c: eliminate void pointer arithmetic
gcc silently treats arithmetic on a void pointer as char pointer
arithmetic without -pedantic. Other compilers do not. Make it explicit
that we are doing arithmetic on a pointer with object size 1.

This eliminates the following diagnostic:

    protobuf-c/protobuf-c.c: In function 'parse_packed_repeated_member':
    protobuf-c/protobuf-c.c:2404:34: warning: pointer of type 'void *' used in arithmetic [-Wpedantic]
      void *array = *(void **) member + siz * (*p_n);

(I did not find any other instances of 'void *' arithmetic when
compiling with -pedantic.)

Based on a patch from alex85k (#167).
2014-09-05 16:35:03 -04:00
Robert Edmonds
7e5c09ea6b protobuf-c: always define PROTOBUF_C__DEPRECATED
If we are not building on gcc, PROTOBUF_C__DEPRECATED needs to be
defined but empty. Previously we were not defining it at all in certain
situations, which would cause build failures.

Based on a patch from alex85k (#167).
2014-09-05 16:05:45 -04:00
Robert Edmonds
3ba170ccc7 .travis.yml: try to speed up the build a bit with "make -j2"
According to the travis-ci documentation, VMs are executed with 1.5
virtual CPU cores, so this should speed up our builds a little bit.
2014-09-05 15:44:47 -04:00