Commit graph

253 commits

Author SHA1 Message Date
Jonah Beckford
a5138e4aaf Do ./dk dkml.wrapper.upgrade 2023-08-10 16:27:55 -07:00
Jonah Beckford
2aeccdbe6a Cache .ci for Conda CI machines 2023-08-08 09:06:00 -07:00
Jonah Beckford
a3e6f6c331 Instructions for CMake usage
Also do lint fixes for Markdown.

Also, do not install tests code, especially
GTest, when installing c-capnproto
through CMake
2023-08-08 07:00:46 -07:00
Jonah Beckford
d8b55078ba Add C++ standard to CMake for MSVC 2023-08-07 20:55:41 -07:00
Jonah Beckford
f07596dbb5 Add CMake and tests
- Port tests to GitLab
- Add GitLab CI test matrix
- Remove gtest submodule
2023-08-07 20:28:42 -07:00
Jonah Beckford
7056638935 Avoid undefined left shift of negatives 2023-08-07 17:26:44 -07:00
Jonah Beckford
311b9cb0e0 Fix clang-tidy bugprone-macro-parentheses
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.
2023-08-03 18:19:55 -07:00
Jonah Beckford
c662042a60 Read schemas in binary on Windows 2023-06-22 12:11:03 -07:00
Jonah Beckford
25784e3ccf Use SSIZE_T from BaseTsd.h to compile MSVC 32-bit 2023-06-07 21:24:33 -07:00
Jonah Beckford
01657913b2 Put alignment on segment fields. Work with MSVC 2023-05-09 18:22:57 -07:00
David Lamparter
632f0d73a1 Update autogenerated files
Signed-off-by: David Lamparter <equinox@diac24.net>
2023-04-23 14:35:11 +02:00
David Lamparter
79d6035e3f Revert "Merge pull request #54 from cbrune/curt/const"
This reverts commit 4109705a8d, reversing
changes made to 5c4e497a72.
2023-04-23 14:33:18 +02:00
David Lamparter
eb1839e001 Fix bool defaults for non-first bit
Fixes: #58
Signed-off-by: David Lamparter <equinox@diac24.net>
2023-04-23 14:30:11 +02:00
David Lamparter
b2b7ade9c0 Fix random warnings
Signed-off-by: David Lamparter <equinox@diac24.net>
2023-04-23 14:21:58 +02:00
David Lamparter
c79b3afbbd
Merge pull request #24 from jlferrer/fix_compiler_big_files 2023-04-23 14:12:52 +02:00
David Lamparter
32520c5eb3
Merge pull request #60 from XVilka/github-ci 2023-04-23 14:12:34 +02:00
David Lamparter
32def19b9d
Merge pull request #57 from XVilka/meson-build 2023-04-23 14:12:13 +02:00
David Lamparter
4109705a8d
Merge pull request #54 from cbrune/curt/const 2023-04-23 14:11:49 +02:00
David Lamparter
5c4e497a72
Merge pull request #53 from cbrune/curt/reduce-imports 2023-04-23 14:11:30 +02:00
David Lamparter
0653675ef4
Merge pull request #52 from cbrune/curt/namespace 2023-04-23 14:11:13 +02:00
David Lamparter
2116160973
Merge pull request #49 from detly/capn_size_size 2023-04-23 14:10:48 +02:00
David Lamparter
560f2c7cb9
Merge pull request #45 from snar/p-field 2023-04-23 14:10:24 +02:00
David Lamparter
4a39ec4251
Merge pull request #46 from snar/freebsd-endian 2023-04-23 14:10:08 +02:00
David Lamparter
b87f0ee3f6 README: make project state clear
Signed-off-by: David Lamparter <equinox@diac24.net>
2023-04-23 14:09:24 +02:00
Anton Kochkov
6377038820 Add GitHub CI 2023-04-23 17:32:46 +08:00
Anton Kochkov
53f6def21b Add Meson building instructions in README 2023-04-23 17:21:34 +08:00
Anton Kochkov
6b8e3caed3 Ignore subprojects in git 2023-04-23 17:19:57 +08:00
Anton Kochkov
6eb98cbd5e Initial Meson build support 2023-04-23 17:10:53 +08:00
Curt Brune
3385b1e73a add #define definitions for integer constants
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>
2022-10-27 13:11:32 -07:00
Curt Brune
40d689516a add 'const' keyword to generated constants
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>
2022-10-14 09:17:09 -07:00
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
Curt Brune
1772643adb only generate '#include' for imports that are used
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>
2022-10-14 09:14:31 -07:00
Jason Heeris
05482f36a8 Use int64_t for the return value of capn_size(). This makes it consistent with a recent change to capn_write_mem(). 2021-05-10 22:39:28 +08:00
Jason Heeris
0650ccbf17
Merge pull request #47 from QQNN-blue/change_capn_write_mem_return_val_type
Change capn_write_mem return value from int to int64_t
2021-05-10 22:19:28 +08:00
Jason Heeris
939aa30c0a
Merge pull request #37 from detly/write_size
Implemented capn_size() for calculating buffer size
2021-05-10 21:58:57 +08:00
Jason Heeris
a2179f48c8 Make the comment for capn_size() clearer that it only applies to unpacked serialisation. 2021-05-10 21:55:01 +08:00
Jason Heeris
bbc208cf04 Simplified size calculation. 2021-05-10 17:52:42 +08:00
Jason Heeris
d29faccc64 Implemented capn_size() for dynamically calculating the required buffer size for capn_write_mem(). 2021-05-10 17:52:42 +08: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
515c06c689
Merge pull request #41 from detly/enum_cast
Fix bug where enums were treated interchangeably with uint16_t.
2021-05-10 17:35:12 +08:00
QQNN-blue
3c0b223b8c Change capn_write_mem return value from int to int64_t 2021-02-17 11:39:03 -08:00
Alexandre Snarskii
86bee96031 Fix FreeBSD builds 2021-02-01 14:11:45 +03:00
Alexandre Snarskii
72efa0bb27 Allow field name to be 'p'. 2021-02-01 13:43:04 +03: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
Joel Carlson
9053ebe6ee compiler/str.h: include stdarg.h for va_list
With some toolchains, compilation of str.c produced the following error:

compiler/str.h:56:50: error: unknown type name ‘va_list’
 int str_vaddf(struct str *v, const char *format, va_list ap) ATTR(2,0);
                                                  ^~~~~~~

One toolchain had the following in its stdarg.h:
"We deliberately do not define va_list when called from
stdio.h, because ANSI C says that stdio.h is not supposed to
define va_list."

str.c includes stdio.h, but none of the prior includes result in the
inclusion of stdarg.h. Therefore, explicitly include it in str.h to fix
the issue on toolchains following this ANSI C rule.

Signed-off-by: Joel Carlson <JoelsonCarl@gmail.com>
2019-04-22 20:58:49 +01:00