Correct the definition of capnp_use(x) macro.
> recommended to surround macro arguments
> in the replacement list with parentheses. This
> ensures that the argument value is calculated
> properly.
When working with integer constants, it is convenient to use #define
macros for the constants, as opposed to a variable of constant type.
This patch adds a '#define CONSTANT (value)' definition to the
generated header files. The name of the constant is in
SCREAMING_SNAKE_CASE, converted from the regular camelCase.
Signed-off-by: Curt Brune <curt@enfabrica.net>
This patch adds the 'const' keyword to constant definitions generated
by the compiler. Previously the compiler generated constants like
this:
foo.h
======
extern int foo;
foo.c
======
int foo = 5;
With this patch, the generated code looks like:
foo.h
======
extern const int foo;
foo.c
======
const int foo = 5;
Signed-off-by: Curt Brune <curt@enfabrica.net>
This patch adds an annotation for creating name spaces within
capnproto files with the C-language code generator.
Use the annotation like this:
using C = import "/c.capnp";
$C.namespace("sample_namespace_");
The string passed into the namespace annotation is prepended to the
name of all the struct's in the schema file.
Signed-off-by: Curt Brune <curt@enfabrica.net>
This patch modifies the code generator to only generate C-language
`#include <imported_schema.h>` lines for imports that are actually used.
Imagine this transitive import scenario: schema A imports a definition
from schema B. However, the definition imported from schema B was
itself imported from schema C.
In this case, the code generated for schema A need not include the
header file for schema B, as it only needs definitions from schema C.
Signed-off-by: Curt Brune <curt@enfabrica.net>
schema files.
Some schema files (eg. those that only decalare annotations) do not actually
result in any generated C code. They do not need to have a corresponding
include directive for C files generated from schemas that include them. This
introduces a "donotinclude" annotation that takes the Cap'n Proto ID (a
UInt64) of any such files and skips generating the include directive for them.