From 6a95f7b765585713b051e252747d30abc710e03c Mon Sep 17 00:00:00 2001 From: lahiker42 Date: Tue, 10 Feb 2009 01:45:41 +0000 Subject: [PATCH] git-svn-id: https://protobuf-c.googlecode.com/svn/trunk@167 00440858-1255-0410-a3e6-75ea37f81c3a --- doc/c-code-generator.xml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/doc/c-code-generator.xml b/doc/c-code-generator.xml index 9ed6de6..79e1558 100644 --- a/doc/c-code-generator.xml +++ b/doc/c-code-generator.xml @@ -47,7 +47,8 @@ called libprotobuf-c rather than generated code. would generate a C type Foo__Bar__BazBah. Functions and globals are all lowercase, with camel-case - words separated by single underscores. + words separated by single underscores; namespaces are separated with + double-underscores. For example:
Message Methods - The message structures all begin with ProtobufCMessageDescriptor* - which is sufficient to allow them to be cast to ProtobufCMessage. + The message structures all begin with ProtobufCMessage, + so they may be cast to that type. We generate some functions for each message: @@ -174,6 +175,7 @@ called libprotobuf-c rather than generated code. We will get generated code: void *closure_data); void (*destroy) (Convert_Service *service); }; - ProtobufCService *convert__create_service (Foo__DirLookup_Service *service); ]]> - Note that create_service takes ownership of service. - For example, here's how to implement a convert service that takes the default radix to use: create_convert_service_from_radix (unsigned radix) { Convert_WithRadix *wr = malloc (sizeof (Convert_WithRadix)); + convert__init (wr, (Convert__ServiceDestroy) free); wr->base.itoa = radix_itoa; wr->base.atoi = radix_atoi; - wr->base.destroy = (void(*)(Convert_Service *)) free; wr->radix = radix; - return convert__create_service (&wr->base); + return (ProtobufCService *) wr; } ]]> - Note that, unlike with messages, you must NOT cast - from Convert_Service to ProtobufCService. + Just like with messages, you may cast + from Convert_Service to ProtobufCService, + at least as long as you have run the __init function. Conversely, we generate functions to help you invoke service