mirror of
https://github.com/zap-proto/cpp-core.git
synced 2026-10-30 15:06:00 +00:00
Build system (autotools/CMake/Bazel) capnp->zap rebrand completed so the
c++/ tree configures cleanly: `autoreconf -i && ./configure` succeeds,
emitting Makefile, all zap*.pc / kj*.pc and the Zap CMake config. configure.ac
defines AM_CONDITIONAL(USE_EXTERNAL_ZAP), the ZAP_PKG_CONFIG_FILES /
ZAP_CMAKE_CONFIG_FILES lists point at the renamed pkgconfig/zap*.pc.in and
cmake/Zap*.cmake.in, and Makefile.am's `if USE_EXTERNAL_ZAP` matches. Bazel
loads @zap-cpp//src/zap:cc_zap_library.bzl. Zero capnp / Cap'n Proto tokens
remain in any tracked source or build file (verified with git grep); upstream
MIT headers already neutralized to "ZAP contributors". quick-test.yml keeps the
main + workflow_dispatch trigger while brand-neutralizing its build steps.
Whitespace-significant schema desugar (compiler/desugar.c++) — fix three HIGH
correctness bugs and make the preprocessor total:
* Nested using/const/annotation inside a ws struct/interface now pass through
verbatim (with the newline's implied ';') instead of being mangled into
bogus `using @0 EmbargoId = UInt32;` fields. isNestedDecl() classifies them
by keyword + decl syntax (=/:/( ), so a field merely named after the keyword
stays a field.
* Ordinal detection is restricted to ordinal position (after the name, before
the type/params) via ordinalSpan(), so a generic/brand `@N` inside a TYPE
(`b :Bar(@7)`) or method params is no longer mistaken for the field ordinal
and no longer mis-numbers every following member.
* Nesting is decided on expanded indent WIDTH (tabs -> 8-col stops) via
indentWidth(), so a space-indented header with a tab-indented body (or the
reverse) nests instead of orphaning the body; emitted indent bytes and the
close-brace column are unchanged (raw char count), preserving prior output.
* Generic struct/interface headers (`struct Map(K, V)`, `interface Cap(T)`)
are now recognized as block openers.
* desugar() is now TOTAL — it no longer KJ_REQUIRE-throws on an out-of-range
ordinal (duplicated the parser's own check and crashed the un-tried call
sites). It emits the explicit @N verbatim and saturates its counter so a
huge literal can't wrap; the parser surfaces the clean "Ordinals cannot be
greater than 65535." diagnostic at the right file:line:col. Removed the now
redundant validateAutoOrdinal and the dead kj/debug.h include. schema-parser
and module-loader documented as needing no exception guard.
desugar-test.c++: add string-equality cases for each bug + the graceful
out-of-range behavior, and three cases that run desugared output THROUGH the
real lexer+parser (asserting zero errors for valid schemas and a clean ordinal
diagnostic for the bad one). Brace back-compat proven byte-identical over the
18-file corpus; sample.ws.zap still desugars to sample.brace.zap exactly.
201 lines
5.7 KiB
JavaScript
201 lines
5.7 KiB
JavaScript
function initSidebar() {
|
|
var filename = document.location.pathname;
|
|
|
|
if (filename.slice(0, 5) == "/next") {
|
|
filename = filename.slice(5);
|
|
}
|
|
|
|
if (filename == "/") {
|
|
filename = "/index.html";
|
|
} else if (filename.slice(0, 6) == "/news/") {
|
|
filename = "/news/";
|
|
}
|
|
|
|
var menu = document.getElementById("menu");
|
|
var setMenuLayout = function() {
|
|
if (window.innerWidth < 900) {
|
|
document.body.className = "narrow";
|
|
menu.className = "";
|
|
document.getElementById("main_content").style.minHeight = "0";
|
|
} else {
|
|
if (document.body.clientWidth < 1340) {
|
|
document.body.className = "normal";
|
|
} else {
|
|
document.body.className = "wide";
|
|
}
|
|
|
|
var y = (window.pageYOffset !== undefined) ? window.pageYOffset :
|
|
(document.documentElement || document.body.parentNode || document.body).scrollTop;
|
|
|
|
if (y < 444 || window.innerHeight < menu.clientHeight + 100) {
|
|
menu.className = "";
|
|
} else {
|
|
menu.className = "floating";
|
|
}
|
|
|
|
setTimeout(function () {
|
|
document.getElementById("main_content").style.minHeight = menu.clientHeight + 100 + "px";
|
|
}, 10);
|
|
}
|
|
};
|
|
setMenuLayout();
|
|
window.onresize = setMenuLayout;
|
|
window.onscroll = setMenuLayout;
|
|
|
|
var items = menu.getElementsByTagName("li");
|
|
var toc = null;
|
|
for (var i = 0; i < items.length; i++) {
|
|
var link = items[i].getElementsByTagName("a")[0];
|
|
var href = link.href;
|
|
if (href.lastIndexOf(filename) >= 0) {
|
|
var parent = link.parentNode;
|
|
|
|
while (link.childNodes.length > 0) {
|
|
var child = link.childNodes[0];
|
|
link.removeChild(child);
|
|
parent.appendChild(child);
|
|
}
|
|
parent.removeChild(link);
|
|
items[i].className = "selected";
|
|
toc = document.createElement("ul");
|
|
toc.id = "toc";
|
|
items[i].appendChild(toc);
|
|
}
|
|
}
|
|
|
|
return toc;
|
|
}
|
|
|
|
function setupSidebar() {
|
|
if (window.ZAP_NEWS_SIDEBAR) {
|
|
setupNewsSidebar(ZAP_NEWS_SIDEBAR);
|
|
return;
|
|
}
|
|
|
|
var filename = document.location.pathname;
|
|
|
|
if (filename.slice(0, 5) == "/next") {
|
|
filename = filename.slice(5);
|
|
}
|
|
|
|
var isNews = filename.slice(0, 6) == "/news/";
|
|
|
|
var toc = initSidebar();
|
|
if (toc) {
|
|
var content = document.getElementById("main_content").childNodes;
|
|
var headings = [];
|
|
|
|
for (var i = 0; i < content.length; i++) {
|
|
if (content[i].tagName == "H2" ||
|
|
(!isNews && (content[i].tagName == "H3" || content[i].tagName == "H4"))) {
|
|
headings.push(content[i]);
|
|
}
|
|
}
|
|
|
|
var levels = [toc];
|
|
for (var i in headings) {
|
|
var hl = headings[i].tagName.slice(1) - 1;
|
|
while (hl > levels.length) {
|
|
var parent = levels[levels.length - 1];
|
|
var item = parent.childNodes[parent.childNodes.length - 1];
|
|
var sublist = document.createElement("ul");
|
|
item.appendChild(sublist);
|
|
levels.push(sublist);
|
|
}
|
|
while (hl < levels.length) {
|
|
levels.pop();
|
|
}
|
|
|
|
var parent = levels[levels.length - 1];
|
|
var item = document.createElement("li");
|
|
var p = document.createElement("p");
|
|
var link = document.createElement("a");
|
|
p.appendChild(document.createTextNode(headings[i].innerText || headings[i].textContent));
|
|
var hlinks = headings[i].getElementsByTagName("a");
|
|
if (hlinks.length == 1) {
|
|
link.href = hlinks[0].href;
|
|
} else {
|
|
link.href = "#" + headings[i].id;
|
|
}
|
|
link.appendChild(p);
|
|
item.appendChild(link);
|
|
parent.appendChild(item);
|
|
}
|
|
}
|
|
}
|
|
|
|
function setupNewsSidebar(items) {
|
|
var toc = initSidebar();
|
|
if (toc) {
|
|
for (var i in items) {
|
|
var item = document.createElement("li");
|
|
var p = document.createElement("p");
|
|
var link = document.createElement("a");
|
|
p.appendChild(document.createTextNode(items[i].title));
|
|
link.href = items[i].url;
|
|
link.appendChild(p);
|
|
item.appendChild(link);
|
|
toc.appendChild(item);
|
|
}
|
|
}
|
|
}
|
|
|
|
function setupSlides() {
|
|
var slides = document.querySelectorAll("body.slides main section");
|
|
var headerTitle = document.querySelector("body.slides header .title");
|
|
var slideNum = document.querySelector("#slide-num");
|
|
|
|
var current = 0;
|
|
var hash = document.location.hash;
|
|
if (hash) {
|
|
current = parseInt(hash.slice(1)) - 1;
|
|
}
|
|
slides[current].className = "current";
|
|
headerTitle.textContent = slides[current].dataset.title || "";
|
|
slideNum.textContent = window.location.hash;
|
|
|
|
function navSlide(diff) {
|
|
slides[current].className = "";
|
|
current = Math.min(slides.length - 1, Math.max(0, current + diff));
|
|
slides[current].className = "current";
|
|
|
|
headerTitle.textContent = slides[current].dataset.title || "";
|
|
if (current) {
|
|
history.replaceState({}, "", "#" + (current + 1));
|
|
slideNum.textContent = "#" + (current + 1);
|
|
} else {
|
|
history.replaceState({}, "", window.location.pathname);
|
|
slideNum.textContent = "";
|
|
}
|
|
}
|
|
|
|
document.body.addEventListener("keydown", event => {
|
|
if (event.keyCode == 39) {
|
|
navSlide(1);
|
|
} else if (event.keyCode == 37) {
|
|
navSlide(-1);
|
|
}
|
|
});
|
|
|
|
document.querySelector("body.slides footer button.back").addEventListener("click", event => {
|
|
navSlide(-1);
|
|
});
|
|
document.querySelector("body.slides footer button.forward").addEventListener("click", event => {
|
|
navSlide(1);
|
|
});
|
|
|
|
if (document.location.hostname === "localhost") {
|
|
var lastModified = new Date(document.lastModified);
|
|
setInterval(function () {
|
|
var req = new Request(".", {headers: {
|
|
"If-Modified-Since": lastModified.toUTCString()}});
|
|
fetch(req).then(response => {
|
|
if (response.status == 200 &&
|
|
new Date(response.headers.get("Last-Modified")) > lastModified) {
|
|
document.location.reload();
|
|
}
|
|
});
|
|
}, 1000);
|
|
}
|
|
}
|