git-svn-id: https://protobuf-c.googlecode.com/svn/trunk@177 00440858-1255-0410-a3e6-75ea37f81c3a
This commit is contained in:
lahiker42 2009-03-08 14:35:12 +00:00
parent fc428c1200
commit c5ae90eb85
3 changed files with 17 additions and 6 deletions

View File

@ -1,5 +1,5 @@
AC_INIT(src/google/protobuf-c/protobuf-c.h) AC_INIT(src/google/protobuf-c/protobuf-c.h)
PROTOBUF_C_VERSION=0.9 PROTOBUF_C_VERSION=0.10-beta0
AM_INIT_AUTOMAKE(protobuf-c, $PROTOBUF_C_VERSION) AM_INIT_AUTOMAKE(protobuf-c, $PROTOBUF_C_VERSION)
PACKAGE=protobuf-c PACKAGE=protobuf-c
@ -21,7 +21,7 @@ you must add '-Iincludedir' to CXXFLAGS
and '-Llibdir' to LDFLAGS. and '-Llibdir' to LDFLAGS.
])]) ])])
pbc_savelibs="$LIBS" pbc_savelibs="$LIBS"
LIBS="$LIBS -lprotoc" LIBS="$LIBS -lprotoc -lprotobuf"
AC_TRY_LINK([#include <google/protobuf/compiler/command_line_interface.h>], AC_TRY_LINK([#include <google/protobuf/compiler/command_line_interface.h>],
[google::protobuf::compiler::CommandLineInterface cli;], [google::protobuf::compiler::CommandLineInterface cli;],
[], [],

View File

@ -255,8 +255,9 @@ struct _ProtobufCMessageDescriptor
* In particular, ProtobufCMessage doesn't have * In particular, ProtobufCMessage doesn't have
* any allocation policy associated with it. * any allocation policy associated with it.
* That's because it is common to create ProtobufCMessage's * That's because it is common to create ProtobufCMessage's
* on the stack. In fact, we recommend that if you are * on the stack. In fact, we that's what we recommend
* sending messages. * for sending messages (because if you just allocate from the
* stack, then you can't really have a memory leak).
* *
* This means that functions like protobuf_c_message_unpack() * This means that functions like protobuf_c_message_unpack()
* which return a ProtobufCMessage must be paired * which return a ProtobufCMessage must be paired
@ -276,6 +277,14 @@ struct _ProtobufCMessage
}; };
#define PROTOBUF_C_MESSAGE_INIT(descriptor) { descriptor, 0, NULL } #define PROTOBUF_C_MESSAGE_INIT(descriptor) { descriptor, 0, NULL }
/* To pack a message: you have two options:
(1) you can compute the size of the message
using protobuf_c_message_get_packed_size()
then pass protobuf_c_message_pack() a buffer of
that length.
(2) Provide a virtual buffer (a ProtobufCBuffer) to
accept data as we scan through it.
*/
size_t protobuf_c_message_get_packed_size(const ProtobufCMessage *message); size_t protobuf_c_message_get_packed_size(const ProtobufCMessage *message);
size_t protobuf_c_message_pack (const ProtobufCMessage *message, size_t protobuf_c_message_pack (const ProtobufCMessage *message,
uint8_t *out); uint8_t *out);
@ -398,8 +407,6 @@ struct _ProtobufCBufferSimple
/* ====== private ====== */ /* ====== private ====== */
#include "protobuf-c-private.h" #include "protobuf-c-private.h"
/* TODO: crib from glib */
#define PROTOBUF_C_GNUC_PRINTF(format_argno, ellipsis_argno)
PROTOBUF_C_END_DECLS PROTOBUF_C_END_DECLS

View File

@ -8,6 +8,10 @@ enum TestEnumSmall {
VALUE = 0; VALUE = 0;
OTHER_VALUE = 1; OTHER_VALUE = 1;
} }
// these number are specifically chosen to test the
// boundaries of when an enum requires a certain number of bytes.
// e.g. 16383 requires 3 bytes; 16383 requires 4.
enum TestEnum { enum TestEnum {
VALUE0 = 0; VALUE0 = 0;
VALUE1 = 1; VALUE1 = 1;