Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 26 additions & 4 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,21 @@ pub fn build(b: *std.Build) void {

// pgzx_pgsys module: C bindings to Postgres
const pgzx_pgsys = blk: {
const translate_c = b.addTranslateC(.{
.root_source_file = b.path("./src/pgzx/c/include/headers.h"),
.target = target,
.optimize = optimize,
});

translate_c.addIncludePath(b.path("./src/pgzx/c/include/"));

translate_c.addIncludePath(.{
.cwd_relative = pgbuild.getIncludeServerDir(),
});
translate_c.addIncludePath(.{
.cwd_relative = pgbuild.getIncludeDir(),
});

const module = b.addModule("pgzx_pgsys", .{
.root_source_file = b.path("./src/pgzx/c.zig"),
.target = target,
Expand Down Expand Up @@ -56,20 +71,27 @@ pub fn build(b: *std.Build) void {
});
module.linkSystemLibrary("pq", .{});

// Import the translated C headers
module.addImport("c_translated", translate_c.createModule());

break :blk module;
};

// codegen
// The codegen produces Zig files that are imported as modules by pgzx.
const node_tags_src = blk: {
const tool = b.addExecutable(.{
.name = "gennodetags",
const tool_module = b.createModule(.{
.root_source_file = b.path("./tools/gennodetags/main.zig"),
.target = b.graph.host,
.link_libc = true,
});
tool.root_module.addIncludePath(.{ .cwd_relative = pgbuild.getIncludeServerDir() });
tool.root_module.addIncludePath(.{ .cwd_relative = pgbuild.getIncludeDir() });
tool_module.addIncludePath(.{ .cwd_relative = pgbuild.getIncludeServerDir() });
tool_module.addIncludePath(.{ .cwd_relative = pgbuild.getIncludeDir() });

const tool = b.addExecutable(.{
.name = "gennodetags",
.root_module = tool_module,
});

const tool_step = b.addRunArtifact(tool);
break :blk tool_step.addOutputFileArg("nodetags.zig");
Expand Down
32 changes: 32 additions & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
<title>Zig Documentation</title>
<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wvZz48L2c+PC9zdmc+">
<style type="text/css">
*, *::before, *::after {
box-sizing: border-box;
}
body {
font-family: system-ui, -apple-system, Roboto, "Segoe UI", sans-serif;
color: #000000;
Expand Down Expand Up @@ -157,6 +160,23 @@
cursor: default;
}

#errors {
background-color: #faa;
position: fixed;
left: 0;
bottom: 0;
width: 100%;
max-height: min(20em, 50vh);
padding: 0.5em;
overflow: auto;
}
#errors h1 {
font-size: 1.5em;
}
#errors pre {
background-color: #fcc;
}

#listSearchResults li.selected {
background-color: #93e196;
}
Expand Down Expand Up @@ -252,6 +272,14 @@
#listSearchResults li.selected a {
color: #fff;
}
#errors {
background-color: #800;
color: #fff;
}
#errors pre {
background-color: #a00;
color: #fff;
}
dl > div {
border-color: #373737;
}
Expand Down Expand Up @@ -414,6 +442,10 @@ <h1>Keyboard Shortcuts</h1>
<dl><dt><kbd>↓</kbd></dt><dd>Move down in search results</dd></dl>
<dl><dt><kbd>⏎</kbd></dt><dd>Go to active search result</dd></dl>
</div>
<div id="errors" class="hidden">
<h1>Errors</h1>
<pre id="errorsText"></pre>
</div>
<script src="main.js"></script>
</body>
</html>
Expand Down
46 changes: 37 additions & 9 deletions docs/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
const CAT_type_type = 9;
const CAT_type_function = 10;

const LOG_err = 0;
const LOG_warn = 1;
const LOG_info = 2;
const LOG_debug = 3;

const domDocTestsCode = document.getElementById("docTestsCode");
const domFnErrorsAnyError = document.getElementById("fnErrorsAnyError");
const domFnProto = document.getElementById("fnProto");
Expand Down Expand Up @@ -48,6 +53,8 @@
const domStatus = document.getElementById("status");
const domTableFnErrors = document.getElementById("tableFnErrors");
const domTldDocs = document.getElementById("tldDocs");
const domErrors = document.getElementById("errors");
const domErrorsText = document.getElementById("errorsText");

var searchTimer = null;

Expand Down Expand Up @@ -84,13 +91,24 @@

WebAssembly.instantiateStreaming(wasm_promise, {
js: {
log: function(ptr, len) {
log: function(level, ptr, len) {
const msg = decodeString(ptr, len);
console.log(msg);
},
panic: function (ptr, len) {
const msg = decodeString(ptr, len);
throw new Error("panic: " + msg);
switch (level) {
case LOG_err:
console.error(msg);
domErrorsText.textContent += msg + "\n";
domErrors.classList.remove("hidden");
break;
case LOG_warn:
console.warn(msg);
break;
case LOG_info:
console.info(msg);
break;
case LOG_debug:
console.debug(msg);
break;
}
},
},
}).then(function(obj) {
Expand All @@ -111,6 +129,11 @@
domSearch.addEventListener('input', onSearchChange, false);
window.addEventListener('keydown', onWindowKeyDown, false);
onHashChange(null);
if (domSearch.value) {
// user started typing a search query while the page was loading
curSearchIndex = -1;
startAsyncSearch();
}
});
});

Expand Down Expand Up @@ -625,27 +648,32 @@
}

function onHashChange(state) {
// Use a non-null state value to prevent the window scrolling if the user goes back to this history entry.
history.replaceState({}, "");
navigate(location.hash);
if (state == null) window.scrollTo({top: 0});
}

function onPopState(ev) {
onHashChange(ev.state);
syncDomSearch();
}

function navigate(location_hash) {
updateCurNav(location_hash);
if (domSearch.value !== curNavSearch) {
domSearch.value = curNavSearch;
}
render();
if (imFeelingLucky) {
imFeelingLucky = false;
activateSelectedResult();
}
}

function syncDomSearch() {
if (domSearch.value !== curNavSearch) {
domSearch.value = curNavSearch;
}
}

function activateSelectedResult() {
if (domSectSearchResults.classList.contains("hidden")) {
return;
Expand Down
Binary file modified docs/main.wasm
Binary file not shown.
Binary file modified docs/sources.tar
Binary file not shown.
Loading