Curt Brune
c70796b9fb
add a capnp annotation for creating name spaces
...
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>
2022-10-14 09:15:11 -07:00
Jason Heeris
024dca615a
Merge pull request #42 from detly/annotations
...
Two extra annotations: donotinclude and typedefto
2021-05-10 17:43:14 +08:00
Jason Heeris
b619a87c61
Merge pull request #44 from detly/nested_unions
...
Fix code generation for nested unions.
2021-05-10 17:37:05 +08:00
Jason Heeris
6661fc9d2d
Fix code generation for nested unions.
...
When a union is nested inside another union, it must be enclosed in a struct
so that its "which" member is not overlapping with its other members.
2021-01-14 10:43:46 +08:00
Jason Heeris
9153fc39c4
Add an annotation to typedef structs and enums.
...
A new annotation 'typedefto' allows you to make a typedef in the generated
code for structs and enums (but not union 'which' enums).
2021-01-02 09:28:31 +08:00
Jason Heeris
fe3a57de13
Added extra line break after structure size block.
2021-01-02 09:28:31 +08:00
Jason Heeris
b995a09c03
Add an annotation to skip including header files generated from specific
...
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.
2021-01-02 09:28:31 +08:00
Jason Heeris
e13c143c99
Fix bug where enums were treated interchangeably with uint16_t.
...
ANSI C makes no guarantee about the size of an enum, only that it will be the
minimum required integer type that can hold all the given values. Treating
enums as interchangeable with uint16_t data caused undefined behavoiur on
platforms where enums were always at least 32 bits.
2020-12-28 21:46:37 +08:00
Alexis Ballier
704a34fa65
Use proper format specifiers for size_t.
2017-05-19 19:26:47 +02:00
David Lamparter
aa1f31d401
Silence empty struct warning
...
Last but not least, -Wpedantic warns about empty structs. With this,
-Wpedantic build is now clean of warnings on gcc 5.4.0 and clang 4.0.
2017-05-19 09:45:01 +02:00
David Lamparter
b0810da2c3
Silence warning on unused struct parameter
...
When generating code for an empty struct, the read_/write_ functions
would print warnings about the unused "s" pointer. Silence these.
2017-05-19 09:40:37 +02:00
David Lamparter
99e9412c02
Silence GCC unnamed union warning
...
We need the unnamed struct/union support, this is user-facing API.
So, silence the -Wpedantic warning.
2017-05-19 09:35:09 +02:00
Alex Helfet
a379aa89ac
Compiler generates absolute #include paths from .capnp imports with leading /'s.
...
As specified in https://capnproto.org/language.html#imports and implemented
in the C++ compiler output plugin.
2017-03-26 18:43:57 +01:00
Alex Helfet
362173091d
compiler: If an explicit symbol wasn't provided, make generated capn_val%d variables static.
2017-03-23 20:18:29 +00:00
Alex Helfet
f16fae57b3
Fix GCC warnings in initializers for capn_val0 and capn_seg.
2017-03-22 06:48:58 +00:00
David Lamparter
54a7bb7ffb
compiler: drop outdated find_node comment & IDs
2016-07-20 08:48:22 +02:00
David Lamparter
c322bc9618
compiler: apply name infix on include filenames
...
This fixes #include output when $C.nameinfix is used.
2016-07-19 15:21:56 +02:00
David Lamparter
da663f83ef
compiler: add annotation to enable field get/set
...
Generating per-field getters/setters adds a lot of functions; this makes
them switchable with an annotation in the source schema.
2016-07-19 15:21:05 +02:00
David Lamparter
52ca907f14
compiler: add find_node_mayfail(), remove hack
...
Fixes github issue #11 , also makes it easier to use annotations.
2016-07-19 15:14:00 +02:00
David Lamparter
5d787b698e
compiler: add "C::nameinfix" annotation
...
allows changing output filenames from "foo.capnp.c" to
"foo.capnpSOMETHING.c" where SOMETHING is the argument to the
annotation.
2016-06-22 15:16:40 +02:00
David Lamparter
48535d02bd
whitespace fixes
2016-06-22 13:44:56 +02:00
Michael Gartsbein
05f5884385
add u to avoid undefined shl
2016-05-05 11:40:13 +03:00
Michael Gartsbein
12ad949df8
working with stricter compiler flags
2016-04-28 12:01:08 +03:00
David Lamparter
e9df12b387
don't write out empty structs
...
"struct { } foo" is not valid ISO C99; while gcc/clang/icc support it,
other compilers and tools don't (e.g. pycparser)
2016-04-06 14:18:29 -03:00
Michael Gartsbein
61a43a4998
static const instead of function in size getters
2016-03-29 10:25:33 +03:00
Michael Gartsbein
e870b5d605
generate setter and getter
2016-03-27 16:35:11 +03:00
David Lamparter
7ecadefbfd
compiler: fix remaining warnings
2016-03-19 00:39:30 +01:00
David Lamparter
811d3046e1
rename to "[lib]capnp_c", use lib/ subdir
2016-03-19 00:39:29 +01:00
David Lamparter
41462901df
lib: fix warning on uint16->enum cast
2016-03-19 00:36:24 +01:00
David Lamparter
ae746a3e08
add approprate per-file license headers
2016-02-28 12:47:42 +01:00
David Lamparter
b55d847db6
Re-fix signed/unsigned warnings
2016-02-28 12:42:52 +01:00
David Lamparter
02268ff818
Merge branch 'kylemanna' into merge
...
Conflicts: (manually resolved)
capn-malloc.c
capn-stream.c
capn-test.cpp
capn.c
capn.h
compiler/capnpc-c.c
2016-02-28 12:32:59 +01:00
Kyle Manna
376b63fb81
signedness: Fix less obvious issues
...
* My compilers mark these as errors
* Attempt to be more correct
* Tested on gcc-5.2.0 and clang-3.6.2
2015-08-17 18:52:36 -07:00
Kyle Manna
e933510236
compiler: Fix missing comments
...
* Later versions of compilers/pre-processors are upset about the syntax
* Bracket unterminated string with proper comment tags
2015-08-17 18:50:53 -07:00
Liam Staskawicz
560366c7d4
compiler: introduce workaround for annotation ids in nestednode list (see comments), and regenerate schema .{c|h} files based on capnproto v0.5.2
2015-08-04 11:56:00 -07:00
Liam Staskawicz
125c638c11
unreal: gcc complains about missing ‘ character in #if 0 block
2015-08-04 10:25:08 -07:00
James McKaskill
ff44e4df26
remove CAPN_COMPOSITE_LIST and add capn_len
2013-09-16 16:53:33 -04:00
James McKaskill
59f827e93d
change ptrsz to ptrs to free up space in capn_ptr
2013-09-13 10:02:03 -04:00
James McKaskill
7b0bfece26
add version checks
2013-09-12 23:28:36 -04:00
James McKaskill
081c783bbf
don't autoresolve pointers
2013-09-12 17:26:51 -04:00
James McKaskill
bba43e67ea
Add test schema
2013-09-12 14:55:42 -04:00
James McKaskill
9682fb2611
list out constants in declaration order
2013-09-12 14:48:11 -04:00
James McKaskill
ca1d07f657
Round trip the schema through the compiler
2013-09-12 14:37:15 -04:00
James McKaskill
82e55f6515
declare enums first
2013-09-12 14:26:22 -04:00
James McKaskill
cada8df6c2
Decode field slot when we get around to declaring it rather than early as the names aren't resolved yet
2013-09-12 14:23:40 -04:00
James McKaskill
316f470c3b
Handle reserved words
2013-09-12 14:14:21 -04:00
James McKaskill
9f75d0c7a6
Update compiler to support groups/unions
2013-09-12 13:49:19 -04:00
James McKaskill
7731509861
add read/write methods for interfaces
2013-05-12 23:10:54 -04:00
James McKaskill
21e7c29a96
add interface to base lib and improve handling of empty lists
2013-05-12 22:58:48 -04:00
James McKaskill
93f695f77c
add constants
2013-05-12 17:21:56 -04:00