Merge pull request #1437 from capnproto/expose-parser-loader
Add `SchemaParser::getAllLoaded()` to get all parsed schemas.
diff --git a/c++/src/kj/compat/http.h b/c++/src/kj/compat/http.h
index a59932e..de5afe7 100644
--- a/c++/src/kj/compat/http.h
+++ b/c++/src/kj/compat/http.h
@@ -298,6 +298,12 @@
kj::Maybe<kj::StringPtr> get(HttpHeaderId id) const;
// Read a header.
+ //
+ // Note that there is intentionally no method to look up a header by string name rather than
+ // header ID. The intent is that you should always allocate a header ID for any header that you
+ // care about, so that you can get() it by ID. Headers with registered IDs are stored in an array
+ // indexed by ID, making lookup fast. Headers without registered IDs are stored in a separate list
+ // that is optimized for re-transmission of the whole list, but not for lookup.
template <typename Func>
void forEach(Func&& func) const;
diff --git a/c++/src/kj/filesystem-disk-test.c++ b/c++/src/kj/filesystem-disk-test.c++
index d1d9fa2..e9530d3 100644
--- a/c++/src/kj/filesystem-disk-test.c++
+++ b/c++/src/kj/filesystem-disk-test.c++
@@ -23,6 +23,7 @@
#include "test.h"
#include "encoding.h"
#include <stdlib.h>
+#include <string>
#if _WIN32
#include <windows.h>
#include "windows-sanity.h"
@@ -945,5 +946,34 @@
}
#endif
+#if !_WIN32 // Only applies to Unix.
+// Ensure the current path is correctly computed.
+//
+// See issue #1425.
+KJ_TEST("DiskFilesystem::computeCurrentPath") {
+ TempDir tempDir;
+ auto dir = tempDir.get();
+
+ // Paths can be PATH_MAX, but the segments which make up that path typically
+ // can't exceed 255 bytes.
+ auto maxPathSegment = std::string(255, 'a');
+
+ // Create a path which exceeds the 256 byte buffer used in
+ // computeCurrentPath.
+ auto subdir = dir->openSubdir(Path({
+ maxPathSegment,
+ maxPathSegment,
+ "some_path_longer_than_256_bytes"
+ }), WriteMode::CREATE | WriteMode::CREATE_PARENT);
+
+ auto origDir = open(".", O_RDONLY);
+ KJ_SYSCALL(fchdir(KJ_ASSERT_NONNULL(subdir->getFd())));
+ KJ_DEFER(KJ_SYSCALL(fchdir(origDir)));
+
+ // Test computeCurrentPath indirectly.
+ newDiskFilesystem();
+}
+#endif
+
} // namespace
} // namespace kj
diff --git a/c++/src/kj/filesystem-disk-unix.c++ b/c++/src/kj/filesystem-disk-unix.c++
index 147b8f1..cc19878 100644
--- a/c++/src/kj/filesystem-disk-unix.c++
+++ b/c++/src/kj/filesystem-disk-unix.c++
@@ -1710,7 +1710,7 @@
KJ_STACK_ARRAY(char, buf, size, 256, 4096);
if (getcwd(buf.begin(), size) == nullptr) {
int error = errno;
- if (error == ENAMETOOLONG) {
+ if (error == ERANGE) {
size *= 2;
goto retry;
} else {
diff --git a/doc/language.md b/doc/language.md
index 034e854..a0bfad9 100644
--- a/doc/language.md
+++ b/doc/language.md
@@ -606,7 +606,7 @@
{% endhighlight %}
The possible targets for an annotation are: `file`, `struct`, `field`, `union`, `group`, `enum`,
-`enumerant`, `interface`, `method`, `parameter`, `annotation`, `const`.
+`enumerant`, `interface`, `method`, `param`, `annotation`, `const`.
You may also specify `*` to cover them all.
{% highlight capnp %}