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